1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
//
// Transform the light's position from eye-space to object-space
//
vector3f vLightPosES; // Light position (in eye-space)
vector3f vLightPosOS; // Light position (in object-space)
vector3f vVertToLightOS; // L vector of N.L (in object-space)
vector3f vVertToLightTS; // L vector of N.L (in tangent-space)
// Get the light's current position, which is in eye-space.
float fLightsPosition[4];
glGetLightfv( GL_LIGHT0, GL_POSITION, fLightsPosition );
vLightPosES.x = fLightsPosition[0];
vLightPosES.y = fLightsPosition[1];
vLightPosES.z = fLightsPosition[2];
// Transform the light's position from eye-space into object-space
matrix4x4f modelViewMatrix;
matrix4x4f modelViewMatrixInverse;
glGetFloatv(GL_MODELVIEW_MATRIX, &modelViewMatrix.m[0] );
modelViewMatrixInverse =
matrix4x4f::invertMatrix(&modelViewMatrix );
vLightPosOS = vLightPosES;
modelViewMatrixInverse.transformPoint( &vLightPosOS ); |
Partager