Pages

Saturday, July 4, 2009

Animating text in a Text Shape

In official max help reference shipped with 3dsmax exist nice "How to" topic. Search for "MAXScript FAQ > How do I change the text in a Text Shape dynamically?".

Quote:
Normally, the text of a Text shape is not animatable. The resulting mesh will be
evaluated once at the beginning of the rendering and will not change as it is
considered static (not changing over time). A workaround is to assign a script
controller to a property of the text shape which will do two things: tell the
renderer that the text shape is animated and thus requires reevaluation on each frame, and set the actual text in the text property.

WARNING!
Changing the text object's text property in anything other than a controller applied to the text object can lead to a renderer crash!

Also there is a good 'how to' example with dependsOn expression:

b=box name:"ControlBox" wirecolor:blue
t=text name:"ControlledText" wirecolor:red
t.baseobject.renderable=true
t.kerning.controller=float_script()
scrpt="dependsOn $'"+b.name+"';$'"+t.name+"'.text=$'"+b.name+"'.height as string\n0"
t.kerning.controller.script=scrpt
animate on at time 100 b.height*=2
max tool zoomextents all
playAnimation()

As you see, there assigned script to kerning controller of the text shape. By right click over text shape and choose Dope Sheet open Track View and double click over Kerning to see script controller dialog. There you can add/edit expressions. Also have options/buttons to Save, Load, Debug, Evaluete, and this is more friendly environment for beginner scripters. On the left side are variable options. You can create new or use existing (there 4 already defined) variables.


And there is some simple example from me, that use default F variable to make a frame counter animation:

-- check if exist and create new shape if not
if not isValidNode $Text01 then (t = text name:"Text01" wirecolor:yellow)
-- make renderable end change size to 10
t.baseobject.renderable = true;t.size = 10
-- assign script controller to object kerning
t.kerning.controller=float_script()
-- define expression and assign it
expr = "$Text01.text=F as string\n0"
t.kerning.controller.script = expr
playAnimation() -- test result



P.S. - final note about 0 (zero) in the end of expression.
It's used to define the end of script.

No comments:

Post a Comment

Thanks for your comment