Irrlicht - how to create a scene from custom scene format?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Irrlicht - how to create a scene from custom scene format?

Post by karx11erx »

Hi,

I am maintaining D2X-XL, an OpenGL conversion of the once popular 3D shooter Descent, and I am looking for a better renderer for it. On my search I have come across Irrlicht, and it looks pretty interesting. While there are a few tutorials and also a lot of stuff in this forum, I still found some general explanation of the purpose of the various elements of the Irrlicht sorely missing.

What e.g. is a scene node? What is the purpose of a mesh? Ok, now I have a rough understanding of these things, but from studying the API, the tutorials and some of the example code here in the forum I still have no idea how to simply have Irrlicht build a "level" from some triangle vertices, textures and texture coordinates I throw at it, or how to create some "object" (e.g. a small space ship) the same way.

I think a mesh basically is what I'd put a triangle in, but how do I have to code that?

Would someone mind giving me a brief outline? I am not at all a programming noob, I am just unfamiliar with Irrlicht's concepts and terminology, so I'd just need some help to get started. :)

Feel free to reply in German if you find that easier. English is of course welcome too. ;)

karx11erx
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

A scene node is a node in the scene graph and is something that gets rendered by irrlicht, generally it contains some list of vertices etc that get rendered to produce an on screen visual.

A mesh is one way that you can group together lots of vertices and polygons and is what's used when loading 3D models, such as .3ds, .x, .md2 etc.

So if you've got a custom model format there, listing your vertices, polygons etc then you can write a loader, similar to the ones already in irrlicht (check the source) to load the model and get it rendered.
Image Image Image
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

I had hoped someone who knows how to do that would post a few lines of code here, saving me from having to dig through engine source code for days ...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well it's going to be more than a few lines of code...

And you won't have to dig through loads of code. Just look at source/irrlicht/C3DSMeshFileLoader.cpp which is how 3DS models are loaded. From that you should be able to see fairly clearly how you could about doing it yourself.
Image Image Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

We should probably change example 3 to use a mesh buffer, as questions about making mesh buffers get asked a lot.
The principle is the same as in example 3 though, you have a list of vertices (points in space) and a list of indices (the index of each vertex that makes up a triangle). add your IMeshBuffers (CMeshBuffer<S3DVertex>) into an IMesh (SMesh) and then call addMeshSceneNode or addOctTreeSceneNode like in the other examples.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

What I mainly looking for is what kind of class to store triangle info in, and how to call that. I don't want a complete loader posted here for me. Rather something like "this is the class for your triangles (Mesh?) - instantiate and call like this". Plug all instances of them in a ... MeshBuf (?), plug all MeshBufs in a ... SceneNode (?) and all SceneNodes (?) in a ... ? like this: ... "

What I think is that a SceneNode are some renderable item of any kind that you organize hierarchically and that there is at least one top scene node you put into your scene ... it's just that there's a lot of classes that do not really seem to be explained at all. Mesh - does that translate to "polygon with some extra properties"? And AnimatedMesh?

I didn't find anything explaining me how to set up a mesh, or how to use an animated mesh (ok, from what I have read I believe I may understand how an animated mesh might work, but I am not sure).

Should be a matter like those tutorials - most of them don't have much code.

But I will check that file, thanks for the info. :)

bitplane,

tutorial 3? If not, where do I find example 3?
Last edited by karx11erx on Wed Mar 05, 2008 3:07 pm, edited 2 times in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

yes, tutorial 3. They're in the /examples/ dir.

IMeshBuffer = a single surface (usually a collection of polygons) with one material
IMesh = a collection of IMeshBuffers
IAnimatedMesh = a mesh that contains animation data
ISceneNode = a branch or leaf of the scene graph; could be a light, terrain, mesh, animated mesh, or special grouping / transformation / culling node

The API docs explain how to use each of the classes, any questions just ask :)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

bitplane wrote:The API docs explain how to use each of the classes, any questions just ask :)
If so, I haven't found this. I am reading the online API doc (the Doxygen generated stuff), but it only explains everything very superficially; definitely not the concepts behind everything, and I think I should understand the concepts of the engine before I can use it.

Is it correct that I can pass one geometrical primitive per append() call to an IMeshBuf? What's the index list good for then? I know that at least OpenGL renders a vertex list fastest if you provide an index list for them, but append() could build it itself, couldn't it?

So far I had thought that an IMesh was a single primitive, and an IMeshBuf was a collection of IMeshes ... how easily one can be mislead ...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This is from STLMeshFileLoader

Code: Select all

SMesh* mesh = new SMesh();
mesh->addMeshBuffer( new SMeshBuffer() );
SMeshBuffer* mb = reinterpret_cast<SMeshBuffer*>(mesh->getMeshBuffer(mesh->getMeshBufferCount()-1));
u32 vCount = mb->getVertexCount();
mb->Vertices.push_back(video::S3DVertex(vertex[0],normal,color,core::vector2df()));
mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color,core::vector2df()));
mb->Vertices.push_back(video::S3DVertex(vertex[2],normal,color,core::vector2df()));
mb->Indices.push_back(vCount);
mb->Indices.push_back(vCount+1);
mb->Indices.push_back(vCount+2);

SAnimatedMesh* pAM = 0;
if ( 0 != mesh->getMeshBufferCount() )
{
  mesh->recalculateBoundingBox();
  pAM = new SAnimatedMesh();
  pAM->addMesh(mesh);
  pAM->recalculateBoundingBox();
}
mesh->drop();
I hope it helps, otherwise look into the other loaders, too.
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

There is no "SMeshBuffer" mentioned in the online Irrlicht Engine Class Index. Is it derived from a base class somewhere in the loader? (Cannot access the engine source code here.)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

It's a typedef for CMeshBuffer<S3DVertex>, just as bitplane already mentioned (or tried to)
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

<rant>
The entire Irrlicht documentation - if you can call it that - is a mess.

Nowhere are the concepts explained. Documenting classes using some inline documentation is not explaining the greater picture or constructs. An API documentation is not a "how do I use this tool" style documentation.

I don't think it's a good idea either to constantly ask people here for a solution for this and that. Years of experience with quite a few projects have taught me that such a thing is very unpopular.

It is so frustrating having to dig through rudimentary tutorials, examples, explanation and source code for weeks and weeks to get something seemingly as simple going as initializing a renderer (ok, that's explained well), throwing a bunch of triangles at it, setting up a camera and tell it "go render"; and that would only be a start. How are complex models handled - particularly if not in some format supported by irrlicht, but again something proprietary I'd have to stuff into some I<whatever>Node. Or light sources? Do I have to derive new classes and create rendering functions for them?

I have been coding D2X-XL for over three years now, with as good as no reward, and I am really fed up of this.

Problem is, I don't want to rewrite that program from scratch, I simply want to drop a modern renderer in it (at least for the first step). So what I need is a way to pass all static geometry (triangle vertex coordinates, textures, texture coordinates) to the engine, pass all 3D objects (again triangle vertices, textures and texture coordinates), to the engine, and tell the engine about all light sources. Give it a view point and orientation (camera), that's it.

Unfortunately I lack the few million dollars for a professional modern game engine plus support.

Oh well. Sigh.

</rant>
Last edited by karx11erx on Thu Mar 27, 2008 11:17 pm, edited 1 time in total.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Super, I await your updated documentation with interest.

Being responsible for a volunteer project, you will of course understand that if you're not prepared to do it yourself, then you have no grounds for complaining that nobody else is prepared to do it.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
karx11erx
Posts: 42
Joined: Wed Mar 05, 2008 1:28 pm

Post by karx11erx »

I am responsible for the stuff I am making. I don't make the Irrlicht engine. I'd expect people building something having the ambition to make it really useable.

Of course I understand that I cannot demand anything here, be it a documentation or whatever else, as the people building it are volunteers and I am not a paying customer. I also understand that volunteers rather do the fun stuff than the tedious work.

It's just that such a documentation would really be needed. I couldn't even create it though, how should I? I have as good as no understanding of the Irrlicht engine yet.

It's so frustrating there is nothing I could just read for a few days and then I'd know how to use all the parts and constructs in the Irrlicht engine, at least know enough to ask "intelligent" questions.

As I said: People usually don't like constantly being asked stuff.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

I'd expect people building something having the ambition to make it really useable.
Wow that's surprising, I would expect people who have the ambition to use something would also want to make it really useable. Maybe you should try and work on that too.
I also understand that volunteers rather do the fun stuff than the tedious work.
Uhmm, they are paying a lot of attention to the "tedious" stuff, which is basically all an engine is.
It's so frustrating there is nothing I could just read for a few days and then I'd know how to use all the parts and constructs in the Irrlicht engine, at least know enough to ask "intelligent" questions.
If you expect that is what you will have to do to use anything, then you are sadly mistaken.
As I said: People usually don't like constantly being asked stuff.
We like being asked things, but not when we provide answers, and the user simply disregards those answers. That is what we don't like.

Seriously, how do you think all these people in this community got so advanced with the Irrlicht engine? By sitting around and bi****n' all day, or by actually studying code, studying the engine, etc.

Take some time, and learn the engine!
TheQuestion = 2B || !2B
Post Reply