Пример #1
0
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);
	}
}
Пример #2
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();
}
Пример #3
0
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();
	}
}