PDA

View Full Version : xpresso challenge?


tcastudios
04-22-2003, 11:09 PM
I have slowly started to get into xpresso and got a few things working as I´d want. It very much reminds me of the eqvivalent in Logic (Audioprog) called "Environment". I did spend many hours making surround mixers and such there.

Now here comes a challenge I cannot figure out. The tools and nodes seems to be there but I´m not yet familiar with all of them, yet.

I´d like to get a ball (sphere) rolling in any direction in the ZX plane. Involving hight (Y) would be to complicated to start with, I think. At first it didn´t seem to complicated, but it was.

The goal is to make it roll (by moving a "leader object") in any direction as a real ball would. By that I mean it should -not- behave as a wheel. A wheel TURNS around the global Y-axis (H) for direction and SPINS around its local X (or Z) axis for speed.
The third axis (X or Z) doesn´t "do" anything, it just moves along sort of.
The behaviour can easely be created by letting the wheel follow a spline and rotate as a function of how far it has come on the spline. (Position to Rotate)

Now this is not the behaviour of a ball. None of its axis (except at the start 0.0.0 position) does constantly point at one direction. Also, a ball does not TURN, it changes direction and rotation as it moves, heading for different goals.

I have tried (and so far ,failed) making a "LeaderObject" (The Null that would be animated) that is controlling a nother Null ("Cage"). The Leader controll the position and direction (where the Z-axis is pointing) of the Cage. My idea was to have the ball rolling inside the Cage and somehow rotate in the direction the Cage was heading. And here I lost it....

Any takers?

Why all this then? you might ask. Well it would be very easy to animate many ballsports more realistically.
Imagine how the numbers on the balls in a poolgame look when they bounce around.

Regards
Lennart

JIII
04-23-2003, 03:09 AM
well if you lock ones spin to another. say have all the balls rotation linked togeter with a drven key. and then use some other sorta thing to control the distance it might work.

astrofish
04-23-2003, 11:22 AM
To do this kind of thing properly you really need to get into quaternions or matrices...

If the ball is on the plane Y=0, with an arbitrary orientation, and you want it to roll in direction 'a' degrees (think of it as the world heading), then you need it to rotate around an axis with direction (Sin(a), 0, Cos(a)).

The amount that you want to rotate it by depends on the distance you want to move, but lets call it angle 'b'.

Trying to do this directly with the HPB angles will just drive you crazy... Don't bother trying.

You can either:

Get the current orentation matrix of the object, multiply it with a matrix which rotates around the above axis, then write it back.

or

Get the current orientation matrix and turn it into a quaternion.
Multiply the quaternion by the quaternion: (Sin(a), 0, Cos(a), b)
Convert back to orientation matrix and write it back.

Since C4D uses matrices to represent rotations, the first option is simpler to write. The second option would be better if C4D stored orientations as quaternions, and is mathematically better.

I'm willing to have a go at implementing this if you're interested.

Background:
Matrix representations use nine numbers to store the orientation, three
orthogonal unit length vectors corresponding to the directions of the three object axes in world space.

Quaternions only use four numbers. The first three represent the axis of rotation, and the fourth represents the amount that the object has been rotated. It is possible to represent any rotation in this way.

HPB only uses three numbers to represent the rotation. Unfortunately, this isn't actually enough, and as a result you can get the 'gimbal lock' problem, and they are difficult to work with for unconstrained rotation.

tcastudios
04-23-2003, 01:04 PM
Great!. I will take a little more time on it but will most likely contact you if it is OK.
I´m not a math genius in any way.....

Cheers
Lennart

kevin3d
04-23-2003, 02:15 PM
Can anyone point me to some exampls of animations done with xpresso?

CGTalk Moderation
01-14-2006, 11:00 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.