IrrAssimp (mesh import/export)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

IrrAssimp (mesh import/export)

Post 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.
Ovan
Posts: 70
Joined: Thu Dec 18, 2008 12:41 am
Contact:

Re: IrrAssimp (mesh import/export)

Post 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 ...
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

Re: IrrAssimp (mesh import/export)

Post 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).
AReichl
Posts: 268
Joined: Wed Jul 13, 2011 2:34 pm

Re: IrrAssimp (mesh import/export)

Post 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 ...
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: IrrAssimp (mesh import/export)

Post by Nadro »

Hi,

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

Cheers,
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
airc
Posts: 25
Joined: Wed Jan 08, 2014 8:17 am

Re: IrrAssimp (mesh import/export)

Post by airc »

looks good , but irrlicht already has plenty of mesh loaders , so why another mesh loader?
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: IrrAssimp (mesh import/export)

Post by thanhle »

I like this : ).
But I don't like the use of boost in Assimp.

Cheers
thanh
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

Re: IrrAssimp (mesh import/export)

Post 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.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: IrrAssimp (mesh import/export)

Post by CuteAlien »

Very cool - several people already asked about assimp and Irrlicht. Great I can finally link them here :-)
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
sunqian
Posts: 2
Joined: Wed Apr 08, 2015 11:42 am

Re: IrrAssimp (mesh import/export)

Post by sunqian »

Very useful. Just tried it, now we can load fbx animation. Thanks for your great work!
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrAssimp (mesh import/export)

Post 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!
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

Re: IrrAssimp (mesh import/export)

Post 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.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrAssimp (mesh import/export)

Post 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.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: IrrAssimp (mesh import/export)

Post by robmar »

Did animation support get added? Tried using the latest Asimp to import an animated FBX and it crashed immediately.
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: IrrAssimp (mesh import/export)

Post by netpipe »

i was wondering the legality's of selling / using this for projects. are any of the formats used proprietary ?
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
Post Reply