Page 1 of 3

IrrAssimp (mesh import/export)

Posted: Sat May 02, 2015 5:44 pm
by JLouisB
Hi,
During the last weeks, I have integrated the Assimp library (http://assimp.sourceforge.net/) in an Irrlicht project.
Assimp is a library actively developed and maintained made to import/export 3D models in a lot of file fomats.
Assimp supports a lot of imports formats (more than 40), and it's useful in particular for animated meshes because Irrlicht doesn't support the most popular formats for that, like FBX or Collada.
Assimp can also export in 4 formats and only static mesh yet (like Irrlicht : Collada, obj, stl, ply), but more formats are available in the trunk version (3DS, Assimp format(binary/XML), DirectX (.x))

To use it :
- Download Assimp and add it to your project.
- Add the content of the IrrAssimp folder in your projet
- And the usage is very simple :

Code: Select all

// The assimp loader is in a separate system and not directly implemented as a meshLoader to give the choice to use Irrlicht or Assimp for mesh loading to the user, in function of the format for example
IrrAssimp assimp(smgr);
IAnimatedMesh* mesh = assimp.getMesh("Media/dwarf.x");
if(!mesh)
{
    std::cout << assimp.getError().c_str() << std::endl;
    device->drop();
    return 1;
}
assimp.exportMesh(mesh, "obj", "Media/export.obj");
If you use a trunk version of Assimp, note that animated meshes support is not yet implemented in the exporter, I will add this.

The code is on Github.

Re: IrrAssimp (mesh import/export)

Posted: Sat May 02, 2015 8:15 pm
by Ovan
uhm just a question for other
why your class isn't derived from IMeshLoader/IMeshWriter then passed to the video driver ?

http://irrlicht.sourceforge.net/docu/cl ... oader.html
http://irrlicht.sourceforge.net/docu/cl ... riter.html

permit to use the default interface from IVideoDriver can be more simple ...

Re: IrrAssimp (mesh import/export)

Posted: Sat May 02, 2015 9:29 pm
by JLouisB
Yes it can be more simple with IMeshLoader/IMeshWriter.

If I have chosen to not create the class as a MeshLoader, it's because there are a lot of formats that Irrlicht and Assimp can load quite both.
So for this formats, I want to have the choice between use Irrlicht loaders or Assimp loaders for each mesh, in function of the format for example.
Maybe some specific formats/files can give a better result with Assimp, maybe with Irrlicht.
If I add the class as a mesh loader, Irrlicht's loaders will be automatically overrided by Assimp, I prefer have a clear difference between the 2 loaders.

So it's not the most simple, but maybe more flexible and it doesn't complicate a lot the things for the same result :

Code: Select all

scene::IAnimatedMesh* getMesh(core::stringc path)
{
    IrrAssimp assimp (Smgr);
    if (assimp.isLoadable(path))
        return assimp.getMesh(path);
    else
        return Smgr.getMesh(path);
}
Otherwise, you can easily change the code to use directly IrrAssimpImport as a mesh loader and IrrAssimpExport as mesh writer (but I'm open to suggestions, if many people think that it's a bad design I can change it).

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 10:46 am
by AReichl
Yeeehaa - something i have waited for a long time.
I think CopperCube (=IrrEdit) also uses Assimp internally.
MAYBE we should go this way - get rid of the buildin loaders (except maybe .irr, .irrmesh)
so the developers can concentrate on MORE IMPORTANT things. Other engines also do it so.
Then JLouisB "only" has to maintain the wrapper.
I know i know - one dependency you would have to install besides Irrlicht, but think about
the advantage ...

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 11:10 am
by Nadro
Hi,

This is really useful stuff, thanks a lot for that :)

Cheers,

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 5:07 pm
by airc
looks good , but irrlicht already has plenty of mesh loaders , so why another mesh loader?

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 6:14 pm
by thanhle
I like this : ).
But I don't like the use of boost in Assimp.

Cheers
thanh

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 9:01 pm
by JLouisB
It's good know that it's can be useful for some people :)


@airc : Irrlicht has a planty of mesh loaders, but some very useful formats are missing in Irrlicht.
In particular if you want import an animated model in Irrlicht, Irrlicht supports only some old and not very popular file formats.
Currently, most of the 3D softwares/modern game engine use formats like FBX or Collada, they are the current standards to transfer 3D models between the applications, and Irrlicht doesn't support them (there is a Collada loader, but for static mesh only).

The export feature is recent in Assimp, but I hope that in the futur, Assimp will be able to export animated mesh in popular formats like FBX.
Currently the only way to export an animated mesh in Irrlicht is with the recently added B3D exporter, it's good to have at least one exporter to do this, but it's not the best format to transfer 3D models with the other applications.


@thanhle : Look at here, Assimp can be built without Boost.

Re: IrrAssimp (mesh import/export)

Posted: Sun May 03, 2015 10:05 pm
by CuteAlien
Very cool - several people already asked about assimp and Irrlicht. Great I can finally link them here :-)

Re: IrrAssimp (mesh import/export)

Posted: Mon May 04, 2015 12:58 am
by sunqian
Very useful. Just tried it, now we can load fbx animation. Thanks for your great work!

Re: IrrAssimp (mesh import/export)

Posted: Mon May 04, 2015 5:40 pm
by christianclavet
Wow! FBX too?!! This is incredible! Now that Irrlicht can save animated meshes (B3D) and with this ability to load all theses format Irrlicht will be more accessible than ever! Great job!

Re: IrrAssimp (mesh import/export)

Posted: Wed May 06, 2015 10:32 pm
by JLouisB
Thanks for your enthusiasm about this :)

Christian, yes, FBX is supported by Assimp, but I have just noticed that it's not written on their website, the "features" page of Assimp is probably not up to date.

Re: IrrAssimp (mesh import/export)

Posted: Sun Aug 07, 2016 10:27 pm
by christianclavet
Used it, and it work now. (Used FBX) I will have to see why my exports from MAX seem to have axis inverted. My swordman is lying on the ground and the sword and buckle inverted (wrong hand, so there is a axis flip)

EDIT:
I fixed it, changed the line 133 in IrrAssimpImport.cpp:
From

Code: Select all

AssimpScene = Importer.ReadFile(to_char_string(FilePath).c_str(), aiProcess_Triangulate |  aiProcess_GenSmoothNormals | aiProcess_FlipUVs);
to

Code: Select all

AssimpScene = Importer.ReadFile(to_char_string(FilePath).c_str(), aiProcess_Triangulate | aiProcess_MakeLeftHanded | aiProcess_GenSmoothNormals | aiProcess_FlipWindingOrder | aiProcess_FlipUVs);
Now my FBX models that come from 3D Studio Max are the same in the application. The buckle and sword appear in the proper hand, no more X axis flipping.

Re: IrrAssimp (mesh import/export)

Posted: Tue Dec 04, 2018 11:48 am
by robmar
Did animation support get added? Tried using the latest Asimp to import an animated FBX and it crashed immediately.

Re: IrrAssimp (mesh import/export)

Posted: Thu Dec 06, 2018 10:59 am
by netpipe
i was wondering the legality's of selling / using this for projects. are any of the formats used proprietary ?