Notifications
Clear all
[Closed] CurveControl
Dec 30, 2014 11:01 am
Hi,
There is not much help in maxhelp about CurveControl and methods of creating the ccCurve.
Can anyone explain me how is it done? Is it similarly to spline? Do I need to create ccCurve first and then add some points? Or maybe add points and make them a spline? I really dont get this.
What I intend to do is to get my object and then place object keys on the CurveControl
1 Reply
Dec 30, 2014 11:01 am
There is a full script that creates a curve with points in the documentation:
This shows how to create it.
rollout uTestCurveControl "Curve Control"
(
-- Curve control Properties
local ccProps = #(
#visible,
#numCurves,
#x_range,
#y_range,
#displayModes,
#zoomValues,
#scrollValues,
#commandMode)
-- Curve properties
local curveProps = #(
#name,
#animatable,
#color,
#disabledColor,
#width,
#disabledWidth,
#style,
#disabledStyle,
#numPoints,
#lookupTableSize)
-- Curve Point properties
local cpProps = #(
#value,
#inTangent,
#outTangent,
#bezier,
#corner,
#lock_x,
#lock_y,
#selected,
#end,
#noXConstraint)
button btn_props "Print Properties"
checkBox chk_visible "Visible" checked:true
checkBox chk_enable "Enable" checked:true
CurveControl cc_test "Curve Control:"
height:200
width:400
align:#center
numCurves:2
visible:true
x_range:[-100,100]
y_range:[-100,100]
scrollValues:[-100,100]
commandMode:#move_xy
-- The following parameters default to all flags if not specified --uiFlags:#(#drawBG, #drawgrid, #upperToolbar, #showReset, #scrollBars, #constrainY, #xvalue)
rcmFlags:#(#delete)
asPopup:false
on chk_visible changed state do cc_test.visible = state
on chk_enable changed state do cc_test.enabled = state
on uTestCurveControl open do
(
zoom cc_test #all
local colors = #(red, green, blue)
local styles = #(#solid, #dash, #dot, #dashDot, #dashDotDot, #null, #insideFrame)
local num = cc_test.numCurves
-- Initialize curve properties
for i=2 to num do
(
local crv = cc_test.curves[i]
local ci = ((mod (i-1) colors.count)+1) as integer
local si = ((mod (i-1) styles.count)+1) as integer
crv.name = "Curve" + i as string
crv.color = colors[ci]
crv.disabledColor = colors[ci]*0.5
crv.style = styles[si]
--crv.width = crv.disabledWidth = i
crv.numPoints = i*2
localdel = (cc_test.x_range.y - cc_test.x_range.x)/(crv.numPoints-1)
-- format "del:%
" del -- Place intermediate points equally spaced
for j=1 to crv.numPoints do
(
local cp = crv.points[j]
format "% end: % -> " j cp.end
--cp.corner = true
cp.value = [cc_test.x_range.x+(j-1)*del, cp.value.y]
cp.inTangent = [0.2,0.2]
cp.outTangent = [0.2,-0.2]
crv.points[j] = cp
format "%
" crv.points[j].end
format "value: %
"crv.points[j].value
)
)
)
on btn_props pressed do
(
local tab =" "
-- print the CC properties
format "Curve Control Properties
"
for p in ccProps do
format (tab +"% : %
") (p as string) (getProperty cc_test p)
format (tab + "Curves:
")
tab += " "
for i=1 to cc_test.numCurves do
(
local crv = cc_test.curves[i]
-- print each Curve's properties
format (tab + "Curve%
") i
for p in curveProps do
format (tab + " % : %
") (p as string) (getProperty crv p)
format (tab + " Points:
")
for j=1 to crv.numPoints do
(
local cp = crv.points[j]
format (tab + " Point%
") j
-- Print each curve point properties
for pp in cpProps do
format (tab + " % : %
") (pp as string) (getProperty cp pp)
)
)
)
-- Curve control event handlers
on cc_test selChanged ci val do format "curve % numSelected : %
" ci val
on cc_test ptChanged ci val do format "curve % ptChanged : %
" ci val
on cc_test tangentChanged ci val type do format "curve % tangentChanged : % %
"ci val (type as string)
on cc_test deleted ci pi do format "curve % deleted : %
" ci pi
on cc_test reset ci do format "curve % resetted
" ci
)
curveFloater = newRolloutFloater "Curve Control Test" 500 400
addRollout uTestCurveControl curveFloater