Page 1 of 4

OgreAssimpConverter

Posted: Thu Aug 04, 2011 6:47 pm
by jacmoe
I made a crude but effective command-line tool called OgreAssimpConverter:
ogreassimpconverter.jpeg
It takes a model and spits out mesh/skeleton/material.

The 'aniSpeed' parameter is not handled yet.
And the list of parameters should of course include the parameters AssImp uses.

I still haven't gotten animations to work properly, but hopefully someone (or even me) will be able to fix it.
It's better than before, but it's not completely solved.

('Before' meaning this topic: MeshMixer)

The code is up at Bitbucket here:
https://bitbucket.org/ogreaddons/ogreassimp
License: MIT

It even imports .blend files... :)

Re: OgreAssimpConverter

Posted: Thu Aug 04, 2011 7:40 pm
by Wolfmanfx
Nice! Have to try this when i am in compile mode :)

Re: OgreAssimpConverter

Posted: Thu Aug 04, 2011 8:04 pm
by jacmoe
This is Bob:
bob_fine.jpg
He's a happy watchman of MD5 origin.

He doesn't feel that good when I animate him:
bob_bad.jpg
To be solved ...

Re: OgreAssimpConverter

Posted: Thu Aug 04, 2011 8:08 pm
by betajaen
You monster! What have you done to poor Bob.


Apart from your sick fantasy about Bob, very nice work Jacmoe. It's likely I'll use this in my project of mine.

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 2:53 am
by dudeabot
i feel sry for Bob :P

this is particular useful for tools like model viewers and scene editors and i guess one day it could eliminate the use of exporting plugins

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 8:38 am
by Zonder
dudeabot wrote:i feel sry for Bob :P

this is particular useful for tools like model viewers and scene editors and i guess one day it could eliminate the use of exporting plugins
yeah this is a great tool. the assimp project has more maintainers than all our plugin maintainers put together I think lol

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 9:25 am
by Jabberwocky
What a tremendously useful tool!
1. It's easier than exporting from a modeling tool, especially for us dumb programmers. :P
2. It circumvents the (sometimes prohibitively expensive) need to purchase 3dsmax/maya/etc to export models in those formats.
Thumbs up!

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 9:33 am
by jacmoe
Thanks, dudes! :D

It's a bit early in development, but since it's open sauce, I hope that we can make it one of the most useful tools for Ogre.
It's amazing what the Assimp guys supports, so why not make them maintain importers for all the various formats and save the hazzle?
Then we only need to worry about handling the Assimp scene format. :)

Lots to do, especially fixing the issues with animation and multi-pass materials, but it's a start, isn't it?

It's a perfect tool for me, because I am not an artist - and I really don't have the patience to really learn the nooks and crannies of Blender and/or other tools.
And command-line means that I can write a script for it. :wink:

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 10:03 am
by nevarim
very useful tool 8)

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 10:03 am
by Jabberwocky
About the bad animations, this may be a useful debugging aid:
  • load the exported .mesh and .skeleton in OgreMeshy
  • click the "show bones" button
  • ensure the bones are properly positioned, scaled, and aligned with the mesh
Also, play some animations, and watch how the bones move.

In my experience, a lot of broken animations are caused by the bones not being aligned properly with the mesh. An example:
  • the modeller creates a model
  • the modeller scales the model x10
  • the animator animates the model (at 10x scale)
  • the model is exported, but for some reason the scaling factor isn't applied to the mesh during the export, so your skeleton is 10x bigger than the mesh, breaking the animations.
This can also happen with other transforms, such as a rotation or translation instead of a scale. You'll see a ton of references to this exact problem with 3dsMax exports by searching the forums for "reset transform".

I'm not sure about the division of labor between OgreAssimpConverter and the assimp library. So it quite likely might be an assimp bug. But narrowing down the issue might at least help report the issue to the assimp devs.

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 10:46 am
by jacmoe
I fixed Bob so that he's almost normal. :)
Need to pick a time scale factor, though. The animations are generally way too slow.

And maybe a size scale factor, although that doesn't matter much, as we can use MeshMagick for that.

I can't see that the bones are misaligned, but I suspect that sometimes the wrong bone is chosen to be the root (not sure).

I also have a feeling that I need to apply a scale factor to bones for the animation frame (not sure here either).

I'll keep trying. :)

This dwarf has a good skeleton:
dwarf_skeleton.jpg
It goes haywire when animated:
dwarf_skeleton_ani.jpg
It's strange, because the skeleton seems to work 'on the vertical local scale' - it follows him, even when he lies/dies down.
It looks squashed from both sides..
Probably something simple?
Like a different animation technique?

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 10:47 am
by jacmoe
Bob is fine:
good_bob.jpg

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 11:07 am
by nevarim
nice cap :lol:

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 11:22 am
by Jabberwocky
My thoughts here may be stating the obvious, but I'll jot them down anyway.
jacmoe wrote:It looks squashed from both sides..
Probably something simple?
Like a different animation technique?
Tough to say. Normally my next step would be to open the dwarf in the modeling tool it was designed in, and have a look. Ideally you, or someone helping you, will have some basic competence in that modeling tool.

OgreMeshy is giving you a vague idea of what to look for. The rig, model, and bone weighting appear fine to me. As you noted, something is messing up the animations themselves. Maybe there is some kind of sketchy X-coord (width) scaling going on?

If you can find a different model built using the same modeling tool that exports properly, it can be helpful to look for differences between the good model and the broken model.

One last thought. Using OgreXMLConverter to convert the .skeleton to a .skeleton.xml file, then visually inspecting the .skeleton.xml file can sometimes help track down the bug.

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 11:30 am
by jacmoe
I am using the stock Assimp test models, so I know they're supposed to work(ish)
I use assimp-viewer and Ogre-Meshy and my own custom viewer.
It seems to work okay in the assimp-viewer, so it must be something in the ogreassimp code.
Most probably something really simple. :)

I am trying with most animated models in a sequence, so that I am not making the mistake of fixing it for one model and breaking it for all other models. :wink:

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 11:40 am
by Jabberwocky
Gotcha. My unfamiliarity with assimp may mean I'm giving some silly advice.

Would it help to export the dwarf using a different exporter, something that handles the export properly? Then compare the skeleton.xml files and see what's different? You could look at things like the bone heirarchy, and the individual rotations and scaling for a specific animation.

Re: OgreAssimpConverter

Posted: Fri Aug 05, 2011 1:57 pm
by jacmoe
A good idea to compare the xml-ed skeleton files.
I'll do that. :)

Re: OgreAssimpConverter

Posted: Sat Aug 13, 2011 7:50 am
by Svenstaro
jacmoe are you intending to contribute this back to upstream? I mean, a separate tool is alright but why have that when it could as well go upstream as an exporter? They already have some exporters in their svn and yours would make an excellent addition.

Re: OgreAssimpConverter

Posted: Sun Aug 14, 2011 3:32 pm
by jacmoe
Isn't this beyond the scope of AssImp?
Besides, this is not much more than a half-working hack at the moment. :)
I'd love to see animations working, and multi-meshes and complete scenes too.

Re: OgreAssimpConverter

Posted: Mon Aug 15, 2011 1:10 am
by tdev
using parts of your work in http://code.google.com/p/ogre-meshtool/ :)

sorry, found this thread later than the MeshMixer thread, so i posted there first but the post certainly belongs here.

Svenstaro wrote:jacmoe are you intending to contribute this back to upstream? I mean, a separate tool is alright but why have that when it could as well go upstream as an exporter? They already have some exporters in their svn and yours would make an excellent addition.
i also think that should go in there :)

Re: OgreAssimpConverter

Posted: Mon Aug 15, 2011 2:54 am
by inzero
This interests me, because I know almost nothing about modelling and exporting. I have seen the Blender exporter for Ogre, but really I'm so terrible with modelling programs (and the Blender GUI is a complex mess even for my poor programming brain) so I can't export anything more than a cube correctly. Since I'm not a modeller and I don't know anyone who is yet, I would like to use a variety of free models for testing, generated from as many modelling packages as I can so I'm not limited to just Blender, and I'm not going to pay for a Max to Ogre exporter or something.

So I have some questions:

1. OgreAssimpConverter, by itself, would allow me to take a model created in a wide variety of packages (Max, Maya, Blender, etc.) and magically convert it to an Ogre mesh that can be used immediately? I know there are animation bugs still, but this is the purpose of the program, yes?

2. MeshMixer is simply a nice looking GUI for OAC so I don't have to use a command-line interface? Possibly allowing drag'n'drop of some .max file or whatever that will then spit out a shiny working Ogre .mesh?

3. If the above questions are true, shouldn't this become a standard Ogre tool that is regularly maintained so us non-modellers can get stuff into our games without jumping through hoops or paying for exporters?

Re: OgreAssimpConverter

Posted: Mon Aug 15, 2011 3:18 am
by jacmoe
The idea is that you can just drag and drop models in various formats on the executable and it will give you mesh/skeleton/material, yes. :)
If you want more control, then give it some arguments from either a script or through the command prompt.
But that's basically it.
Like the OgreXMLConverter, but for any model format supported by Assimp.

Re: OgreAssimpConverter

Posted: Mon Aug 15, 2011 3:48 am
by Svenstaro
jacmoe wrote:Isn't this beyond the scope of AssImp?
Besides, this is not much more than a half-working hack at the moment. :)
I'd love to see animations working, and multi-meshes and complete scenes too.
Isn't this exactly the scope of assimp? You should definitely try to get your stuff upstream.

Re: OgreAssimpConverter

Posted: Sat Aug 20, 2011 8:12 am
by cloud
Don't know if this helps or not but I tried to clean up the code a bit and added callbacks to customise the creation the material and/or scene data, setup codes a bit like

Code: Select all

		
OgreAssimp::Loader assLoader;
assLoader.setCustomMaterialExportCallback(boost::bind(&OgreAssimp::LoaderCustomisation::scriptMaterialExportCallback, _1, _2, _3));
assLoader.setSceneExportCallback(boost::bind(&OgreAssimp::LoaderCustomisation::dotSceneExportCallback, _1, _2));
assLoader.convert("/Ogre/assimp--2.0.863-sdk/test/models-nonbsd/MD5/Bob.md5mesh", "", OgreAssimp::Loader::LP_GENERATE_SINGLE_MESH);
The setSceneExportCallback obviously isn't needed if exporting a single mesh, and the same default as before will be used if setCustomMaterialExportCallback isn't called.

This might not be useful in the context of command tool, but I thought I might as well post it anyway and let you decide.

The root node still seems to be a problem for me, with certain model formats (I think it was collada) in grabBoneNamesFromNode, if I comment out first two occurances of flagNodeAsNeeded it seems to work, some oddity going on there.

http://www.pearsonp.force9.co.uk/OgreAssimpLoader.zip

Re: OgreAssimpConverter

Posted: Sun Aug 21, 2011 8:35 pm
by jacmoe
The root node is a complete mystery. :)
If you have any problem models, send then this way.
I'll check out your code - I'll pick it up again shortly as I've gotten my grubby hands on some juicy code which just might fix the animation issues too.. :wink:

<edit>
Really cool to see that you are using GOOF - I thought no one remembered it now. :)

Do you have a real name I can attribute you with?
OgreAssimp owe you a lot.
</edit>
Svenstaro wrote:You should definitely try to get your stuff upstream.
Not now, later. :)
I don't feel like dealing with their exporter interface right now - at least not until everything works.
It's far easier to have Ogre around to help out than a pure code approach.