本文整理汇总了C++中CPVRTPrint3D::SetModelView方法的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTPrint3D::SetModelView方法的具体用法?C++ CPVRTPrint3D::SetModelView怎么用?C++ CPVRTPrint3D::SetModelView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPVRTPrint3D
的用法示例。
在下文中一共展示了CPVRTPrint3D::SetModelView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method
/*!***************************************************************************
@Function RenderText
@Description Draws the 3D text and scrolls in to the screen.
*****************************************************************************/
void OGLES2IntroducingPrint3D::RenderText()
{
float fAspect = (float)PVRShellGet(prefWidth) / (float)PVRShellGet(prefHeight);
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
// Calculate the frame delta.
unsigned long ulNow = PVRShellGetTime();
if(m_ulPrevFrameT == 0) m_ulPrevFrameT = ulNow;
float fDT = (ulNow - m_ulPrevFrameT) * 0.001f;
m_ulPrevFrameT = ulNow;
// Calculate the FPS scale.
float fFPSScale = fDT / c_fTargetFPS;
// Move the text. Progressively speed up.
float fSpeedInc = 0.0f;
if(m_fTextOffset > 0.0f)
fSpeedInc = m_fTextOffset / TEXT_END_Y;
m_fTextOffset += (0.75f + (1.0f * fSpeedInc)) * fFPSScale;
if(m_fTextOffset > TEXT_END_Y)
m_fTextOffset = TEXT_START_Y;
PVRTMat4 mProjection = PVRTMat4::PerspectiveFovRH(0.7f, fAspect, 1.0f, 2000.0f, PVRTMat4::OGL, bRotate);
PVRTMat4 mScale = PVRTMat4::Scale(PVRTVec3(1.0f, -1.0f, 1.0f));
PVRTMat4 mCamera = PVRTMat4::LookAtRH(PVRTVec3(0.0f, -900.0f, 700.0f), PVRTVec3(0.0f,-200.0f,0.0f), PVRTVec3(0.0f,1.0f,0.0f));
PVRTMat4 mTrans = PVRTMat4::Translation(PVRTVec3(0.0f, m_fTextOffset, 0.0f));
PVRTMat4 mModelView = mCamera * mTrans;
float fStrWidth = 0.0f;
/*
Print3D can optionally be provided with user-defined projection and model-view matrices
which allow custom layout of text. Here we are proving both a projection and model-view
matrix. The projection matrix specified here uses perspective projection which will
provide the 3D effect. The model-view matrix positions the the text in world space
providing the 'camera' position and the scrolling of the text.
*/
m_CentralText.SetProjection(mProjection);
m_CentralText.SetModelView(mModelView);
/*
The previous method (RenderTitle()) explains the following functions in more detail
however put simply, we are looping the entire array of loaded text which is encoded
in UTF-8. Print3D batches this internally and the call to Flush() will render the
text to the frame buffer. We are also fading out the text over a certain distance.
*/
float fPos, fFade;
unsigned int uiCol;
for(unsigned int uiIndex = 0; uiIndex < m_TextLines.GetSize(); ++uiIndex)
{
fPos = (m_fTextOffset - (uiIndex * 36.0f));
fFade = 1.0f;
if(fPos > TEXT_FADE_START)
{
fFade = PVRTClamp(1.0f - ((fPos - TEXT_FADE_START) / (TEXT_FADE_END - TEXT_FADE_START)), 0.0f, 1.0f);
}
uiCol = (((unsigned int)(fFade * 255)) << 24) | 0x00FFFF;
m_CentralText.MeasureText(&fStrWidth, NULL, 1.0f, (const char*)m_TextLines[uiIndex]);
m_CentralText.Print3D(-(fStrWidth*0.5f), -(uiIndex * 36.0f), 1.0f, uiCol, (const char*)m_TextLines[uiIndex]);
}
m_CentralText.Flush();
}