JOGL: Strange behaviour with color material for an obj model

Started by
0 comments, last by p_ooya 12 years, 3 months ago
For a project with a 3d model I was given an Autocad file. I imported the file in 3ds max and exported it as .obj file. So far so good. But when I load this file into my Jogl application, I have a strange problem with color material. Te be more precise, look at the images below. The first one is an screenshot from my application and the second one, is a screenshot of the exactly the same file loaded into a 3d manipulation software.

How it looks like:

6I3xP.png

How it should look like (exactly the same file loaded in milkshape3d)

DJlH7.png

Moreover, when I add the classical teapot to the scene, it is shown very good without any problem (I mean the light and material are ok). Here is part of my code:

gl.glNewList(1, gl.GL_COMPILE);
for (int i = 0; i < len; i=i+3) {

gl.glBegin(GL.GL_TRIANGLES);

gl.glTexCoord2f(body.body_textCoords[0], body.body_textCoords[1]);
gl.glNormal3f(body.body_normal[0], body.body_normal[1], body.body_normal[2]);
gl.glVertex3f(body.body_vertex[0], body.body_vertex[1], body.body_vertex[2]);

gl.glTexCoord2f(body.body_textCoords[i+1][0], body.body_textCoords[i+1][1]);
gl.glNormal3f(body.body_normal[i+1][0], body.body_normal[i+1][1], body.body_normal[i+1][2]);
gl.glVertex3f(body.body_vertex[i+1][0], body.body_vertex[i+1][1], body.body_vertex[i+1][2]);

gl.glTexCoord2f(body.body_textCoords[i+2][0], body.body_textCoords[i+2][1]);
gl.glNormal3f(body.body_normal[i+2][0], body.body_normal[i+2][1], body.body_normal[i+2][2]);
gl.glVertex3f(body.body_vertex[i+2][0], body.body_vertex[i+2][1], body.body_vertex[i+2][2]);
gl.glEnd();
}
gl.glEndList();


Any ideas?
Advertisement
Problem solved. The problem was that Normals were not normalized. GL_NORMALIZE did the job.

This topic is closed to new replies.

Advertisement