Archived

This topic is now archived and is closed to further replies.

Shadow lesson 27 question?

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

In the tutorial you have to calculate the light''s position relative to the local coordinate system of the object. ************************************************************ glLoadIdentity(); // Reset Matrix glRotatef(-yrot, 0.0f, 1.0f, 0.0f); // Rotate By -yrot On Y Axis glRotatef(-xrot, 1.0f, 0.0f, 0.0f); // Rotate By -xrot On X Axis glTranslatef(-ObjPos[0], -ObjPos[1], -ObjPos[2]); // Move Negative On All Axis Based On ObjPos[] Values (X, Y, Z) glGetFloatv(GL_MODELVIEW_MATRIX,Minv); // Retrieve ModelView Matrix (Stores In Minv) lp[0] = LightPos[0]; // Store Light Position X In lp[0] lp[1] = LightPos[1]; // Store Light Position Y In lp[1] lp[2] = LightPos[2]; // Store Light Position Z In lp[2] lp[3] = LightPos[3]; // Store Light Direction In lp[3] VMatMult(Minv, lp); ************************************************************ Why? I don''t understand the point? Can someone please enlight me?? thanks,

Share this post


Link to post
Share on other sites
in that demo (which is pretty simple), it''s a rotating model casting a shadow, the reason why this code is here is so you rotate the light''s position, not the model verticies (ie, do the opposite rotation on the light). that means you rotate 1 point (the light), where if you rotate the model, you rotate potentially 1000''s of points (and then have to rotate the generated shadow coords back again). hence it''s MUCH faster just to rotate the light about the model.

Share this post


Link to post
Share on other sites