本文整理汇总了C++中GLFrame::GetForwardVector方法的典型用法代码示例。如果您正苦于以下问题:C++ GLFrame::GetForwardVector方法的具体用法?C++ GLFrame::GetForwardVector怎么用?C++ GLFrame::GetForwardVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLFrame
的用法示例。
在下文中一共展示了GLFrame::GetForwardVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderScene
///////////////////////////////////////////////////////////////////////////////
// Render a frame. The owning framework is responsible for buffer swaps,
// flushes, etc.
void RenderScene(void)
{
static CStopWatch animationTimer;
float yRot = animationTimer.GetElapsedSeconds() * 60.0f;
M3DVector3f vCameraPos;
M3DVector3f vCameraForward;
M3DVector3f vMirrorPos;
M3DVector3f vMirrorForward;
cameraFrame.GetOrigin(vCameraPos);
cameraFrame.GetForwardVector(vCameraForward);
// Set position of mirror frame (camera)
vMirrorPos[0] = 0.0;
vMirrorPos[1] = 0.1f;
vMirrorPos[2] = -6.0f; // view pos is actually behind mirror
mirrorFrame.SetOrigin(vMirrorPos);
// Calculate direction of mirror frame (camera)
// Because the position of the mirror is known relative to the origin
// find the direction vector by adding the mirror offset to the vector
// of the viewer-origin
vMirrorForward[0] = vCameraPos[0];
vMirrorForward[1] = vCameraPos[1];
vMirrorForward[2] = (vCameraPos[2] + 5);
m3dNormalizeVector3(vMirrorForward);
mirrorFrame.SetForwardVector(vMirrorForward);
// first render from the mirrors perspective
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboName);
glDrawBuffers(1, fboBuffs);
glViewport(0, 0, mirrorTexWidth, mirrorTexHeight);
// Draw scene from the perspective of the mirror camera
modelViewMatrix.PushMatrix();
M3DMatrix44f mMirrorView;
mirrorFrame.GetCameraMatrix(mMirrorView);
modelViewMatrix.MultMatrix(mMirrorView);
// Flip the mirror camera horizontally for the reflection
modelViewMatrix.Scale(-1.0f, 1.0f, 1.0f);
glBindTexture(GL_TEXTURE_2D, textures[0]); // Marble
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite, 0);
floorBatch.Draw();
DrawWorld(yRot);
// Now draw a cylinder representing the viewer
M3DVector4f vLightTransformed;
modelViewMatrix.GetMatrix(mMirrorView);
m3dTransformVector4(vLightTransformed, vLightPos, mMirrorView);
modelViewMatrix.Translate(vCameraPos[0],vCameraPos[1]-0.8f,vCameraPos[2]-1.0f);
modelViewMatrix.Rotate(-90.0f, 1.0f, 0.0f, 0.0f);
shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF,
modelViewMatrix.GetMatrix(),
transformPipeline.GetProjectionMatrix(),
vLightTransformed, vBlue, 0);
cylinderBatch.Draw();
modelViewMatrix.PopMatrix();
// Reset FBO. Draw world again from the real cameras perspective
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDrawBuffers(1, windowBuff);
glViewport(0, 0, screenWidth, screenHeight);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
glBindTexture(GL_TEXTURE_2D, textures[0]); // Marble
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite, 0);
floorBatch.Draw();
DrawWorld(yRot);
// Now draw the mirror surfaces
modelViewMatrix.PushMatrix();
modelViewMatrix.Translate(0.0f, -0.4f, -5.0f);
if(vCameraPos[2] > -5.0)
{
glBindTexture(GL_TEXTURE_2D, mirrorTexture); // Reflection
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(), 0);
}
else
{
// If the camera is behind the mirror, just draw black
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack);
}
mirrorBatch.Draw();
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vGrey);
mirrorBorderBatch.Draw();
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
//.........这里部分代码省略.........
示例2: Display
void Display()
{
static CStopWatch timer;
GLfloat yRot = timer.GetElapsedSeconds() * 60.0;
M3DVector3f vCameraPosition;
M3DVector3f vCameraForward;
M3DVector3f vMirrorPosition;
M3DVector3f vMirrorForward;
void movingCylinder();
cameraFrame.GetOrigin(vCameraPosition);
cameraFrame.GetForwardVector(vCameraForward);
vMirrorPosition[0] = 0.0f;
vMirrorPosition[1] = 0.1f;
vMirrorPosition[2] = -20.0f;
mirrorFrame.SetOrigin(vMirrorPosition);
vMirrorForward[0] = vCameraPosition[0];
vMirrorForward[1] = vCameraPosition[1];
vMirrorForward[2] = (vCameraPosition[2] + 20);
m3dNormalizeVector3(vMirrorForward);
mirrorFrame.SetForwardVector(vMirrorForward);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER,fboName);
glDrawBuffers(1,fboBuffers);
glViewport(0,0,mirrorWidth,mirrorHeight);
modelViewMatrix.PushMatrix();
M3DMatrix44f mMirrorView;
mirrorFrame.GetCameraMatrix(mMirrorView);
modelViewMatrix.MultMatrix(mMirrorView);
modelViewMatrix.Scale(-1.0f,1.0f,1.0f);
glBindTexture(GL_TEXTURE_2D,textures[0]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE,
transformPipeline.GetModelViewProjectionMatrix(),
vWhite,0);
floorBatch.Draw();
drawSun();
drawTorus(yRot);
modelViewMatrix.PopMatrix();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
glDrawBuffers(1,windowBuffer);
glViewport(0,0,mirrorWidth,mirrorHeight);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
modelViewMatrix.PushMatrix();
glBindTexture(GL_TEXTURE_2D,mirrorTexture);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE,
transformPipeline.GetModelViewProjectionMatrix(),0);
mirrorFrontBatch.Draw();
modelViewMatrix.PopMatrix();
modelViewMatrix.PushMatrix();
glBindTexture(GL_TEXTURE_2D,textures[0]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE,
transformPipeline.GetModelViewProjectionMatrix(),
vWhite,0);
floorBatch.Draw();
drawSun();
drawTorus(yRot);
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
//control to moving cylinder
movingCylinder();
glutSwapBuffers();
glutPostRedisplay();
}