«

»

Apr 27 2012

Animations, animations and animations …

Did someone say animations were easy? Even with the very useful and well written animation loader class from Scott at No Limits Designs (i.e. this), some things still don’t add up …

First, his class is for D3D and that implies a lot of transposes around the code. Sorted …

Secondly, he uses his own custom mat4 class and I use my templated mat4<F32> for transforms. Aligning it with aiMatrix4x4 turned out to be a simple memcpy instead of element by element copy. That simple memcpy turned this:

…. into this:

And now … on to sorting bones out …
Later edit: Hallelujah \:D/

The previous transformations were corrected fast enough, but the proper solution came after upgrading the VBO class to OpenGL 3.x standards (glVertexAttribPointers). Bone indices got lost in the process 😛
The only problems that remain for now:
-Those damn Bounding Boxes that don’t like moving very much
-Optimize, optimise, optimize, optimise

The link to the code is in the video’s description on youtube.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

5 comments

Skip to comment form

  1. scott

    Hey, i see you are trying out the animation code. Obviously something bad is going on.

    The ASSIMP library uses a right handed system for their matrix’ and I use the left handed system so I transpose their matrix over in the initial copy. You can swap out the mat4 for D3DXMATRIX and change the few calls to inverse and transpose to the d3d equivalent and it will be the same. The internal matrix layout of D3DXMATRIX and my mat4 are the same, so you could even cast if you wanted.

    Also, I notice that you did a memcpy to copy the matrix from assimp, so I would guess you are using a right handed system. All my code is for left-handed so the order of operations will all be backwards.

    If you need any help, or you want to yell at me to tell me how badly the code is.. You can do that too ….

    Good luck!

    1. IonutCava

      Hello! 🙂 “the very useful and well written animation loader class from Scott at No Limits Designs” is meant as a compliment so “want to yell at me” will never happen.

      I am using a right-handed system, OpenGL for now, but the rendering interface is hidden behind a wrapper (similar to that used by Torque from GarageGames, as I worked with that before), thus my mat4 class defaults to RHS but implements the necessary transpose() and inverse() methods. For RHS I do a memcpy and for LHS an element-by-element copy. As to the videos, I tried my best to hack some API independent matrix transforms just to get it working, in the sense that transpose is only called if D3D is used, and multiplication order for matrices is reversed for OGL case (I think this is were the problem rises)
      I checked the calculations in openFrameworks‘s ASSIMP implementation (OGL) and compared them to those of the SDK’s viewer (D3D) and all test cases should be correct.
      This is what I have so far: http://pastebin.com/riLQJBBG

      I appreciate any input you could provide but if not, I’ll figure it out eventually but time is something I quite lack these days :))

      P.S. Love your work!

  2. jeremy

    First, as i commented on your youtube video i would like to say CONGRATS on getting this to work. Good show. I am trying to down load the code you provide for you animation but i was wondering do i need to down load it one file at a time or is there a link there some where that has the complete project. if i have to i will spend the time to down load it one file at a time. I have been spending so much time trying to get animation to work. I to down loaded scottss animationController and began doing what you did but i still have not been able to get it running yet. any ways if there is a link where i can get the code all at once that would be awesome but if not ill just do it the hard way lol thank you sooo much for providing your code it will save me many hours and again good job

    1. IonutCava

      You do not have to download every file, but if you wish to do so anyway, it’s a simple SVN pull systemm described in this guide: http://tinyurl.com/7yfzrj7 . Otherwise, you can look in the “Geometry” folder and from there go to “Animations” for Scott’s converted code, “Shapes” for the Mesh/Submesh structure I use (which I tried to make as generic as possible) and under “Importer” for the actual ASSIMP usage code.
      Basically, I use a convention that every ASSIMP scene should only contain one model (so I can convert it to a proprietary system later), be it a building, character or whatever. Thus the ASSIMP-scene is a “Mesh” for me, and every ASSIMP-mesh is a “SubMesh” for me (the structure with the actual vertex info). I give each “SubMesh” it’s own “Animator” with that submesh’s bones only (so that I can skip updating animations for culled parts of the mesh) and update the timestep from the parent “Mesh”.
      The main problems that you may have will be related to the matrix class you use. Scott used D3DMATRIX, I use Unigine’s “mat4” class (Alexander Zaprjagaev’s MathLib) found in “core/math/headers/mathclasses.h”

  3. jeremy

    Thanks for getting back to me so quickly. the only reason i would like to see all the code is just so i can see how your using the animation class. Thanks for the description of the use it will help a lot. Ill compare your math library with the one i have constructed so see if there are any functions you are using that i don’t have available. also can i ask i noticed you have a scenegraph class in your project there is that the scene graph you are weaving your animation into?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>