PDA

View Full Version : Ball Expression



Lightbase
12-12-2003, 06:36 AM
Hi
Here is my problem. I want to move a ball along X and Z axises and make my ball rotate automatically by expression. I wrote one but it works only when I move my ball only along X or only by Z.
([Ball.PositionX]/2*p*r) *360 and ([Ball.PositionZ]/2*p*r) *360.

Please help me to solve this problem.

Thanks!

Matt
12-12-2003, 07:06 AM
interesting one that! :)

my math sucks so I can't help you there, but what you need to do is some kind of blending between the two when it's not going in a straight line (X or Z axis)

if you set your heading to 'align to path' you could use the heading angle somehow as a test as to how much to 'blend'.

as I said I'm not great at maths but sitting down with a pen / paper helps understand what you want it to do!

iluvatar
12-12-2003, 08:51 AM
hmm... very interresting... don't know a build-in solution, but i do know worley wrote a plugin for this.. check this link (http://www.worley.com/polk/polk_wheelie.html) homepage of worley: worley (http://www.worley.com)

mattbolton
12-12-2003, 10:02 AM
Time do get out the old trig book and do some vector math. :P

mattbolton
12-12-2003, 09:37 PM
Well, I could not figure out how to do it with an expression without getting an infinte loop error.
So, I decided to check out LScripts for the first time. Pretty simple to use, especially with the LScript Editor. Looked through a couple freely available LScripts and was able to figure it out well enough to write a script that rotates the ball based on the motion in the XZ plane. No movement on the Y axis accounted for.
Also, the only rotation I am affecting is the Pitch, so you will need to set the Heading Controller to "Align to Path."
This script can only be loaded from the Motion Options panel for the ball object. Add Modifier of type LScript and then double click that modifier to choose which LScript to load. Load the attached LScript, and then double click again to enter the radius and starting frame number. Then click the play button and watch it roll. :D
The LScript should be attached.

A Mejias
12-12-2003, 09:58 PM
hmm, I haven't done this in a while, but... to do it as an expression you'd calculate it as a vector. I don't think you need trig functions since you are getting your position for the X and Z axies which are at right angles to each other. You would use the Pythagorean theorem to calculate the length of the hypotenuse (vector). That formula is A^2+B^2=C^2 or A*A+B*B=C*C. You would use that length to calculate your rotation for that direction. You'd then have to figure out how to adjust the calculation as the direction changes.

That's all I can think of at this hour. Hope it helps.

Triple G
12-12-2003, 10:44 PM
I'm not sure exactly what you need your ball object to do, but here's a pretty simple example using Cyclist that you might want to try:

Go to frame -30, and key your ball's pitch rotation at 0. At frame 0, key it at 360. Take your ball object, and apply Cyclist in the Motion Modifiers panel. In the Cyclist panel, keep only Pitch active. Set the Cycle Frames from -30 to 0. Cycle controller is the ball object, and set it to Forward Progress. Controller range would be From 0 to (the circumference of your ball, or 2*Pi*r). End behavior set to Repeat, and check World Coordinates. Click ok.

Now, in the Controllers and Limits section of the Motion options panel, set the Heading Controller to Align to Path.

Now, set some position keyframes for your ball object, and it should look pretty natural rolling around. Again, this is not a perfect solution for all situations, but it may be worth a shot depending on what you're going for. :)

mattbolton
12-13-2003, 08:13 PM
Here's a 5 second movie showing a wagon wheel turning using this LScript.

toby
12-13-2003, 11:44 PM
a www.richardbrak.net expressions tutorial will clear it all up.

mattbolton
12-15-2003, 12:08 PM
All of the expressions that I have seen have the limitation of only calculating rotation at a constant speed and/or movement along a single axis.
I have uploaded an enhanced version of the "Rolling" Lscript in the LScript forum.
http://vbulletin.newtek.com/showthread.php?s=&threadid=15188

Lightbase
12-16-2003, 12:48 PM
Thanks for help, everyone!
I liked a Cyclist and Align to Path method by Triple G, great idea thanks!!! It was the simplest way!
Thanks for expressions tutorial links.

Triple G
12-17-2003, 07:27 PM
No problem...I must admit that I'm a bit of an expression-phobe myself. I've used them before, but that doesn't mean I hafta like 'em. :D Glad I could help. :)