本文整理汇总了C++中mat4::zero方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::zero方法的具体用法?C++ mat4::zero怎么用?C++ mat4::zero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::zero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateMatrices
void Shadow::calculateMatrices(const Light &light, const Actor &actor, int shadowMapSize, mat4& lightProjectionMatrix, mat4& lightViewMatrix, mat4& textureMatrix, float lx, float ly)
{
const vec3 &lightPosition = light.getPosition();
const vec3 &lightCenter = actor.getPos();
const vec3 lightUp(0.0f, 1.0f, 0.0f);
// Calculate the model-view matrix
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
gluLookAt( lightPosition.x, lightPosition.y, lightPosition.z,
lightCenter.x, lightCenter.y, lightCenter.z,
lightUp.x, lightUp.y, lightUp.z);
lightViewMatrix.zero();
glGetFloatv(GL_MODELVIEW_MATRIX, lightViewMatrix);
glPopMatrix();
// Calculate the projection matrix
// row 1
lightProjectionMatrix.m[0] = (0.995f-1.0f/(float)shadowMapSize)/lx;
lightProjectionMatrix.m[1] = 0.0f;
lightProjectionMatrix.m[2] = 0.0f;
lightProjectionMatrix.m[3] = 0.0f;
// row 2
lightProjectionMatrix.m[4] = 0.0f;
lightProjectionMatrix.m[5] = (0.995f-1.0f/(float)shadowMapSize)/ly;
lightProjectionMatrix.m[6] = 0.0f;
lightProjectionMatrix.m[7] = 0.0f;
// row 3
lightProjectionMatrix.m[8] = 0.0f;
lightProjectionMatrix.m[9] = 0.0f;
lightProjectionMatrix.m[10] = (farClip + nearClip) / (nearClip - farClip);
lightProjectionMatrix.m[11] = -1.0f;
// row 4
lightProjectionMatrix.m[12] = 0.0f;
lightProjectionMatrix.m[13] = 0.0f;
lightProjectionMatrix.m[14] = 2.0f * (farClip * nearClip) / (nearClip - farClip);
lightProjectionMatrix.m[15] = 0.0f;
//Calculate texture matrix for projection
//This matrix takes us from eye space to the light's clip space
//It is postmultiplied by the inverse of the current view matrix when specifying texgen
const float biasMatrixf[] = { 0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f}; //bias from [-1, 1] to [0, 1]
mat4 biasMatrix = biasMatrixf;
// Calculate the texture matrix
textureMatrix = biasMatrix * lightProjectionMatrix * lightViewMatrix;
}