本文整理汇总了C++中CPVRTModelPOD类的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTModelPOD类的具体用法?C++ CPVRTModelPOD怎么用?C++ CPVRTModelPOD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPVRTModelPOD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
/*!****************************************************************************
@Function dump_materials
@Input pszFile
@Input config
@Description Helper function to extract the materials referenced in the
configuration set (to reduce the size of materials necessary
for the demo to run).
******************************************************************************/
void dump_materials(const char *pszFile, const vector<ModelDescription> &descriptions)
{
set<string> refmaterials;
size_t nrmodels = descriptions.size();
for (unsigned int i=0; i < nrmodels; i++)
{
for (unsigned int j=0; j < descriptions[i].aszLodFilenames.size(); j++)
{
CPVRTModelPOD model;
if (PVR_SUCCESS != model.ReadFromFile(descriptions[i].aszLodFilenames[j].c_str()))
{
cerr << "Failed loading file: " << descriptions[i].aszLodFilenames[j] << endl;
return;
}
for (unsigned int k=0; k < model.nNumTexture; k++)
refmaterials.insert(model.pTexture[k].pszName);
}
}
// Write to a plain text file, starting with the number of materials found and then
// enumerating all referenced materials (aka textures).
ofstream materialfile(pszFile);
materialfile << refmaterials.size() << endl;
copy(refmaterials.begin(), refmaterials.end(), ostream_iterator<string>(materialfile, "\n"));
materialfile.close();
}
示例2: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occured
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLESRenderToTexture::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
/*
Loads the scene from the .pod file into a CPVRTModelPOD object.
We could also export the scene as a header file and
load it with ReadFromMemory().
*/
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_szSceneFile) + "'.";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
return true;
}
示例3:
/*!****************************************************************************
@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.
}
示例4: InitApplication
/*******************************************************************************
* Function Name : InitApplication
* Inputs :
* Returns : true if no error occured
* Description : Code in InitApplication() will be called by the Shell ONCE per
* run, early on in the execution of the program.
* Used to initialize variables that are not dependant on the
* rendering context (e.g. external modules, loading meshes, etc.)
*******************************************************************************/
bool OGLESOptimizeMesh::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Set some parameters in the Shell
PVRShellSet(prefAppName, "OptimizeMesh");
PVRShellSet(prefSwapInterval, 0);
// Load POD File Data
// Load the meshes
if(m_Model.ReadFromFile(c_szSphere) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Failed to load Sphere_*.pod!");
return false;
}
if(m_ModelOpt.ReadFromFile(c_szSphereOpt) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Failed to load SphereOpt_*.pod!");
return false;
}
#ifdef ENABLE_LOAD_TIME_STRIP
// Create a stripped version of the mesh at load time
m_i32Init = 2;
#endif
// Init values to defaults
m_i32Page = 0;
return true;
}
示例5: QuitApplication
/*******************************************************************************
* Function Name : QuitApplication
* Returns : true if no error occured
* Description : Code in QuitApplication() will be called by the Shell ONCE per
* run, just before exiting the program.
*******************************************************************************/
bool OGLESOptimizeMesh::QuitApplication()
{
m_Model.Destroy();
m_ModelOpt.Destroy();
delete[] m_puiVbo;
delete[] m_puiIndexVbo;
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 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;
}
示例7: QuitApplication
/*!****************************************************************************
@Function QuitApplication
@Return bool true if no error occurred
@Description Code in QuitApplication() will be called by PVRShell once per
run, just before exiting the program.
If the rendering context is lost, QuitApplication() will
not be called.
******************************************************************************/
bool OGLES2Glass::QuitApplication()
{
// Free the memory allocated for the scene
m_Ball.Destroy();
m_Balloon.Destroy();
delete [] m_puiVbo;
delete [] m_puiIndexVbo;
delete [] m_puiBalloonVbo;
delete [] m_puiBalloonIndexVbo;
return true;
}
示例8: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occurred
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLES2FilmTV::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the scene
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_szSceneFile) + "'.";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// The cameras are stored in the file. We check it contains at least one.
if(m_Scene.nNumCamera == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a camera. Please add one and re-export.\n");
return false;
}
// We also check that the scene contains at least one light
if(m_Scene.nNumLight == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a light. Please add one and re-export.\n");
return false;
}
return true;
}
示例9: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occured
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLES3Refraction::InitApplication()
{
m_puiVbo = 0;
m_puiIndexVbo = 0;
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the scene
if (m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Couldn't load the .pod file\n");
return false;
}
m_bSpecular = true;
m_fAngleX = 0.0f;
m_fAngleY = 0.0f;
return true;
}
示例10: InitApplication
/*******************************************************************************
* Function Name : InitApplication
* Returns : true if no error occured
* Description : Code in InitApplication() will be called by the Shell ONCE per
* run, early on in the execution of the program.
* Used to initialize variables that are not dependant on the
* rendering context (e.g. external modules, loading meshes, etc.)
*******************************************************************************/
bool OGLESSkinning::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the POD file.
/*
The vertex data in the pod file is interleaved. Due to requirements with alignment
on some ARM based MBX platforms this data needs to be 32 bit aligned (the stride of
a vertex should be divisible by 4). To achieve this we have padded out the vertex
data by exporting a dummy second set of UV coordinates where each coordinate is a
byte in size.
*/
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "Error: Failed to load scene.\n");
return false;
}
m_fFrame = 0;
return true;
}
示例11: QuitApplication
/*!****************************************************************************
@Function QuitApplication
@Return bool true if no error occurred
@Description Code in QuitApplication() will be called by PVRShell once per
run, just before exiting the program.
If the rendering context is lost, QuitApplication() will
not be called.
******************************************************************************/
bool OGLESPVRScopeRemote::QuitApplication()
{
if (m_psSPSCommsData)
{
m_bCommsError |= !pplSendProcessingBegin(m_psSPSCommsData, __FUNCTION__, static_cast<unsigned int>(strlen(__FUNCTION__)), m_i32FrameCounter);
}
// Free the memory allocated for the scene
m_Scene.Destroy();
delete [] m_puiVbo;
delete [] m_puiIndexVbo;
// Close the data connection to PVRPerfServer
if(m_psSPSCommsData)
{
for(unsigned int i = 0; i < 40; ++i)
{
char buf[128];
const int nLen = sprintf(buf, "test %u", i);
m_bCommsError |= !pplSendMark(m_psSPSCommsData, buf, nLen);
}
m_bCommsError |= !pplSendProcessingEnd(m_psSPSCommsData);
pplShutdown(m_psSPSCommsData);
}
return true;
}
示例12:
/*!****************************************************************************
@Function DrawSceneWithShadow
@Input viewMat The view matrix to use for rendering
@Description Draws the scene with the shadow
******************************************************************************/
void OGLES2ShadowMapping::DrawSceneWithShadow(PVRTMat4 viewMat)
{
for (unsigned int i = 0; i < m_Scene.nNumMeshNode; ++i)
{
if(i == 1) continue;
SPODNode& Node = m_Scene.pNode[i];
PVRTMat4 mWorld, mModelView;
m_Scene.GetWorldMatrix(mWorld, Node);
PVRTMatrixMultiply(mModelView, mWorld, viewMat);
glUniformMatrix4fv(m_ShadowShaderProgram.uiModelViewMatrixLoc, 1, GL_FALSE, mModelView.f);
// Calculate the light direction for the diffuse lighting
PVRTVec4 vLightDir;
PVRTTransformBack(&vLightDir, &m_vLightDirection, &mWorld);
PVRTVec3 vLightDirModel = *(PVRTVec3*)&vLightDir;
PVRTMatrixVec3Normalize(vLightDirModel, vLightDirModel);
glUniform3fv(m_ShadowShaderProgram.uiLightDirLoc, 1, &vLightDirModel.x);
// Load the correct texture using our texture lookup table
GLuint uiTex = 0;
if (Node.nIdxMaterial != -1)
uiTex = m_puiTextureIDs[Node.nIdxMaterial];
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, uiTex);
DrawMesh(i);
}
}
示例13: QuitApplication
/*!****************************************************************************
@Function QuitApplication
@Return bool true if no error occured
@Description Code in QuitApplication() will be called by PVRShell once per
run, just before exiting the program.
If the rendering context is lost, QuitApplication() will
not be called.
******************************************************************************/
bool OGLESIntroducingPFX::QuitApplication()
{
// Frees the memory allocated for the scene
m_Scene.Destroy();
return true;
}
示例14: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occurred
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLES2MagicLantern::InitApplication()
{
m_puiVbo = 0;
m_puiIndexVbo = 0;
m_puiMaterialEffectID = 0;
// Get and set the read path for content files.
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the scene
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Couldn't load the .pod file\n");
return false;
}
// The cameras are stored in the file. We check it contains at least one.
if(m_Scene.nNumCamera == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a camera. Please add one and re-export.\n");
return false;
}
m_LightPosition.x = 0.0f; m_LightPosition.z = -130.0f;
return true;
}
示例15: QuitApplication
/*!****************************************************************************
@Function QuitApplication
@Return bool true if no error occured
@Description Code in QuitApplication() will be called by PVRShell once per
run, just before exiting the program.
If the rendering context is lost, QuitApplication() will
not be called.
******************************************************************************/
bool OGLESFur::QuitApplication()
{
// Frees the memory allocated for the scene
m_Scene.Destroy();
delete[] m_puiVbo;
delete[] m_puiIndexVbo;
return true;
}