Esempio n. 1
0
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle,  std::string sceneNodeName[], int elements)
{
    assert(mInsert);
    Ogre::SceneNode *parent = mInsert;
     //std::cout << "ELEMENTS:" << elements;
    for (int i = 0; i < elements; i++){
       if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
           parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
    }
       parent->rotate(axis, angle);
}
Esempio n. 2
0
void InteriorCellRender::scaleMesh(Ogre::Vector3 axis,  std::string sceneNodeName[], int elements)
{
    assert(insert);
    Ogre::SceneNode *parent = insert;
    //std::cout << "ELEMENTS:" << elements;
    for (int i = 0; i < elements; i++) {
        if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
            parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
    }
    parent->scale(axis);
}
Esempio n. 3
0
void Objects::removeCell(MWWorld::Ptr::CellStore* store)
{
    if(mCellSceneNodes.find(store) != mCellSceneNodes.end())
    {
        Ogre::SceneNode* base = mCellSceneNodes[store];

        for (int i=0; i<base->numChildren(); ++i)
            clearSceneNode (static_cast<Ogre::SceneNode *> (base->getChild (i)));

        base->removeAndDestroyAllChildren();
        mCellSceneNodes.erase(store);
        mRenderer.getScene()->destroySceneNode(base);
        base = 0;
    }

    if(mStaticGeometry.find(store) != mStaticGeometry.end())
    {
        Ogre::StaticGeometry* sg = mStaticGeometry[store];
        mStaticGeometry.erase(store);
        mRenderer.getScene()->destroyStaticGeometry (sg);
        sg = 0;
    }
    if(mStaticGeometrySmall.find(store) != mStaticGeometrySmall.end())
    {
        Ogre::StaticGeometry* sg = mStaticGeometrySmall[store];
        mStaticGeometrySmall.erase(store);
        mRenderer.getScene()->destroyStaticGeometry (sg);
        sg = 0;
    }

    if(mBounds.find(store) != mBounds.end())
        mBounds.erase(store);
}
	//-----------------------------------------------------------------------
	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();
	}
Esempio n. 5
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--;
}
Esempio n. 6
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));
		}
	}
}
Esempio n. 7
0
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle,  std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){

       assert (mInsert);
     //mInsert->
       Ogre::SceneNode *parent = mInsert;
       for (int i = 0; i < elements; i++){
       if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
           parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
        }

     mNpcPart = parent->createChildSceneNode(sceneNodeName);
   MeshPtr good2 = NifOgre::NIFLoader::load(mesh);

  MovableObject *ent = mScene.getMgr()->createEntity(mesh);


  if(translateFirst){
  mNpcPart->translate(vec);
  mNpcPart->rotate(axis, angle);
  }
  else{

  mNpcPart->rotate(axis, angle);
  mNpcPart->translate(vec);
  }
  mNpcPart->attachObject(ent);

   Ogre::MeshManager *m = MeshManager::getSingletonPtr();
  const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
    const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
    const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
    const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif";

    const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif";
    const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif";
    const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif";
    const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif";

    const std::string beastfoot1 ="foot\\b\\B_N_Khajiit_F_Skins.nif";
    const std::string beastfoot2 ="foot\\b\\B_N_Khajiit_M_Skins.nif";
    const std::string beastfoot3 ="foot\\b\\B_N_Argonian_F_Skins.nif";
    const std::string beastfoot4 ="foot\\b\\B_N_Argonian_M_Skins.nif";
    if(mesh.compare(beast1) == 0 && m->getByName(beasttail1).isNull())
        {
            //std::cout << "CLONINGKHAJIITF\n";
            good2->reload();
            MeshPtr tail = good2->clone(beasttail1);
            good2->reload();
            MeshPtr foot = good2->clone(beastfoot1);
            good2->reload();
        }
        else if(mesh.compare(beast2) == 0 && m->getByName(beasttail2).isNull())
        {
            //std::cout << "CLONINGKHAJIITM\n";
            good2->reload();
            MeshPtr tail = good2->clone(beasttail2);
            good2->reload();
            MeshPtr foot = good2->clone(beastfoot2);
            good2->reload();
        }
        else if(mesh.compare(beast3) == 0 && m->getByName(beasttail3).isNull())
        {
            //std::cout << "CLONINGARGONIANF\n";
            good2->reload();
            MeshPtr tail = good2->clone(beasttail3);
            good2->reload();
            MeshPtr foot = good2->clone(beastfoot3);
            good2->reload();
        }
        else if(mesh.compare(beast4) == 0 && m->getByName(beasttail4).isNull())
        {
            //std::cout << "CLONINGARGONIANM\n";
            good2->reload();
            MeshPtr tail = good2->clone(beasttail4);
            good2->reload();
            MeshPtr foot = good2->clone(beastfoot4);
            good2->reload();
        }
}