Ejemplo n.º 1
0
void TerrainManager::initHDR()
{
	Viewport *vp = gEnv->mainCamera->getViewport();
	CompositorInstance *instance = CompositorManager::getSingleton().addCompositor(vp, "HDR", 0);
	CompositorManager::getSingleton().setCompositorEnabled(vp, "HDR", true);

	// HDR needs a special listener
	hdr_listener = new HDRListener();
	instance->addListener(hdr_listener);
	hdr_listener->notifyViewportSize(vp->getActualWidth(), vp->getActualHeight());
	hdr_listener->notifyCompositor(instance);
}
Ejemplo n.º 2
0
	void BaseGame::Initialize()
	{
		ResourceGroupManager::getSingleton().addResourceLocation(Directories::GetContentDirectory() + "/Fonts", "FileSystem", "Essential");
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Essential");

		// Create scene manager
		m_sceneMgr = m_root->createSceneManager(ST_GENERIC, "SceneManager");
		m_sceneMgr->setAmbientLight(ColourValue::Black);

		// Light
		m_light = m_sceneMgr->createLight();
		m_light->setType(Light::LT_DIRECTIONAL);
		m_light->setDirection(1.0f, 0.0f, 0.0f);

		// Space camera
		m_camera = new SpaceCamera(*this, Vector3(0, 0, -5));
		assert(m_camera);
		GetCamera().setFOVy(FieldOfView);
		GetCamera().setNearClipDistance(NearPlane);
		GetCamera().setFarClipDistance(FarPlane);

		m_viewport = m_renderWnd->addViewport(&GetCamera());
		m_viewport->setBackgroundColour(m_backgroundColour);

		GetCamera().setAspectRatio(Real(m_viewport->getActualWidth()) / Real(m_viewport->getActualHeight()));	
		m_viewport->setCamera(&GetCamera());

		// Ogre overlay
		m_textRenderer = new TextRenderer();

		Game::Initialize();

		// Player
		m_player = new Player(*this);

		// Sprite
		m_sceneMgr->getRenderQueue()->getQueueGroup(RENDER_QUEUE_MAIN + 1)->setShadowsEnabled(false);
		m_sprite = new Sprite();
		m_sprite->Init(m_sceneMgr, m_viewport, RENDER_QUEUE_MAIN + 1, true);
		m_sprite->SetSpriteLocation(Directories::GetContentDirectory() + "/Sprites");

		// Lens flare
		m_lensFlare = new LensFlare(*this, LensFlare::DefaultSunPos);

		//
		// Compositors
		//
		CompositorManager &compMgr = CompositorManager::getSingleton();

		// Bloom (crash on d3d if device lost occur)
		compMgr.addCompositor(m_viewport, "Bloom");
		if (m_root->getRenderSystem()->getName().find("Direct3D") == std::string::npos)
		{
			compMgr.setCompositorEnabled(m_viewport, "Bloom", true);
		}

		// Radial blur
		CompositorInstance *radialBlur = compMgr.addCompositor(m_viewport, "Radial Blur");
		radialBlur->addListener(new RadialBlurListener(*m_player));
		compMgr.setCompositorEnabled(m_viewport, "Radial Blur", true);

		//
		// CEGUI
		//
		m_ceguiLogger = new CEGUI::DefaultLogger();
		assert(m_ceguiLogger);
		CEGUI::Logger::getSingleton().setLogFilename(Directories::GetWritablePath("cegui.log"));

		m_renderer = &CEGUI::OgreRenderer::bootstrapSystem(*m_renderWnd);

		// Disable calls to beginFrame and endFrame, which also disables
		// default rendering: we will use a custom rendering method.
		m_renderer->setFrameControlExecutionEnabled(true);
		
		// Hook back into the rendering process
		//m_sceneMgr->addRenderQueueListener(new CEGUIRQListener(m_renderer, RENDER_QUEUE_OVERLAY, false));

		CEGUI::Imageset::setDefaultResourceGroup("GUI");
		CEGUI::Font::setDefaultResourceGroup("GUI");
		CEGUI::Scheme::setDefaultResourceGroup("GUI");
		CEGUI::WidgetLookManager::setDefaultResourceGroup("GUI");
		CEGUI::WindowManager::setDefaultResourceGroup("GUI");
		CEGUI::ScriptModule::setDefaultResourceGroup("GUI");

		CEGUI::SchemeManager::getSingleton().create("VanillaSkin.scheme");
		CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
		CEGUI::SchemeManager::getSingleton().create("InGame.scheme");

		// Set default font
		CEGUI::Font &font = CEGUI::FontManager::getSingleton().create("GameFont.font", "GUI");
		CEGUI::System::getSingleton().setDefaultFont(&font);

		// Set mouse cursor
		CEGUI::System::getSingleton().setDefaultMouseCursor("Vanilla-Images", "MouseArrow");
		CEGUI::MouseCursor::getSingleton().setImage(CEGUI::System::getSingleton().getDefaultMouseCursor());

		// Set initial cursor position		
		CEGUI::System::getSingleton().injectMousePosition((float)m_renderWnd->getWidth() / 2.0f + 1, (float)m_renderWnd->getHeight() / 2.0f);

		//
		// Sound
		//
		m_sound = new Sound();

		// FPS
		m_textRenderer->AddTextBox("txtFps", "Fps: ", 
			(Real)m_viewport->getActualLeft(), (Real)m_viewport->getActualTop(), 
			(Real)m_viewport->getActualWidth(), (Real)m_viewport->getActualHeight() + m_fpsOverlayHeight);

	}