Esempio n. 1
0
/**
*  @brief
*    Sets the scene container
*/
bool SPScene::SetSceneContainer(SceneContainer *pContainer)
{
	// Anything to do in here?
	if (pContainer == GetSceneContainer())
		return true; // Done

	// Destroy the old cull query
	if (m_pCullQuery->GetElement()) {
		SceneQuery *pSceneQuery = m_pCullQuery->GetElement();
		if (pSceneQuery)
			pSceneQuery->GetSceneContainer().DestroyQuery(*pSceneQuery);
	}

	// Create cull query
	SQCull *pCullQuery = static_cast<SQCull*>(m_pCullQuery->GetElement());
	if (!pCullQuery && pContainer) {
		pCullQuery = static_cast<SQCull*>(pContainer->CreateQuery("PLScene::SQCull"));
		if (pCullQuery) {
			m_pCullQuery->SetElement(pCullQuery);

			// Set the cull mode
			pCullQuery->SetMode(SQCull::Frustum);

			// We do not need to inform any scene query listeners
			pCullQuery->SetFlags(0);
		}
	}

	// Set container
	return m_pSceneContainerHandler->SetElement(pContainer);
}
Esempio n. 2
0
/**
*  @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();
		}
	}
}
Esempio n. 3
0
/**
*  @brief
*    Destructor
*/
SPScene::~SPScene()
{
	// Destroy scene root container handler
	delete m_pRootContainerHandler;

	// Destroy scene container handler
	delete m_pSceneContainerHandler;

	// Destroy the cull query
	if (m_pCullQuery) {
		SceneQuery *pSceneQuery = m_pCullQuery->GetElement();
		if (pSceneQuery)
			pSceneQuery->GetSceneContainer().DestroyQuery(*pSceneQuery);
		delete m_pCullQuery;
	}

	// Destroy camera scene node handler
	delete m_pCameraNodeHandler;

	// Destroy the default scene renderer handler
	delete m_pDefaultSceneRendererHandler;
}
Esempio n. 4
0
/**
*  @brief
*    Destructor
*/
VisContainer::~VisContainer()
{
	// Free all nodes
	FreeNodes();

	// Destroy the query
	SceneQuery *pSceneQuery = m_pQueryHandler->GetElement();
	if (pSceneQuery)
		pSceneQuery->GetSceneContainer().DestroyQuery(*pSceneQuery);
	delete m_pQueryHandler;

	{ // Destroy all containers
		Iterator<VisContainer*> cIterator = m_mapContainers.GetIterator();
		while (cIterator.HasNext())
			delete cIterator.Next();
	}

	{ // Destroy all portals
		Iterator<VisPortal*> cIterator = m_mapPortals.GetIterator();
		while (cIterator.HasNext())
			delete cIterator.Next();
	}
}
Esempio n. 5
0
/**
*  @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();
			}
		}
	}
}
Esempio n. 6
0
bool EngineApplication::LoadScene(const String &sFilename)
{
	// Get the scene container holding our scene
	SceneContainer *pContainer = GetScene();
	if (!pContainer)
		return false; // Error! (should NEVER happen...)

	// Disable the ingame GUI
	SceneNode *pGui = pContainer->GetContainer()->GetByName("GUI");
	if (pGui)
		pGui->SetActive(false);

	// Clear the scene, after calling this method the scene is empty
	ClearScene();

	// Load the scene
	bool bResult = pContainer->LoadByFilename(sFilename);
	if (bResult) {
		// Set a null pointer camera and default scene renderer
		m_sDefaultSceneRenderer		= "";
		m_sSceneRendererVariables	= "";
		m_sClearColor				= "";
		m_sStartCamera				= "";
		m_pFirstFoundCamera			= nullptr;
		m_bHasLoadScreen			= false;

		// Get scene surface painter
		SurfacePainter *pPainter = GetPainter();
		if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
			// Assign the first found camera scene node to your surface listener and look for
			// known key/value data scene nodes
			SceneQuery *pSceneQuery = pContainer->CreateQuery("PLScene::SQEnumerate");
			if (pSceneQuery) {
				// Connect event handler
				pSceneQuery->SignalSceneNode.Connect(EventHandlerSceneNode);

				// Perform the query
				pSceneQuery->PerformQuery();

				// Destroy the query
				pContainer->DestroyQuery(*pSceneQuery);
			}

			// Set to default scene renderer?
			if (!m_sDefaultSceneRenderer.GetLength())
				m_sDefaultSceneRenderer = DefaultSceneRenderer;

			// Sets all scene renderer pass attribute values to their default value
			GetSceneRendererTool().SetDefaultValues();

			// Set the used scene renderer
			GetSceneRendererTool().SetSceneRenderer(pContainer, m_sDefaultSceneRenderer, DefaultSceneRenderer);

			// Set clear color
			GetSceneRendererTool().SetPassAttribute("Begin", "ColorClear", m_sClearColor);

			// Set scene renderer variables
			if (m_sSceneRendererVariables.GetLength())
				GetSceneRendererTool().SetValues(m_sSceneRendererVariables);

			// Is there a given start camera?
			SceneNode *pCamera = nullptr;
			if (m_sStartCamera.GetLength()) {
				SceneNode *pStartCamera = pContainer->GetByName(m_sStartCamera);
				if (pStartCamera && pStartCamera->IsCamera())
					pCamera = pStartCamera;
			}

			// Use the first found camera?
			if (!pCamera)
				pCamera = m_pFirstFoundCamera;

			// Activate the current used camera by default
			if (pCamera)
				pCamera->SetActive(true);

			// Assign this camera to the scene renderer and to the application
			SetCamera(reinterpret_cast<SNCamera*>(pCamera));
		}

		// Emit the scene loading has been finished successfully event
		SignalSceneLoadingFinished();
	}

	// Enable the ingame GUI
	if (pGui)
		pGui->SetActive(true);

	// Done
	return bResult;
}