Animated Text - Bar Chart

It was a lazy attempt to ceate such animation sequence in 3D. It can be done easily in compositing software in presto. But like I said, I was too lazy to switch back and forth from 3D to compositing softs. So.. here we go... watch the movie and you'll know what I mean.





The basic idea is to fetch the locator.translateY value, and pass that value to the beveled text.

The basic setup:
I use simple polyCube, with two clusters. First cluster contains all vertices from the top face. The second cluster contains all the vertices from bottom face. And I point cons the top cluster with a locator. This locator is the one that will be animated along th Y axis. Simple setup.

Next... the text. The text created from create text menu, and set the type to "bevel". This will create five nodes, outterStyleCurve - innerStyleCurve - textForBevel - bevelPlus - and polyPlanarProj. The main key here is the textForBevel node (it's actually makeTextCurve node, but renamed automatically when making the text).

To "connect" the locator.translateY value into the textForBevel node, is by using simple expression.

Open expression editor, and type these codes:

float $n = `getAttr locator1.translateY`;
string $val = `ceil ($n)`;
setAttr textForBevel1.text -type "string" ($val);

and hit create.

There should be some error reporting cannot perform polyPlanar thing. But just ignore that. It will be fine.

Explanation of the code:
first line: float $n = `getAttr locator1.translateY`;Tells Maya to get the value of locator1.translateY. In my case it's locator1, because that locator is the one that controlling the cluster. Set it to proper name if you have different scene.

second line: string $val = `ceil ($n)`;
Tells Maya to round up the value from $n. Without the ceil command, it will shows numbers with comma and many digits behind it (float type).

last line: setAttr textForBevel1.text -type "string" ($val);Tels Maya to set the value of the "round-up" locator1.translateY value to the textForBevel.text. This line quite tricky. I was struggling on this line as It gave errors, but until I added -type "string" flag.

Now, make some keyframe for the locator1.ty, eg. frame 1 set to 0, frame 20 set to 8 (like mine). When you scrub the timeline, the text should be updated with the locator value.

Simlpe setup for old lazy dog. Next ... pie chart.

Komentar

Posting Komentar

Monggo komennya