Skip to main content
GameDev.net gamedev.net
🔒 Locked

*.stl to triangular data structure, *.ply or *.obj - *.stl issue...

Started by luckyyyyyy Feb 27, 2012 at 4:15 PM 2 replies 2.6k views
Original Post
luckyyyyyy
luckyyyyyy
Actually, I want to convert *.stl file format into *.ply or *.obj.
The reason is that, stl file doesn't contain the triangles information. its just contains vertices. (normals is not an issue here..). But I want the triangular information like *.ply or *.obj has.

triangular means..*ply or *obj file format

vertex 0 0 0
vertex 0 1 0
vertex 1 1 0
vertex 1 0 0
face 1 2 3
face 1 2 4

above code has two triangles and 4 vertices. right? but *stl file doesn't contain any kind of face information.

I don't have any issue to read *stl or write *stl ... I can even render the 3D stl model.

My issue is I just want to convert this *.stl file format into *.ply or *obj.
I spent too much time on net but didn't find any kind of code or idea relevant to this. Kindly give me some idea that how can I convert it. How can i extract face information from stl ?

thanks.
jesse007
jesse007

I don't have any issue to read *stl or write *stl ... I can even render the 3D stl model.

[...]

How can i extract face information from stl ?
So you can read, write, and render an stl model, but can't extract the faces. That makes no sense. I don't know exactly what you want, but MeshlLab seems to do .stl conversions:

http://meshlab.sourceforge.net/

and Wikipedia describes .stl:

http://en.wikipedia....8file_format%29
Good judgment comes from experience; experience comes from bad judgment.
luckyyyyyy
luckyyyyyy
Its really simple... I want to load the *.stl vertices and faces into my *.obj or *.ply data structures.

Following is the data structure that can be used with *.obj or *.ply. But we can not use this data structure for *.stl. For *.stl we do not know the indices information. I want to extract that information. for example triangle (indic1, indic2, indic3). So this the issue to use the same data structure for *.stl.

struct GLpoint
{
float x, y, z;
};
GLpoint *Vertices;

struct GLface
{
unsigned int v1, v2, v3;
};
GLface *indinces;


Thanks.
luckyyyyyy
luckyyyyyy
Solved.. I have done it. Now i can import stl and can export ply or obj.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.