Ejemplo n.º 1
0
MapCameraLightningInstance::MapCameraLightningInstance(MapCameraLightning& lightning)
: mLightning(lightning)
{

	Ogre::SceneManager::MovableObjectIterator iterator = lightning.getSceneManager().getMovableObjectIterator(Ogre::LightFactory::FACTORY_TYPE_NAME);

	while (iterator.hasMoreElements()) {
		Ogre::MovableObject* light = iterator.getNext();
		if (light && light != mLightning.getLight()) {
			if (light->getVisible()) {
				mVisibleLights.push_back(light);
				light->setVisible(false);
			}
		}
	}
	mLightning.getLight()->setVisible(true);
	mAmbientColour = mLightning.getSceneManager().getAmbientLight();
	mLightning.getSceneManager().setAmbientLight(mLightning.getLight()->getDiffuseColour());
}
Ejemplo n.º 2
0
bool gkPhysicsController::_markDbvt(bool v)
{
	if (m_suspend)
		return false;

	bool result = false;
	if (m_dbvtMark != v)
	{
		m_dbvtMark = v;
		if ( m_object->getType() == GK_ENTITY &&  !m_object->getProperties().isInvisible())
		{
			Ogre::MovableObject* mov = m_object->getMovable();

			if (mov)
			{
				result = mov->isVisible() != m_dbvtMark;
				mov->setVisible(m_dbvtMark);
			}
		}
	}
	return result;
}
Ejemplo n.º 3
0
void ReflectionTextureListener::preRenderTargetUpdate(const RenderTargetEvent& evt)
{
    // Hide plane and objects below the water
    mWater->setVisible(false);


	/*list<Ogre::Entity*> entList = Level::getSingleton()->getEntityList();
	list<Ogre::Entity*>::iterator it;
	for (it = entList.begin();it != entList.end();it++){
		if ((*it)->isVisible()){
			Ogre::AxisAlignedBox box = (*it)->getWorldBoundingBox();
			if (box.getMinimum().y < mWater->getSceneNode()->_getDerivedPosition().y){
				(*it)->setVisible(false);
				belowWaterEnts.push_back((*it));
			}
		}
	}*/

    /*std::vector<Entity*>::iterator i, iend;
    iend = belowWaterEnts.end();
    for (i = belowWaterEnts.begin(); i != iend; ++i)
    {
        (*i)->setVisible(false);
    }*/

	Ogre::SceneManager::MovableObjectIterator it = Level::getSingleton()->getSceneManager()->getMovableObjectIterator("Entity");
	while(it.hasMoreElements()){
		Ogre::MovableObject *m = it.getNext();	
		if (m->isVisible() && m->getParentSceneNode()->_getDerivedPosition().y < mWater->getSceneNode()->_getDerivedPosition().y){
			m->setVisible(false);
			belowWaterEnts.push_back(m);
		}
	}


	Ogre::Camera* cam = Level::getSingleton()->getCurrentSegment()->getActiveCamera()->getCamera();
	cam->enableReflection(mWater->getReflectionPlane());

}
Ejemplo n.º 4
0
void ImpostorTexture::renderTextures(bool force)
{
#ifdef IMPOSTOR_FILE_SAVE
	TexturePtr renderTexture;
#else
	TexturePtr renderTexture(texture);
	//if we're not using a file image we need to set up a resource loader, so that the texture is regenerated if it's ever unloaded (such as switching between fullscreen and the desktop in win32)
	loader = std::auto_ptr<ImpostorTextureResourceLoader>(new ImpostorTextureResourceLoader(*this));
#endif
	RenderTexture *renderTarget;
	Camera *renderCamera;
	Viewport *renderViewport;
	SceneNode *camNode;

	//Set up RTT texture
	uint32 textureSize = ImpostorPage::impostorResolution;
	if (renderTexture.isNull()) {
	renderTexture = TextureManager::getSingleton().createManual(getUniqueID("ImpostorTexture"), "Impostors",
				TEX_TYPE_2D, textureSize * IMPOSTOR_YAW_ANGLES, textureSize * IMPOSTOR_PITCH_ANGLES, 0, PF_A8R8G8B8, TU_RENDERTARGET, loader.get());
	}
	renderTexture->setNumMipmaps(MIP_UNLIMITED);
	
	//Set up render target
	renderTarget = renderTexture->getBuffer()->getRenderTarget(); 
	renderTarget->setAutoUpdated(false);
	
	//Set up camera
	camNode = sceneMgr->getSceneNode("ImpostorPage::cameraNode");
	renderCamera = sceneMgr->createCamera(getUniqueID("ImpostorCam"));
	camNode->attachObject(renderCamera);
	renderCamera->setLodBias(1000.0f);
	renderViewport = renderTarget->addViewport(renderCamera);
	renderViewport->setOverlaysEnabled(false);
	renderViewport->setClearEveryFrame(true);
	renderViewport->setShadowsEnabled(false);
	renderViewport->setBackgroundColour(ImpostorPage::impostorBackgroundColor);
	
	//Set up scene node
	SceneNode* node = sceneMgr->getSceneNode("ImpostorPage::renderNode");
	
	Ogre::SceneNode* oldSceneNode = entity->getParentSceneNode();
	if (oldSceneNode) {
		oldSceneNode->detachObject(entity);
	}
	node->attachObject(entity);
	node->setPosition(-entityCenter);
	
	//Set up camera FOV
	const Real objDist = entityRadius * 100;
	const Real nearDist = objDist - (entityRadius + 1); 
	const Real farDist = objDist + (entityRadius + 1);
	
	renderCamera->setAspectRatio(1.0f);
	renderCamera->setFOVy(Math::ATan(entityDiameter / objDist));
	renderCamera->setNearClipDistance(nearDist);
	renderCamera->setFarClipDistance(farDist);
	
	//Disable mipmapping (without this, masked textures look bad)
	MaterialManager *mm = MaterialManager::getSingletonPtr();
	FilterOptions oldMinFilter = mm->getDefaultTextureFiltering(FT_MIN);
	FilterOptions oldMagFilter = mm->getDefaultTextureFiltering(FT_MAG);
	FilterOptions oldMipFilter = mm->getDefaultTextureFiltering(FT_MIP);
	mm->setDefaultTextureFiltering(FO_POINT, FO_LINEAR, FO_NONE);

	//Disable fog
	FogMode oldFogMode = sceneMgr->getFogMode();
	ColourValue oldFogColor = sceneMgr->getFogColour();
	Real oldFogDensity = sceneMgr->getFogDensity();
	Real oldFogStart = sceneMgr->getFogStart();
	Real oldFogEnd = sceneMgr->getFogEnd();
	sceneMgr->setFog(Ogre::FOG_EXP2, Ogre::ColourValue(0,0,0,0), 0.0f, 0.0f, 0.0f); //Ember change
	
	//We need to disable all lightning and render it full bright
	Ogre::ColourValue oldAmbientColour = sceneMgr->getAmbientLight();
	sceneMgr->setAmbientLight(ColourValue::White);

	std::vector<Ogre::MovableObject*> lightStore;
	Ogre::SceneManager::MovableObjectIterator lightIterator = sceneMgr->getMovableObjectIterator(Ogre::LightFactory::FACTORY_TYPE_NAME);
	while (lightIterator.hasMoreElements()) {
		Ogre::MovableObject* light = lightIterator.getNext();
		if (light) {
			if (light->getVisible()) {
				lightStore.push_back(light);
				light->setVisible(false);
			}
		}
	}

	// Get current status of the queue mode
	Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode = sceneMgr->getSpecialCaseRenderQueueMode();
	//Only render the entity
	sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE); 
	sceneMgr->addSpecialCaseRenderQueue(group->geom->getRenderQueue() + 1);

	uint8 oldRenderQueueGroup = entity->getRenderQueueGroup();
	entity->setRenderQueueGroup(group->geom->getRenderQueue() + 1);
	bool oldVisible = entity->getVisible();
	entity->setVisible(true);
	float oldMaxDistance = entity->getRenderingDistance();
	entity->setRenderingDistance(0);

	bool needsRegen = true;
#ifdef IMPOSTOR_FILE_SAVE
	//Calculate the filename hash used to uniquely identity this render
	String strKey = entityKey;
	char key[32] = {0};
	uint32 i = 0;
	for (String::const_iterator it = entityKey.begin(); it != entityKey.end(); ++it)
	{
		key[i] ^= *it;
		i = (i+1) % sizeof(key);
	}
	for (i = 0; i < sizeof(key); ++i)
		key[i] = (key[i] % 26) + 'A';

	String tempdir = this->group->geom->getTempdir();
	ResourceGroupManager::getSingleton().addResourceLocation(tempdir, "FileSystem", "BinFolder");

	String fileNamePNG = "Impostor." + String(key, sizeof(key)) + '.' + StringConverter::toString(textureSize) + ".png";
	String fileNameDDS = "Impostor." + String(key, sizeof(key)) + '.' + StringConverter::toString(textureSize) + ".dds";

	//Attempt to load the pre-render file if allowed
	needsRegen = force;
	if (!needsRegen){
		try{
			texture = TextureManager::getSingleton().load(fileNameDDS, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
		}
		catch (...){
			try{
				texture = TextureManager::getSingleton().load(fileNamePNG, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
			}
			catch (...){
				needsRegen = true;
			}
		}
	}
#endif

	if (needsRegen){
		//If this has not been pre-rendered, do so now
		const float xDivFactor = 1.0f / IMPOSTOR_YAW_ANGLES;
		const float yDivFactor = 1.0f / IMPOSTOR_PITCH_ANGLES;
		for (int o = 0; o < IMPOSTOR_PITCH_ANGLES; ++o){ //4 pitch angle renders
#ifdef IMPOSTOR_RENDER_ABOVE_ONLY
			Radian pitch = Degree((90.0f * o) * yDivFactor); //0, 22.5, 45, 67.5
#else
			Radian pitch = Degree((180.0f * o) * yDivFactor - 90.0f);
#endif

			for (int i = 0; i < IMPOSTOR_YAW_ANGLES; ++i){ //8 yaw angle renders
				Radian yaw = Degree((360.0f * i) * xDivFactor); //0, 45, 90, 135, 180, 225, 270, 315
					
				//Position camera
				camNode->setPosition(0, 0, 0);
                camNode->setOrientation(Quaternion(yaw, Vector3::UNIT_Y) * Quaternion(-pitch, Vector3::UNIT_X));
                camNode->translate(Vector3(0, 0, objDist), Node::TS_LOCAL);
						
				//Render the impostor
				renderViewport->setDimensions((float)(i) * xDivFactor, (float)(o) * yDivFactor, xDivFactor, yDivFactor);
				renderTarget->update();
			}
		}
	
#ifdef IMPOSTOR_FILE_SAVE
		//Save RTT to file with respecting the temp dir
		renderTarget->writeContentsToFile(tempdir + fileNamePNG);

		//Load the render into the appropriate texture view
		texture = TextureManager::getSingleton().load(fileNamePNG, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
#else
		texture = renderTexture;
#endif
	}
	

	entity->setVisible(oldVisible);
	entity->setRenderQueueGroup(oldRenderQueueGroup);
	entity->setRenderingDistance(oldMaxDistance);
	sceneMgr->removeSpecialCaseRenderQueue(group->geom->getRenderQueue() + 1);
	// Restore original state
	sceneMgr->setSpecialCaseRenderQueueMode(OldSpecialCaseRenderQueueMode); 

	//Re-enable mipmapping
	mm->setDefaultTextureFiltering(oldMinFilter, oldMagFilter, oldMipFilter);

	//Re-enable fog
	sceneMgr->setFog(oldFogMode, oldFogColor, oldFogDensity, oldFogStart, oldFogEnd);

	//Re-enable both scene lightning and disabled individual lights
	sceneMgr->setAmbientLight(oldAmbientColour);
	for (std::vector<Ogre::MovableObject*>::const_iterator I = lightStore.begin(); I != lightStore.end(); ++I) {
		(*I)->setVisible(true);
	}

	//Delete camera
	renderTarget->removeViewport(0);
	renderCamera->getSceneManager()->destroyCamera(renderCamera);
	
	//Delete scene node
	node->detachAllObjects();
	if (oldSceneNode) {
		oldSceneNode->attachObject(entity);
	}
#ifdef IMPOSTOR_FILE_SAVE
	//Delete RTT texture
	assert(!renderTexture.isNull());
	String texName2(renderTexture->getName());

	renderTexture.setNull();
	if (TextureManager::getSingletonPtr())
		TextureManager::getSingleton().remove(texName2);
#endif
}
Ejemplo n.º 5
0
///void _updateRenderQueue(RenderQueue* queue) = 0;
//TODO:DLL void movableobject__update_render_queue(MovableObjectHandle handle, RenderQueueHandle queue);
///void setVisible(bool visible);
void movableobject_set_visible(MovableObjectHandle handle, int visible)
{
    Ogre::MovableObject* obj = static_cast<Ogre::MovableObject*>(handle);
    obj->setVisible(visible);
}
Ejemplo n.º 6
0
 void setVisible(bool visible)   { if (mOgreObject) mOgreObject->setVisible(visible); }
Ejemplo n.º 7
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;
}