Page 1 of 3

An8 Importer[Updated 08.Mai 2006: Beta 1.3]

Posted: Tue May 02, 2006 11:42 pm
by sudi
Today i sat down and thought that i really need a fast and easy way to edit my gamelevels.......eventhough there are no lightmaps......anyways i came up with a Anim8or fileimporter...
Ok right now it's only able to load basic meshes and i got some problems with the normals Anim8or exports....but other than that i works great...

Ohhh and how do i get irrlicht to render a meshbuffer with more than 3 vertizes? this is mainly the reason for my importer that it only supports triangel meshes right now.

I will upload some screenshots and the source as soon as i get some more time

DOWNLOAD: http://www.gdlib.net/index.php?name=Dow ... ails&id=90

Image

PS: It's not integrated into irrlicht as all the other loaders i saw....so i still have to do that but it's easy to use:
Exampel:
CAn8Parser MyData;
MyData.parse("Anim8or.an8"); //Anim8or.an8 is an Anim8or File
IAnimatedMeshSceneNode* myNode = smgr->addAnimatedMeshSceneNode(MyData.getFile().makeIrrlichtObject(device,0));
or to load a whole scene
MyData.getFile().makeIrrlichtScene(device, 0);

makeIrrlichtObject takes two parameters...the first is the Irrlicht device u r using...and the second is the object index of the An8 Object in the file(0=first....and so on)
makeIrrlichtScene takes two parameters...the first is the Irrlicht device u r using...and the second is the scene index of the An8 Scene in the file(0=first....and so on)

Posted: Wed May 03, 2006 1:30 am
by bitplane
yey! we like more importers :)
re: more than 3 verts, I think you mean you want to triangulate concave polygons. You might want to steal the algorithm from wings3d's source since the license is compatible with irrlicht's :)
edit: oh no you won't, I forgot its written in some obscure 3d language!

Posted: Wed May 03, 2006 7:54 am
by hybrid
For simple polygons take a triangle fan alorithm. Use the first vertex as root and use these indices: 0,1,2, 0,2,3, 0,3,4,...
Many mesh loaders do it like this. It would be much easier to use triangle fans directly, but that's currently not possible with Irrlicht's mesh buffers.
What are the benefits of anim8 over the formats which aim8tor can export?

Posted: Wed May 03, 2006 8:14 am
by hybrid
Ok, I just read an example file. The anim8tor files use some basic primitives which have to be triangulated. Maybe implement some mesh buffer creators to easily add the primitive elements. For quadruple faces the triangulation is also rather simple. although the previously mentioned algorithm works just like that, too.
What about texture mapping? I think planar mapping is used by default?
And there are lots of advanced features left...

Posted: Wed May 03, 2006 8:17 am
by jam
hybrid wrote: What are the benefits of anim8 over the formats which aim8tor can export?
Don't know if the importer will support this, but one can maybe finally load animated models into irrlicht as Anim8tor only saves this info in an8 files.

Posted: Wed May 03, 2006 1:31 pm
by sudi
@hybrid
right now u can uv map the mesh in anim8or and than apply the texture in irrlicht but at this moment i'm working on the marterial loader...so it will be there soon.
@jam
i actually just thought about supporting objects and scenes(want to use it as a level editor)
But maybe i will add animated meshes too....but that is just hypotetical.

Posted: Wed May 03, 2006 4:09 pm
by jam
[quote="Sudi"
@jam
i actually just thought about supporting objects and scenes(want to use it as a level editor)
But maybe i will add animated meshes too....but that is just hypotetical.[/quote]

That would be great if you did, if not maybe someone can use the File export plug-ins support that is coming to v0.95 of anim8tor to bring animations to irrlicht, either way I think this would be a very useful importer.

Posted: Wed May 03, 2006 4:22 pm
by sudi
[offtopic]
is this plugin already out?
if the whole thing was pointless
since i already have a mapformat in which i'm formating the an8 files to load them.........
[/offtopic]

Posted: Thu May 04, 2006 4:22 pm
by sudi
Released!!
see first post

Posted: Fri May 05, 2006 6:57 am
by jam
Sudi wrote:[offtopic]
is this plugin already out?
if the whole thing was pointless
since i already have a mapformat in which i'm formating the an8 files to load them.........
[/offtopic]
No, the plugin in not already out. Now I have to go off and try your loader as soon as it is available 8)

Posted: Fri May 05, 2006 7:39 am
by hybrid
Hmm, still not uploaded. Could you please send me the files via e-mail (see webpage for adress) such that I can integrate it into the file formats patch page?

Posted: Fri May 05, 2006 12:05 pm
by sudi
I uploaded it in the anim8or forums....but it's still not finished and the loading is really slow

http://www.anim8or.org/pn/index.php?nam ... 4496#44496

PS: the loader doesn't support groups....so u have to ungroup ur meshes before resaving

Posted: Fri May 05, 2006 12:26 pm
by hybrid
:shock: Did you notice that Irrlicht Mesh loaders follow a special (actually not special, but consistent :wink: ) implementation style? Your files (although only headers included in the file - will you open source your loader sometimes :?: ) seem to be really split into too small pieces.
Lack of speed is porbably due to IReadFile->read() because many calls of this method require lots of locking/unlocking of the file. I have the same with my dxf/ase loaders. But I dislike the approach of buffering the file into a large string. The file system should do that.

Posted: Fri May 05, 2006 12:41 pm
by sudi
Sry i forgot to ship the source while cutting down file size i probably deleted the source folder.....my bad(uploaded the one with source)

And i'm not using IReadFile....thats why i sad i have to port it......

Posted: Fri May 05, 2006 1:54 pm
by hybrid
Ok, got the code.
Well, using fgetc or fread does exactly the same as IReadFile->read() so basically each byte oriented reading in files is slow. You got to read large portions of the file and parse them later on to speed up these things. And of course string handling is also slow. But the latter is harder to reduce, but you shouldn't probably pay attention to such things.
It's much more important to implement the IMeshLoader interface and make the file format accessible by Irrlicht the usual way. Also make your additional structures only structs, not classes, and hide them inside the an8loader class. That way you save some memory and avoid name space pollution by unnecessary structures.