Jump to content
  • Advertisement
Sign in to follow this  
sandral

OpenGL camera transformation

This topic is 5073 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

hello, i'm implementing shadow maps with OpenGL. It is necessary to render the scene from the light'S point-of-view. So I move the camera to lightposition and get the Modelviewmatrix. gluLookAt(lightPoint[0], lightPoint[1], lightPoint[2], 0, 0, 0, 0, 0, -1); glGetFloatv(GL_MODELVIEW_MATRIX, lightViewMatrix); Now my problem is to position the objects right. Every object in the scene has it's own transformationmatrix. But I don't know how to combine the "lightViewMatrix" with the transformationmatrix from the objects, so that the objects are oriented right. Here is some code: gluPerspective(90.0f,(GLfloat)640/(GLfloat)480,1, 10000); glGetFloatv(GL_MODELVIEW_MATRIX, lightFrustumMatrix); gluLookAt(m_globalLightP[0],m_globalLightP[1], m_globalLightP[2], 0, 0, 0, 0, 0, -1); glGetFloatv(GL_MODELVIEW_MATRIX, lightViewMatrix); // setup LightView glMatrixMode(GL_PROJECTION); glLoadMatrixf(lightFrustumMatrix); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(lightViewMatrix); glMultMatrixf(lightViewMatrix); glPushMatrix(); glMultMatrixf(transMat); // transMat the objects transformationmatrix renderObj(); glPopMatrix(); The result is, that i see all objects from the bottom. But I have to see all objects from top view, because the light sit above all aobjects. thanks sandra

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!