Reputation: 1276
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:
How it should look like:
For sake of clearance, in my code, I use triangles and for each of them I have vertex, normal, texture coordinate. So the question is, What is missing?
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[i][0], body.body_textCoords[i][1]);
gl.glNormal3f(body.body_normal[i][0], body.body_normal[i][1], body.body_normal[i][2]);
gl.glVertex3f(body.body_vertex[i][0], body.body_vertex[i][1], body.body_vertex[i][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();
Upvotes: 0
Views: 415
Reputation: 16354
Just some random things to try:
Are your normals already normalized? (If not, this could account for the appearance of too-bright light. Enable GL_NORMALIZE to fix)
What happens if you disable textures and just paint everything in orange? (Just one less variable to worry about)
Upvotes: 2
Reputation: 14668
Based on the image, it looks like a mix of having the wrong front face culled (change it with glCullFace
) and a really bright light. Seeing the rest of your drawing code will be really useful.
Upvotes: 0