SMeshBuffer Indices

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.
Post Reply
Tempest
Posts: 9
Joined: Fri Jan 11, 2008 11:26 pm

SMeshBuffer Indices

Post by Tempest »

Hello folks.

I'm trying to load a POV-Ray mesh2 structure into my program and display it with Irrlicht. The task should be pretty straightforward; parse the file and stuff all the vertex and normal data into an SMeshBuffer, right?
But I'm a little confused about the Indices. Since they are used to define triangles, and hence always come in groups of three, I would have expected Irrlicht to store them as vectors, not just an array of integers.
So how do I fill them in? Just one after the other, like t1-1, t1-2, t1-3, t2-1, t2-2, t2-3, t3-1, t3-2, t3-3, t4-1,... ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SMeshBuffer Indices

Post by hybrid »

Yes, for the standard mesh type just put them into this order. You have to respect the winding order, so triangles have to be in clockwise order when being looked at from their front side. The reason why we do not use vectors is that you can also have other types of meshes which use different index types.
Please also note that for standard types, the indices have type short (16bit), so make sure you have less than 65535 vertices and you use that data type as well.
Tempest
Posts: 9
Joined: Fri Jan 11, 2008 11:26 pm

Re: SMeshBuffer Indices

Post by Tempest »

Gotcha, thanks for the reply.

The 65k limit shouldn't be a problem for any of the models I'm working with. As to the winding order of the indices, I can only hope that they are in the right order in the source file, for how would I check that? :P
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SMeshBuffer Indices

Post by hybrid »

Usually all model formats define the winding order. Otherwise you can disable backface culling for a first test, and later on work out a method to access the proper front facing order.
Post Reply