本文整理汇总了C++中Transform::GetMVPMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform::GetMVPMatrix方法的具体用法?C++ Transform::GetMVPMatrix怎么用?C++ Transform::GetMVPMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::GetMVPMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
static void display()
{
const Vector3f eyePosition(0, 0, 13);
const Vector3f eyeCenter(0,0,0);
const Vector3f eyeUp(0,1,0);
const Vector3f lightPosition(5 * sin(lightAngle), 1.5, 5 * cos(lightAngle));
Camera camera(eyePosition, eyeCenter, eyeUp);
transform.SetCamera(camera);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
cgGLBindProgram(programVertex);
Log("binding vertex program");
cgGLEnableProfile(profileVertex);
Log("enabling vertex profile");
cgGLBindProgram(programFragment);
Log("binding fragment program");
cgGLEnableProfile(profileFragment);
Log("enabling fragment profile");
setBrassMaterial();
transform.SetTranslate(2, 0, 0);
transform.SetArbitraryRotation(20, 1, 1, 1);
Matrix4f modelMatrix;
transform.GetModelMatrix(modelMatrix);
Matrix4f invModelMatrix = modelMatrix.Invert();
Vector4f objSpaceEyePosition = invModelMatrix.Mul(eyePosition);
Vector4f objSpaceLightPosition = invModelMatrix.Mul(lightPosition);
Matrix4f modelViewProjMatix;
transform.GetMVPMatrix(modelViewProjMatix);
CgSetParam(paramVertexmodelViewProj, modelViewProjMatix);
//CgSetParam(paramFragmentEyePosition, objSpaceEyePosition);
CgSetParam(paramFragmentLightPosition, objSpaceLightPosition);
CgSetParam(paramVertexLightPosition, objSpaceLightPosition);
CgSetParam(paramVertexEyePosition, objSpaceEyePosition);
cgUpdateProgramParameters(programVertex);
cgUpdateProgramParameters(programFragment);
glutSolidSphere(2.0, 10, 10);
cgGLDisableProfile(profileVertex);
Log("disabling vertex profile");
cgGLDisableProfile(profileFragment);
Log("disabling fragment profile");
glutSwapBuffers();
}