示例#1
0
	// Create text area for SkyX parameters
	void createTextArea()
	{
		// Create a panel
		Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
			OverlayManager::getSingleton().createOverlayElement("Panel", "SkyXParametersPanel"));
		panel->setMetricsMode(Ogre::GMM_PIXELS);
		panel->setPosition(10, 10);
		panel->setDimensions(400, 400);

		// Create a text area
		mTextArea = static_cast<Ogre::TextAreaOverlayElement*>(
			OverlayManager::getSingleton().createOverlayElement("TextArea", "SkyXParametersTextArea"));
		mTextArea->setMetricsMode(Ogre::GMM_PIXELS);
		mTextArea->setPosition(0, 0);
		mTextArea->setDimensions(100, 100);
		mTextArea->setCaption("SkyX plugin demo");
		mTextArea->setCharHeight(16);
		mTextArea->setFontName("BlueHighway");
		mTextArea->setColourBottom(ColourValue(0.3, 0.5, 0.3));
		mTextArea->setColourTop(ColourValue(0.5, 0.7, 0.5));

		// Create an overlay, and add the panel
		Ogre::Overlay* overlay = OverlayManager::getSingleton().create("OverlayName");
		overlay->add2D(panel);

		// Add the text area to the panel
		panel->addChild(mTextArea);

		// Show the overlay
		overlay->show();
	}
void ViargoOgreKinectTrackingCalibrationMetaphor::_finalizeCalibration() {
	// Build extended positions (calculates average normal plane and adds translated points to list, needed for opencv affine transformation solver)
	//_buildExtendedPositions(_screenPositions3D);
	//_buildExtendedPositions(_worldPositions);

	cv::Point3f origin = _worldPositions[2];
	cv::Point3f xAxis  = _worldPositions[3];
	cv::Point3f yAxis  = _worldPositions[0];

	_buildTransformationMatrix(origin, xAxis, yAxis);
	// SVD 
	//_solveRigidBodyTransformation(_worldPositions, _screenPositions3D);

	// Store transformation matrix in file
	_storeCalibrationData();
	storeTransformation("kinect_calibration.txt");

	// Reset state
	_calibrating = false;
	_calibrated = true;

	// Hide overlays
	_overlay->hide();
	_backgroundOverlayContainer->hide();

	for (unsigned int i = 0; i < _markers.size(); i++) {
		Ogre::OverlayContainer* currentMarkerOverlay = _markers[i];
		currentMarkerOverlay->hide();
	}

	_worldPositions.clear();
}
示例#3
0
文件: Menu.cpp 项目: Thoronador/Dusk
void Menu::showQuestLogEntries()
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  if (om==NULL) return;
  Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
                            om->getOverlayElement(cQuestLogOverlay+"/Panel"));
  if (panel==NULL)
  {
    std::cout << "Menu::showQuestLogEntries: ERROR: Panel not found!\n";
    return;
  }//if
  std::vector<QLogEntry> entries = QuestLog::getSingleton().listQuestEntries(m_QuestLogOffset, cQuestLogEntriesPerPage);
  if (m_QuestLogOffset>0 and entries.empty())
  { //reset offset, because we've gone too far, and fetch entries again
    m_QuestLogOffset = 0;
    entries = QuestLog::getSingleton().listQuestEntries(m_QuestLogOffset, cQuestLogEntriesPerPage);
  }
  Ogre::TextAreaOverlayElement* text_elem = NULL;

  const Ogre::FontPtr glyphs = Ogre::FontManager::getSingleton().getByName("Console");
  unsigned int i;
  //create text areas for entries
  for (i=0; i<entries.size(); ++i)
  {
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
        om->createOverlayElement("TextArea", cQuestLogOverlay+"/"+IntToString(i)));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.025, cQuestLogEntryHeight*i+0.5*cQuestLogEntryHeight);
    text_elem->setDimensions(0.725, cQuestLogEntryHeight);
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Left);
    text_elem->setCaption(chopString(Journal::getSingleton().getText(entries[i].questID, entries[i].index),
                cQuestLogCharHeight, glyphs));
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
  }//for
  //delete unneccessary textareas, if present
  for (i=entries.size(); i<m_QuestLogEntryCount; ++i)
  {
    om->destroyOverlayElement(cQuestLogOverlay+"/"+IntToString(i));
  }//for
  m_QuestLogEntryCount = entries.size();
  //show notification, if no elements are present yet
  if (entries.empty())
  {
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
                    om->createOverlayElement("TextArea", cQuestLogOverlay+"/0"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.025, 0.0+0.5*cQuestLogEntryHeight);
    text_elem->setDimensions(0.725, cQuestLogEntryHeight);
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setCaption("You don't have any journal entries yet!");
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
    m_QuestLogEntryCount = 1;
  }//if
}//func
示例#4
0
GameplayScreen::~GameplayScreen()
{
	//Destroy our game objects
	delete mWhacker;
	for(unsigned int i=0; i<mDragons.size(); i++)
	{
		delete mDragons[i];
	}
	//Destroy all entities created
	Ogre::SceneManager* mSceneManager = Ogre::Root::getSingletonPtr()->getSceneManager("ApplicationSceneManager");
	mSceneManager->destroyEntity("Stage");
	//Remove the stage mesh
	mStageNode->removeAndDestroyAllChildren();
	mStageNode->getParentSceneNode()->removeAndDestroyChild(mStageNode->getName());
	//Destroy our score overlay
	//To do this, we must traverse all elements contained within
	//the overlay and remove them one at a time.
	Ogre::OverlayManager* overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	Ogre::Overlay::Overlay2DElementsIterator iter = mOverlay->get2DElementsIterator();
	for(;iter.hasMoreElements();)
	{
		Ogre::OverlayContainer * childContainer = iter.getNext();
		Ogre::OverlayContainer::ChildIterator contIter = childContainer->getChildIterator();
		for(;contIter.hasMoreElements();)
		{
			Ogre::OverlayElement* curElement = contIter.getNext();
			overlayMgr->destroyOverlayElement(curElement->getName());
		}
		overlayMgr->destroyOverlayElement(childContainer->getName());
	}
	overlayMgr->destroy(mOverlay->getName());
}
示例#5
0
Ogre::OverlayContainer *GUIHelper::findContainer(Ogre::OverlayContainer *overlay,
			const Ogre::String subStrName)
{
	ASSERT(overlay);

	std::queue<Ogre::OverlayContainer *> q;
	q.push(overlay);

	Ogre::OverlayContainer *parent = 0;
	while(!q.empty()){
		parent = q.back();
		q.pop();
		if(parent->getName().find(subStrName) != Ogre::String::npos){
			// we find it
			return parent;
		}
		// else we have to iterate over all the children an put it in the queue
		Ogre::OverlayContainer *child = 0;
		Ogre::OverlayContainer::ChildIterator it = parent->getChildIterator();
		while(it.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it.peekNextValue());
			if(!child){
				break;
			}
			// else we put it in the queue
			q.push(child);
			it.moveNext();
		}

	}

	return 0;
}
示例#6
0
void OgreApp::createScene()
{
	sceneMgr->setSkyBox(true, "Sky", 5, 8, 4000);
    sceneMgr->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
    sceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);

	node = sceneMgr->getRootSceneNode()->createChildSceneNode("OgreHead");
	ent = sceneMgr->createEntity("Ogre", "ogrehead.mesh");
	node->attachObject(ent);
	node->setPosition(0, 50, 0);

	OgreAL::Sound *bgSound = soundManager->createSound("5.1 Test", "6chan.ogg", true);
	bgSound->setGain(2);
	bgSound->setRelativeToListener(true);
	bgSound->play();

	node = sceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
	node->setPosition(0, 100, 100);
	node = node->createChildSceneNode("PitchNode");
	node->attachObject(camera);
	node->attachObject(soundManager->getListener());
	node->pitch(Ogre::Degree(-30));

	// Create a ground plane
    Plane plane(Vector3::UNIT_Y, 0);
    MeshManager::getSingleton().createPlane("ground",
       ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
       15000,15000,20,20,true,1,5,5,Vector3::UNIT_Z);
    ent = sceneMgr->createEntity("GroundEntity", "ground");
    sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
    ent->setMaterialName("Ground");
    ent->setCastShadows(false);

	light = sceneMgr->createLight("sun");
	light->setType(Light::LT_DIRECTIONAL);
	light->setDirection(-1,-1,-1);

	OverlayManager& overlayMgr = OverlayManager::getSingleton();
	Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(
	   overlayMgr.createOverlayElement("Panel", "PanelName"));
	panel->setMetricsMode(Ogre::GMM_PIXELS);
	panel->setPosition(10, 10);
	panel->setDimensions(100, 100);

	TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>(
	   overlayMgr.createOverlayElement("TextArea", "TextAreaName"));
	textArea->setMetricsMode(Ogre::GMM_PIXELS);
	textArea->setPosition(0, 0);
	textArea->setDimensions(100, 100);
	textArea->setCharHeight(16);
	textArea->setFontName("Arial");
	textArea->setCaption("Hello, World!");

	Ogre::Overlay* overlay = overlayMgr.create("AverageFps");
	overlay->add2D(panel);
	panel->addChild(textArea);
	overlay->show();
}
示例#7
0
void GUIHelper::reposContainer(Ogre::OverlayContainer *o)
{
	ASSERT(o);
	if(!o->getParent()){
		debugWARNING("This overlay has no parent (%s)\n", o->getName().c_str());
		return;
	}
	// if we have parent then we call the other function
	Ogre::OverlayContainer *parent = o->getParent();
	reposContainer(o, parent->getLeft(), parent->getTop(),parent->getHeight(),
			parent->getWidth());
}
示例#8
0
	void LoadingBar::deleteOverlayContainerContents(Ogre::OverlayContainer& container) const
	{
		{
			OverlayContainer::ChildContainerIterator I = container.getChildContainerIterator();
			while (I.hasMoreElements()) {
				deleteOverlayContainerContents(*I.getNext());
			}
		}
		OverlayContainer::ChildIterator I = container.getChildIterator();
		while (I.hasMoreElements()) {
			OverlayManager::getSingleton().destroyOverlayElement(I.getNext());
		}
	}
示例#9
0
	void DirectShowControl::createOverlay()
	{
		mOverlay = Ogre::OverlayManager::getSingleton().create(mName);

		Ogre::OverlayContainer *mContainer = (Ogre::OverlayContainer*)
			(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Ogre/DebugTexPanel" +mName));

		mContainer->setMetricsMode(Ogre::GMM_PIXELS);
		mContainer->setDimensions(mVp->getActualWidth(),mVp->getActualHeight());
		mContainer->setMaterialName(mMaterial->getName());
		mOverlay->add2D(mContainer);
		mOverlay->show();
		PlayMovie();
	}
示例#10
0
文件: Menu.cpp 项目: Thoronador/Dusk
void Menu::killDialogueOverlayLines()
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  /*If overlay manager is NULL, then it is not present any more and all overlays
    should already be destroyed at that point. So we can return anyway. */
  if (om==NULL) return;
  Ogre::OverlayContainer* oc = static_cast<Ogre::OverlayContainer*> (om->getOverlayElement(cDialogueOverlay+"/Box"));
  unsigned int i;
  for (i=0; i<m_DialogueLineCount; i=i+1)
  {
    oc->removeChild(cDialogueOverlay+"/Box/Line"+IntToString(i));
    om->destroyOverlayElement(cDialogueOverlay+"/Box/Line"+IntToString(i));
  }//for
  m_DialogueLineCount = 0;
}
示例#11
0
文件: Menu.cpp 项目: Thoronador/Dusk
void Menu::showDialogue(const std::string& first, const std::vector<std::string>& options)
{
  Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton();
  std::cout << "getByName(overlay)\n";
  Ogre::Overlay* dialOverlay = om.getByName(cDialogueOverlay);
  if (dialOverlay == NULL)
  {
    std::cout << "create(overlay)\n";
    dialOverlay = om.create(cDialogueOverlay);
  }
  Ogre::OverlayContainer* dialCont = NULL;
  std::cout << "getOE(Box)\n";
  dialCont = static_cast<Ogre::OverlayContainer*> (om.getOverlayElement(cDialogueOverlay+"/Box"));
  if (dialCont == NULL)
  {
    std::cout << "createOE(Box)\n";
    dialCont = static_cast<Ogre::OverlayContainer*>
                    (om.createOverlayElement("Panel", cDialogueOverlay+"/Box"));
    dialCont->setPosition(0.0, 0.75);
    dialCont->setDimensions(1.0, 0.25);
    dialCont->setMaterialName("Dusk/Dialogue/Black");
  }
  std::cout << "getOE(Box/First)\n";
  Ogre::OverlayElement* dialElem;
  dialElem = om.getOverlayElement(cDialogueOverlay+"/Box/First");
  if (dialElem==NULL)
  {
    std::cout << "createOE(Box/First)\n";
    dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/First");
    dialElem->setDimensions(1.0, 0.0625);
    dialElem->setPosition(0.0, 0.0);
    dialElem->setMaterialName("Dusk/Dialogue/Element");
    dialCont->addChild(dialElem);
  }
  dialElem->setCaption(first);
  dialElem->show();
  unsigned int elemCount = options.size();
  if (elemCount > cMaxDialogueOptions)
  {
    elemCount = cMaxDialogueOptions;
  }

  killDialogueOverlayLines();
  unsigned int i;
  const float elemHeight = 0.8/(float)elemCount;
  for (i=0; i<elemCount; i=i+1)
  {
    //dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i));
    dialElem = om.createOverlayElementFromTemplate(cDialogueOverlay+"/LineTemplate", "TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i));
    dialElem->setPosition(0.1, dialCont->getHeight()*(0.2+i*elemHeight));
    dialElem->setDimensions(0.8, elemHeight*dialCont->getHeight());
    dialElem->setCaption(IntToString(i+1)+": "+options[i]);
    dialElem->show();
    dialCont->addChild(dialElem);
    m_DialogueLineCount = i+1;
  }//for
  dialOverlay->show();
}
示例#12
0
//-------------------------------------------------------------------------------------
///Load all songs, initializes overlay and play first
	Sound::Sound(const char* path, int width, int height):volumeDiff(1),actualSongNumber(0),overlayIsShowed(false),durationOverlay(0),startVolume(5)
{
	volume = startVolume; //50%
	engine = irrklang::createIrrKlangDevice();
	
	struct dirent *entry;
	DIR *dp;

	dp = opendir(path);
	std::string stringName;

	if (dp == NULL) {
		perror("opendir: Path does not exist or could not be read.");
	}else{
		while ((entry = readdir(dp))){
			stringName = entry->d_name;
			if(!(!strcmp(".", stringName.c_str())||!strcmp("..",stringName.c_str()))){
				songNames.push_back(std::string(path)+ '/'+ entry->d_name);	
			}
		}
	}
	song = engine->play2D(songNames[0].c_str(), false, false, true);
	song->setVolume(volume);

	closedir(dp);
	
	//Event Listener
	song->setSoundStopEventReceiver(this);
	
	//overlay
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 

    //Create a panel 
    Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "MusicPanel")); 
    panel->setMetricsMode(Ogre::GMM_PIXELS); 
	panel->setDimensions(width*9/10, 50);
 
	panel->setLeft((width - panel->getWidth()) / 2);   
    panel->setMaterialName("Core/StatsBlockCenter"); // Optional background material 
   
    // Create a text area 
    musicTextArea = static_cast<Ogre::TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "MusicTextArea")); 
    musicTextArea->setMetricsMode(Ogre::GMM_PIXELS); 
	musicTextArea->setTop(5);
	musicTextArea->setLeft((( panel->getWidth())) / 4);
	musicTextArea->setCharHeight(14);   
    musicTextArea->setFontName("StarWars"); 

	// Add the text area to the panel 
    panel->addChild(musicTextArea); 

    // Create an overlay, and add the panel 
    overlay = overlayManager.create("MusicBox"); 
    overlay->add2D((panel)); 

	actualSong();
}
示例#13
0
void gkDebugScreen::initialize()
{
	if (m_isInit)
		return;

	try
	{

		m_font = new gkBuiltinFont;
		Ogre::FontPtr fp = Ogre::FontManager::getSingleton().create("<gkBuiltin/Font>", GK_BUILTIN_GROUP, true, m_font);
		fp->load();

		Ogre::OverlayManager& mgr = Ogre::OverlayManager::getSingleton();
		m_over  = mgr.create("<gkBuiltin/gkDebugScreen>");
		m_ele   = mgr.createOverlayElement("TextArea", "<gkBuiltin/gkDebugScreen/TextArea>");

		Ogre::OverlayContainer* cont = (Ogre::OverlayContainer*)mgr.createOverlayElement("BorderPanel", "<gkBuiltin/gkDebugScreen/Containter>");
		cont->setMetricsMode(Ogre::GMM_PIXELS);
		cont->setVerticalAlignment(Ogre::GVA_TOP);

		const gkVector2& dims = gkWindowSystem::getSingleton().getMouse()->winsize;

		m_ele->setMetricsMode(Ogre::GMM_PIXELS);
		m_ele->setVerticalAlignment(Ogre::GVA_TOP);
		m_ele->setPosition(0, 0);
		m_ele->setDimensions(dims.x, dims.y);

		Ogre::TextAreaOverlayElement* textArea = static_cast<Ogre::TextAreaOverlayElement*>(m_ele);
		textArea->setFontName("<gkBuiltin/Font>");
		textArea->setCharHeight(SCREEN_SIZE);
		textArea->setColour(Ogre::ColourValue::White);

		m_over->setZOrder(500);
		cont->addChild(m_ele);
		m_over->add2D(cont);
	}
	catch (Ogre::Exception& e)
	{
		gkPrintf("%s", e.getDescription().c_str());
		return;
	}


	m_isInit = true;
	gConsole = this;
}
// -------------------------------------------------------------------------
OgreBulletGuiListener::OgreBulletGuiListener(OgreBulletListener *listener, Ogre::RenderWindow *win) :
    mListener(listener),
    mWindow(win),
    mMouseOverlay(0),
    mMousePanel(0)
{	
        
    /******************* CREATE Cursor Overlay ***************************/
    mMouseOverlay = (Overlay*)OverlayManager::getSingleton().getByName("GuiOverlay");
    if (mMouseOverlay)
    {
        mMousePanel = OverlayManager::getSingleton().getOverlayElement ("GUIMouse");
    }
    else
    {
        mMouseOverlay = OverlayManager::getSingletonPtr()->create("GuiOverlay");
        mMouseOverlay->setZOrder(600);
        mMousePanel = (Ogre::OverlayElement *)
            OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "GUIMouse");
        mMousePanel->setMaterialName("OgreBulletDemos/TargetSights");

        TexturePtr mouseTex = TextureManager::getSingleton().load("target.png", "Bullet");
        mMousePanel->setWidth (mouseTex->getWidth() / (float)win->getWidth());
        mMousePanel->setHeight (mouseTex->getHeight() / (float)win->getHeight());

        Ogre::OverlayContainer		*mouseContainer = (Ogre::OverlayContainer*) 
            OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "GUIContainer");
        mMouseOverlay->add2D(mouseContainer);
        mouseContainer->addChild(mMousePanel);
    }

    mMouseOverlay->show(); 
    TexturePtr mouseTex = TextureManager::getSingleton().load("target.png", "Bullet");
    mMouseCursorHalfWidth = (Real(mouseTex->getWidth()) / mWindow->getWidth()) * 0.5;
    mMouseCursorHalfHeight = (Real(mouseTex->getHeight())  / mWindow->getHeight ()) * 0.5;

    /******************* CREATE GUI ***************************/
    mGui = new BetaGUI::GUI("OgreBulletGui", "BlueHighway", 14, win);
    OverlayContainer* mouseCursor = mGui->createMousePointer(Vector2(32, 32), "bgui.pointer");
    mouseCursor->hide();

    mGui->injectMouse(mWindow->getWidth() * 0.5, mWindow->getHeight() * 0.5, false);

}
示例#15
0
/**
 * @inheritDoc
 */
BrowserWindow::BrowserWindow() {
    m_texture = Ogre::TextureManager::getSingleton().createManual("HUDTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
       Ogre::TEX_TYPE_2D, 500, 500, 0, Ogre::PF_BYTE_BGRA, Ogre::TU_DYNAMIC);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("HUDMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    material->getTechnique(0)->getPass(0)->createTextureUnitState("HUDTexture");
    material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);

    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
    m_overlay = overlayManager.create("OverlayName");

    Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "PanelName"));
    panel->setPosition(0.0, 0.0);
    panel->setDimensions(1.0, 1.0);
    panel->setMaterialName("HUDMaterial");

    m_overlay->add2D(panel);
    m_overlay->show();
}
示例#16
0
void GameScreen::setUpOverlay(){
	// Load the Font
	FontManager &fontMgr = FontManager::getSingleton();
	ResourcePtr font = fontMgr.create("GameFont","General");
	font->setParameter("type","truetype");
	font->setParameter("source","Smirnof.ttf");
	font->setParameter("size","20");
	font->setParameter("resolution","96");
	font->load();

	// Load the overlay
	OverlayManager& overlayMgr = OverlayManager::getSingleton();
	Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(
    overlayMgr.createOverlayElement("Panel", "PanelName"));
	panel->_setPosition(0.05, 0.925);
	panel->setDimensions(300, 120);

	TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>(
    overlayMgr.createOverlayElement("TextArea", "TextAreaName"));
	textArea->setMetricsMode(Ogre::GMM_PIXELS);
	textArea->setPosition(0, 0);
	textArea->setDimensions(300, 120);
	textArea->setCharHeight(24);
	textArea->setColour(ColourValue(1,1,0));
	// set the font name to the font resource that you just created.
	textArea->setFontName("GameFont");
	// say something

	std::stringstream ss;
	ss << "Score: " << score;

	textArea->setCaption(ss.str().c_str());

	overlay = overlayMgr.create("OverlayName");
	overlay->add2D(panel);

	panel->addChild(textArea);

}
示例#17
0
void GUIHelper::fullDestroyOverlay(Ogre::Overlay *overlay)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator it = overlay->get2DElementsIterator();
	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();
	std::vector<Ogre::OverlayElement *> elements;

	Ogre::OverlayContainer *parent = 0;
	while(it.hasMoreElements()){
		parent = it.peekNext();
		if(!parent){
			break;
		}

		Ogre::OverlayContainer::ChildIterator it2 = parent->getChildIterator();
		Ogre::OverlayContainer *child = 0;
		while(it2.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it2.peekNextValue());
			if(!child){
				break;
			}
			// else.. delete the container
			fullDestroyOverlayElement(child);

			it2.moveNext();
		}

		elements.push_back(parent);
		it.moveNext();
	}
	for(int i = 0; i < elements.size(); ++i){
		destroyMaterial(elements[i]->getMaterialName());
		om.destroyOverlayElement(elements[i]);
	}

	om.destroy(overlay);
}
void SalamancerApplication::createBrowser(){
    Ogre::TexturePtr renderTexture = Ogre::TextureManager::getSingleton().createManual(
                "texture",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_A8R8G8B8, Ogre::TU_WRITE_ONLY);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("BrowserMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    material->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_CLOCKWISE); // print both sides of the polygones
    material->getTechnique(0)->getPass(0)->createTextureUnitState("texture");
    material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
    material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
    
    Ogre::Overlay *overlay = Ogre::OverlayManager::getSingletonPtr()->create("BrowserOverlay");
    Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "BrowserPanel"));
    
    panel->setPosition(0.0, 0.0);
    panel->setDimensions(1.0, 1.0);
    panel->setMaterialName("BrowserMaterial");
    overlay->add2D(panel);
    
    overlay->show();
    
    this->windowInfo.SetAsWindowless(0, true);
    
    this->clientHandler = new ClientHandler(renderTexture, this->mRoot->getAutoCreatedWindow(), mMouse, this->mCamera, this->mSceneMgr, this->world, this->context);
    
    browserSettings.web_security = STATE_DISABLED;
    
    this->browser = CefBrowserHost::CreateBrowserSync(windowInfo, this->clientHandler.get(),
            "file:///home/nathan/Projects/salamancer/dist/bin/hud/index.html",
            browserSettings, 
            NULL);
    
    this->clientHandler->SetBrowser(this->browser);
    
    mRoot->addFrameListener(this->clientHandler.get());
    
}
void ViargoOgreKinectTrackingCalibrationMetaphor::_updateOverlays(bool state) {
	_overlay->show();
	_backgroundOverlayContainer->show();

	// Update overlay for each marker
	for (unsigned int i = 0; i < _markers.size(); i++) {
		Ogre::OverlayContainer* currentMarkerOverlay = _markers[i];

		if (_calibrationProgress == i) {
			if (state) {
				currentMarkerOverlay->setMaterialName("kinecttrackingCalibrationGreenMat");
			}
			else {
				currentMarkerOverlay->setMaterialName("kinecttrackingCalibrationYellowMat");
			}
		}
		else {
			currentMarkerOverlay->setMaterialName("kinecttrackingCalibrationRedMat");
		}

		currentMarkerOverlay->show();
	}
}
示例#20
0
void OverlayMask::preViewportUpdate(const Ogre::RenderTargetViewportEvent &event)
{
    if(event.source == mViewport)
    {
        Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
        for(Ogre::OverlayManager::OverlayMapIterator iter = overlayMgr.getOverlayIterator();
                iter.hasMoreElements();)
        {
            Ogre::Overlay* item = iter.getNext();
            for(Ogre::Overlay::Overlay2DElementsIterator it = item->get2DElementsIterator();
                    it.hasMoreElements();)
            {
                Ogre::OverlayContainer* container = it.getNext();
                if(container) container->hide();
            }
        }

        std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator it = mTextOverlays.begin();
        for(; it != mTextOverlays.end(); ++it)
        {
            it->second->show(true);
        }
    }
}
示例#21
0
void gkHUD::newImpl(void)
{

	try
	{

		m_overlay = Ogre::OverlayManager::getSingleton().getByName(m_name.getName());

		// Auto create if it's here
		if (m_overlay)
		{
			Ogre::Overlay::Overlay2DElementsIterator elements = m_overlay->get2DElementsIterator();

			while (elements.hasMoreElements())
			{
				Ogre::OverlayContainer* cont = elements.getNext();
				addChild(new gkHUDElement(cont->getName()));

				Ogre::OverlayContainer::ChildIterator childs = cont->getChildIterator();

				while (childs.hasMoreElements())
				{
					Ogre::OverlayElement* elm = childs.getNext();
					gkHUDElement* hele = new gkHUDElement(elm->getName());
					addChild(hele);
				}
			}

		}
	}
	catch (Ogre::Exception& e)
	{
		gkLogMessage("HUD: " << e.getDescription());
		m_overlay = 0;
	}
}
示例#22
0
/**
 * Get the absolute position of the container
 * @param	cont	The container
 * @param	top		The absolute top
 * @param	left	The absolute left
 * @param	w		The absolute width
 * @param	h		The absolute height
 */
void GUIHelper::getAbsoluteGeometry(Ogre::OverlayContainer *cont, Ogre::Real &top,
		Ogre::Real &left, Ogre::Real &right, Ogre::Real &bottom)
{
	ASSERT(cont);
	Ogre::OverlayContainer *parnet = cont->getParent();
	if(parnet){
		if(parnet->getParent()){
			debugWARNING("TODO: tenemos que contemplar este caso... en el que "
					"haya mas de un parnet... tendriamos que calcular recursivamente"
					" las posiciones...\n");
			ASSERT(false);
		}
		top = cont->getTop() + parnet->getTop();
		left = cont->getLeft() + parnet->getLeft();
		right = left + cont->getWidth();
		bottom = top + cont->getHeight();
	} else {
		top = cont->getTop();
		left = cont->getLeft();
		right = left + cont->getWidth();
		bottom = top + cont->getHeight();
	}

}
示例#23
0
/**
 * Bugfix for the nested overlay containers position. This function will
 * get a overlay and will iterate over all the (child) containers and will
 * set the new "relative" position
 * @param	overlay		The overlay to fix the childs positions
 */
void GUIHelper::fixOverlayPosition(Ogre::Overlay *overlay)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator it = overlay->get2DElementsIterator();

	Ogre::OverlayContainer *parent = 0;
	while(it.hasMoreElements()){
		parent = it.peekNext();
		if(!parent){
			break;
		}

		// else we have the parent... get the top left and sizes
		Ogre::Real top = parent->getTop();
		Ogre::Real left = parent->getLeft();
		Ogre::Real height = parent->getHeight();
		Ogre::Real width = parent->getWidth();


		Ogre::OverlayContainer::ChildIterator it2 = parent->getChildIterator();
		Ogre::OverlayContainer *child = 0;
		while(it2.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it2.peekNextValue());
			if(!child){
				break;
			}
			// else.. we have to configure this child with the parent size and
			// position
			reposContainer(child, left, top, height, width);

			it2.moveNext();
		}


		it.moveNext();
	}
}
示例#24
0
    void OgreEngine::initOverlay() {

        Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
        Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "PanelName"));
            panel->setMetricsMode(Ogre::GMM_PIXELS);
            panel->setPosition(10, 10);
            panel->setDimensions(100, 100);

            Ogre::TextAreaOverlayElement* textArea = static_cast<Ogre::TextAreaOverlayElement*>(
            overlayManager.createOverlayElement("TextArea", "worldName"));
            textArea->setMetricsMode(Ogre::GMM_PIXELS);
            textArea->setPosition(10, 10);
            textArea->setDimensions(100, 200);
            textArea->setFontName("StarWars");
            //textArea->setCaption(this->data["name"].toString().toStdString());
            textArea->setCharHeight(16);
            textArea->setColourBottom(Ogre::ColourValue(1, 1, 1));
            textArea->setColourTop(Ogre::ColourValue(1, 1, 1));

            Ogre::TextAreaOverlayElement* textArea2 = static_cast<Ogre::TextAreaOverlayElement*>(
            overlayManager.createOverlayElement("TextArea", "timeArea"));
            textArea2->setMetricsMode(Ogre::GMM_PIXELS);
            textArea2->setPosition(10, 30);
            textArea2->setDimensions(100, 200);
            textArea2->setFontName("StarWars");
            textArea2->setCaption("0min 0sec");
            textArea2->setCharHeight(16);
            textArea2->setColourBottom(Ogre::ColourValue(1, 1, 1));
            textArea2->setColourTop(Ogre::ColourValue(1, 1, 1));

            Ogre::Overlay* overlay = overlayManager.create("OverlayName");
            overlay->add2D(panel);
            panel->addChild(textArea);
            panel->addChild(textArea2);
            overlay->show();
    }
示例#25
0
void GUIManager::_toggleMenu()
{
  Ogre::OverlayContainer *panel = overlay->getChild("RootPanel");
  if (_menuVisible)
  {
    panel->getChild("MenuTip")->setCaption("(M) Show menu");
    panel->getChild("ExitTip")->hide();
    panel->getChild("RandomizeTip")->hide();
    panel->getChild("ResetTip")->hide();
    panel->getChild("DecSizeTip")->hide();
    panel->getChild("IncSizeTip")->hide();
    panel->getChild("SaveTip")->hide();
    panel->getChild("LoadTip")->hide();
  }
  else
  {
    panel->getChild("MenuTip")->setCaption("(M) Hide menu");
    panel->getChild("ExitTip")->show();
    panel->getChild("RandomizeTip")->show();
    panel->getChild("ResetTip")->show();
    panel->getChild("DecSizeTip")->show();
    panel->getChild("IncSizeTip")->show();
    panel->getChild("SaveTip")->show();
    panel->getChild("LoadTip")->show();
  }
  _menuVisible = !_menuVisible;
}
示例#26
0
GameplayScreen::GameplayScreen()
{
	//Set up the 3D scene
	Ogre::SceneManager* mSceneManager = Ogre::Root::getSingletonPtr()->getSceneManager("ApplicationSceneManager");
	Ogre::Entity* stageEntity = mSceneManager->createEntity("Stage", "Stage.mesh");
	mStageNode = mSceneManager->getRootSceneNode()->createChildSceneNode("StageNode");
	mStageNode->attachObject(stageEntity);
	mStageNode->setPosition(0.0f, -6.0f, -6.5f);

	//Set up game objects
	mWhacker = new Whacker(mSceneManager, mSceneManager->getRootSceneNode());
	mWhacker->SetMovePlane(Ogre::Vector3(0.0f, 2.0f, 1.0f), Ogre::Vector3(0.0f, -0.5f, -6.5f), 3.8f, 3.0f);
	float dragonPositions[] = { -3.0f, -2.5f, -7.0f,
								-1.5f, -2.0f, -8.0f,
								-1.5f, -3.0f, -6.0f,
								0.0f, -2.5f, -7.0f,
								1.5f, -2.0f, -8.0f,
								1.5f, -3.0f, -6.0f,
								3.0f, -2.5f, -7.0f };
	mDragons = std::vector<Dragon*>();
	for (int i=0; i < 7; i++)
	{
		mDragons.push_back(new Dragon(mSceneManager, mSceneManager->getRootSceneNode()));
		mDragons[i]->SetPosition(Ogre::Vector3(dragonPositions[i*3], dragonPositions[(i*3)+1], dragonPositions[(i*3)+2]));
	}

	//Set up game variables
	timeBetweenPopups = 1.0f;
	timeSinceLastPopup = 0.0f;
	score = 0;
	numPeasants = 200;
	subtractPopTime = 0.05f;
	scorePerPopTimeSub = 15;
	minPopTime = 0.75f;
	mWhackerMoveScalar = 0.01f;

	//Lets set up our scoring overlay (Lots of uninteresting code :/ )
	//Fonts are loaded due to a resource loading bug in OGRE 1.8 http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63652
	Ogre::FontManager::getSingleton().load( "YeOldShire", "General" );
	Ogre::FontManager::getSingleton().load( "DejaVuSans", "General" );
	//Title overlays
	Ogre::OverlayManager* overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	mOverlay = overlayMgr->create("GameStats");
	Ogre::OverlayContainer* newContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr->createOverlayElement("Panel", "StatsTitleContainer")); //Breaks Here
	newContainer->setMetricsMode(Ogre::GMM_RELATIVE);
    newContainer->setDimensions(0.4f, 0.15f);
    newContainer->setPosition(0.5f, 0.75f);
	newContainer->setHorizontalAlignment(Ogre::GHA_LEFT);
	Ogre::TextAreaOverlayElement* newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "ScoreTitleText"));
	newElement->setCaption("Score");
	newElement->setFontName("YeOldShire");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Right);
	newElement->setVerticalAlignment(Ogre::GVA_TOP);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.028f);
	newContainer->addChild(newElement);
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "PeasantsTitleText"));
	newElement->setCaption("Peasants Left");
	newElement->setFontName("YeOldShire");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Right);
	newElement->setVerticalAlignment(Ogre::GVA_BOTTOM);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.028f);
	newContainer->addChild(newElement);
	mOverlay->add2D(newContainer);
	//Value Overlays
	newContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr->createOverlayElement("Panel", "StatsValueContainer"));
	newContainer->setMetricsMode(Ogre::GMM_RELATIVE);
    newContainer->setDimensions(0.4f, 0.15f);
    newContainer->setPosition(0.5f, 0.75f);
	newContainer->setHorizontalAlignment(Ogre::GHA_LEFT);
	newContainer->setColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f, 0.3f));
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "ScoreValueText"));
	Ogre::String num_str = Ogre::StringConverter::toString(score);
	newElement->setCaption(":"+num_str);
	newElement->setFontName("DejaVuSans");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Left);
	newElement->setVerticalAlignment(Ogre::GVA_TOP);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.045f);
	mScoreText = newElement;
	newContainer->addChild(newElement);
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "PeasantsValueText"));
	num_str = Ogre::StringConverter::toString(numPeasants);
	newElement->setCaption(":"+num_str);
	newElement->setFontName("DejaVuSans");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Left);
	newElement->setVerticalAlignment(Ogre::GVA_BOTTOM);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.045f);
	mPeasantText = newElement;
	newContainer->addChild(newElement);
	mOverlay->add2D(newContainer);

	mOverlay->show();
}
示例#27
0
文件: Menu.cpp 项目: Thoronador/Dusk
void Menu::showQuestLog(const bool visible)
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  if (om==NULL) return;
  //Do we actually need to do something?
  if (visible==isQuestLogVisible()) return;

  if (visible)
  {
    //show it
    // -- create basic overlay
    Ogre::Overlay* ol = om->create(cQuestLogOverlay);
    // -- create container - panel
    Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
                 om->createOverlayElement("Panel", cQuestLogOverlay+"/Panel"));
    panel->setMetricsMode(Ogre::GMM_RELATIVE);
    panel->setPosition(0.0, 0.0);
    panel->setDimensions(1.0, 1.0);
    /*set material via panel->setMaterialName(...)?*/
    panel->setMaterialName("QuestLog/Transparency");
    //add panel to overlay
    ol->add2D(panel);

    //create elements
    // -- "vorwärts blättern"
    Ogre::TextAreaOverlayElement* text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
                         om->createOverlayElement("TextArea", cQuestLogOverlay+"/Plus"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.125, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("+ (Next)");
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
    //-- "rückwärts blättern"
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
              om->createOverlayElement("TextArea", cQuestLogOverlay+"/Minus"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.425, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("- (Previous)");
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);

    //lists all entries that fit onto the page
    showQuestLogEntries();

    // -- page number
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
              om->createOverlayElement("TextArea", cQuestLogOverlay+"/Page"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.725, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("Page "+IntToString(m_QuestLogOffset/cQuestLogEntriesPerPage+1));
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);

    //show the overlay
    ol->show();
  }//if visible
  else
  {
    //destroy all elements
    unsigned int i;
    // destroy entries
    for (i=0; i<m_QuestLogEntryCount; ++i)
    {
      om->destroyOverlayElement(cQuestLogOverlay+"/"+IntToString(i));
    }//for
    m_QuestLogEntryCount = 0;
    //destroy navigation elements
    om->destroyOverlayElement(cQuestLogOverlay+"/Plus");
    om->destroyOverlayElement(cQuestLogOverlay+"/Minus");
    om->destroyOverlayElement(cQuestLogOverlay+"/Page");
    //destroy panel
    om->destroyOverlayElement(cQuestLogOverlay+"/Panel");
    //destroy overlay
    om->destroy(cQuestLogOverlay);
  }//else
}//function
void ViargoOgreKinectTrackingCalibrationMetaphor::_buildPattern() {
	// Horizontal and vertical offets
	float horizontalOffset = _offsets.x + _offsets.z;
	float verticalOffset   = _offsets.y + _offsets.w;

	// Step in horizontal and vertical direction
	double widthStep  = (1.0 - horizontalOffset) / (_patternSize  - 1);
	double heightStep = (1.0 - verticalOffset)   / (_patternSize - 1);

	// Clear old positions
	_screenPositions.clear();
	_screenPositions3D.clear();

	// Build new 2d screen positions
	for (int j = 0; j < _patternSize; j++) {
		for (int i = 0; i < _patternSize; i++) {
			double positionX = _offsets.x + i * widthStep;
			double positionY = _offsets.y + j * heightStep;

			// Add to list
			_screenPositions.push_back(cv::Point2d(positionX, positionY));
		}
	}

	// Transform 2d screen positions into world space relative to window center
	for (unsigned int i = 0; i < _screenPositions.size(); i++) {
		cv::Point3f worldPosition = cv::Point3f(0, 0, 0);

		// Scale to window size and correct position for [0,0] in window center
		worldPosition.x = _screenPositions[i].x * _windowSize.x - _windowSize.x / 2.0f;
		worldPosition.y = -(_screenPositions[i].y * _windowSize.y - _windowSize.y / 2.0f); // Flipped
		
		_screenPositions3D.push_back(worldPosition);
	}

	// Build pattern as overlays
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();

	// Main overlay, specific overlay containers are inserted here
	_overlay = overlayManager.create("KinectTrackingCalibrationOverlay");
	_overlay->hide();

	_backgroundOverlayContainer = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "KinectTrackingCalibrationBG"));
	_backgroundOverlayContainer->setPosition(0.0, 0.0);
	_backgroundOverlayContainer->setDimensions(1.0, 1.0);
	_backgroundOverlayContainer->setMaterialName("kinecttrackingCalibrationBlackMat");
	_backgroundOverlayContainer->hide();

	// Add background first
	_overlay->add2D(_backgroundOverlayContainer);

	char overlayName[100];

	// Build overlay for each marker
	for (unsigned int i = 0; i < _screenPositions.size(); i++) {
		Ogre::Vector2 screenPostion = Ogre::Vector2(_screenPositions[i].x, _screenPositions[i].y);

		sprintf(overlayName, "KinectTrackingCalibration_%d", i);

		Ogre::OverlayContainer* container = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", std::string(overlayName)));
		container->setPosition(screenPostion.x - _markerSize.x / (Ogre::Real)2.0, screenPostion.y - _markerSize.y / (Ogre::Real)2.0);
		container->setDimensions(_markerSize.x, _markerSize.y);
		container->setMaterialName("kinecttrackingCalibrationRedMat");
		container->hide();

		// Add overlay item
		_overlay->add2D(container);

		// Add to list
		_markers.push_back(container);
	}
}
示例#29
0
void gkDebugScreen::initialize()
{
	if (m_isInit)
		return;

	try
	{

		m_font = new gkBuiltinFont;
		Ogre::FontPtr fp = Ogre::FontManager::getSingleton().create("<gkBuiltin/Font>", GK_BUILTIN_GROUP, true, m_font);
		fp->load();

#define  FONT_MATERIAL 1
#if FONT_MATERIAL

#ifndef OGREKIT_USE_OLD
		gkString ShareMaterail = "Examples/BumpMapping/MultiLight";
		static int Use_Init_Once = 0;
		if(Use_Init_Once < 2)
		{
			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				"",
				"*.material");

			for (Ogre::FileInfoList::const_iterator cit=fileInfoList->begin();
				cit != fileInfoList->end();
				++cit) {
					const Ogre::String& name = cit->filename;
					const Ogre::String& basename = cit->basename;
					Ogre::String sType = cit->archive->getType();
					Ogre::String sPath = cit->archive->getName();
					if (sType=="Zip" || sType=="FileSystem") { 
						Ogre::DataStreamPtr pData=
							Ogre::ResourceGroupManager::getSingleton().openResource(
							basename,"");
						Ogre::MaterialManager::getSingleton().parseScript(
							pData, "");
						Ogre::MaterialManager::getSingleton().load(basename,"");
					}
			}
			Use_Init_Once++;
		}	
#endif

		Ogre::MaterialPtr ShareMaterailPtr = Ogre::MaterialManager::getSingleton().getByName(ShareMaterail, "");
		if (!ShareMaterailPtr.isNull())
		{
			ShareMaterailPtr->load();
			//ShareMaterailPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("textureCount",1);
		}

		Ogre::MaterialPtr oma = Ogre::MaterialManager::getSingleton().getByName("Fonts/<gkBuiltin/Font>");

		if (!oma.isNull())
		{
			Ogre::Pass* pass1 = oma->getTechnique(0)->getPass(0);

			Ogre::GpuProgramPtr vsPtr = Ogre::HighLevelGpuProgramManager::getSingleton().getByName("FixVs");

			if (vsPtr.isNull())
			{
				LogManager::getSingleton().logMessage("GpuProgramPtr NULL");
			}

			gkString VertexProgramName = "FixVs";
			gkString FragmentProgramName ="FixPs";

			if (pass1)
			{
				pass1->setVertexProgram(VertexProgramName);
				pass1->setFragmentProgram(FragmentProgramName);
				Ogre::GpuProgramParametersSharedPtr vsParams = pass1->getVertexProgramParameters();
				vsParams->copyMatchingNamedConstantsFrom(*ShareMaterailPtr->getTechnique(0)->getPass(0)->getVertexProgramParameters().get());
				Ogre::GpuProgramParametersSharedPtr psParams = pass1->getFragmentProgramParameters();
				psParams->copyMatchingNamedConstantsFrom(*ShareMaterailPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters().get());
				//psParams->setNamedConstant("textureCount",1);
				//psParams->setNamedConstant("AlphaValue",0.0f);
				//vsParams->setNamedConstant("lightOpen",0);
				LogManager::getSingleton().logMessage("set font es2.0");
			}
		}
#endif

		Ogre::OverlayManager& mgr = Ogre::OverlayManager::getSingleton();
		m_over  = mgr.create("<gkBuiltin/gkDebugScreen>");
		m_ele   = mgr.createOverlayElement("TextArea", "<gkBuiltin/gkDebugScreen/TextArea>");

		Ogre::OverlayContainer* cont = (Ogre::OverlayContainer*)mgr.createOverlayElement("BorderPanel", "<gkBuiltin/gkDebugScreen/Containter>");
		cont->setMetricsMode(Ogre::GMM_PIXELS);
		cont->setVerticalAlignment(Ogre::GVA_TOP);

		const gkVector2& dims = gkWindowSystem::getSingleton().getMouse()->winsize;

		m_ele->setMetricsMode(Ogre::GMM_PIXELS);
		m_ele->setVerticalAlignment(Ogre::GVA_TOP);
		m_ele->setPosition(0, 0);
		m_ele->setDimensions(dims.x, dims.y);

		Ogre::TextAreaOverlayElement* textArea = static_cast<Ogre::TextAreaOverlayElement*>(m_ele);
		textArea->setFontName("<gkBuiltin/Font>");
		textArea->setCharHeight(SCREEN_SIZE);
		textArea->setColour(Ogre::ColourValue::White);

		m_over->setZOrder(500);
		cont->addChild(m_ele);
		m_over->add2D(cont);
	}
	catch (Ogre::Exception& e)
	{
		gkPrintf("%s", e.getDescription().c_str());
		return;
	}


	m_isInit = true;
	gConsole = this;
}
示例#30
0
YZ::GuiIcon::~GuiIcon(void) {
    LOG_FUNCTION
    Ogre::OverlayContainer* c = this->icon->getParent();
    c->removeChild(this->icon->getName());
    Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->icon);
}