View Full Version : Rolling a ball

01-15-2007, 10:56 PM
Does anyone know if there is a way to setup expressions on a ball so that as it's dragged around on a floor (XZ plane) it would rotate correctly to make it look like its rolling around (based on its radius)?

01-16-2007, 04:05 AM
This isn't as straightforward as it seems.
Firstly you need to specify the vector (XYZ) the last frame the ball was positioned and the current one.
Then find the angle that the difference in these two positions creates.
That angle then has to be used for the axis of rotation between the two frames.
Otherwise, you can get it rolling like a wheel, with a simple formula but that's not what you want as it's not what a ball does.

As to how to set this up with expressions in LW I have no idea. I'd wager that it can't be done because you only have control of one channel at a time. It probably needs to be scripted and applied as a motion modifier

01-16-2007, 06:58 AM
Relativity is your answer. I'm on the way out the door at the moment and am not willing to be late to explain. Hopefully, others who have used Relativity can chime in.

Nonetheless, wheel rotater and Odist will be your friend. If you didn't get the tutes that came with Rel, do a search here as someone offered them, I believe.

01-16-2007, 08:35 AM
Dynamics can be used, but is not very accurate/ you can't really modify it.
Here's something that worked, nothing fancy,

01-16-2007, 09:02 AM
Nonetheless, wheel rotater and Odist will be your friend. If you didn't get the tutes that came with Rel, do a search here as someone offered them, I believe.

Rolling a ball is far more complicated than a wheel. A ball doesn't 'turn' to face the direction of travel like a wheel does and the axis of rotation is constantly changing, unlike a wheel, which will always be, say, the pitch.

Unless relativity has some special ball-solver, I doubt it will be an easy task.


Here is a link to a script to roll a ball in Max. Maybe you can get someone adept in L-script to translate it to LW.
It seems very well explained and I'm sure very do-able by someone up to the challenge..

Safe Harbor
01-16-2007, 09:38 AM
Impact (http://www.sharbor.com/products/DYNN0280001.html) can do this.

01-16-2007, 10:02 AM
The only reason that expressions aren't the easy way to solve this is the issue of gimbal. Otherwise, you could just set up an expression to rotate the ball on the pitch channel based on Z movement times circumfrence, and rotate on bank based on X movement times circumference.

It seems to me that if you can create the right hierarchy to create a floating gimbal for the ball, it would work pretty well.


01-16-2007, 11:25 AM
I'd love to see it..

(that's not sarcastic.. I spent ages a while ago convinced that the answer lay in heirarchies, but I couldn't get it working)

01-16-2007, 12:00 PM
Amazing how complicated this problem is, eh?

erikals, your solution is looks great. I've been playing with it just to get a handle on it, and I will see if I can get some useful results. It might be better than than the expression approach because it adds some "natural" animation that one might not arrive at by keyframing, we'll see. BTW, here's a way to (try to) tweak it:
1. Add a single pt poly to the center of the ball.
2. Get some HardFX animation that your happy with.
3. Use the EditFX panel and the Edittool to copy the motion of the center poly to a null.
4. Parent a ball to the null.
5. The baked motion can be KF-reduced and edited (and check out those bizarre curves on the oreintation channels - I think that sums up the difficulty of doing this by hand).
I attached this setup to this post. Note that my files are "older" than erikals because of timezones on a different spinning ball...
Thanks for taking the time to put together the sample.

Pooby, that article is a good find. Might be doable in Relativity or LScript, but beyond my programming skills.

BTW, does anyone know how to turn off the Edittool? It stays active everytime I select the ball.

01-16-2007, 12:20 PM
I'd love to see it..

(that's not sarcastic.. I spent ages a while ago convinced that the answer lay in heirarchies, but I couldn't get it working)

I'm honestly not sure it's possible, but it's the only theory that comes to mind. The fact is, even if you rotate the parent of the ball on pitch, you'll still end up swapping the H and B orientations every 90 degrees. If you know your trig, you could probably integrate a sine function into all three axis to get it to work right, but it's not going to be easy.

As I think about this, another workaround idea is forming...

It seems likely to me that any ball that can freely roll around is going to be perfectly round. So the only evidence you would see that it is rolling is in the texture of the ball. I wonder if you could tie the texture rotations to the movement, and never actually rotate the ball itself? The real question is, do texture rotations follow the same gimbal rules as objects?


01-16-2007, 12:36 PM
Eric, have you been spying on me? :)
I also spent ages with spinning textures but came to the conclusion that it was just the same as having a hierarchy.

The advantage of rotating a texture though is that you could have squash and stretch on the ball, as the texture would rotate, but the ball could still stay 'upright'

01-16-2007, 12:46 PM
Do you have any animations of your avatar? I bet that would be cool.

01-16-2007, 04:25 PM
no.. I never finished him.. If I ever do I'll post it (but it would be animated In XSI)

01-17-2007, 06:27 AM
Thanks Pixelfarmer,

Not sure how much you are into dynamics, but be aware that you will run into lots of problems as of LW dynamics don't cut it.

Hints for trying to get LW dynamics to work, experiment with the number of polys on the objects, the position of the objects, the different dynamics settings, and note the resolution setting might help for a tiny tad better calculation.

Just so you know :) LW dynamics require "lots" of tweaking, and if you are lucky it might work, without the ball falling through the ground, shaking, or suddenly bursting into the air. B warned :)


01-17-2007, 09:23 PM
I haven't done a lot of dynamics work, but I do know from experience that it requires a lot of iterations. I was able to get some interesting results using the path wind generator (a cool tool) to push the ball around, though I couldn't get wind to play very nice w/gravity. Like anything, the more you use it, the more you figure out what the bells and whistles do.
I think this will get me the motion I'm looking for.
I've attached the latest effort, which includes a copy of the ball parented to a null which has the dynamics motion baked into it. So if anyone looks at it, you might want to make one of the balls invisible...

Thanks again for taking the time to put together the sample, its been interesting to explore dynamics for an application like this.