コード例 #1
0
void SponsorsState::enter(const MainMachineInfo &info)
{
	// load the fader state
	ASSERT(!mFader);
	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();
	mFader = om.getByName("FaderOverlay");
	ASSERT(mFader);
	Ogre::PanelOverlayElement *panel = static_cast<Ogre::PanelOverlayElement *>(
					mFader->getChild("FaderOverlay/Background"));
	ASSERT(panel);
	Ogre::MaterialPtr mat = panel->getMaterial();
	ASSERT(!mat.isNull());
	mTexture = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
	mTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL,
						Ogre::LBS_TEXTURE, 0);
	ASSERT(mTexture);

	// load the  sponsors Overlay
	ASSERT(!mOverlay);
	mOverlay = om.getByName("SponsorsOverlay");
	ASSERT(mOverlay);
	mOverlay->setZOrder(mFader->getZOrder() - 1);	// put behind it

	mState = STATE_FADE_IN;
}
コード例 #2
0
ファイル: gkHUDElement.cpp プロジェクト: Ali-il/gamekit
void gkHUDElement::setPosition(float x,float y)
{
	if (m_element)
	{
		Ogre::PanelOverlayElement* panel = dynamic_cast<Ogre::PanelOverlayElement*>(m_element);
		if (panel) panel->setPosition(x,y);
	}
}
コード例 #3
0
ファイル: gkHUDElement.cpp プロジェクト: Ali-il/gamekit
void gkHUDElement::setUvCoords(float u1, float v1, float u2, float v2)
{
	if (m_element)
	{
		Ogre::PanelOverlayElement* panel = dynamic_cast<Ogre::PanelOverlayElement*>(m_element);
		if (panel) panel->setUV(u1, v1, u2, v2);
	}
}
コード例 #4
0
void BasisManager::createInput() // создаем систему ввода
{
	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
	OIS::ParamList pl;
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;

	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

	mInputManager = OIS::InputManager::createInputSystem( pl );

	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
	mKeyboard->setEventCallback(this);


	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
	mMouse->setEventCallback(this);

	mRoot->addFrameListener(this);

	windowResized(mWindow); // инициализация

	Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("wallpaper");
	if (false == material.isNull()) {
		Ogre::OverlayManager & manager = Ogre::OverlayManager::getSingleton();
		Ogre::Overlay * overlay = manager.create("wallpaper");
		overlay->setZOrder(0);
		overlay->show();
		Ogre::PanelOverlayElement * panel = static_cast<Ogre::PanelOverlayElement*>(manager.createOverlayElement("Panel", "wallpaper"));
		panel->setDimensions(1, 1);
		/*Ogre::FontPtr mpFont = Ogre::FontManager::getSingleton().getByName("MyGUI_font");
		mpFont->load();
		if (!mpFont.isNull()) {
			const Ogre::MaterialPtr & material2 = mpFont->getMaterial();
			panel->setMaterialName(material2->getName());
		}*/
		panel->setMaterialName(material->getName());
		overlay->add2D(panel);
	}
}
コード例 #5
0
ファイル: GUIHelper.cpp プロジェクト: agudpp/CordobaZombie
/**
 * Create a new PanelOverlayElement
 * @param	matName		The name of the material
 * @param	rSize		The resulting size of the texture (width)
 * @param	name		The name of the panel
 */
Ogre::PanelOverlayElement *GUIHelper::createPanel(const Ogre::String &matName,
		int &rSize, const Ogre::String &name)
{
	static int counter = 0;

	Ogre::PanelOverlayElement *result = 0;
	Ogre::String realName;

	if(name.empty()){
		realName = "pan" + Ogre::StringConverter::toString(counter);
		counter++;
	} else {
		realName = name;
	}

#ifdef DEBUG
	// ensures the material exists
	Ogre::MaterialPtr		material;
	material = Ogre::MaterialManager::getSingleton().getByName(matName);
	if(material.isNull()){
		debug("Material %s not found\n", matName.c_str());
	}
//	ASSERT(!material.isNull());
#endif

	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
	result = static_cast<Ogre::PanelOverlayElement*>(
		overlayManager.createOverlayElement("Panel", realName));
	result->setMetricsMode(Ogre::GMM_RELATIVE);
	result->setMaterialName(matName); // Optional background material

	// get the texture size
	Ogre::String text = result->getMaterial()->getTechnique(0)->getPass(0)->
			getTextureUnitState(0)->getTextureName();
	Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(text);
	ASSERT(!texture.isNull());
	rSize = texture->getWidth();

	return result;
}
コード例 #6
0
void OgreAppLogic::createCanvasOverlay()
{
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
	Ogre::Overlay* overlay = overlayManager.create("Canvas/Overlay");

	Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "CanvasClock1/Panel"));
	panel->setMetricsMode(Ogre::GMM_PIXELS);
	panel->setMaterialName("CanvasClock1");
	panel->setDimensions(150.0f, 150.0f);
	panel->setPosition(0, 0);
	overlay->add2D(panel);

	panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "CanvasClock2/Panel"));
	panel->setMetricsMode(Ogre::GMM_PIXELS);
	panel->setMaterialName("CanvasClock2");
	panel->setDimensions(150.0f, 150.0f);
	panel->setPosition(mApplication->getRenderWindow()->getWidth()-150.0f, 0);
	overlay->add2D(panel);

	overlay->show();
}
コード例 #7
0
ファイル: OgreAppLogic.cpp プロジェクト: zphilip/KinectOgreAR
void OgreAppLogic::createKinectOverlay(const std::string& colorTextureName, const std::string& depthTextureName, const std::string& coloredDepthTextureName)
{
	//Create Color Overlay
	
	{
		//Create Overlay
		Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
		Ogre::Overlay* overlay = overlayManager.create("KinectColorOverlay");

		//Create Material
		const std::string materialName = "KinectColorMaterial";
		Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
		material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
		material->getTechnique(0)->getPass(0)->createTextureUnitState(colorTextureName);

		//Create Panel
		Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectColorPanel"));
		panel->setMetricsMode(Ogre::GMM_PIXELS);
		panel->setMaterialName(materialName);
		panel->setDimensions((float)Kinect::colorWidth/4, (float)Kinect::colorHeight/4);
		panel->setPosition(0.0f, 0.0f);
		overlay->add2D(panel);		
		overlay->setZOrder(300);
		overlay->show(); 
	}
	
	//Create Depth Overlay
	{
		//Create Overlay
		Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
		Ogre::Overlay* overlay = overlayManager.create("KinectDepthOverlay");

		//Create Material
		const std::string materialName = "KinectDepthMaterial";
		Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
		material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
		material->getTechnique(0)->getPass(0)->setAlphaRejectSettings(CMPF_GREATER, 127);
		material->getTechnique(0)->getPass(0)->createTextureUnitState(depthTextureName);
		//material->getTechnique(0)->getPass(0)->setVertexProgram("Ogre/Compositor/StdQuad_vp");
		//material->getTechnique(0)->getPass(0)->setFragmentProgram("KinectDepth");

		//Create Panel
		Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectDepthPanel"));
		panel->setMetricsMode(Ogre::GMM_PIXELS);
		panel->setMaterialName(materialName);
		panel->setDimensions((float)Kinect::depthWidth/4, (float)Kinect::depthHeight/4);
		panel->setPosition((float)640.0f/4, 0.0f);
		overlay->add2D(panel);		
		overlay->setZOrder(310);
		overlay->show();
	}
	
	//Create Colored Depth Overlay
	{
		//Create Overlay
		Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
		Ogre::Overlay* overlay = overlayManager.create("KinectColoredDepthOverlay");

		//Create Material
		const std::string materialName = "KinectColoredDepthMaterial";
		Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
		material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
		material->getTechnique(0)->getPass(0)->createTextureUnitState(coloredDepthTextureName);

		//Create Panel
		Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectColoredDepthPanel"));
		panel->setMetricsMode(Ogre::GMM_PIXELS);
		panel->setMaterialName(materialName);
		panel->setDimensions((float)Kinect::depthWidth/4, (float)Kinect::depthHeight/4);
		panel->setPosition((float)1280.0f/4, 0.0f);
		overlay->add2D(panel);		
		overlay->setZOrder(320);
		overlay->show();
	}
}