//-----------------------------------------------------------------------
	void EntityRenderer::_destroyAll(void)
	{
		if (!mParentTechnique)
			return;


		// Delete the visual data
		vector<EntityRendererVisualData*>::const_iterator it;
		vector<EntityRendererVisualData*>::const_iterator itEnd = mAllVisualData.end();
		for (it = mAllVisualData.begin(); it != itEnd; ++it)
		{
			PU_DELETE_T(*it, EntityRendererVisualData, MEMCATEGORY_SCENE_OBJECTS);
		}

		mAllVisualData.clear();
		mVisualData.clear();

		// V1.5: Destroy the created ChildSceneNodes (which leads to detaching the Entities)
		if (mParentTechnique->getParentSystem())
		{
			Ogre::SceneNode* parentNode = mParentTechnique->getParentSystem()->getParentSceneNode();
			if (parentNode)
			{
				String sceneNodeName;
				std::stringstream ss; 
				unsigned short numChilds = parentNode->numChildren();
				for (unsigned short i = 0; i < numChilds; ++i)
				{
					Ogre::Node* node = parentNode->getChild(i);
					if (node)
					{
						Ogre::String name = node->getName();
						if (name.find("ParticleUniverse") != Ogre::String::npos)
						{
							parentNode->removeAndDestroyChild(i);
						}
					}
				}
			}
		} // V1.5

		// Destroy the Entities. Do it like this, because it must be assured that the entity still exists
		// and has not already been destroyed.
		Ogre::SceneManager* sceneManager = mParentTechnique->getParentSystem()->getSceneManager();
		for (size_t i = 0; i < mQuota; i++)
		{
			if (sceneManager->hasEntity(mEntityName + StringConverter::toString(i)))
			{
				sceneManager->destroyEntity(mEntityName + StringConverter::toString(i));
			}
		}
		mEntities.clear();

		// Reset the visual data in the pool
		mParentTechnique->initVisualDataInPool();
	}
Beispiel #2
0
 void StereoManager::destroyDebugPlane(void)
 {
     if(debug_plane_)
     {
         Ogre::SceneNode *parent = static_cast<Ogre::SceneNode*>(debug_plane_node_->getParent());
         parent->removeAndDestroyChild("Stereo/DebugPlaneNode");
         debug_plane_node_ = NULL;
         sceneMngr_->destroyEntity("Stereo/DebugPlane");
         debug_plane_ = NULL;
         Ogre::MeshManager::getSingleton().remove("Stereo/Plane");
     }
 }
Beispiel #3
0
void StereoManager::destroyDebugPlane(void)
{
	if(mDebugPlane)
	{
		Ogre::SceneNode *parent = static_cast<Ogre::SceneNode*>(mDebugPlaneNode->getParent());
		parent->removeAndDestroyChild("Stereo/DebugPlaneNode");
		mDebugPlaneNode = NULL;
		mSceneMgr->destroyEntity("Stereo/DebugPlane");
		mDebugPlane = NULL;
		Ogre::MeshManager::getSingleton().remove("Stereo/Plane");
	}
}
Beispiel #4
0
void MapManager::RemoveObstacle(MapArea* area, Objects* input)
{
	char areaString[30];
	sprintf(areaString, "map_area_%d", area->getIndex());

	//get the area node from map node.
	Ogre::SceneNode* areaNode = (Ogre::SceneNode*)mMapNode->getChild(Ogre::String(areaString));

	char cubeString[30];
	sprintf(cubeString, "cube_%d", input->index);

	Ogre::SceneNode* objectNode = (Ogre::SceneNode*)areaNode->getChild(Ogre::String(cubeString));

	objectNode->detachAllObjects();

	mSceneMgr->destroyEntity(Ogre::String(cubeString));

	//remove the object node from areanode
	areaNode->removeAndDestroyChild(Ogre::String(cubeString));

	input->mLoaded = false;

	//we also need to remove rigid body
	
	std::vector<OgreBulletDynamics::RigidBody*>::iterator rigidBodyIterator;
	for(rigidBodyIterator = mRigidBodyList.begin(); rigidBodyIterator != mRigidBodyList.end(); rigidBodyIterator++)
	{
		//is this the rigid body for this cube?
		if((*rigidBodyIterator)->getName().compare("BoxRigid" + Ogre::StringConverter::toString(input->index)))
		{
			//yes!
			//get out of this loop
			break;
		}
	}

	//remove it from the physic manager
	PhysicManager::getSingletonPtr()->removeRigidBody((*rigidBodyIterator), BODIES_NONE);

	//remove from the list
	mRigidBodyList.erase(rigidBodyIterator);
	
	mNumEntitiesInstanced--;
}
	//-----------------------------------------------------------------------
	void SceneDecoratorExtern::_notifyStop (void)
	{
		if (mSubnode && mParentTechnique->getParentSystem())
		{
			Ogre::SceneNode* sceneNode = mParentTechnique->getParentSystem()->getParentSceneNode();
			Ogre::SceneNode::ChildNodeIterator it = sceneNode->getChildIterator();
			unsigned int i = 0;
			while (it.hasMoreElements()) 
			{ 
				Ogre::SceneNode* child = static_cast<Ogre::SceneNode*>(it.getNext());
				if (child == mSubnode)
				{
					mSubnode->detachAllObjects();
					sceneNode->removeAndDestroyChild(i);
					mSubnode = 0;
				}
				++i;
			}

			destroyEntity();
		}
	}
//-----------------------------------------------------------------------
Ogre::SceneNode* OrthoCameraGizmo::detachFromNode(void)
{
	Ogre::SceneNode* parent = 0;

	if (mOrthoCameraNodeBox)
	{
		parent = mOrthoCameraNodeBox->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeBox->getName());
		mOrthoCameraNodeBox = 0;
	}
	if (mOrthoCameraNodeX)
	{
		parent = mOrthoCameraNodeX->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeX->getName());
		mOrthoCameraNodeX = 0;
	}
	if (mOrthoCameraNodeMinX)
	{
		parent = mOrthoCameraNodeMinX->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeMinX->getName());
		mOrthoCameraNodeMinX = 0;
	}
	if (mOrthoCameraNodeY)
	{
		parent = mOrthoCameraNodeY->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeY->getName());
		mOrthoCameraNodeY = 0;
	}
	if (mOrthoCameraNodeZ)
	{
		parent = mOrthoCameraNodeZ->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeZ->getName());
		mOrthoCameraNodeZ = 0;
	}
	if (mOrthoCameraNodeMinZ)
	{
		parent = mOrthoCameraNodeMinZ->getParentSceneNode();
		parent->removeAndDestroyChild(mOrthoCameraNodeMinZ->getName());
		mOrthoCameraNodeMinZ = 0;
	}
	
	return parent;
}
Beispiel #7
0
//update that checks the loaded list for adding or removing objects inside
void MapManager::UpdateLoadedList(std::vector<MapArea*> *input)
{
	//run through our current list
	//see if there is anything in the list to be updated
	std::vector<MapArea*>::iterator loadedIterator;
	for(loadedIterator = input->begin(); loadedIterator != input->end(); loadedIterator++)
	{
		//No matter if the area is fully inside or not, let's check if the area is now outside of the HOLDRADIUS
		if(!IsAreaInsideLoadRadius((*loadedIterator)))
		{
			if(!IsAreaInsideHoldRadius((*loadedIterator)))
			{
				//now, time to remove the area node
				//std::cout << "REMOVING AREA NODE!\n";
				char areaString[30];
				sprintf(areaString, "map_area_%d", (*loadedIterator)->getIndex());

				//get the area node from map node.
				Ogre::SceneNode* areaNode = (Ogre::SceneNode*)mMapNode->getChild(Ogre::String(areaString));

				//delete ground node
				char groundString[30];
				sprintf(groundString, "map_area_ground_%d", (*loadedIterator)->getIndex());

				Ogre::SceneNode* groundNode = (Ogre::SceneNode*)areaNode->getChild(Ogre::String(groundString));

				groundNode->removeAndDestroyAllChildren();
				groundNode->detachAllObjects();

				areaNode->removeAndDestroyChild(groundString);

				areaNode->removeAndDestroyAllChildren();
				areaNode->detachAllObjects();
				
				mMapNode->removeAndDestroyChild(areaString);

				//set the map area to be unloaded
				(*loadedIterator)->setLoaded(false);

				//remove it from the list
				input->erase(loadedIterator);
				return;
			}
		}

		//since this area is not fully inside, lets check if this object is currently inside the scene
		std::vector<Objects*>::iterator obstacleIterator;
		for(obstacleIterator = (*loadedIterator)->_mObstacleList.begin(); obstacleIterator!=(*loadedIterator)->_mObstacleList.end(); obstacleIterator++)
		{
			//is this object in the load radius?
			if(IsObjectInsideRadius((*obstacleIterator), LOADRADIUS))
			{
				//yes
				//is this object already loaded in the game?
				if((*obstacleIterator)->mLoaded)
				{
					//yes
					//skip
					continue;
				}
				else
				{
					//no
					//add it into the game
					AddObstacle((*loadedIterator), (*obstacleIterator));
				}
			}
			//is this object out of hold radius?
			else if(!IsObjectInsideRadius((*obstacleIterator), HOLDRADIUS))
			{
				//no
				//is this object already loaded in the game?
				if((*obstacleIterator)->mLoaded)
				{
					//yes
					//remove it
					RemoveObstacle((*loadedIterator),(*obstacleIterator));
				}
				else
				{
					//no
					//skip
					continue;
				}
			}
		}

		std::vector<Objects*>::iterator enemyIterator;
		for(enemyIterator = (*loadedIterator)->_mEnemySpawnPointList.begin(); enemyIterator!=(*loadedIterator)->_mEnemySpawnPointList.end(); enemyIterator++)
		{
			//is this object inside the load radius?
			if(IsObjectInsideRadius((*enemyIterator), ENEMY_LOADRADIUS))
			{
				//yes
				//is this enemy spawn point already loaded?
				if(!(*enemyIterator)->mLoaded)
				{
					//no
					//add enemy
					AddEnemy((*enemyIterator));
				}
			}
		}

		std::vector<Objects*>::iterator flamethrowerIterator;
		for(flamethrowerIterator = (*loadedIterator)->_mFlameThrowerList.begin(); flamethrowerIterator!=(*loadedIterator)->_mFlameThrowerList.end(); flamethrowerIterator++)
		{
			//no
			//is this object inside the load radius?
			if(!IsObjectInsideRadius((*flamethrowerIterator), ENEMY_LOADRADIUS))
			{
				//no
				//skip this object
				continue;
			}
			//yes continue whatever we need to do

			if(!(*flamethrowerIterator)->mLoaded)
				AddFlameThrower((*flamethrowerIterator));
		}
	}
}