STL (file format)

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!
Post Reply
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

STL (file format)

Post by asparagusx »

Hello

There seems to be an issue with large STL files (more than 65535 vertex indices). I am using 1.8.1. Is this a known issue - has it been resolved. Here is a sample model http://www.thingiverse.com/thing:293268 that does not load correctly. Triangles all over the place. Looks like STL loader only supports 16-bit indices?

Regards

Anton
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: STL (file format)

Post by CuteAlien »

Yeah, STL only supports 16-bit meshbuffers. I think the same is true for most mesh-loaders. Generally it's a good idea to split meshes up into more meshbuffers. If that's not possible at all you will have to rewrite the loader to use CDynamicMeshBuffer instead of SMeshBuffer (preferably only when more than 65k vertices are used).
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: STL (file format)

Post by asparagusx »

I converted the file (STL) using an online converter (to .OBJ) and I still had issues. When you look in the .OBJ file the indices has this format :-

f 3027//685 3029//1177 3043//685 (as an example)

which looks like an index into vertex normals as the 2nd number?? Other .OBJ files do not have the additional //nnnn

Looking at the index values in the .OBJ file, they all appear to be 16-bit indices.

Anybody working on these loaders?

Anton
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: STL (file format)

Post by CuteAlien »

I checked yesterday and the only meshes supporting 32-bit so far are IrrMesh, PLY and the terrainscenenode. I don't know anyone who is currently working on the loaders. The thing is that larger meshes are rarely useful for games - as it's always more effective splitting the meshes up onto 16-bit meshbuffers. Doesn't mean it wouldn't be nice if someone would modify the loaders to support both. But that has to come from the community, our small core-team is currently working on other stuff (mainly on the Android branch to get that in a state where it can be merged back into the trunk).
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: STL (file format)

Post by asparagusx »

I will see if I can track the problem down. I need these loaders to work as my application as is CAD system, which uses irrlicht as a 'viewer, but we need to load external models'. I think it is not actually related to the large index buffers, but something else in the files. Is there an example loader I can use to see how to use dynamic mesh buffers to switch between 32 and 16 bit indices if needed.

Got a nice bit of 3D printing going out of our system now :-)

Anton
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: STL (file format)

Post by CuteAlien »

Maybe take a look at the PLY loader in Irrlicht. I've not worked yet with 32-bit buffers myself.
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: STL (file format)

Post by asparagusx »

I have changed the STL loader to use Dynamic Buffers and my test model is now loading correctly. I have never submitted any changes re irrlicht - how do I go ahead to add the changes to some kind of version control? The issue was simply related to the fact that the number of vertices was a lot more than 65535.

I also changed the code for the OBJ loader to assume indices more than 65535 using DynamicMeshBuffer. If the actual number of vertices is less than that for a material, I set the size back to a 16bit index array.

Thanks

Anton
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: STL (file format)

Post by CuteAlien »

You can't add to the version control directly. What you can do is to create a patch and paste that somewhere (patchtracker - or maybe http://ideone.com/ and put a link in here) so we can apply it. It would be great to have some example models in this case to be able to test if it works (preferably one with less that 65k vertices and one with more so I'm able to check both situations). If the model can't be made public it's ok to send them to me by mail.

There are several ways to create patches. The easiest one is if you work already with an svn version of irrlicht (preferably svn trunk). In that case the command "svn diff" will produce a patch with all the changes to the current svn version. Otherwise you have to use tools like diff and compare the changed with the original file (I guess on Windows Windiff might be able to create patches, but I have not much experience with that as I mostly use cygwin or mingw on Windows which allows me to use the unix diff command).

Also I guess I have to warn you about using the functions in IMeshManipulator with 32 bit meshes. Many of them don't support that yet to my knowledge. As long as you're only rendering it will be fine.
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: STL (file format)

Post by asparagusx »

CuteAlien

All I have done is to use CDynamicMeshBuffer instead of SMeshBuffer in the STL and OBJ loaders and adding checking for > 65335 indices. I have tested on a number of models (from Thingiverse). I will send some links to these test models and somebody can then verify the changes. I will look at the issue of creating a patch. I am using Visual Studio as a development platform. I am aware of the shortcomings of IMeshManipulator (I don't use them) and I have my own versions of most of these routines. I suspect that the mesh writers might also have issues when trying to create meshbuffers with more than 65K indices....

Anton
lumamaki
Posts: 1
Joined: Mon Jan 19, 2015 9:06 pm

Re: STL (file format)

Post by lumamaki »

Anton

Would you be welling to share your STL and OBJ loader files? I am working with STL models that where created from solidworks to model a minning shovel and I am having problems converting SMeshBuffer to CDynamicMeshBuffer.


Thanks in advance for the help
Post Reply