• Advertisement
Sign in to follow this  

JOGL: Strange behaviour with color material for an obj model

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Problem solved. The problem was that Normals were not normalized. GL_NORMALIZE did the job.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement