32 Bit OBJ File reading

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

32 Bit OBJ File reading

Postby Wol101 » Tue Jul 05, 2016 9:48 am

Here is a quick patch to allow the 1.9 COBJMeshFileLoader.cpp to cope with bigger meshes. All it does is replace the SMeshBuffer with a 32 bit CDynamicMeshBuffer as used in some of the other asset loaders. There will be a small performance hit in this simple implementation because it doesn't check the number of vertices and use the appropriate index size. I doubt it will make much difference in practice since if you are in a situation where you have large meshes to deal with you obviously have the hardware to cope! The OBJ loader is fairly slow anyway but it's not a high performance asset format (a binary format that tells you how many items there are before you try and read them would be much quicker). That's the cost of flexibility and simplicity.
cpp Code: Select all
 
diff -r1.1.1.1 COBJMeshFileLoader.cpp
262,263c262,267
<                   currMtl->Meshbuffer->Vertices.push_back(v);
<                   vertLocation = currMtl->Meshbuffer->Vertices.size() -1;
---
>                   // patch - altered to allow bigger meshes
>                   currMtl->Meshbuffer->getVertexBuffer().push_back(v);
>                   vertLocation = currMtl->Meshbuffer->getVertexBuffer().size() -1;
>                   // currMtl->Meshbuffer->Vertices.push_back(v);
>                   // vertLocation = currMtl->Meshbuffer->Vertices.size() -1;
>                   // ~patch - altered to allow bigger meshes
277,279c281,288
<               currMtl->Meshbuffer->Indices.push_back( faceCorners[i+1] );
<               currMtl->Meshbuffer->Indices.push_back( faceCorners[i] );
<               currMtl->Meshbuffer->Indices.push_back( faceCorners[0] );
---
>               // patch - altered to allow bigger meshes
>               currMtl->Meshbuffer->getIndexBuffer().push_back( faceCorners[i+1] );
>               currMtl->Meshbuffer->getIndexBuffer().push_back( faceCorners[i] );
>               currMtl->Meshbuffer->getIndexBuffer().push_back( faceCorners[0] );
>               // currMtl->Meshbuffer->Indices.push_back( faceCorners[i+1] );
>               // currMtl->Meshbuffer->Indices.push_back( faceCorners[i] );
>               // currMtl->Meshbuffer->Indices.push_back( faceCorners[0] );
>               // ~patch - altered to allow bigger meshes
 
diff -r1.1.1.1 COBJMeshFileLoader.h
12c12,15
< #include "SMeshBuffer.h"
---
> // patch - altered to allow bigger meshes
> #include "CDynamicMeshBuffer.h"
> //#include "SMeshBuffer.h"
> // ~patch - altered to allow bigger meshes
48c51,54
<           Meshbuffer = new SMeshBuffer();
---
>           // patch - altered to allow bigger meshes
>           Meshbuffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_32BIT);
>           //Meshbuffer = new SMeshBuffer();
>           // ~patch - altered to allow bigger meshes
60c66,69
<           Meshbuffer = new SMeshBuffer();
---
>           // patch - altered to allow bigger meshes
>           Meshbuffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_32BIT);
>           //Meshbuffer = new SMeshBuffer();
>           // ~patch - altered to allow bigger meshes
65c74,77
<       scene::SMeshBuffer *Meshbuffer;
---
>       // patch - altered to allow bigger meshes
>       scene::CDynamicMeshBuffer *Meshbuffer;
>       // scene::SMeshBuffer *Meshbuffer;
>       // ~patch - altered to allow bigger meshes
 
 
Wol101
 
Posts: 9
Joined: Sat Apr 23, 2016 6:39 am

Re: 32 Bit OBJ File reading

Postby CuteAlien » Tue Jul 05, 2016 10:56 am

Thanks. Do you have some test-model you could share for this? (not to include to Irrlicht, just for me to test the code)

edit: Hm, not good to always use a 32-bit meshbuffer. In general having 16-bit is still prefered (faster to transfer 16-bit meshes to gpu).
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8363
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: 32 Bit OBJ File reading

Postby mongoose7 » Tue Jul 05, 2016 11:13 am

Probably better to use more groups if the mesh is that big.
mongoose7
 
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: 32 Bit OBJ File reading

Postby AReichl » Tue Jul 05, 2016 11:25 am

I once had changed the .stl loader to SWITCH to a 32-bit buffer if the number of loaded vertices was bigger than 65000.
AReichl
 
Posts: 234
Joined: Wed Jul 13, 2011 2:34 pm

Re: 32 Bit OBJ File reading

Postby CuteAlien » Tue Jul 05, 2016 12:00 pm

@AReichl: Hm, we didn't apply that yet I guess. Do you have the link to that? Or was it just a private thing? Btw - several of NASA recently release free models are STL!
@mongoose7: Generally aggreed. But won't hurt if Irrlicht can load larger meshes, just 16-bit should stay default.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8363
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: 32 Bit OBJ File reading

Postby Foaly » Tue Jul 05, 2016 6:52 pm

I also have a version of the stl loader which allows 32 bit indices, I can post it here if you need it.
But it's actually quite simple, because the stl format doesn't use indices at all, so they can be generated afterwards.
Foaly
 
Posts: 141
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: 32 Bit OBJ File reading

Postby CuteAlien » Tue Jul 05, 2016 8:00 pm

Sure post it and preferably also post a test-model so it's easy to check if it works.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8363
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany


Re: 32 Bit OBJ File reading

Postby CuteAlien » Wed Jul 06, 2016 10:24 am

thanks!
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8363
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest