Anim8or Loader

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
n00bc0de
Posts: 55
Joined: Tue Oct 04, 2022 1:21 am

Anim8or Loader

Post by n00bc0de »

I am still in early progress on loading animations from Anim8or but I have made some progress.

I should also mention that this is not going to be a traditional irrlicht loader. I chose the method I am using for the following reasons:

1. I am only going to be loading data from scenes in anim8or rather than from the object, figure, or sequence views. The reason for this is that I wanted to be able to load position and scale keys and you can only set those in scenes in anim8or. The sequence view in anim8or is almost pointless (atleast I never use it) and figures by themselves don't have animation.

2. *.an8 files are anim8ors project files. They have more than just the model and animation data for a single model so I wrote a separate library that parses a *.an8 file and returns an an8_project structure. Since this project can have multiple scenes, you will be able to load a *.an8 file with all your animations into an an8_project and then load which scenes you want with loadAN8Scene().


Currently I have models loaded and textured, joints are loaded and weights are applied to each vertex and the position, rotation, and scale keys are loaded. The problem I am currently working on is that there seems to be some crazy issue with the rotation keys. Whenever I add rotation keys, the limbs for my model seem to stretch and bend in the wrong direction. The limbs are the only things moving so I think my weights are correct so I am still just trying to figure out why the rotation keys are so messed up. I also noticed that I have to key every bone in anim8or as well as apply a weight to the base bone the object is attached to in irrlicht. I am still trying to figure out why my keys are so messed up but if anyone wants to try it out, the code is available at the github link in this post.


Anim8or Loader for Irrlichthttps://github.com/n00b87/an8-parser

Currently this is just a WIP branch. You can clone it and just compile main.cpp. The only dependency is irrlicht.
Last edited by n00bc0de on Sun Nov 26, 2023 7:46 am, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Anim8or Loader

Post by CuteAlien »

Thanks, nice to have code for it. I'm sure you'll figure out the rest. Just start with simplest possible rotations, like singles bones rotating in just one direction with 1.0 weights. And maybe check rotation angles below and above 180° - easy to have those accidentally snap the wrong way around.

And if things scale when they should rotate... maybe something about order of operations - Irrlicht nodes alway scale at the end (after rotation and translation). Thought not sure right now about animation keys...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
n00bc0de
Posts: 55
Joined: Tue Oct 04, 2022 1:21 am

Re: Anim8or Loader

Post by n00bc0de »

Thanks for the tips. I have already found a few major issues from trying with a simpler model. The X axis were actually reversed in the loaded vertices which I didn't notice because my model was symetrical. I fixed that. The other weird issue is the joints lengths seem to be cut in half when loading it into irrlicht. I don't know why that is but I can just multiply the lengths by 2 before calculating the positions so not that big a deal. I am hopefully going to have this usable by the end of this month since I still have a number of other things I need to work on before starting on the project I am planning.
n00bc0de
Posts: 55
Joined: Tue Oct 04, 2022 1:21 am

Re: Anim8or Loader

Post by n00bc0de »

I finally got it working. Rotation and Position Keys seem to be working just fine. I had a slight problem with position keys but I fixed it by giving every vertex a weight of 0.001 for the base bone the mesh is attached to. You can see it in action by cloning the branch in my original post.

Here is a list of things that are working:
1. Import Figures with Texture Coordinates (You still need to import the texture separately though)

2. Bone Weights

3. Rotation, Position, and Scale Keys (scale keys have not been tested as thoroughly as the other 2 right now but I will get to it after I finish some other stuff)


Things I still need to do:
1. Materials - I basically want to convert anim8or materials to the closest equivalent material in irrlicht. I forsee this probably not being as easy as I would like so this may take some time.

2. Import Objects - This is going to be pretty simple since I am already importing objects attached to the figure but I was focused on figures first since I knew that was going to be way harder

3. Morph Targets - In anim8or, morph targets are basically a way of key framing vertices directly rather than using bones. This should be easy but I have been wrong on so much already so I am assuming this will take a while.

4. Importing sequences. I don't really use the sequence editor since you can do everything in the scene editor and more but I will look into adding this after I finish the features that will be most useful to me.


Things I have no intention of doing:
1. Importing lights, cameras, backgrounds, or any environment settings from scenes. You should really do all this stuff in your level editor anyway.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Anim8or Loader

Post by CuteAlien »

Nice.

... and you may be right with your assumption about 3 - mixing morph animations with bone animations could get interesting. I think CAnimatedMeshMD2 are morph animations. Don't see a general solution yet for mixing morph and bone animations. Or maybe using a single global bone could do it? Not sure.

I suspect the original idea was that each new animation format overwrites IAnimatedMesh. Then later bone animations got added for a more general solution. So maybe you'll also have to derive a class from IAnimatedMesh.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
n00bc0de
Posts: 55
Joined: Tue Oct 04, 2022 1:21 am

Re: Anim8or Loader

Post by n00bc0de »

I will look at CAnimatedMeshMD2 to get an idea of how to do it. If bone animations don't mix well with the morph targets I might add an optional flag for converting each frame of the bone animations to morph targets and applying the morph animations from anim8or that way.

My immediate priority to try to finish in the next few weeks is implementing materials, static objects, and cleaning up the code so I can merge it into my master branch. I will probably start a new branch for those other features.

Thanks for all the help with figuring out skinned meshes.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Anim8or Loader

Post by CuteAlien »

No problem, glad you got it working! And don't forget Irrlicht can also change if you need any features patched in to get things done.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
n00bc0de
Posts: 55
Joined: Tue Oct 04, 2022 1:21 am

Re: Anim8or Loader

Post by n00bc0de »

I decided to merge what I already had as far as using skeletal animation. I will update my original post with the link to the repo rather than the branch.

I should note for anyone interested in using it that it currently only loads figures and there rotation, position, and scale keys. If you are using morph targets for facial animation or doing anything other than skeletal animation then it currently doesn't support that.

I have also decided to bundle it all in 1 header file for ease of use. Just include an8parser.h and you can load an animated mesh with just 2 lines:

Code: Select all

an8::an8_project myProject = an8::loadAN8("myAnim8orProject.an8");
scene::IAnimatedMesh* mesh = an8::loadAN8Scene(device, myProject, "scene01");
In the above example "scene01" would be the name of the scene you want to load. You can save multiple animated models in a project in separate scenes and you can use loadAN8Scene() without having to load the project each time.

I do plan to add support for the other stuff I mentioned but I am going to make each one there on branch and work on them 1 at a time.
Post Reply