Beispiel #1
0
void PendulumTest::handleInput(opal::real elapsedRealTime, 
	const SimulationEngine& engine)
{
	OIS::Keyboard* keyboard = engine.getKeyboard();

	// This variable can be used to keep keys from repeating too fast.
	static Ogre::Real toggleTimer = 0;
	if (toggleTimer >= 0)
	{
		toggleTimer -= elapsedRealTime;
	}

	// Toggle GUI.
	if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
	{
		Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
			getByName("Verve/TrialNumber");

		if (debugOverlay->isVisible())
        {
			debugOverlay->hide();
			mAgentDebugger->setDisplayEnabled(false);
		}
		else
		{
			debugOverlay->show();
			mAgentDebugger->setDisplayEnabled(true);
		}

		toggleTimer = 0.5;
	}
}
void FrameListener::showDebugOverlay(bool show) {
	Ogre::Overlay *overlay = Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay");
	if (show)
		overlay->show();
	else
		overlay->hide();
}
Beispiel #3
0
    void fade(Ogre::Real tpf) {
        if (m_eFadeOperation != FADE_NONE && m_pTextUnitState) {
            m_pTextUnitState->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_TEXTURE, m_fAlpha);

            if (m_eFadeOperation == FADE_IN) {
                m_fCurrentDuration -= tpf;
                m_fAlpha = m_fCurrentDuration / m_fTotalDuration;
                if (m_fAlpha < 0.0) {
                    m_pOverlay->hide();
                    m_eFadeOperation = FADE_NONE;
                    if (m_pFaderCallback) {
                        m_pFaderCallback->fadeInCallback();
                    }
                }
            }
            else if (m_eFadeOperation == FADE_OUT) {
                m_fCurrentDuration += tpf;
                m_fAlpha = m_fCurrentDuration / m_fTotalDuration;
                if (m_fAlpha > 1.0) {
                    m_eFadeOperation = FADE_NONE;
                    if (m_pFaderCallback) {
                        m_pFaderCallback->fadeOutCallback();
                    }
                }
            }
        }
#ifdef USE_SPRITE_SHADER
        m_SpritePixelShaderParameters->setNamedConstant("colour", Ogre::ColourValue(1, 1, 1, m_fAlpha));
#endif
    }
Beispiel #4
0
 void setVisible(bool bShow) {
     if (bShow) {
         m_pOverlay->show();
     }
     else {
         m_pOverlay->hide();
     }
 }
Beispiel #5
0
void Menu::hideDialogue()
{
  Ogre::OverlayManager* olMgr =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 (olMgr==NULL) return;
  Ogre::Overlay* ol = olMgr->getByName(cDialogueOverlay);
  if (ol!=NULL)
  {
    ol->hide();
  }
}
Beispiel #6
0
void MenuState::exit ()
{
//	delete _fader;
	// musica del menu STOP
	IntroState::getSingleton().getMenuTrackPtr()->stop();

	CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().hide();
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->hide();
	Ogre::Overlay *overlay = _overlayManager->getByName("Menu");
	overlay->hide();
	_sceneMgr->clearScene();
	_root->getAutoCreatedWindow()->removeAllViewports();
}
Beispiel #7
0
    void init() {
        Ogre::MaterialPtr matptr = Ogre::MaterialManager::getSingleton().getByName("FadeMaterial");
#ifdef USE_SPRITE_SHADER
        CShaderManager::getSingleton().addAlphaBlendTextureShader(matptr);
        Ogre::Pass *pPass = matptr->getTechnique(0)->getPass(0);
        m_SpritePixelShaderParameters = pPass->getFragmentProgram()->createParameters();
        m_SpriteVertexShaderParameters = pPass->getVertexProgram()->createParameters();
        pPass->setFragmentProgramParameters(m_SpritePixelShaderParameters);
        pPass->setVertexProgramParameters(m_SpriteVertexShaderParameters);
#endif
        m_pTextUnitState = matptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
        m_pOverlay = Ogre::OverlayManager::getSingleton().getByName("FadeOverlay");
        m_pOverlay->hide();
    }
Beispiel #8
0
  CAlphaFader(CFaderCallback *pCallback = NULL)
    :
    m_fAlpha(0),
    m_fCurrentDuration(0),
    m_fTotalDuration(0),
    m_pFaderCallback(pCallback),
    m_eFadeOperation(FADE_NONE) {
    Ogre::MaterialPtr matptr = Ogre::MaterialManager::getSingleton().getByName("FadeMaterial");
#ifdef USE_SPRITE_SHADER
    CShaderManager::getSingleton().addAlphaBlendTextureShader(matptr);
    Ogre::Pass *pPass = matptr->getTechnique(0)->getPass(0);
    m_SpritePixelShaderParameters = pPass->getFragmentProgram()->createParameters();
    m_SpriteVertexShaderParameters = pPass->getVertexProgram()->createParameters();
    pPass->setFragmentProgramParameters(m_SpritePixelShaderParameters);
    pPass->setVertexProgramParameters(m_SpriteVertexShaderParameters);
#endif
    m_pTextUnitState = matptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
    m_pOverlay = Ogre::OverlayManager::getSingleton().getByName("FadeOverlay");
    m_pOverlay->hide();
  }
Beispiel #9
0
void handleInput(Ogre::Real elapsedRealTime)
{
	// This variable can be used to keep keys from repeating too fast.
	static Ogre::Real toggleTimer = 0;
	if (toggleTimer >= 0)
	{
		toggleTimer -= elapsedRealTime;
	}

	OIS::Keyboard* keyboard = gEngine.getKeyboard();

	if (keyboard->isKeyDown(OIS::KC_W))
	{
		gCar->forward();
	}
	else if (keyboard->isKeyDown(OIS::KC_S))
	{
		gCar->reverse();
	}
	else
	{
		gCar->idle();
	}

	if (keyboard->isKeyDown(OIS::KC_A))
	{
		gCar->setSteering(-1);
	}
	else if (keyboard->isKeyDown(OIS::KC_D))
	{
		gCar->setSteering(1);
	}
	else
	{
		gCar->setSteering(0);
	}

	// If available, get data from the game controller.
	if (gGamePad)
	{
		// Update the game controller state.
		SDL_JoystickUpdate();

		Ogre::Real joy0X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 0) / 
			(Ogre::Real)32768;
		Ogre::Real joy0Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 1) / 
			(Ogre::Real)32768;
		Ogre::Real joy1X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 4) / 
			(Ogre::Real)32768;
		Ogre::Real joy1Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 3) / 
			(Ogre::Real)32768;

		if (fabs(joy0Y) > 0.1)
		{
			gCar->setThrottle(-joy0Y);
		}
		else
		{
			gCar->idle();
		}

		if (fabs(joy0X) > 0.1)
		{
			gCar->setSteering(joy0X);
		}
		else
		{
			gCar->setSteering(0);
		}

		if (joy1X > 0.2 || joy1X < -0.2)
		{
			Ogre::Degree rotAroundY = -Ogre::Degree(joy1X);
			gEngine.getCamera()->yawRelative(rotAroundY.valueDegrees());
		}

		if (joy1Y > 0.2 || joy1Y < -0.2)
		{
			Ogre::Degree rotAroundX = -Ogre::Degree(joy1Y);
			gEngine.getCamera()->pitchRelative(rotAroundX.valueDegrees());
		}
	}

	// Toggle GUI.
	if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
	{
		Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
			getByName("Verve/Debug");

		if (debugOverlay->isVisible())
        {
			debugOverlay->hide();
			gAgentDebugger->setDisplayEnabled(false);
		}
		else
		{
			debugOverlay->show();
			gAgentDebugger->setDisplayEnabled(true);
		}

		toggleTimer = 0.5;
	}
}