Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / ASE, camera, quaternions Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Laze Ristoski

March 12, 2005, 07:41 AM

Howdy,

I'm writing a proggy to play animations out of ASE files. So far, everything works fine but the camera. It's a target camera which I handle using D3DUtil_SetViewMatrix (DX7). As far as I can see, the translations are relative to the initial point (i.e. *TM_POS). So I subtract this value from the pos-samples (*CONTROL_POS_SAMPLE). The same is done for the look-at point, i.e. camera.target. Now, instead of the expected animation, the camera stands right above the objects and as I move through the animation, the camera gets lower (closer to the objects). I was ignoring the rotation of the camera, so that may be the reason.

Somewhere I read that the rotation is written in form of quaternions, where the first 3 values are the vector, and the last is the angle: x,z,y,w (note that Max swaps Y and Z). Also it says that the rot-samples are relative, so if I need rot-sample 5, I multiply quaternions 0-5 together, and then I convert this to a matrix. All this is done using D3DUtil and D3DMath functions, so the possibility of incorrect quaternion multiplication, etc. is thrown away. The view matrix is multiplied by the matrix from the quaternion, then the resulting matrix is multiplied by the projection matrix. But now it gets even worse. The whole thing seems distorted.

Any ideas of what I might be doing wrong?
I was also searching for a source code of something similar, but without any luck so far. If anyone knows where I can find one, that would be of great help too.

 
Victor Widell

March 12, 2005, 08:50 PM

Will rotation make any difference if you use an "Identity" quaternion? If it does, there is something wrong with the matrices.

 
Scali

March 13, 2005, 04:00 AM

You're right about the quaternions being relative and having to multiply them together.

I vaguely seem to recall that the resulting matrix has to be inverted if you want to use it as a view matrix in D3D. So that may be the problem.
Another problem could be that you are using a left-handed coordinate system. You should use a right-handed system (generate perspective matrix with D3DXMatrixPerspectiveFovRH()).

 
Illco

March 13, 2005, 04:39 AM

Quaternions do not represent rotations by simply storing a vector (x,y,z) and an angle of rotation around that vector (w). How they do represent rotations is a far longer story. However, simply exchanging y and z in the quaternion can hardly be thought of as converting a right-handed system to a left-handed one.

 
Laze Ristoski

March 13, 2005, 04:26 PM

I got it working. Actually the pos-samples of the camera are not relative to the initial position, but the objects are. To clarify: the translation matrix doesn't take absolute coordinates, but an amount of move. Since the pos-samples are absolute, one has to subtract the initial coordinate from the current pos-sample.

Rotations are still ignored. For my specific purpose (a demo) it's ok, since objects don't rotate. But I'll certainly have to work out quaternions in the near future.

Thank you all for the tips. I appreciate it.

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.