Loading obj mesh files with 32bit index type

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Loading obj mesh files with 32bit index type

Post by robmar »

Its really easy, don't worry! Just search for all u16 references related to indices, add a switch like:

#ifndefine _INDICES_32
u16 *indices;
#else
u32 *indices;
#endif

Do a good search for all indices reference calls, and make sure the functions use the 32-bit value if _INDICES_32 is used.

Doing this isn't difficult and its a good way to learn you way around the code.
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: Loading obj mesh files with 32bit index type

Post by AReichl »

> Just search for all u16 references related to indices ...

fine again - but where all?
Only in the .stl loader or all over the library?
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Loading obj mesh files with 32bit index type

Post by CuteAlien »

AReichl: Both answers are correct :-) Basically you only have to fix the loader to get 32-bit meshes working. But I think there are also still places in the library which don't support 32-bit yet. So drawing will work, some mesh-manipulation stuff might not.
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
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: Loading obj mesh files with 32bit index type

Post by AReichl »

Got it!

I changed the stl loader in the shader-pipeline branch similar to the TerrainSceneNode. If during loading the number of indices exceeds 16bit-max (65536 or a little less) then i switch to 32bit. You could also begin with 32bit, but that would be a giveaway for small meshes.

And guess what - it runs faster than other stl-viewers i tried (specially with Directx11).

I will also try to get it working with trunk (CDynamicMeshBuffer?), but in principle the problem is solved.
Post Reply