PDA

View Full Version : Problem with materials, normal vectors ?



Whilibarj
09-29-2004, 07:55 AM
I have been going through Nate Robins's OpenGL tutors (http://www.xmission.com/~nate/tutors.html) and am trying to use his .obj loader into another application.

I have a problem with the rendering of materials. When I use a very basic projection matrix, e.g :


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat)320/240, 1.0, 256.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0); The rendering is correct, the materials are correct, so are the axis.

But then, instead of this projection matrix, I am loading my own projection matrix (which is calculated by another tool, called ARToolKit).

With this matrix, the axis are in the same exact position, so is the model, but the materials are not rendered and the model appears totally black.

I have tried to move my light source around, but it had no effects. I also considered the idea that my normals could have been inverted by that new matrix, but in that case, I guess the model's and axis's orientation would have been affected too, right ?

Any one has a clue on where the problem could be ?

Thanks

Korval
09-29-2004, 08:04 AM
Are you certain that you're adding your matrix to GL_PROJECTION, and not GL_MODELVIEW? Because lighting problems can certainly result if the projection matrix was loaded to the modelview.

Whilibarj
09-29-2004, 08:38 AM
it is currently loaded as GL_MODELVIEW since the matrix that I get from ARToolkit combines both the projection (camera matrix) and modelview (position matrix).

you mean that the lightning could be affected, but not the object itself ? why that ?

Whilibarj
09-29-2004, 08:43 AM
what I mean here is that this matrix converts directly world coordinates to normalized device coordinates ([-1,1])