3d loader

Started by
9 comments, last by GENTS 18 years, 9 months ago
Hy guys! I'm doing my thesis on OpenGL ES, and I have to load a 3d model in a Symbian application. What file format can I use? There's a specific 3d loader for OpenGL ES?? Thanks!
Advertisement
Open GL ES is just a rendering API and as such has no concept of file formats. You can load the vertex/index/etc data from any format you want in much the same way you would for an Open GL application. Its relativly simple to convert loading/rendering code written for Open GL to the GL ES equivilent, just be aware of the float/fixed issues and general memory constraints of the type of platforms Gl ES runs on.

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
You might want to ask your question on the OpenGL ES message board at khronos.org.


You will probably find it easier to convert your 3d file into face, vertex and normal data and put it all in a .h file rather than write a loader. I have had some success with this method.

If you use a 3ds file you can convert it into standard OpenGL code using a program called Deep Exploration. Then put the data into a .h file that looks something like this:


// MACROS
#define numFaces 186

// CONSTANTS
const GLshort model_verts[]=
{

};

const GLbyte model_norms[]=
{

};

const GLubyte model_faces[]=
{

};


Then just draw your model using glDrawElements like this:


void drawModel(void) {

glVertexPointer( 3, GL_FLOAT, 0, model_verts );
glNormalPointer( GL_FLOAT, 0, model_norms );
glDrawElements( GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_BYTE, model_faces );
}

I hope this helps!
Ahh crap, that last post was me.

Sorry for the lack of code tags, I can't edit it...
Thanks for the answer!
I load vertex, faces and normal from a .ASE file, but there's something wrong in the normal because my model, a simple box, is not correct illuminated. I try to put vertex, face and normal of a nokia example, and the illuination is correct! I don't know why, but the normal in the file .ASE don't work very well!
How can I obtain normals from deep exploration?
Thanks!

[Edited by - Giacomo83 on June 24, 2005 1:57:57 PM]
I'm not sure what an ase file is, but just try opening it in deep exploration. If it opens then just go to "save as" and select a .cpp file and it will generate face, normal and vertex data for you in a .cpp file. You then just need to make it OpenGL ES compatible (which is the tricky part...).
Thanks Miranda, but I've the same problem: 8 vertices and 6 normals and my object is illuminated in a wrong way...
The problem is the number of normals, in fact in the nokia example are equal to the number of vrtices; try 3DS and milkshape3d but I always have number of normals different to the number of vertices..
try to look into .X file format...
I hope that will help you ^__^

Byez,
----------------------------------------------- - GENTS -"Every man dies, not every man really lives"[William Wallace] - visit my website: GENTS.it -- Using Effect files with DirectX 9 Basics Tutorial -- MilkShape 3D models and OpenGL ES Tutorial -
Quote:Original post by Giacomo83
Thanks Miranda, but I've the same problem: 8 vertices and 6 normals and my object is illuminated in a wrong way...
The problem is the number of normals, in fact in the nokia example are equal to the number of vrtices; try 3DS and milkshape3d but I always have number of normals different to the number of vertices..


8 vertices and 6 normals is perfrctly correct - the cube have 8 vertices aqnd 6 faces.
If you want to get per-vertex normal you should triple the number of vertices (to separate the vertices belonging different faces) look up the face the vertex belong to and get the normal of that face. It seems you should read some introductory book on the geometry applyed to 3d graphics (not platform specific) - such things should be explained there.

This topic is closed to new replies.

Advertisement