/** * @brief * Called when a scene node was found */ void SNProjectile::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode) { // Is this projectile still active? if (IsActive()) { // Is this a bomb? if (cSceneNode.IsInstanceOf("SNBomb")) { // Is the bomb still alive? if (!cSceneNode.GetAttribute("Killed")->GetBool()) { // Jap, kill the bomb right now cSceneNode.SetAttribute("Killed", "1"); // Destroy this projectile Delete(); // Done, do NOT continue the query! cQuery.Stop(); } // Is this the UFO? (can not be killed :) } else if (cSceneNode.IsInstanceOf("SNUFO")) { // Jap, destroy this projectile Delete(); // Done, do NOT continue the query! cQuery.Stop(); } } }
//[-------------------------------------------------------] //[ Protected virtual PLScene::SceneApplication functions ] //[-------------------------------------------------------] void EngineApplication::OnCreateRootScene() { // Get the scene context SceneContext *pSceneContext = GetSceneContext(); if (pSceneContext) { // First, create the scene root container which holds the scene container with our 'concrete' scene within it SceneContainer *pRootContainer = pSceneContext->GetRoot() ? static_cast<SceneContainer*>(pSceneContext->GetRoot()->Create("PLScene::SceneContainer", "RootScene")) : nullptr; if (pRootContainer) { // Protect this important container! pRootContainer->SetProtected(true); // Create a scene container with our 'concrete scene' SceneNode *pSceneContainerNode = pRootContainer->Create("PLScene::SceneContainer", "Scene"); if (pSceneContainerNode && pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) { SceneContainer *pSceneContainer = static_cast<SceneContainer*>(pSceneContainerNode); // Protect this important container! pSceneContainer->SetProtected(true); // Connect event handler if (pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) static_cast<SceneContainer*>(pSceneContainerNode)->SignalLoadProgress.Connect(EventHandlerLoadProgress); // Create the 'concrete scene' OnCreateScene(*pSceneContainer); } // Create scene node for engine information SceneNode *pSceneNode = pRootContainer->Create("PLEngine::SNEngineInformation"); if (pSceneNode) pSceneNode->SetActive(m_bEditModeEnabled); // Create console scene node - using the console command 'timescale <value>' we // can change the scene time (slowdown or accelerate) pSceneNode = pRootContainer->Create("PLEngine::SNConsole"); if (pSceneNode && pSceneNode->GetClass()->IsDerivedFrom("PLEngine::SNConsoleBase")) { SNConsoleBase *pConsole = static_cast<SNConsoleBase*>(pSceneNode); // Register default commands pConsole->RegisterCommand(0, "quit", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this)); pConsole->RegisterCommand(0, "exit", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this)); pConsole->RegisterCommand(0, "bye", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this)); pConsole->RegisterCommand(0, "logout", "", "", Functor<void, ConsoleCommand &>(&EngineApplication::ConsoleCommandQuit, this)); // Set active state pConsole->SetActive(m_bEditModeEnabled); } } // Set the root scene SetRootScene(pRootContainer); } }
//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application65::OnCreateScene(SceneContainer &cContainer) { // Create a scene node with the soldier mesh cContainer.Create("PLScene::SNMesh", "Soldier", "Position=\"0.0 -0.7 -4.0\" Scale=\"0.008 0.008 0.008\" Mesh=\"Data/Meshes/Soldier.mesh\""); // Create a nice particle effect behind the soldier cContainer.Create("PLParticleGroups::PGMagic2", "Magic2", "Position=\"0.0 0.0 -25.0\""); // Create a moving light source to illuminate the scene cContainer.Create("PLScene::SNPointLight", "Light", "Position=\"1.0 2.0 -2.0\" Flags=\"Flares|Corona|Blend\" Range=\"15.0\""); // Create a camera - this time we increase the camera FOV to get a better space feeling :) SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FixedCamera", "Position=\"0.0 0.0 -2.5\" Rotation=\"0.0 180.0 0.0\" FOV=\"60\""); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) { // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCamera)); // Get class list of all available post process scene node modifiers m_lstModifierClasses.Clear(); ClassManager::GetInstance()->GetClasses(m_lstModifierClasses, "PLCompositing::SNMPostProcess", Recursive, NoBase, NoAbstract); // 'Activate' the first effect if (m_lstModifierClasses.GetNumOfElements()) pCamera->AddModifier(m_lstModifierClasses[m_nCurrentSelectedModifier]->GetClassName()); } // 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(&cContainer); } // Within the parent container... SceneContainer *pContainer = cContainer.GetContainer(); if (pContainer) { // Add our information text scene nodes SceneNode *pInfoText = pContainer->Create("PLScene::SceneContainer", "InfoText", "Flags=\"NoCulling\""); if (pInfoText && pInfoText->IsInstanceOf("PLScene::SceneContainer")) { SceneContainer *pInfoTextContainer = static_cast<SceneContainer*>(pInfoText); pInfoTextContainer->Create("PLScene::SNText2D", '0', "Position=\"0.01 0.01\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("'F1' = Show/hide this help text") + '\"'); pInfoTextContainer->Create("PLScene::SNText2D", '1', "Position=\"0.01 0.03\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("'Space' = Enable/disable post processing") + '\"'); pInfoTextContainer->Create("PLScene::SNText2D", '2', "Position=\"0.01 0.05\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("'1-7' = Custom post process effects") + '\"'); pInfoTextContainer->Create("PLScene::SNText2D", '3', "Position=\"0.01 0.07\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("'Page up' = Next post process effect") + '\"'); pInfoTextContainer->Create("PLScene::SNText2D", '4', "Position=\"0.01 0.09\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("'Page down' = Previous post process effect") + '\"'); } } // Set scene container SetScene(&cContainer); }
/** * @brief * Restarts the game */ void Application67::Restart() { // Get the scene container SceneContainer *pSceneContainer = GetScene(); if (pSceneContainer) { // Clean up your scene container pSceneContainer->Clear(); // Create the camera (we need the camera to control the post processing) SceneNode *pCamera = pSceneContainer->Create("PLScene::SNCamera", "FixedCamera"); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) { // Add a post process scene node modifier from the 'PLPostProcessEffects'-plugin pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm", "Flags='Inactive'"); // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCamera)); } // Create an UFO from mars attacking the earth :D pSceneContainer->Create("SNUFO", "Ufo"); // Create the gun (the player) pSceneContainer->Create("SNGun", "Gun", "Position=\"157 155\""); } }
//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application60::OnCreateScene(SceneContainer &cContainer) { // Create a camera scene node SceneNode *pCameraSceneNode = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\""); if (pCameraSceneNode && pCameraSceneNode->IsInstanceOf("PLScene::SNCamera")) { // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCameraSceneNode)); } // Create a scene node with the soldier mesh which can produce a shadow SceneNode *pSoldierSceneNode = cContainer.Create("PLScene::SNMesh", "Soldier", "Flags=\"CastShadow|ReceiveShadow\" Position=\"0.0 0.1 -5.0\" Scale=\"0.008 0.008 0.008\" Mesh=\"Data/Meshes/Soldier.mesh\""); if (pSoldierSceneNode) { // Add a scene node modifier which will constantly rotate the soldier pSoldierSceneNode->AddModifier("PLScene::SNMRotationLinearAnimation", "Velocity=\"0 10 0\""); // Add a scene node modifier which will playback the animation named "walk_0" letting the soldier walk pSoldierSceneNode->AddModifier("PLScene::SNMMeshAnimation", "Name=\"walk_0\""); // Add a scene node modifier which will animate the morph target named "blink" letting the soldier blink from time to time pSoldierSceneNode->AddModifier("PLScene::SNMMeshMorphBlink", "Name=\"blink\""); } // Create a light source scene node to illuminate the scene - this light can cast shadows cContainer.Create("PLScene::SNPointLight", "Light", "Flags=\"CastShadow|Flares|Corona\" Range=\"4\""); // Create the floor scene node cContainer.Create("PLScene::SNMesh", "Floor", "Flags=\"CastShadow|ReceiveShadow\" Position=\"0.0 0.0 -5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\""); // Set scene container SetScene(&cContainer); }
/** * @brief * Called when a scene node was found */ void EngineApplication::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode) { // Is this a camera? if (cSceneNode.IsCamera()) { if (!m_pFirstFoundCamera) m_pFirstFoundCamera = &cSceneNode; // Deactivate all camera's by default cSceneNode.SetActive(false); // Key/value data scene node? } else if (cSceneNode.IsInstanceOf("PLScene::SNKeyValue")) { const SNKeyValue &cKeyValue = static_cast<const SNKeyValue&>(cSceneNode); // SceneRenderer if (cKeyValue.Key.GetString() == "SceneRenderer") { // Use the first found key if (!m_sDefaultSceneRenderer.GetLength()) m_sDefaultSceneRenderer = cKeyValue.Value.GetString(); // SceneRendererVariables } else if (cKeyValue.Key.GetString() == "SceneRendererVariables") { // Use the first found key if (!m_sSceneRendererVariables.GetLength()) m_sSceneRendererVariables = cKeyValue.Value.GetString(); // ClearColor } else if (cKeyValue.Key.GetString() == "ClearColor") { // Use the first found key if (!m_sClearColor.GetLength()) m_sClearColor = cKeyValue.Value.GetString(); // StartCamera } else if (cKeyValue.Key.GetString() == "StartCamera") { // Use the first found key if (!m_sStartCamera.GetLength()) m_sStartCamera = cKeyValue.Value.GetString(); } // Load screen scene node? } else if (cSceneNode.IsInstanceOf("PLEngine::SNLoadScreenBase")) { m_bHasLoadScreen = true; } }
//[-------------------------------------------------------] //[ Protected virtual PLFrontendQt::QPLSceneContext functions ] //[-------------------------------------------------------] void MySceneContext::OnCreateScene(SceneContainer &cContainer) { // Create a camera SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 0 0\""); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) SetCamera(reinterpret_cast<SNCamera*>(pCamera)); // Create the floor cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0.0 0.0 5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\""); // Set scene container SetScene(&cContainer); }
//[-------------------------------------------------------] //[ 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 * Searches for the first (= nearest) visible clip plane scene node, recursive part */ const VisNode *SRPVolume::GetFirstClipPlaneRec(const SQCull &cCullQuery) const { // Get visibility container const VisContainer &cVisContainer = cCullQuery.GetVisContainer(); // Search through all visible scene nodes of this scene container Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator(); while (cIterator.HasNext()) { // Get visibility node and scene node const VisNode *pVisNode = cIterator.Next(); SceneNode *pSceneNode = pVisNode->GetSceneNode(); if (pSceneNode) { // Is this scene node a portal? if (pVisNode->IsPortal()) { // Get the target cell visibility container const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer(); if (pVisCell && pVisCell->GetCullQuery()) { // Search within the target cell const VisNode *pFoundVisNode = GetFirstClipPlaneRec(*pVisCell->GetCullQuery()); if (pFoundVisNode) return pFoundVisNode; } // Is this scene node a container? We do not need to check for cells because we will // NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above) } else if (pVisNode->IsContainer()) { // Search within this container without special processing if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery()) { const VisNode *pFoundVisNode = GetFirstClipPlaneRec(*static_cast<const VisContainer*>(pVisNode)->GetCullQuery()); if (pFoundVisNode) return pFoundVisNode; } // This must just be a quite boring scene node :) } else { // Is this a clip plane scene node? if (pSceneNode->IsInstanceOf("PLVolume::SNClipPrimitivePlane")) return pVisNode; } } } // Sorry, no result :/ return nullptr; }
/** * @brief * Called when a scene node was found */ void SNGun::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode) { // Is this gun still active? if (IsActive()) { // Is this a bomb? if (cSceneNode.IsInstanceOf("SNBomb")) { // Is the bomb still alive? if (!cSceneNode.GetAttribute("Killed")->GetBool()) { // Jap, kill the bomb right now cSceneNode.SetAttribute("Killed", "1"); // Destroy this gun Delete(); // Done, do NOT continue the query! cQuery.Stop(); } } } }
//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application70::OnCreateScene(SceneContainer &cContainer) { // Create a camera SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\""); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) { // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCamera)); // Add a controller modifier so we can look around the camera by using a default control pCamera->AddModifier("PLEngine::SNMEgoLookController"); // Add a controller modifier so we can move around the camera by using a default control pCamera->AddModifier("PLEngine::SNMMoveController"); } // Create the floor cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0 0 -5\" Scale=\"4 0.1 4\" Mesh=\"Default\""); // Create an instance of the fire particle effect scene node cContainer.Create("SNFireSample", "Fire", "Position=\"0.5 0.3 -5\" Scale=\"0.1 0.1 0.1\""); // Create an instance of the basic particle effect scene node cContainer.Create("SNBasicSample", "Basic", "Position=\"-0.5 0.1 -8\" Scale=\"0.5 0.5 0.5\""); // Create an instance of the gravitation particle effect scene node cContainer.Create("SNGravitationSample", "Gravitation", "Position=\"-1 1 -5\" Scale=\"0.5 0.5 0.5\""); // Create an instance of the galaxy particle effect scene node cContainer.Create("SNGalaxySample", "Galaxy", "Position=\"-3 0.5 -8\" Scale=\"0.5 0.5 0.5\""); // 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(&cContainer); } // Set scene container SetScene(&cContainer); }
//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application64::OnCreateScene(SceneContainer &cContainer) { // Create a camera SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\""); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) { // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCamera)); } // Create a scene node with the soldier mesh - in debug mode, show some fancy technical visualizations SceneNode *pSceneNode = cContainer.Create("PLScene::SNMesh", "Soldier", "Position=\"0.0 0.1 -5.0\" Scale=\"0.008 0.008 0.008\" Mesh=\"Data/Meshes/Soldier.mesh\" DebugFlags=\"DebugShowWireframe|DebugShowJoints|DebugShowJointNames|DebugShowSkeleton\""); if (pSceneNode) { // Rotate the soldier pSceneNode->AddModifier("PLScene::SNMRotationLinearAnimation", "Velocity=\"0 10 0\""); // Playback the animation named "walk_0" letting the soldier walk pSceneNode->AddModifier("PLScene::SNMMeshAnimation", "Name=\"walk_0\""); // Animate the morph target named "blink" letting the soldier blink from time to time pSceneNode->AddModifier("PLScene::SNMMeshMorphBlink", "Name=\"blink\""); } // Create the floor cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0.0 0.0 -5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\""); // 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(&cContainer); } // Set scene container SetScene(&cContainer); // Create the picking component m_pMyPicking = new MyPicking(*this); }
//[-------------------------------------------------------] //[ Private virtual PLEngine::EngineApplication functions ] //[-------------------------------------------------------] void Application61::OnCreateScene(SceneContainer &cContainer) { // Set no scene container as default SetScene(nullptr); // Sound API given? if (m_sSoundAPI.GetLength()) { // Create a scene container with our 'concrete sound scene' using the chosen sound API SceneNode *pSceneContainerNode = cContainer.Create("PLSound::SCSound", "SoundScene", "SoundAPI=\"" + m_sSoundAPI + "\" Pitch=\"" + Timing::GetInstance()->GetTimeScaleFactor() + '\"'); if (pSceneContainerNode && pSceneContainerNode->IsInstanceOf("PLScene::SceneContainer")) { SceneContainer *pSceneContainer = static_cast<SceneContainer*>(pSceneContainerNode); // Protect this important container! pSceneContainer->SetProtected(true); // Set scene container SetScene(pSceneContainer); // Populate the scene container // Create a camera SceneNode *pCamera = pSceneContainer->Create("PLScene::SNCamera", "FreeCamera", "Position=\"0.0 -1.5 1.4\" Rotation=\"-14.0 180.0 0.0\""); if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) { // Make this to our main scene camera SetCamera(reinterpret_cast<SNCamera*>(pCamera)); // Add a controller modifier so we can look around the camera by using a default control pCamera->AddModifier("PLEngine::SNMEgoLookController"); // Add a controller modifier so we can move around the camera by using a default control pCamera->AddModifier("PLEngine::SNMMoveController", "Speed=\"2\""); // Make this camera to the 'sound listener' pSceneContainer->SetAttribute("Listener", pCamera->GetName()); } // Create the floor pSceneContainer->Create("PLScene::SNMesh", "Floor", "Position=\"0.0 -2.1 -5.0\" Rotation=\"0.0 180.0 0.0\" Scale=\"4.0 0.1 4.0\" Mesh=\"Default\""); // Create a box on the floor pSceneContainer->Create("PLScene::SNMesh", "Box", "Position=\"0.0 -1.5 -5.0\" Scale=\"0.5 0.5 0.5\" Mesh=\"Default\""); // Create rain particles and rain sound pSceneContainer->Create("PLParticleGroups::PGRain", "Rain", "Position=\"0.0 15.0 -5.0\" Flags=\"ForceUpdate\" MediumSize=\"3\""); pSceneContainer->Create("PLSound::SNSound", "RainSound", "Sound=\"Data/Sounds/Rain.ogg\" Volume=\"0.2\""); // Create the soldier walking in the rain :) SceneNode *pSoldier = pSceneContainer->Create("PLScene::SNMesh", "Soldier", "Position=\"0.0 -1.5 -5.0\" Scale=\"0.007 0.007 0.007\" Mesh=\"Data/Meshes/Soldier.mesh\""); if (pSoldier) { // Add animation modifier pSoldier->AddModifier("PLScene::SNMMeshAnimation", "Name=\"walk_0\" Speed=\"2\""); // Let the soldier walk on a path... pSoldier->AddModifier("PLScene::SNMPositionPath", "Filename=\"Data/Misc/61Sound_Soldier.path\" Speed=\"0.5\" Flags=\"NodeIndexProgress\" Interpolation=\"CatmullRomCurve\""); // ... and we should look into the direction he's moving pSoldier->AddModifier("PLScene::SNMRotationMoveDirection"); // Link a footsteps sound to the soldier pSoldier->AddModifier("PLSound::SNMSound","Sound=\"Data/Sounds/Walking.ogg\""); } // 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); } // Within the parent container... SceneContainer *pContainer = pSceneContainer->GetContainer(); if (pContainer) { // Get/add our information text scene nodes SceneNode *pInfoText = pContainer->Create("PLScene::SceneContainer", "InfoText", "Flags=\"NoCulling\""); if (pInfoText && pInfoText->IsInstanceOf("PLScene::SceneContainer")) { SceneContainer *pInfoTextContainer = static_cast<SceneContainer*>(pInfoText); // The name of the used sound API pInfoTextContainer->Create("PLScene::SNText2D", "SoundAPI", "Position=\"0.01 0.01\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("Sound API: ") + GetSoundAPI() + '\"'); // Draw keys information pInfoTextContainer->Create("PLScene::SNText2D", "Keys", "Position=\"0.01 0.04\" Flags=\"No3DPosition|NoCenter\" Text=\"" + PLT("Keys:") + '\"'); pInfoTextContainer->Create("PLScene::SNText2D", "TimeScale", "Position=\"0.06 0.08\" Flags=\"No3DPosition|NoCenter\""); UpdateTimeScaleTextNode(); } } } } }
/** * @brief * Recursive part of PerformQuery() */ bool SQPlaneSet::PerformQueryRec(SceneHierarchyNode &cHierarchyNode) { // Is this scene hierarchy node intersecting the plane set? if (!cHierarchyNode.CheckPlaneSet(m_cPlaneSet)) return true; // Continue the query // Touch this node cHierarchyNode.Touch(); // Get the scene context SceneContext *pSceneContext = GetSceneContext(); if (pSceneContext) { // Inform all listeners const SceneHierarchyNodeItem *pItem = cHierarchyNode.GetFirstItem(); while (pItem) { // Get the linked scene node SceneNode *pSceneNode = pItem->GetSceneNode(); // Was this scene node already processed? if (pSceneNode && !pSceneContext->IsNodeTouched(*pSceneNode)) { // Check scene node const AABoundingBox &cAABB = pSceneNode->GetContainerAABoundingBox(); if (Intersect::PlaneSetAABox(m_cPlaneSet, cAABB.vMin, cAABB.vMax)) { // Touch this node pSceneContext->TouchNode(*pSceneNode); // Emit signal SignalSceneNode(*this, *pSceneNode); if (m_nFlags & StopQuery) return false; // Stop the query right now // Continue recursive? if (m_nFlags & Recursive) { // Is this a container and is recursion allowed? if (pSceneNode->IsContainer() && !(pSceneNode->GetFlags() & SceneContainer::NoRecursion)) { // Backup current plane set const PlaneSet cPlaneSet = m_cPlaneSet; // Transform the plane set into container space m_cPlaneSet *= pSceneNode->GetTransform().GetInverseMatrix(); // Container recursion const bool bContinue = PerformQueryRec(static_cast<SceneContainer*>(pSceneNode)->GetHierarchyInstance()->GetRootNode()); // Restore plane set m_cPlaneSet = cPlaneSet; // Stop the query right now? if (!bContinue) return false; // Is this a cell-portal? } else if (pSceneNode->IsPortal() && pSceneNode->IsInstanceOf("PLScene::SNCellPortal") && !(pSceneNode->GetFlags() & SNCellPortal::NoPassThrough)) { // Get the target cell SNCellPortal &cCellPortal = static_cast<SNCellPortal&>(*pSceneNode); SceneContainer *pCell = reinterpret_cast<SceneContainer*>(cCellPortal.GetTargetCellInstance()); if (pCell && pCell != pSceneNode->GetContainer()) { // Backup current plane set const PlaneSet cPlaneSet = m_cPlaneSet; // Transform the plane set into container space m_cPlaneSet *= cCellPortal.GetWarpMatrix(); // Container recursion const bool bContinue = PerformQueryRec(pCell->GetHierarchyInstance()->GetRootNode()); // Restore plane set m_cPlaneSet = cPlaneSet; // Stop the query right now? if (!bContinue) return false; } } } } } // Next item, please pItem = pItem->GetNextItem(); } } // Check all sub-hierarchies for (uint32 i=0; i<cHierarchyNode.GetNumOfNodes(); i++) { if (!PerformQueryRec(*cHierarchyNode.GetNode(i))) return false; // Stop the query right now } // Done, continue the query return true; }