本文整理汇总了C++中CPVRTModelPOD::GetCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTModelPOD::GetCamera方法的具体用法?C++ CPVRTModelPOD::GetCamera怎么用?C++ CPVRTModelPOD::GetCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPVRTModelPOD
的用法示例。
在下文中一共展示了CPVRTModelPOD::GetCamera方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*!****************************************************************************
@Function SetupView()
@Return N/A
@Description Sets up the view matrices required for the training course
******************************************************************************/
void OGLES3EdgeDetection::SetupView(bool bRotate)
{
PVRTVec3 vEyePos, vLookAt, vCamUp=PVRTVec3(0.00f, 1.0001f, 0.00f);
// Checks if a camera is in the scene, if there is, uses it, otherwise creates one.
if(m_Scene.nNumCamera>0)
{
// vLookAt is taken from the target node, or..
if(m_Scene.pCamera[0].nIdxTarget != -1) m_Scene.GetCameraPos(vEyePos, vLookAt, 0);
// ..it is calculated from the rotation
else m_Scene.GetCamera(vEyePos, vLookAt, vCamUp, 0);
}
else
{
//Creates a camera if none exist.
vEyePos = PVRTVec3(0, 0, 200);
vLookAt = PVRTVec3(0, 0, 0);
}
// Set the view and projection matrix for rendering to texture.
m_mR2TView = PVRTMat4::LookAtRH(vEyePos, vLookAt, vCamUp);
m_mR2TProjection = PVRTMat4::PerspectiveFovRH(PVRT_PI*0.125, (float)m_i32TexWidth/(float)m_i32TexHeight, g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
// The textured quad this program renders to will be rendered full screen, in orthographic mode, so doesn't need camera variables to be set.
}
示例2: PVRShellGetTime
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occured
@Description Main rendering loop function of the program. The shell will
call this function every frame.
eglSwapBuffers() will be performed by PVRShell automatically.
PVRShell will also manage important OS events.
Will also manage relevent OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES3TextureStreaming::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Time based animation and locks the app to 60 FPS.
// Uses the shell function PVRShellGetTime() to get the time in milliseconds.
unsigned long ulTime = PVRShellGetTime();
unsigned long ulDeltaTime = ulTime - m_ulTimePrev;
m_ulTimePrev = ulTime;
m_fFrame += (float)ulDeltaTime * (60.0f/1000.0f);
m_fBandScroll += (float)ulDeltaTime * (60.0f/1000.0f) * c_fBandScrollSpeed;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0.0f;
if(m_fBandScroll > 1.0f)
m_fBandScroll = -c_fBandWidth;
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
m_Scene.SetFrame(m_fFrame);
// Setup the main camera
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + c_ui32Camera].nIdx;
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, c_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, c_ui32Camera); // vTo is calculated from the rotation
float fTargetAspect = 960.0f/640.0f;
float fAspect = (float)PVRShellGet(prefWidth) / (float)PVRShellGet(prefHeight);
fFOV *= fTargetAspect / fAspect;
PVRTMat4 mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
PVRTMat4 mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), c_fCameraNear,
c_fCameraFar, PVRTMat4::OGL, bRotate);
PVRTMat4 mViewProjection = mProjection * mView;
DrawPODScene(mViewProjection);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Texture Streaming", c_pszDescription, ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
++m_i32Frame;
return true;
}
示例3: CameraGetMatrix
/*******************************************************************************
* Function Name : CameraGetMatrix
* Global Used :
* Description : Function to setup camera position
*
*******************************************************************************/
void OGLESSkinning::CameraGetMatrix()
{
PVRTVec3 vFrom, vTo, vUp(0.0f, 1.0f, 0.0f);
float fFOV;
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
//.. get the Camera's position, direction and FOV.
fFOV = m_Scene.GetCamera(vFrom, vTo, vUp, 0);
// Set up the view matrix
m_mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Set up the projection matrix
m_mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float) PVRShellGet(prefWidth) / (float) PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
}
示例4: PVRShellGetTime
/*!****************************************************************************
@Function Update
@Description Handles user input and updates all timing data.
******************************************************************************/
void OGLES3ShadowMapping::Update()
{
if (PVRShellIsKeyPressed(PVRShellKeyNameSELECT)) m_bDebug = !m_bDebug;
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT)) m_fBias *= 0.9f;
if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT)) m_fBias *= 1.1f;
// Calculates the frame number to animate in a time-based manner.
// Uses the shell function PVRShellGetTime() to get the time in milliseconds.
static unsigned long ulTimePrev = PVRShellGetTime();
unsigned long ulTime = PVRShellGetTime();
unsigned long ulDeltaTime = ulTime - ulTimePrev;
ulTimePrev = ulTime;
static float fFrame = 0;
if (!m_bDebug)
fFrame += (float)ulDeltaTime * 0.05f;
if (fFrame > m_Scene.nNumFrame-1)
fFrame = 0;
// Update the animation data
m_Scene.SetFrame(fFrame);
PVRTVec3 vFrom, vTo, vUp;
float fFOV = m_Scene.GetCamera(vFrom, vTo, vUp, 0) * 0.75f;
m_mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), m_Scene.pCamera[0].fNear, m_Scene.pCamera[0].fFar, PVRTMat4::OGL, m_bRotate);
m_mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
m_Scene.GetLight(m_vLightPosition, m_vLightDirection, 0);
PVRTVec3 lightFrom, lightTo, lightUp;
m_Scene.GetCamera(lightFrom, lightTo, lightUp, 1);
m_mLightView = PVRTMat4::LookAtRH(lightFrom, lightTo, lightUp);
m_mLightProjection = PVRTMat4::PerspectiveFovRH(PVRT_PI_OVER_TWO, 1.0f, m_Scene.pCamera[1].fNear, m_Scene.pCamera[1].fFar, PVRTMat4::OGL, m_bRotate);
}
示例5: InitView
//.........这里部分代码省略.........
if(!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Initialize Print3D
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
//Set OpenGL ES render states needed for this demo
// Enable backface culling and depth test
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// Find the largest square power of two texture that fits into the viewport
m_i32TexSize = 1;
int iSize = PVRT_MIN(PVRShellGet(prefWidth), PVRShellGet(prefHeight));
while (m_i32TexSize * 2 < iSize) m_i32TexSize *= 2;
// Get the currently bound frame buffer object. On most platforms this just gives 0.
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_i32OriginalFB);
for(int i = 0; i < 2; ++i)
{
// Create texture for the FBO
glGenTextures(1, &m_uiTexture[i]);
glBindTexture(GL_TEXTURE_2D, m_uiTexture[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_i32TexSize, m_i32TexSize, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Create FBO
glGenFramebuffers(1, &m_uiFbo[i]);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFbo[i]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_uiTexture[i], 0);
glGenRenderbuffers(1, &m_uiDepthBuffer[i]);
glBindRenderbuffer(GL_RENDERBUFFER, m_uiDepthBuffer[i]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, m_i32TexSize, m_i32TexSize);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uiDepthBuffer[i]);
// Check that our FBO creation was successful
GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(uStatus != GL_FRAMEBUFFER_COMPLETE)
{
m_bFBOsCreated = false;
PVRShellOutputDebug("ERROR: Failed to initialise FBO");
break;
}
// Clear the colour buffer for this FBO
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFB);
// Setup the main camera
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + g_ui32Camera].nIdx;
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, g_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, g_ui32Camera); // vTo is calculated from the rotation
m_View = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix
PVRTMat4 mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
m_ViewProjection = mProjection * m_View;
// Check to see if the GL_EXT_discard_framebuffer extension is supported
if(m_bFBOsCreated && (m_bDiscard = CPVRTgles2Ext::IsGLExtensionSupported("GL_EXT_discard_framebuffer")) != false)
{
m_Extensions.LoadExtensions();
m_bDiscard = m_Extensions.glDiscardFramebufferEXT != 0;
}
return true;
}
示例6: PVRShellGetTime
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occured
@Description Main rendering loop function of the program. The shell will
call this function every frame.
eglSwapBuffers() will be performed by PVRShell automatically.
PVRShell will also manage important OS events.
Will also manage relevent OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2ChameleonMan::RenderScene()
{
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use shader program
glUseProgram(m_SkinnedShaderProgram.uiId);
if(PVRShellIsKeyPressed(PVRShellKeyNameACTION1))
{
m_bEnableDOT3 = !m_bEnableDOT3;
glUniform1i(m_SkinnedShaderProgram.auiLoc[ebUseDot3], m_bEnableDOT3);
}
/*
Calculates the frame number to animate in a time-based manner.
Uses the shell function PVRShellGetTime() to get the time in milliseconds.
*/
unsigned long iTime = PVRShellGetTime();
if(iTime > m_iTimePrev)
{
float fDelta = (float) (iTime - m_iTimePrev);
m_fFrame += fDelta * g_fDemoFrameRate;
// Increment the counters to make sure our animation works
m_fLightPos += fDelta * 0.0034f;
m_fWallPos += fDelta * 0.00027f;
m_fBackgroundPos += fDelta * -0.000027f;
// Wrap the Animation back to the Start
if(m_fLightPos >= PVRT_TWO_PI)
m_fLightPos -= PVRT_TWO_PI;
if(m_fWallPos >= PVRT_TWO_PI)
m_fWallPos -= PVRT_TWO_PI;
if(m_fBackgroundPos <= 0)
m_fBackgroundPos += 1.0f;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0;
}
m_iTimePrev = iTime;
// Set the scene animation to the current frame
m_Scene.SetFrame(m_fFrame);
// Set up camera
PVRTVec3 vFrom, vTo, vUp(0.0f, 1.0f, 0.0f);
PVRTMat4 mView, mProjection;
PVRTVec3 LightPos;
float fFOV;
int i;
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[0].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, 0); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, 0); // vTo is calculated from the rotation
fFOV *= bRotate ? (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight) : (float)PVRShellGet(prefHeight)/(float)PVRShellGet(prefWidth);
/*
We can build the model view matrix from the camera position, target and an up vector.
For this we use PVRTMat4::LookAtRH().
*/
mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix
mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
// Update Light Position and related VGP Program constant
LightPos.x = 200.0f;
LightPos.y = 350.0f;
LightPos.z = 200.0f * PVRTABS(sin((PVRT_PI / 4.0f) + m_fLightPos));
glUniform3fv(m_SkinnedShaderProgram.auiLoc[eLightPos], 1, LightPos.ptr());
// Set up the View * Projection Matrix
PVRTMat4 mViewProjection;
mViewProjection = mProjection * mView;
glUniformMatrix4fv(m_SkinnedShaderProgram.auiLoc[eViewProj], 1, GL_FALSE, mViewProjection.ptr());
// Enable the vertex attribute arrays
for(i = 0; i < eNumAttribs; ++i) glEnableVertexAttribArray(i);
//.........这里部分代码省略.........
示例7: glClear
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occurred
@Description Main rendering loop function of the program. The shell will
call this function every frame.
eglSwapBuffers() will be performed by PVRShell automatically.
PVRShell will also manage important OS events.
Will also manage relevant OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES3PhantomMask::RenderScene()
{
if(PVRShellIsKeyPressed(PVRShellKeyNameACTION1))
m_bEnableSH = !m_bEnableSH;
// Clear the colour and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw the background
m_Background.Draw(m_ui32TexBackground);
// Enable culling
glEnable(GL_CULL_FACE);
// Enable depth testing
glEnable(GL_DEPTH_TEST);
// Use shader program
GLuint ProgramID, MVPLoc, ModelLoc;
if(m_bEnableSH)
{
ProgramID = m_SHShaderProgram.uiId;
MVPLoc = m_SHShaderProgram.auiLoc[eSHMVPMatrix];
ModelLoc = m_SHShaderProgram.auiLoc[eSHModel];
}
else
{
ProgramID = m_DiffuseShaderProgram.uiId;
MVPLoc = m_DiffuseShaderProgram.auiLoc[eDifMVPMatrix];
ModelLoc = m_DiffuseShaderProgram.auiLoc[eDifModel];
}
glUseProgram(ProgramID);
/*
Calculates the frame number to animate in a time-based manner.
Uses the shell function PVRShellGetTime() to get the time in milliseconds.
*/
unsigned long ulTime = PVRShellGetTime();
if(ulTime > m_ulTimePrev)
{
unsigned long ulDeltaTime = ulTime - m_ulTimePrev;
m_fFrame += (float)ulDeltaTime * g_fDemoFrameRate;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0;
// Sets the scene animation to this frame
m_Scene.SetFrame(m_fFrame);
}
m_ulTimePrev = ulTime;
/*
Set up the view and projection matrices from the camera
*/
PVRTMat4 mView, mProjection;
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Setup the camera
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + g_ui32Camera].nIdx;
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, g_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, g_ui32Camera); // vTo is calculated from the rotation
fFOV *= bRotate ? (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight) : (float)PVRShellGet(prefHeight)/(float)PVRShellGet(prefWidth);
// We can build the model view matrix from the camera position, target and an up vector.
// For this we usePVRTMat4LookAtRH()
mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix
mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
SPODNode& Node = m_Scene.pNode[0];
// Get the node model matrix
PVRTMat4 mWorld;
mWorld = m_Scene.GetWorldMatrix(Node);
// Set the model inverse transpose matrix
//.........这里部分代码省略.........
示例8: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occurred
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES3MagicLantern::InitView()
{
CPVRTString ErrorStr;
// At this point m_Scene should have been already processed by InitApplication()
// and all the POD data properly loaded, but lets do a little test just in case.
if (!m_Scene.IsLoaded())
{
PVRShellSet(prefExitMessage, "ERROR: POD file has not been loaded correctly. Cannot continue. \n");
return false;
}
// Initialize VBO data
if(!LoadVbos())
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Load and compile the shaders, link programs and load textures.
if(!LoadPFX())
{
return false;
}
// Initialize Print3D
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
// Enable backface culling and depth test
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Black as clear colour
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// Disable blending
glDisable(GL_BLEND);
// Set up the view and projection matrices from the camera.
// The camera does not moves so these matrices only need to be
// calculated once.
// If you want to make the camera dynamic, re-calculate the view matrix
// every frame.
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Camera nodes are after the mesh and light nodes in the array.
// We grab camera num 0 (the only one in the scene)
const int g_ui32Camera = 0;
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + g_ui32Camera].nIdx;
// Get the camera position and target
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
m_Scene.GetCameraPos( vFrom, vTo, g_ui32Camera); // vTo is taken from the target node.
else
m_Scene.GetCamera( vFrom, vTo, vUp, g_ui32Camera); // vTo is calculated from the rotation.
// Calculate the FOV depending of the screen dimensions so everything fit in view
// regardless whether the screen is rotated or not.
// if the aspect ratio is different than 640x480 adapt FOV so the scene still looks correct.
float fRatioWoverH = (480.0f/640.0f) * ((!bRotate) ? (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight) : (float)PVRShellGet(prefHeight)/(float)PVRShellGet(prefWidth));
fFOV = m_Scene.pCamera[i32CamID].fFOV / fRatioWoverH;
// We can build the model view matrix from the camera position, target and an up vector.
m_mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix.
m_mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), m_Scene.pCamera[i32CamID].fNear, m_Scene.pCamera[i32CamID].fFar, PVRTMat4::OGL, bRotate);
return true;
}
示例9: PVRShellGetTime
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occured
@Description Main rendering loop function of the program. The shell will
call this function every frame.
eglSwapBuffers() will be performed by PVRShell automatically.
PVRShell will also manage important OS events.
Will also manage relevent OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES3Skinning::RenderScene()
{
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
glActiveTexture(GL_TEXTURE0);
/*
Calculates the frame number to animate in a time-based manner.
Uses the shell function PVRShellGetTime() to get the time in milliseconds.
*/
unsigned long iTime = PVRShellGetTime();
if(iTime > m_iTimePrev)
{
float fDelta = (float) (iTime - m_iTimePrev);
m_fFrame += fDelta * g_fDemoFrameRate;
// Modify the transformation matrix if it is needed
bool bRebuildTransformation = false;
if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_fAngle -= 0.03f;
if(m_fAngle < PVRT_TWO_PIf)
m_fAngle += PVRT_TWO_PIf;
bRebuildTransformation = true;
}
if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
m_fAngle += 0.03f;
if(m_fAngle > PVRT_TWO_PIf)
m_fAngle -= PVRT_TWO_PIf;
bRebuildTransformation = true;
}
if(PVRShellIsKeyPressed(PVRShellKeyNameUP))
{
m_fDistance -= 10.0f;
if(m_fDistance < -500.0f)
m_fDistance = -500.0f;
bRebuildTransformation = true;
}
if(PVRShellIsKeyPressed(PVRShellKeyNameDOWN))
{
m_fDistance += 10.0f;
if(m_fDistance > 200.0f)
m_fDistance = 200.0f;
bRebuildTransformation = true;
}
if(bRebuildTransformation)
m_Transform = PVRTMat4::Translation(0,0, m_fDistance) * PVRTMat4::RotationY(m_fAngle);
}
m_iTimePrev = iTime;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0;
// Set the scene animation to the current frame
m_Scene.SetFrame(m_fFrame);
/*
Set up camera
*/
PVRTVec3 vFrom, vTo, vUp(0, 1, 0);
PVRTMat4 mView, mProjection;
float fFOV;
// We can get the camera position, target and field of view (fov) with GetCameraPos()
fFOV = m_Scene.GetCamera(vFrom, vTo, vUp, 0);
/*
We can build the model view matrix from the camera position, target and an up vector.
For this we use PVRTMat4::LookAtRH().
*/
//.........这里部分代码省略.........
示例10: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occurred
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependent on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES3DisplacementMap::InitView()
{
CPVRTString ErrorStr;
/*
Initialize VBO data
*/
if(!LoadVbos(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Load textures
*/
if(!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Load and compile the shaders & link programs
*/
if(!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Initialize Print3D
*/
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
/*
Set OpenGL ES render states needed for this training course
*/
// Enable backface culling and depth test
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Use a nice bright blue as clear colour
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
//Get the direction of the first light from the scene.
m_LightDir = m_Scene.GetLightDirection(0);
// For direction vectors, w should be 0
m_LightDir.w = 0.0f;
// Set up the view and projection matrices from the camera
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Setup the camera
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + g_ui32Camera].nIdx;
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, g_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, g_ui32Camera); // vTo is calculated from the rotation
// We can build the model view matrix from the camera position, target and an up vector.
// For this we usePVRTMat4LookAtRH()
m_View = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix
m_Projection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
// Initialize variables used for the animation
m_ulTimePrev = PVRShellGetTime();
return true;
}