Sign in to follow this  
Giacomo83

3d loader

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
You might want to ask your question on the OpenGL ES message board at khronos.org.


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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...).

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Hi frinds!!!
I still have some problem in loading correct geometries...
I do something as it:

// 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_SHORT, 0, model_verts );
glNormalPointer( GL_BYTE, 0, model_norms );

glDrawElements( GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_BYTE, model_faces );

}


but the only thing I can say is: "Hey man! That's not your model!!!"...
It's possible that my problem consist in the use of GL_SHORT and GL_BYTE instead of GL_FLOAT in vertex and normal pointer functions?!

THANKS FOR REPLIES!!!

Bye,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this