Archived

This topic is now archived and is closed to further replies.

Small issues with ms3d animation

This topic is 5648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have (mostly) solved .ms3d skeletal animation in D3D. My only three remaining problems are: 1. I have been testing my code on Brett Porters bert.ms3d model. It looks pretty good now, but it looks a little funny around the shoulder region when the model jumps (though not when it walks) and it (the whole model) rotates strangely around the z axis when it jumps. 2. Also, the model walks backwards, but when I negate the x (!)translation in the keyframes it walks correctly. 3. I also made an animation with a cube rotating on an arm around the origin. It is supposed to rotate around the z axis but instead it rotates around the x axis. When setting up the transformations I create a matrixfor each bone, relative that I 1. Insert the x axis rotation. 2. Multiply by the y axis rotation 3. Multiply by the z axis rotation 4. Multiply by the translation. Then I create another matrix, absolute, that is the product of relative and the absolute matrix of the parent, if there is one, else it is set to the relative matrix. All the vertices are then transformed with the inverse of their bone''s absolute matrix. When advancing the animation I use quaternions to slerp the rotations and insert that into a matrix. This matrix is multiplied by the translation and then by the relative matrix. Then it is multiplied by the parents final matrix, if there is one, to create the final matrix which is used to transform the vertices. I have decided to write a small tutorial explaining the differences between D3D and OpenGL in doing ms3d animations, but I''d like to get it right first... I realise that this is alot of abstraction but there is quite alot of code and I dont think it would help to post all that... Does anyone know why the models behave like this. I thought that it had to do with translating first and then rotating, but that produces a rather weird model...

Share this post


Link to post
Share on other sites
Sounds like your matrices are wrong somewhere? Did you take into account the difference between dx and ogl matrices?

I''m doing ms3d animations now too. However I''m doing the rotations in quats first. Ie converting the euler anges to quats, multiplying the quats to form the absolute quats.

The transform can be stored as a quat(Px,Py,Pz,w==0.0) where Px,Py,Pz is the position. Quats use less memory than matrices here(6-8 floats depending on how much you want to complicate things). They are also faster to multiply than matrices.

Then I''m slerping on the quats. Finally to transform the verts I''m converting to matrices, as they are faster to transform points with.

anyway... it''s still a work in progress. I have the design and soon some code at the following link:

http://www.py3d.org/py3d_zwiki/milkshape3d_animation

Share this post


Link to post
Share on other sites
I have finally gotten it to work now. The answer lay not where I was looking for it though. It turns out that the problem was not with the matrices nor the quaternions I used (although I did accidentally exchanged x rotation for y rotation when creating the quaternions). The solution lay in not inverting any of the position, translation or rotation values of the model. I am not sure I can explain why quite yet. OpenGL uses, as most are aware, a left-handed coordinate system and my setup of D3D used a right-handed. My mistake was that I thought, drawing knowledge from other tutorials on loading (static) ms3d models in D3D, that I had to invert the z-values. On a whim I removed all the minus signs (after having fiddled with all other possible combinations for a week) and it worked!! Imagine my surprise. Now I need to tidy up my code a bit. It is quite messy after all the tweaks and turns I have tried before to make it work.

Share this post


Link to post
Share on other sites
Sounds great! If you are interested in posting it as a port or a separate tutorial, let me know. NeXe.gamedev.net may also be interested.

BTW, the bert model came from polycount. I included the README file of the original author.

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!

Share this post


Link to post
Share on other sites
Brett: It is my intention to write some sort of tutorial on the subject as I haven''t seen anyone else do it before me. I just need to think it all through a couple of times; how and why it works. Where would be the smart place to post such a tutorial? Who should I contact (w.r.t. format and such)?

Share this post


Link to post
Share on other sites