PDA

View Full Version : Help with expression? Please?


neuromancer1978
07-25-2006, 08:38 PM
I tried this post in the Character Anim thread, but have no response so since this is more of an expression question figured I would try here instead? Any tips? Pointers? A slap in the face? :D

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?

isoparmB
07-26-2006, 03:17 AM
So you want both these object to move in the same direction, is that right?

Are both your objects scale attributes set to 1 1 1? One of them could have an axis that is in negative scale. In that case, you should freeze transform the object using just the freeze scale option.

neuromancer1978
07-26-2006, 05:24 AM
Well this was just a test scene, and yes both objects were scaled a 1 1 1. The "box" was to represent the object in my real scene that I hope will be able to control the rotation of the sphere, via translation (translation in ZX space rotates the ball in the direction of translation....or something to that effect). Like I said it works fine till the translation on the box reaches a certain point where the sphere's Z rotation is in other words on it's back. Then when you move the box on the Z axis around that area, the sphere rotates opposite of it's intended direction.

I KNOW there is a way to fix this, I just cannot figure out what is involved to calculate where the sphere is at that certain point and to reverse rotation.... unless it's right there and I just can't see it.

Ge-ZUS
07-27-2006, 07:41 AM
Hi neuromancer1978

I'm not a mathematician nor an expression specialist as well. The expression you used (or have found on the net) looks a little strange to me although, or just too complicated for your purpose. Why you don't just say that the ball.rotation is equal the box.translation? If there is too few rotation you can multiply the value. If the ball rotates in the wrong direction, just use a negative multiplier.

Your expressions could then look like this:

ball.rotateZ = box.translateX;

ball.rotateX = box.translateZ;


with double rotation (brackets would actually not be used here). If you want even more rotation just rise the multiplier to 3 or 3000 or whatever:

ball.rotateZ = (2) * (box.translateX);

ball.rotateX = (2) * (box.translateZ);


If you want the rotation to run in the inverse direction just set the multiplier mentioned above to a negative value (this time brackets are necessary!!). But still: set the multiplier to a value to get enough rotation (-2 or -2000 or whatever):

ball.rotateZ = (-2) * (box.translateX);

ball.rotateX = (-2) * (box.translateZ);


Hope I could lead you onto the correct way... ;-)


Greetings Ge-ZUS

CGTalk Moderation
07-27-2006, 07:41 AM
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.