Ejemplo n.º 1
0
void SplashScreenState::enter()
{
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Entering SplashScreenState...");

	m_pSceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->createSceneManager(Ogre::ST_GENERIC, "SplashSceneMgr");
	m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));

	m_pSceneMgr->addRenderQueueListener(OgreFramework::getSingletonPtr()->m_pOverlaySystem);

	m_pCamera = m_pSceneMgr->createCamera("SplashCam");
	m_pCamera->setPosition(Ogre::Vector3(0, 25, -50));
	m_pCamera->lookAt(Ogre::Vector3(0, 0, 0));
	m_pCamera->setNearClipDistance(1);

	m_pCamera->setAspectRatio(Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) /
		Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight()));

	OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera);

	createScene();

	OgreFramework::getSingletonPtr()->m_pTrayMgr->destroyAllWidgets();

	new ObjectCache(m_pSceneMgr);

	Ogre::OverlayElement * btn = OgreFramework::getSingletonPtr()->m_pTrayMgr->createButton(OgreBites::TL_NONE, "SplashBtn", "Press Enter to continue...", 250)->getOverlayElement();
	btn->setPosition(Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) * 50 / 100 - 125,
			Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight()) * 75 / 100);
	OgreFramework::getSingletonPtr()->m_pTrayMgr->hideCursor();
}
Ejemplo n.º 2
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());
}
void ResourceGroupReloader::visitRecursivelyRenderablesFrom(Ogre::OverlayContainer* pOverlayContainer, Ogre::Renderable::Visitor& pVisitor, bool debugRenderable)
{
	// call on 'this'
	pOverlayContainer->visitRenderables(&pVisitor,false);

	// call on 'leaf' (cf composite pattern)
	{
		Ogre::OverlayContainer::ChildIterator childIter = pOverlayContainer->getChildIterator();
		for(;childIter.hasMoreElements();)
		{
			Ogre::OverlayElement* lOverElem = childIter.getNext();
			lOverElem->visitRenderables(&pVisitor,false);
		}
	}

	// call on 'not-leaf' (cf composite pattern)
	{
		Ogre::OverlayContainer::ChildContainerIterator childContainerIter = pOverlayContainer->getChildContainerIterator();
		for(;childContainerIter.hasMoreElements();)
		{
			Ogre::OverlayContainer * childContainer = childContainerIter.getNext();
			visitRecursivelyRenderablesFrom(childContainer, pVisitor,debugRenderable);
		}
	}
}
Ejemplo n.º 4
0
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();
}
Ejemplo n.º 5
0
void PendulumTest::updateOverlayData(unsigned int trialNum)
{
	Ogre::OverlayElement* trialElement = 
		Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/TrialNumber/Trial");

	trialElement->setCaption("Trial " + 
		Ogre::StringConverter::toString(trialNum));
}
Ejemplo n.º 6
0
void HUDInGame::processMessageBoxVisibilityChanged(MsgBoxVisibilityChangedEventPtr evt)
{
    Ogre::OverlayElement* diamondPanel = Ogre::OverlayManager::getSingleton().getOverlayElement(PANEL_DIAMONDS);
    if (evt->mVisible)
        diamondPanel->hide();
    else diamondPanel->show();


}
Ejemplo n.º 7
0
bool wxOgre::frameEnded(const Ogre::FrameEvent& evt)
{
	static const wxString camPosCaption(wxT("CamPos:X:%06.3f, Y:%06.3f, Z:%06.3f"));
	Ogre::OverlayElement* guiCurr  = Ogre::OverlayManager::getSingleton().getOverlayElement("TextAreaOverlayElement");
	Ogre::Vector3 camPos(mCamera->getRealPosition());
	wxString camText(wxString::Format(camPosCaption, camPos.x, camPos.y, camPos.z));
	guiCurr->setCaption(Ogre::String(camText.mb_str(wxConvUTF8)));
	return true;
		
}
Ejemplo n.º 8
0
	void COverlay::createChildPanel(const std::string& name, 
		float left, float top, float width, float height,
		const std::string& material)
	{
		assert( !_overlayManager->hasOverlayElement(name) && "Ya existe un elemento hijo con el mismo nombre" );
		
		Ogre::OverlayElement* newChild = 
			createChildElement(TChildType::PANEL, name, left, top, width, height);

		if(material.length() > 0)
			newChild->setMaterialName(material);

		_overlay->add2D( static_cast<Ogre::OverlayContainer*>(newChild) );
	} //createChildPanel
Ejemplo n.º 9
0
	Ogre::OverlayElement* COverlay::createChildElement(const std::string &type, const std::string& name, 
		float left, float top, float width, float height)
	{		
		assert( !_overlayManager->hasOverlayElement(name) && "Ya existe un elemento hijo con el mismo nombre" );
		
		Ogre::OverlayElement* newChild = _overlayManager->createOverlayElement(type, name);
			newChild->setMetricsMode(_metricsMode); 
			newChild->setPosition(left, top);		// segun metricsMode: relativas o en pixeles
			newChild->setDimensions(width, height); 
		
		_childElements[name] = newChild;

		return newChild;
	} // createChildTextArea
Ejemplo n.º 10
0
	void TextRenderer::SetText(const std::string &id, const char *fmt, /* args */ ...)
	{
		char       text[256] = {'\0'};
		va_list    ap;

		if (fmt)
		{
			va_start(ap, fmt);
			vsprintf(text, fmt, ap);
			va_end(ap);
		}

		Ogre::OverlayElement *textBox = m_overlayMgr->getOverlayElement(id);
		textBox->setCaption(text);
	}
Ejemplo n.º 11
0
void Application::updateOverlayInfo()
{
	m_debug_1 = "";
	m_debug_2 = "";
	
	if (onSurface)
	{
		m_debug_1 = "On surface";
	}
	else
	{
		m_debug_1 = "On air";	
		last_hit_position = NxOgre::Vec3(0,0,0);
		last_hit_normal = NxOgre::Vec3(0,0,0);
		last_hit_sliding = NxOgre::Vec3(0,0,0);
		angle_normal = 0;
	}

	m_debug_1 = m_debug_1 + " :: " + "P[" 
		" " + Ogre::StringConverter::toString(last_hit_position.x) +
		" " + Ogre::StringConverter::toString(last_hit_position.y) +
		" " + Ogre::StringConverter::toString(last_hit_position.z) +
		" " + "]" + " :: " + "N[" +
		" " + Ogre::StringConverter::toString(last_hit_normal.x) +
		" " + Ogre::StringConverter::toString(last_hit_normal.y) +
		" " + Ogre::StringConverter::toString(last_hit_normal.z) +
		" " + "]" + " :: " + "S[" +
		" " + Ogre::StringConverter::toString(last_hit_sliding.x) +
		" " + Ogre::StringConverter::toString(last_hit_sliding.y) +
		" " + Ogre::StringConverter::toString(last_hit_sliding.z) +
		" " + "]" + " :: " + "A[" +
		" " + Ogre::StringConverter::toString(Ogre::Real(angle_normal)) +
		" " + "]";

	if (m_showInfo)
	{
		Ogre::OverlayElement* overlay  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelFps");
		overlay->setCaption("Current FPS: "+Ogre::StringConverter::toString(m_window->getLastFPS()));
		overlay = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelNTriangles");
		overlay->setCaption("Triangle count: "+Ogre::StringConverter::toString(m_window->getTriangleCount()));
	}
	else 
	{
		Ogre::OverlayElement* overlay  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelFps");
		overlay->setCaption(m_debug_2);
		overlay = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelNTriangles");
		overlay->setCaption("");
	}
	if (m_showDebug)
	{
		Ogre::OverlayElement* overlay  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelDebug");
		overlay->setCaption(m_debug_1);
	}
	else 
	{
		Ogre::OverlayElement* overlay_2  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelDebug");
	}
}
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit(
	Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny)
{
	const Ogre::MaterialPtr mat = rend->getMaterial();
	if(!mat.isNull())
	{
		std::string newMatName = mat->getName();
		Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName);
		if(newMat.isNull())
		{
			// this can happen if there was error during the reloading of the material.
			// in that case, we keep the ancient one.
			// Ice::Log::Instance().LogMessage(newMatName+" : new material is null!");
			return;
		}

		// unfortunately, the renderable gives access only to a const MaterialPtr.
		// and there is no 'setMaterial' or 'setMaterialName' method on renderables.
		// so I have to try to down cast with known classes...
		{   
			Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{
			Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMatName);return;} 
		}
		{
			Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMat);return;} 
		}
		{   
			Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
	}else{
		// was there for debug...
		// Ice::Log::Instance().LogMessage("material of renderable is null!");
	}
}
Ejemplo n.º 13
0
bool
COgreDebugOverlay::frameEnded( const Ogre::FrameEvent& evt )
{GUCE_TRACE;

    if ( NULL != m_debugOverlay )
    {
        static Ogre::String currFps = "Current FPS: ";
        static Ogre::String avgFps = "Average FPS: ";
        static Ogre::String bestFps = "Best FPS: ";
        static Ogre::String worstFps = "Worst FPS: ";
        static Ogre::String tris = "Triangle Count: ";

        // update stats when necessary
        try
        {
            Ogre::OverlayElement* guiAvg = m_overlayManager->getOverlayElement( "Core/AverageFps" );
            Ogre::OverlayElement* guiCurr = m_overlayManager->getOverlayElement( "Core/CurrFps" );
            Ogre::OverlayElement* guiBest = m_overlayManager->getOverlayElement( "Core/BestFps" );
            Ogre::OverlayElement* guiWorst = m_overlayManager->getOverlayElement( "Core/WorstFps" );

            const Ogre::RenderTarget::FrameStats& stats = m_window->GetOgreWindowPtr()->getStatistics();

            guiAvg->setCaption( avgFps + Ogre::StringConverter::toString( stats.avgFPS ) );
            guiCurr->setCaption( currFps + Ogre::StringConverter::toString( stats.lastFPS ) );
            guiBest->setCaption( bestFps + Ogre::StringConverter::toString( stats.bestFPS )
                +" "+Ogre::StringConverter::toString(stats.bestFrameTime)+" ms");
            guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS )
                +" "+Ogre::StringConverter::toString(stats.worstFrameTime)+" ms");

            Ogre::OverlayElement* guiTris = m_overlayManager->getOverlayElement( "Core/NumTris" );
            guiTris->setCaption( tris + Ogre::StringConverter::toString( stats.triangleCount ) );

            //Ogre::OverlayElement* guiDbg = m_overlayManager->getOverlayElement( "Core/DebugText" );
            //guiDbg->setCaption( m_window->GetOgreWindowPtr()->getDebugText() );
        }
        catch( Ogre::Exception& )
        {
            // ignore
        }    
    }
    
    return true;
}
Ejemplo n.º 14
0
Display::Display(Game * game) :
    game(game),
    overlay(overlayMgr()->getByName(OVERLAY_NAME)),
    infoBar(overlay->getChild(INFO_BAR_NAME)),
    levelTextBox(getTextArea(LEVEL_TEXT_BOX_NAME, infoBar)),
    distanceTextBox(getTextArea(DISTANCE_TEXT_BOX_NAME, infoBar)),
    statsPanel(overlay->getChild(STATS_PANEL_NAME)),
    positionTextBox(getTextArea(POSITION_TEXT_BOX_NAME)),
    velocityTextBox(getTextArea(VELOCITY_TEXT_BOX_NAME)),
    pitchRollYawTextBox(getTextArea(PITCH_ROLL_YAW_TEXT_BOX_NAME)),
    thrustTextBox(getTextArea(THRUST_TEXT_BOX_NAME)),
    speedTextBox(getTextArea(SPEED_TEXT_BOX_NAME)),
    aoaTextBox(getTextArea(AOA_TEXT_BOX_NAME)) {

    Ogre::OverlayElement * elt = overlayMgr()->getOverlayElement(TEXT_BOX_TEMPLATE_NAME, true);
    normalValueColor = elt->getColour();
    
    elt = overlayMgr()->getOverlayElement(MAXED_TEXT_BOX_TEMPLATE_NAME, true);
    maxedValueColor = elt->getColour();
}
Ejemplo n.º 15
0
	void TextRenderer::AddTextBox(const std::string &id,
		const std::string &text,
		Ogre::Real x, Ogre::Real y,
		Ogre::Real width, Ogre::Real height,
		const Ogre::ColourValue &color)
	{
		Ogre::OverlayElement *textBox = m_overlayMgr->createOverlayElement("TextArea", id);
		textBox->setDimensions(width, height);
		textBox->setMetricsMode(Ogre::GMM_PIXELS);
		textBox->setPosition(x, y);
		textBox->setWidth(width);
		textBox->setHeight(height);
		textBox->setParameter("font_name", "DebugFont");
		textBox->setParameter("char_height", "16");
		textBox->setColour(color);

		textBox->setCaption(text);

		m_panel->addChild(textBox);
	}
Ejemplo n.º 16
0
void
FrameStatsListener::updateStats(void)
{
    static Ogre::String currFps = "Current FPS: ";
    static Ogre::String avgFps = "Average FPS: ";
    static Ogre::String bestFps = "Best FPS: ";
    static Ogre::String worstFps = "Worst FPS: ";
    static Ogre::String tris = "Triangle Count: ";

    // update stats when necessary
    try {
        Ogre::OverlayElement* guiAvg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
        Ogre::OverlayElement* guiCurr = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
        Ogre::OverlayElement* guiBest = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
        Ogre::OverlayElement* guiWorst = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

        const Ogre::RenderTarget::FrameStats& stats = mRenderTarget->getStatistics();

        guiAvg->setCaption(avgFps + Ogre::StringConverter::toString(stats.avgFPS));
        guiCurr->setCaption(currFps + Ogre::StringConverter::toString(stats.lastFPS));
        guiBest->setCaption(bestFps + Ogre::StringConverter::toString(stats.bestFPS)
            + " " + Ogre::StringConverter::toString(stats.bestFrameTime) + " ms");
        guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS)
            + " " + Ogre::StringConverter::toString(stats.worstFrameTime) + " ms");

        Ogre::OverlayElement* guiTris = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
        guiTris->setCaption(tris + Ogre::StringConverter::toString(stats.triangleCount));

        Ogre::OverlayElement* guiDbg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
        //guiDbg->setCaption(mRenderTarget->getDebugText());
    }
    catch (...)
    {
        // ignore
    }
}
Ejemplo n.º 17
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;
	}
}
Ejemplo n.º 18
0
void Application::updateOverlayInfo()
{
	if (m_showInfo)
	{
		Ogre::OverlayElement* overlay  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelFps");
		overlay->setCaption("Current FPS: "+Ogre::StringConverter::toString(m_window->getLastFPS()));
		overlay = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelNTriangles");
		overlay->setCaption("Triangle count: "+Ogre::StringConverter::toString(m_window->getTriangleCount()));
	}
	else 
	{
		Ogre::OverlayElement* overlay  = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelFps");
		overlay->setCaption("Press I to view Statistics");
		overlay = Ogre::OverlayManager::getSingleton().getOverlayElement("InfoPanelNTriangles");
		overlay->setCaption("");
	}
}
Ejemplo n.º 19
0
void
EndGameState::enter ()
{
	bool mapFit=false;
	if (!_root)
	{
	  _root = Ogre::Root::getSingletonPtr();
	  _gameMgr = GameManager::getSingletonPtr();

	  // Se recupera el gestor de escena y la cámara.
	  _sceneMgr = _root->getSceneManager("SceneManager");
	  
	  _camera = _sceneMgr->getCamera("IntroCamera");
	  _viewport = _root->getAutoCreatedWindow()->getViewport(0);
	  //_viewport = _root->getAutoCreatedWindow()->addViewport(_camera);
	  // Nuevo background colour.
	  _viewport->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0));
	  _overlayMgr = Ogre::OverlayManager::getSingletonPtr();

	  mapFit=false;
	}

	_overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	overlay = _overlayMgr->getByName("EndOverlay");
	Ogre::OverlayElement *endOverlay = _overlayMgr->getOverlayElement("endPanel");

	double width = _viewport->getActualWidth();
	double height = _viewport->getActualHeight();
	double aspectRatio = endOverlay->getWidth()/endOverlay->getHeight();
	endOverlay->setDimensions(width,width/aspectRatio);
	endOverlay->setPosition(0,(height/2)-(endOverlay->getHeight()/2));
	_gameMgr->playEndMusic();


	
  overlay->show();

  _exitGame = false;
}
Ejemplo n.º 20
0
bool MyFrameListener::frameStarted(const Ogre::FrameEvent& evt) {
	
	Ogre::Vector3 vt(0,0,0);
	Ogre::Real deltaT = evt.timeSinceLastFrame;
	Ogre::Real tSpeed = 20.0;
	int fps = 1.0 / deltaT;

	_keyboard->capture();
	if(_keyboard->isKeyDown(OIS::KC_ESCAPE)) return false;
	if(_keyboard->isKeyDown(OIS::KC_0)) // reset
	{
		if (_gameState == 1)
		{
			_gameState = 0;
			deleteBoard();
			_overlayManager->getByName("Title")->show();
		}
	}
	if(_keyboard->isKeyDown(OIS::KC_1)) // jugar
	{
		if (_gameState == 0)
		{
			_gameState = 1;
			createBoard();
			_overlayManager->getByName("Title")->hide();
			_overlayManager->getByName("Win")->hide();
			_overlayManager->getByName("Lose")->hide();
		}
	}

	//if(_keyboard->isKeyDown(OIS::KC_2)) return false;

	// Captura del raton
	_mouse->capture();
	int posx = _mouse->getMouseState().X.abs;
	int posy = _mouse->getMouseState().Y.abs;

	// Dibujado del cursor
	Ogre::OverlayElement *oe;
	oe = _overlayManager->getOverlayElement("cursor");
	oe->setLeft(posx);
	oe->setTop(posy);
	
	// Accion del raton
	bool mbleft = _mouse->getMouseState().buttonDown(OIS::MB_Left);
	if (mbleft) {
		Ogre::Ray r = setRayQuery(posx, posy, 1);
		Ogre::RaySceneQueryResult &result = _raySceneQuery->execute();
		Ogre::RaySceneQueryResult::iterator it;
		it = result.begin();
		//AGUA
		if (it != result.end())
		{
			if (it->movable->getParentSceneNode()->getName() != "nodeG")
			{
				Ogre::Vector3 pos = it->movable->getParentSceneNode()->getPosition();
				it->movable->detachFromParent();
				
				// tirada del CPU.
				int lResult = 0;
				do
				{
					lResult = playCPU();
					if (endGame()!=0)
					{
						_gameState = 0;
						deleteBoard();
						_overlayManager->getByName("Title")->show();
						_overlayManager->getByName("Lose")->show();
					}
				}
				while ((lResult == 1) && (_gameState==1));
			}
		}
		//TOCADO
		r = setRayQuery(posx, posy, 2);
		Ogre::RaySceneQueryResult &resultShip = _raySceneQuery->execute();
		it = resultShip.begin();
		if (it != resultShip.end())
		{
			if (it->movable->getParentSceneNode()->getName() != "nodeG")
			{
				
				Ogre::Vector3 pos = it->movable->getParentSceneNode()->getPosition();
				it->movable->detachFromParent();
				
				// Creacion de otro cubo para cuando haya barco.
				Ogre::Entity* ent1;
				ent1 = _sceneManager->createEntity("CuboBarco.mesh");
				ent1->setQueryFlags(4);
				Ogre::SceneNode* node1 = _sceneManager->createSceneNode();
				node1->attachObject(ent1);
				node1->translate(pos.x,pos.y,pos.z);
				_sceneManager->getRootSceneNode()->addChild(node1);
				
				_maxFires--;
				// no tira CPU
				if (endGame()!=0)
				{
					_gameState = 0;
					deleteBoard();
					_overlayManager->getByName("Title")->show();
					_overlayManager->getByName("Win")->show();

				}

			}
		}
		
	}
	
	return true;
}
Ejemplo n.º 21
0
const std::string& Terminal::getText(const std::string& ID)
{
    Ogre::OverlayElement* textBox = _overlayMgr->getOverlayElement(ID);
    return textBox->getCaption();
}
Ejemplo n.º 22
0
void Application::updateStats()
{
	static Ogre::String currFps = "Current FPS: ";
	static Ogre::String avgFps = "Average FPS: ";
	static Ogre::String bestFps = "Best FPS: ";
	static Ogre::String worstFps = "Worst FPS: ";
	static Ogre::String tris = "Triangle Count: ";
	static Ogre::String batches = "Batch Count: ";

	// update stats when necessary
	try {
		Ogre::OverlayElement* guiAvg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
		Ogre::OverlayElement* guiCurr = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
		Ogre::OverlayElement* guiBest = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
		Ogre::OverlayElement* guiWorst = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

		const Ogre::RenderTarget::FrameStats& stats = m_window->getStatistics();
		guiAvg->setCaption(avgFps + Ogre::StringConverter::toString(stats.avgFPS));
		guiCurr->setCaption(currFps + Ogre::StringConverter::toString(stats.lastFPS));
		guiBest->setCaption(bestFps + Ogre::StringConverter::toString(stats.bestFPS)
			+" "+Ogre::StringConverter::toString(stats.bestFrameTime)+" ms");
		guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS)
			+" "+Ogre::StringConverter::toString(stats.worstFrameTime)+" ms");

		Ogre::OverlayElement* guiTris = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
		guiTris->setCaption(tris + Ogre::StringConverter::toString(stats.triangleCount));

		Ogre::OverlayElement* guiBatches = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
		guiBatches->setCaption(batches + Ogre::StringConverter::toString(stats.batchCount));

		/////////////////////////
		
		Ogre::Vector3 camPos = m_camera->getPosition();
		Ogre::Quaternion camOri = m_camera->getOrientation();
		Ogre::Vector3 freddyPos = m_sceneNode->getPosition();
		Ogre::Quaternion freddyOri = m_sceneNode->getOrientation();
		
		Ogre::OverlayElement* guiDbg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
		guiDbg->setTop(0);

		Ogre::String message = 
			"Camera Position: x: "+Ogre::StringConverter::toString(camPos.x)+", y: "+Ogre::StringConverter::toString(camPos.y)+", z:"+Ogre::StringConverter::toString(camPos.z) + "\n" + 
			"Camera orientation: yaw: "+Ogre::StringConverter::toString(camOri.getYaw())+", pitch: "+Ogre::StringConverter::toString(camOri.getPitch())+", roll:"+Ogre::StringConverter::toString(camOri.getRoll()) + "\n" + 
			"Freddy position: x: "+Ogre::StringConverter::toString(freddyPos.x)+", y: "+Ogre::StringConverter::toString(freddyPos.y)+", z:"+Ogre::StringConverter::toString(freddyPos.z) + "\n" + 
			"Freddy orientation: yaw: "+Ogre::StringConverter::toString(freddyOri.getYaw())+", pitch: "+Ogre::StringConverter::toString(freddyOri.getPitch())+", roll:"+Ogre::StringConverter::toString(freddyOri.getRoll());
		
		guiDbg->setCaption(message);
		debugWindow->setText("This is a demo!");
	}
	catch(...) { /* ignore */ }
}
Ejemplo n.º 23
0
void TextRenderer::setText(const std::string& ID, const std::string& Text)
{
    Ogre::OverlayElement* textBox = _overlayMgr->getOverlayElement(ID);
    textBox->setCaption(Text);
}
Ejemplo n.º 24
0
void RenderPump::renderOneFrame()
{
    if(!initialized)
    {
        initialized = TRUE;
        roaming.initialize();
    }

    static unsigned long LastTime = root->getTimer()->getMilliseconds();
    unsigned long NowTime = root->getTimer()->getMilliseconds();
    float Elapsed = (NowTime-LastTime)*0.001f;
    LastTime = NowTime;

    roaming.process(Elapsed);
    root->renderOneFrame();

    CMaterialPreviewPage::Current->update(Elapsed);
    ParticlePreviewPage::current->update(Elapsed);
    ResourcePreview::Current->update(Elapsed);
    if(SceneDoc::current != NULL)
    {
        if(debugOverlay && debugOverlay->isVisible())
        {
            static std::string currFps = "Current FPS: ";
            static std::string avgFps = "Average FPS: ";
            static std::string bestFps = "Best FPS: ";
            static std::string worstFps = "Worst FPS: ";
            static std::string tris = "Triangle Count: ";
            static std::string batches = "Batch Count: ";

            Ogre::OverlayElement *guiAvg = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/AverageFps");
            Ogre::OverlayElement *guiCurr = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/CurrFps");
            Ogre::OverlayElement *guiBest = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/BestFps");
            Ogre::OverlayElement *guiWorst = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/WorstFps");

            const Ogre::RenderTarget::FrameStats& stats = SceneDoc::current->getActiveView()->getRenderWindow()->getStatistics();
            guiAvg->setCaption(avgFps + Ogre::StringConverter::toString(stats.avgFPS));
            guiCurr->setCaption(currFps + Ogre::StringConverter::toString(stats.lastFPS));
            guiBest->setCaption(bestFps + Ogre::StringConverter::toString(stats.bestFPS)
                                +" "+Ogre::StringConverter::toString(stats.bestFrameTime)+" ms");
            guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS)
                                 +" "+Ogre::StringConverter::toString(stats.worstFrameTime)+" ms");

            Ogre::OverlayElement* guiTris = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/NumTris");
            guiTris->setCaption(tris + Ogre::StringConverter::toString(stats.triangleCount));

            Ogre::OverlayElement* guiBatches = Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Core/NumBatches");
            guiBatches->setCaption(batches + Ogre::StringConverter::toString(stats.batchCount));
        }
        SceneDoc::current->update(Elapsed);
    }
    if(GameDoc::current != NULL)
        GameDoc::current->update(Elapsed);
}
Ejemplo n.º 25
0
void test()
{
	Ogre::Root* pOgre = new Ogre::Root("", "");

    pOgre->loadPlugin(RENDER_SYSTEM);
	pOgre->setRenderSystem(pOgre->getAvailableRenderers().front());

	pOgre->initialise(false);
	
	Ogre::NameValuePairList lArgs;
	//lArgs["externalWindowHandle"] = bk::format("%d", (bk::uint)l_window.get_handle()).astr;
	Ogre::RenderWindow* pWindow = pOgre->createRenderWindow("Heart|Dockyard", 1024, 768, false, &lArgs);

	Ogre::SceneManager* pSceneManager = pOgre->createSceneManager(Ogre::ST_GENERIC,"SceneManager");
	pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
	pSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
	pSceneManager->setAmbientLight(Ogre::ColourValue(0.1f, 0.1f, 0.1f));

	Ogre::Camera* pCamera = pSceneManager->createCamera("Camera");
	pCamera->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
	pCamera->setPosition(Ogre::Vector3(0.0f, 50.0f, 20.0f));
	pCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f)); 
	pCamera->setNearClipDistance(0.1f);
	pCamera->setFarClipDistance(100.0f);
	Ogre::Viewport* pViewport = pWindow->addViewport(pCamera);
	pViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
	pCamera->setAspectRatio(Ogre::Real(pViewport->getActualWidth()) / Ogre::Real(pViewport->getActualHeight()));

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data/dockyard.zip", "Zip", "Dockyard", true);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	Ogre::MeshManager::getSingleton().createPlane("GroundPlane", "Dockyard", Ogre::Plane(0.0f, 0.0f, 1.0f, 0.0f), 100.0f, 100.0f, 100, 100, true, 1, 3.0f, 3.0f);
	Ogre::Entity* pGroundEntity = pSceneManager->createEntity("GroundPlane");
	pGroundEntity->setMaterialName("Examples/Rockwall");
	pGroundEntity->setCastShadows(false);
	pGroundEntity->getSubEntity(0)->getMaterial()->setShadingMode(Ogre::SO_PHONG);
	Ogre::SceneNode* pGroundNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
	pGroundNode->attachObject(pGroundEntity);

	Ogre::Entity* pCubeEntity = pSceneManager->createEntity("Cube", Ogre::SceneManager::PT_CUBE);
	pCubeEntity->setMaterialName("Examples/10PointBlock");
	pCubeEntity->setCastShadows(true);
	Ogre::SceneNode* pCubeNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
	pCubeNode->attachObject(pCubeEntity);
	pCubeNode->setPosition(0.0f, 0.0f, 5.f);
	pCubeNode->setScale(0.1f, 0.1f, 0.1f);

	Ogre::ColourValue lColour1(1.0f, 1.0f, 1.0f);
	Ogre::ColourValue lColour2(1.0f, 1.0f, 1.0f);
	Ogre::ColourValue lColour3(1.0f, 1.0f, 1.0f);
	Ogre::Light* pLight1 = pSceneManager->createLight();
	pLight1->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight1->setPosition(30.0f, 30.0f, 30.0f);
	pLight1->setDirection(-1.0f, -1.0f, -1.0f);
	pLight1->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight1->setDiffuseColour(lColour1 * 0.5f);
	Ogre::Light* pLight2 = pSceneManager->createLight();
	pLight2->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight2->setPosition(-30.0f, 30.0f, 30.0f);
	pLight2->setDirection(1.0f, -1.0f, -1.0f);
	pLight2->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight2->setDiffuseColour(lColour2 * 0.5f);
	Ogre::Light* pLight3 = pSceneManager->createLight();
	pLight3->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight3->setPosition(30.0f, -30.0f, 30.0f);
	pLight3->setDirection(-1.0f, 1.0f, -1.0f);
	pLight3->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight3->setDiffuseColour(lColour3 * 0.5f);

	Ogre::Overlay* pMenuOverlay = Ogre::OverlayManager::getSingleton().create("Menu");
	Ogre::OverlayElement* pMenu = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Menu");
    pMenu->setMetricsMode(Ogre::GMM_PIXELS);
    pMenu->setWidth(200);
    pMenu->setHeight(200);
    pMenu->setTop(30);
    pMenu->setLeft(30);
    pMenu->setMaterialName("Examples/BumpyMetal");
	if (pMenu->isContainer()) pMenuOverlay->add2D(static_cast<Ogre::OverlayContainer*>(pMenu));
	pMenuOverlay->show();

	pOgre->startRendering();
}
Ejemplo n.º 26
0
void FrameListener::setGuiCaption(std::string elementName, std::string text) {
	Ogre::OverlayElement *element = Ogre::OverlayManager::getSingleton().getOverlayElement(elementName, false);
	element->setCaption(text);
}
Ejemplo n.º 27
0
void updateOverlay()
{
	const verve::Agent* a = gRobot->getAgent();

	Ogre::OverlayElement* overlayElement = 
		Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/PrimaryReward");
	overlayElement->setCaption("Primary Reward: " + 
		Ogre::StringConverter::toString(a->getDebugData().reward, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/ValueEstimation");
	overlayElement->setCaption("Value Estimation: " + 
		Ogre::StringConverter::toString(a->getDebugData().valueEstimation, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/TDError");
	overlayElement->setCaption("TD Error: " + 
		Ogre::StringConverter::toString(a->getDebugData().TDError, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/CuriosityReward");
	overlayElement->setCaption("Curiosity Reward: " + 
		Ogre::StringConverter::toString(a->getDebugData().curiosityReward, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/Uncertainty");
	overlayElement->setCaption("Uncertainty Estimation: " + 
		Ogre::StringConverter::toString(
		a->getDebugData().predictionUncertaintyEstimation, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/ModelError");
	overlayElement->setCaption("Model Error: " + 
		Ogre::StringConverter::toString(a->getDebugData().modelPredictionError, 4));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/PlanLength");
	overlayElement->setCaption("Plan Length: " + 
		Ogre::StringConverter::toString(a->getDebugData().planLength));

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/Age");
	overlayElement->setCaption("Age: " + a->getAgeString());

	overlayElement = Ogre::OverlayManager::getSingleton().getOverlayElement(
		"Verve/Debug/Action");
	overlayElement->setCaption("Action: " + gRobot->getCurrentActionName());

	for (unsigned int i = 0; i < a->getNumContinuousSensors(); ++i)
	{
		Ogre::String sensorNumStr = Ogre::StringConverter::toString(i);
		Ogre::String label = "Sensor " + sensorNumStr;
		Ogre::OverlayElement* sensorElement = 
			Ogre::OverlayManager::getSingleton().getOverlayElement(
			"Verve/Debug/Sensor" + sensorNumStr);
		const verve::real* sensorData = gRobot->getContinuousInputs();
		sensorElement->setCaption(label + ": " + 
			Ogre::StringConverter::toString(sensorData[i], 4));
	}
}
Ejemplo n.º 28
0
bool MyFrameListener::frameStarted(const Ogre::FrameEvent& evt) {
  Ogre::Vector3 vt(0,0,0);     Ogre::Real tSpeed = 20.0;  
  Ogre::Real r = 0;
  Ogre::Real deltaT = evt.timeSinceLastFrame;
  int fps = 1.0 / deltaT;

  _keyboard->capture();
  if(_keyboard->isKeyDown(OIS::KC_ESCAPE)) return false;
  if(_keyboard->isKeyDown(OIS::KC_UP))    vt+=Ogre::Vector3(0,0,-1);
  if(_keyboard->isKeyDown(OIS::KC_DOWN))  vt+=Ogre::Vector3(0,0,1);
  if(_keyboard->isKeyDown(OIS::KC_LEFT))  vt+=Ogre::Vector3(-1,0,0);
  if(_keyboard->isKeyDown(OIS::KC_RIGHT)) vt+=Ogre::Vector3(1,0,0);
  if(_keyboard->isKeyDown(OIS::KC_W))   vt+=Ogre::Vector3(0,0,-1);
  if(_keyboard->isKeyDown(OIS::KC_S))   vt+=Ogre::Vector3(0,0,1);
  if(_keyboard->isKeyDown(OIS::KC_A))   vt+=Ogre::Vector3(-1,0,0);
  if(_keyboard->isKeyDown(OIS::KC_D))   vt+=Ogre::Vector3(1,0,0);

  if(_keyboard->isKeyDown(OIS::KC_1)) {
    _sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE);
    _shadowInfo = "TEXTURE_MODULATIVE";
    _pMyApp->getSoundFXPtr()->play();
  }

  if(_keyboard->isKeyDown(OIS::KC_2)) {
    _sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
    _shadowInfo = "STENCIL_MODULATIVE";
    _pMyApp->getSoundFXPtr()->play();
  }

  Ogre::Entity *ent = static_cast <Ogre::Entity *> (_node->getAttachedObject("Neptuno"));
  if(_keyboard->isKeyDown(OIS::KC_7)) {
    ent->setMaterialName("Material");  
    _materialInfo = "MaterialBase";
  }
  if(_keyboard->isKeyDown(OIS::KC_8)) {
    ent->setMaterialName("MaterialAO");  
    _materialInfo = "MaterialAO";
  }
  if(_keyboard->isKeyDown(OIS::KC_9)) {
    ent->setMaterialName("MaterialTex");  
    _materialInfo = "MaterialTex";
  }
  if(_keyboard->isKeyDown(OIS::KC_0)) {
    ent->setMaterialName("MaterialAOTex");
    _materialInfo = "MaterialAOTex";
  }  
  
  _camera->moveRelative(vt * deltaT * tSpeed);
  if (_camera->getPosition().length() < 10.0) {
    _camera->moveRelative(-vt * deltaT * tSpeed);
  }


  if(_keyboard->isKeyDown(OIS::KC_E)) r+=180;
  if(_keyboard->isKeyDown(OIS::KC_Q)) r-=180;
  _node->yaw(Ogre::Degree(r * deltaT));
  
  _mouse->capture();
  float rotx = _mouse->getMouseState().X.rel * deltaT * -1;
  float roty = _mouse->getMouseState().Y.rel * deltaT * -1;
  _camera->yaw(Ogre::Radian(rotx));
  _camera->pitch(Ogre::Radian(roty));

  Ogre::OverlayElement *oe;
  oe = _overlayManager->getOverlayElement("fpsInfo");
  oe->setCaption(Ogre::StringConverter::toString(fps));

  oe = _overlayManager->getOverlayElement("shadowInfo");
  oe->setCaption(_shadowInfo);

  oe = _overlayManager->getOverlayElement("materialInfo");
  oe->setCaption(_materialInfo);


  return true;
}
Ejemplo n.º 29
0
	void TextRenderer::SetText(const std::string &id, const std::string &text)
	{
		Ogre::OverlayElement* textBox = m_overlayMgr->getOverlayElement(id);
		textBox->setCaption(text);
	}