Ejemplo n.º 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();
	}
Ejemplo n.º 2
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();
}
Ejemplo n.º 3
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();
}
Ejemplo n.º 4
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();
	}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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();
    }
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
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
Ejemplo n.º 9
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();
}
Ejemplo n.º 10
0
static void InitStartScene()
{
	if(app.state.CurentState > 0)
	{
		return;
	}

	Ogre::RTShader::ShaderGenerator::initialize();
	Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
	gMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
	Ogre::MaterialManager::getSingleton().addListener(gMatListener);

	LOGW("Create SceneManager");
	gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
	Ogre::RTShader::ShaderGenerator::getSingletonPtr()->addSceneManager(gSceneMgr);

	camera = gSceneMgr->createCamera("MyCam");
	camera->setNearClipDistance(1.0f);
	camera->setFarClipDistance(100000.0f);
	camera->setPosition(0,0,20.0f);
	camera->lookAt(0,0,0);
	camera->setAutoAspectRatio(true);

	vp = gRenderWnd->addViewport(camera);
	vp->setBackgroundColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
	vp->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);

	/**
	 * http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Creating+Overlays+via+Code
	 * http://www.ogre3d.org/forums/viewtopic.php?f=2&t=78278#p492027
	 */
	LOGW("Create OverlaySystem");
	Ogre::OverlaySystem *mOverlaySystem = OGRE_NEW Ogre::OverlaySystem();
	gSceneMgr->addRenderQueueListener(mOverlaySystem);

	LOGW("Create overlayManager");
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();

	loadResources("resources.cfg");
	Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup("Start");

	LOGW("Create a img overlay panel");
	Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>( overlayManager.createOverlayElement( "Panel", "PanelLogo" ) );
	panel->setPosition( vp->getActualWidth()/2 - 64, vp->getActualHeight()/2 - 64 - 20 );
	panel->setDimensions( 128, 64 );
	panel->setMaterialName("overlay_image_material");
	panel->setMetricsMode(Ogre::GMM_PIXELS);

	Ogre::Overlay* LogoOverlay = overlayManager.create( "OverlayLogo" );
	LogoOverlay->add2D( panel );
	LogoOverlay->show();


	LOGW("Create a text overlay panel");
	textArea = static_cast<Ogre::TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "TextAreaName"));
	textArea->setMetricsMode(Ogre::GMM_PIXELS);
	textArea->setPosition(0, 0);
	textArea->setDimensions(100, 100);
	textArea->setCaption("Hello, World!");
	textArea->setCharHeight(48);
	textArea->setFontName("QWcuckoo");
	textArea->setColourBottom(Ogre::ColourValue(0.0f, 0.0f, 1.0f));
	textArea->setColourTop(Ogre::ColourValue(1.0f, 0.0f, 0.0f));

	Ogre::OverlayContainer* TextPanel = static_cast<Ogre::OverlayContainer*>( overlayManager.createOverlayElement( "Panel", "PanelText" ) );
	TextPanel->setPosition( vp->getActualWidth()/2 - 128, vp->getActualHeight()/2 + 20 );
	TextPanel->setDimensions( 256, 64 );
	TextPanel->setMaterialName("overlay_text_material");
	TextPanel->setMetricsMode(Ogre::GMM_PIXELS);
	TextPanel->addChild(textArea);

	Ogre::Overlay* TextOverlay = overlayManager.create( "OverlayText" );
	TextOverlay->add2D( TextPanel );
	TextOverlay->show();

	app.state.CurentState = 1;

}