Exemplo n.º 1
0
///void setQueryFlags(uint32 flags);
void movableobject_set_query_flags(MovableObjectHandle handle, unsigned int flags)
{
    Ogre::MovableObject* obj = static_cast<Ogre::MovableObject*>(handle);
    obj->setQueryFlags(flags);
}
Exemplo n.º 2
0
void Map::Load(std::string sceneFile)
{
	this->mLoader = new Utilities::DotSceneLoader();
	this->mLoader->parseDotScene(sceneFile, "General", GameFramework::getSingletonPtr()->sceneManager);

	std::vector<Ogre::Entity*> mNavmeshEnts;
			/*Ogre::Entity* mapE = GameFramework::getSingletonPtr()->sceneManager->createEntity("Map", "dungeon.mesh");
			Ogre::SceneNode* mapNode = GameFramework::getSingletonPtr()->sceneManager->getRootSceneNode()->createChildSceneNode("MapNode");
			mapNode->scale(Vector3(2,2,2));
			mapNode->attachObject(mapE);
			mNavmeshEnts.push_back(mapE);*/

			mRecast = new OgreRecast(GameFramework::getSingletonPtr()->sceneManager); 
			mDetourTileCache = new OgreDetourTileCache(mRecast);

			if (this->mLoader != 0)
			{
				if (this->mLoader->entityList->size() > 0)
				{
					ConfigFile cf;
					std::vector<Ogre::Entity*> srcMeshes;// =  std::vector<Ogre::Entity*>(this->mLoader->entityList->begin(), this->mLoader->entityList->end());
					bool could_find_plane = false;
					for (int i = 0; i < this->mLoader->entityList->size(); i++	)
					{
						Ogre::Entity* ent = this->mLoader->entityList->at(i);
						if (ent->getName() == "Plane#0")
						{
							//ent->setMaterialName("MyMaterial");
							ent->setMaterialName("PlaneMaterial");
							ent->setCastShadows(false);
							//ent->setVisible(false);
							//ent->getParentSceneNode()->setPosition(Vector3(0,0,0));
							srcMeshes.clear();
							srcMeshes.push_back(ent);
							could_find_plane = true;
						}
					}

					if (could_find_plane)
					{
						inputGeom = new InputGeom(srcMeshes);
					}
					else
					{
						//srcMeshes =  std::vector<Ogre::Entity*>(this->mLoader->entityList->begin(), this->mLoader->entityList->end());
						if (this->mLoader->getTerrainGroup() != 0)
						{
							inputGeom = new InputGeom(this->mLoader->getTerrainGroup(), srcMeshes);
						}
						else
						{
							inputGeom = new InputGeom(srcMeshes);
						}
					}
					

					

					if(mDetourTileCache->TileCacheBuild(inputGeom)) 
					{
						mDetourTileCache->drawNavMesh();
					} 
					else 
					{
						Ogre::LogManager::getSingletonPtr()->logMessage("ERROR: could not generate useable navmesh from mesh using detourTileCache.");
						return;
					}
				}
			}

			Ogre::SceneNode* mNavMeshNode = (Ogre::SceneNode*)GameFramework::getSingletonPtr()->sceneManager->getRootSceneNode()->getChild("RecastSN");
			int ttt = mNavMeshNode->numAttachedObjects();
			//mNavMeshNode->setVisible(true);
			for (int i = 0; i < mNavMeshNode->numAttachedObjects(); i++) 
			{
				Ogre::MovableObject *obj = mNavMeshNode->getAttachedObject(i);
				obj->setVisible(false);
				obj->setQueryFlags(QueryFlags::NAVMESH_MASK);
			}

			

	this->isLoaded = true;
}