PDA

View Full Version : Doing expression for rolling ball


neuromancer1978
07-23-2006, 08:17 PM
OK... so I am running a test to get expressions right, but because I suck at programming, I can't seem to get it right. Specificly with this scene, I have a sphere that moves in the direction when another object - a cylinder - moves (or translates, have yet to even figure out rotation). The expression I have so far works well, untill it reaches a certain point. When moving on the X axis it works fine, but once you reach a point and then move down the Z axis the ball totally moves in the opposite direction. I know it's something that can be fixed, but I got this expression off the net and just modified it a tad, but I have no idea WHERE to fix this.

(expression1)
ball.rotateZ = (box.translateX / (2 * 3.14 * 1)) * -360;
(expression2)
ball.rotateX = (box.translateZ / (2 * 3.14 * 1)) * -360;

I can upload the test scene (66kb) if anyone wants to see what it is I am talking about. Otherwise if you are an expression wiz I will be totally in your debt.

Ideas?

danylyon
10-14-2006, 12:17 PM
Hey Ted

Did you get this working? I'm triing a similar thing.
Right now I have a ball that rolls nicely, but only thing that doesn't work yet is. Instead of rolling sideways it's actually turning in then rolling forward again.

Must be something with the Rotation Axis.

Has Anybody an Idea? My expression skills are slightly not up to it.

Attached is the scene so far.

danylyon
10-15-2006, 03:37 PM
Ok.. I just triied half a day to get this working. No luck :-(

What I'm triing to do, the "Rotation Axis" have to rotate without the ball geometry moving. But then I want to roll the ball, with the geometry moving.

Normally if I change the rotation axis, the gemoetry moves aswell, I can "contra" rotate with the rotation value, but that only works one time, after that the actual rotations and the rotation axis don't align anymore and so I can't contra rotate easely.

The other thing I triied was with a constraint, orient constraining, set weight to 0 rotate the locator, but then if I set the weight to 1 again, it rotates to the default offset again. There doesn't seem to be a way to reset the offset.

In another thread, I've read that this is very difficult with euler rotation and that I would need quaternion, but maya doesn't seem to have quaternion rotations.

Now I've run out of Ideas.

danylyon
10-18-2006, 12:30 PM
Yes!! I got it working.
Had to do it with Vectors and constraints, that was though.

Attached is the working file, in case anybody runs in the same problem. =)

Kris-S
03-28-2007, 06:25 AM
I just DL it it didn't work for me? ... can you go through it a little tutorial on how it was made? I'm trying to do the exact same thing.

scroll-lock
03-28-2007, 03:50 PM
hi guys , sorry to chime in, but why don`t you use the makeRoll command instead ? What it does is with given parameters as - ground level, and radius you can only translate the ball and it rotates perfectly! A downside of it is that you have to bake the animation because there are unpredictable results sometimes /because of the caching/

Kris-S
03-28-2007, 10:54 PM
Yeah I just found that command after I posted. it worked a treat

CGTalk Moderation
03-28-2007, 10:54 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.