//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application67::OnCreateScene(SceneContainer &cContainer) { // Create a scene container with our 'concrete sound scene' using the default sound API SceneNode *pSceneContainerNode = cContainer.Create("PLSound::SCSound", "SoundScene"); if (pSceneContainerNode && pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) { SceneContainer *pSceneContainer = static_cast<SceneContainer*>(pSceneContainerNode); // Protect this important container! pSceneContainer->SetProtected(true); // Populate the scene container // Setup scene surface painter SurfacePainter *pPainter = GetPainter(); if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) { SPScene *pSPScene = static_cast<SPScene*>(pPainter); pSPScene->SetRootContainer(cContainer.GetContainer()); pSPScene->SetSceneContainer(pSceneContainer); // Get the scene context SceneContext *pSceneContext = GetSceneContext(); if (pSceneContext) { // Create us a scene renderer SceneRenderer *pSceneRenderer = pSceneContext->GetSceneRendererManager().Create("2DGame"); if (pSceneRenderer) { // Add begin scene renderer pass pSceneRenderer->Create("PLCompositing::SRPBegin", "Begin", "TextureFormat=\"R8G8B8A8\" Flags=\"Inactive\""); // Add our own scene renderer pass pSceneRenderer->Create("SRP2DGame", "2DGame"); // Add post processing scene renderer pass pSceneRenderer->Create("PLCompositing::SRPPostProcessing", "PostProcessing"); // Add end scene renderer pass pSceneRenderer->Create("PLCompositing::SRPEnd", "End"); // Make this scene renderer to the default scene renderer of our scene surface painter pSPScene->SetDefaultSceneRenderer(pSceneRenderer->GetName()); } } } // Set scene container SetScene(pSceneContainer); // Start the game Restart(); } }
/** * @brief * Returns the used scene renderer */ SceneRenderer *SNCamera::GetSceneRenderer() const { // Get/load the scene renderer SceneRenderer *pSceneRenderer = m_pSceneRendererHandler->GetResource(); if (!pSceneRenderer && m_sSceneRendererFilename.GetLength()) { // Get the scene context SceneContext *pSceneContext = GetSceneContext(); if (pSceneContext) { pSceneRenderer = pSceneContext->GetSceneRendererManager().LoadResource(m_sSceneRendererFilename); m_pSceneRendererHandler->SetResource(pSceneRenderer); } } // Return the scene renderer return pSceneRenderer; }
/** * @brief * Returns the default scene renderer */ SceneRenderer *SPScene::GetDefaultSceneRenderer() const { // Get/load the scene renderer SceneRenderer *pSceneRenderer = m_pDefaultSceneRendererHandler->GetResource(); if (!pSceneRenderer && m_sDefaultSceneRenderer.GetLength()) { // Get the root scene container SceneContainer *pRootContainer = GetRootContainer(); if (pRootContainer) { // Get the scene context SceneContext *pSceneContext = pRootContainer->GetSceneContext(); if (pSceneContext) { pSceneRenderer = pSceneContext->GetSceneRendererManager().LoadResource(m_sDefaultSceneRenderer); m_pDefaultSceneRendererHandler->SetResource(pSceneRenderer); } } } // Return the scene renderer return pSceneRenderer; }