bool PODPlayer::InitApplication() { // set up console/log m_pConsole = ConsoleLog::ptr(); // grab pointers to these handlers and initialise them m_pUniformHandler = UniformHandler::ptr(); m_pTimeController = TimeController::ptr(); m_psMeshManager = NULL; m_psTransparentMeshManager = NULL; m_pOptionsMenu = NULL; // deal with command line int i32NumCLOptions = PVRShellGet(prefCommandLineOptNum); SCmdLineOpt* sCLOptions = (SCmdLineOpt*)PVRShellGet(prefCommandLineOpts); CPVRTString strFilename; PVRESParser cParser; bool bFoundFile = false; if(sCLOptions) { for(int i=0;i<i32NumCLOptions;++i) { if(!sCLOptions[i].pVal) { // could be script or pod strFilename=sCLOptions[i].pArg; // determine whether a script or a POD or nothing CPVRTString strExtension = PVRTStringGetFileExtension(strFilename); if(strExtension.compare(".pvres")==0 || strExtension.compare(".PVRES")==0) { // script file m_pConsole->log("Found script:%s\n", strFilename.c_str()); cParser.setScriptFileName(strFilename); bFoundFile = true; } else { if(strExtension.compare(".pod")==0 || strExtension.compare(".POD")==0) { // pod file m_pConsole->log("Found POD\n"); cParser.setPODFileName(strFilename); bFoundFile = true; } else { m_pConsole->log("Unrecognised filetype.\n"); } } } } } if(!bFoundFile) { // no command line options so open default pvres CPVRTString strDefaultPVRES((char*)(PVRShellGet(prefReadPath))); strDefaultPVRES += "Sample.pvres"; cParser.setScriptFileName(strDefaultPVRES); } m_cPVRES = cParser.Parse(); // sets up whether the console should write out constantly or not CPVRTString strLogPath = CPVRTString((char*)PVRShellGet(prefWritePath)); m_pConsole->setOutputFile(strLogPath+="log.txt"); m_pConsole->setStraightToFile(m_cPVRES.getLogToFile()); m_pConsole->log("PODPlayer v0.2 alpha\n\n Initialising...\n"); CPVRTString error = cParser.getError(); if(!error.empty()) { m_pConsole->log("Couldn't parse script: %s:\n%s",m_cPVRES.getScriptFileName().c_str(),error.c_str()); PVRShellSet(prefExitMessage, m_pConsole->getLastLogLine().c_str()); return false; } // Deal with results of script read // Load the scene from the .pod file into a CPVRTModelPOD object. if(m_Scene.ReadFromFile(m_cPVRES.getPODFileName().c_str()) != PVR_SUCCESS) { m_pConsole->log("Error: couldn't open POD file: %s\n",m_cPVRES.getPODFileName().c_str()); PVRShellSet(prefExitMessage, m_pConsole->getLastLogLine().c_str()); return false; } // The cameras are stored in the file. Check if it contains at least one. if(m_Scene.nNumCamera == 0) { m_bFreeCamera = true; } else { m_bFreeCamera = false; } // use camera 0 to begin with m_u32CurrentCameraNum = 0; // Ensure that all meshes use an indexed triangle list for(unsigned int i = 0; i < m_Scene.nNumMesh; ++i) { if(m_Scene.pMesh[i].nNumStrips || !m_Scene.pMesh[i].sFaces.pData) { m_pConsole->log("ERROR: The meshes in the scene should use an indexed triangle list\n"); PVRShellSet(prefExitMessage, m_pConsole->getLastLogLine().c_str()); return false; } } PVRShellSet(prefFSAAMode,m_cPVRES.getFSAA()); // set fullscreen anti-aliasing PVRShellSet(prefPowerSaving,m_cPVRES.getPowerSaving()); // set power saving mode PVRShellSet(prefHeight,m_cPVRES.getHeight()); // set height of window PVRShellSet(prefWidth,m_cPVRES.getWidth()); // set width of window PVRShellSet(prefPositionX,m_cPVRES.getPosX()); // set horizontal position of window PVRShellSet(prefPositionY,m_cPVRES.getPosY()); // set vertical position of window PVRShellSet(prefQuitAfterTime,m_cPVRES.getQuitAfterTime()); // time after which PODPlayer will automatically quit PVRShellSet(prefQuitAfterFrame,m_cPVRES.getQuitAfterFrame()); // frame after which PODplayer will automatically quit PVRShellSet(prefSwapInterval,m_cPVRES.getVertSync()?1:0); // set vertical sync with monitor PVRShellSet(prefFullScreen, m_cPVRES.getFullScreen()); // set fullscreen m_pUniformHandler->setScene(&m_Scene); m_pUniformHandler->setLightManager(LightManager::ptr()); // Initialize variables used for the animation m_bOptions = false; // don't show options at start up m_bOverlayOptions = false; // don't overlay the options by default m_pTimeController->setNumFrames(m_Scene.nNumFrame); // set the number of frames to animate across m_pTimeController->setFrame(m_cPVRES.getStartFrame()); // set the frame from which to start the animation m_pTimeController->setAnimationSpeed(m_cPVRES.getAnimationSpeed()); // set the speed with which to animate // set PODPlayer to initialising state m_i32Initialising = 1; m_pConsole->log("Initial setup Succeeded\n"); return true; }