# OpenGL From openGL to various 3D format

This topic is 1084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone , i'm still working on my 3D app with openGL 2.1 ; and now i need to export files from the current scene , to various 3D format (3 to be precise) which are the following : Obj , VRML , and PLY. I need to also implement file loaders for these 3 formats (which means i will be creating a kind of 3D conversion program ).

Anyway , i have some questions :

1)in my code i'm using some Glut built-in methods and function to create object such as glutSolidTeapot() , glutSolidCube() etc .. I would like to know if i can "export" them to one of the formats named up above. If not , should i build my own functions to display them , so i can have the vertices position and save them in the files.

2)i'm already done with the obj parsing , but i have no clue on how the PLY and VRML files behave , i could use a little help here please , thanks !

##### Share on other sites

1)in my code i'm using some Glut built-in methods and function to create object such as glutSolidTeapot() , glutSolidCube() etc .. I would like to know if i can "export" them to one of the formats named up above. If not , should i build my own functions to display them , so i can have the vertices position and save them in the files.

I do not know a way to ask the models from OpenGL besides interception. You can download a GLUT source code from internet, e.g. here, and extract the mesh data (consiering any copyright, of course).

But I also do not see what this should be good for. Generating a cube is easy, and the teapot (like any hundreds of other meshes) can be loaded from the internet (e.g. here as OBJ).

2)i'm already done with the obj parsing , but i have no clue on how the PLY and VRML files behave , i could use a little help here please , thanks !

The specifications can be found on the internet, e.g. here for PLY. What exactly do you want to know?

However: I'm surprised of your intent.

a) Does PLY really play a role nowadays?

b) VRML is superseded by X3D. Besides that … VRML / X3D is a beast!

c) OBJ and PLY are both supported by AssImp for both import and export.

##### Share on other sites

Thanks again Haegarr ; i don't know if the PLY format still plays a role , but i was asked to implement it (see this more like an academic task to be done). I will take a look at assImp and the link you sent me for more details !

##### Share on other sites

So i have finally managed to import Ply and Obj files and implement them the right way in my code , but there's a visual detail that i would like to fix;

When an object is selected , i try to display its wire-frame on top of the model. The thing is , it works great with glut object(glutWiredTeapot for example) , but for the imported object as obj or ply , you can see and the triangular faces that do not look very good (especially from a certain distance , the density of the wireframe makes the object look white)

i would like to know if there's anyway i could delete those diagonal lines in the faces , just to display the wire-frame as Quads instead of triangles ;

here's the code i've used :

void MeshObj::WireFrameMode()
{

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);

glVertexPointer(0,GL_FLOAT,0,vertice);

glNormalPointer(GL_FLOAT,0,normals);

glDrawArrays(GL_LINES,0,n_data);

glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);

}

Edited by Hdjo

##### Share on other sites

The simplest solution would be to build a vertex element (i.e. vertex index) array on the CPU side and put only indices for interesting lines into it. You need to identify whether an edge is wanted or not. Is the mesh at the outset already build of triangles so that you need an algorithm to detect the kind of edge? May it happen that diagonal edges belong to the contour?

BTW: Your recent post has nothing to do with 3D file import, so you should have started a new topic for it. So, with a new title better matching the problem, you may have attracted more people who could help with this new problem.

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002135
×