//------------------------------------------------------------------------------ void Background2D::InputDebug( const Event& event ) { if( cv_background2d_manual.GetB() == true ) { if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_W ) { m_PositionReal.y += 2; } else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_A ) { m_PositionReal.x += 2; } else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_S ) { m_PositionReal.y -= 2; } else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_D ) { m_PositionReal.x -= 2; } CameraManager::getSingleton().Set2DScroll( m_PositionReal ); } }
//------------------------------------------------------------------------------ void Background2D::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation ) { if( cv_show_background2d.GetB() == false ) { return; } if( queueGroupId == Ogre::RENDER_QUEUE_MAIN ) { m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY ); m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY ); Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() ); float width = viewport->getActualWidth(); float height = viewport->getActualHeight(); Ogre::Matrix4 view; view.makeTrans( Ogre::Vector3( m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0 ) ); m_RenderSystem->_setViewMatrix( view ); if( m_AlphaRenderOp.vertexData->vertexCount != 0 ) { m_SceneManager->_setPass( m_AlphaMaterial->getTechnique( 0 )->getPass( 0 ), true, false ); m_RenderSystem->_render( m_AlphaRenderOp ); } if( m_AddRenderOp.vertexData->vertexCount != 0 ) { m_SceneManager->_setPass( m_AddMaterial->getTechnique( 0 )->getPass( 0 ), true, false ); m_RenderSystem->_render( m_AddRenderOp ); } } }
//------------------------------------------------------------------------------ void Background2D::applyScroll() { if( cv_background2d_manual.GetB() != true ) { m_PositionReal = GetScreenScroll(); CameraManager::getSingleton().Set2DScroll( m_PositionReal ); } }
bool GameFrameListener::frameEnded( const Ogre::FrameEvent& evt ) { if( cv_debug_fps.GetB() == true ) { const Ogre::RenderTarget::FrameStats& stats = m_Window->getStatistics(); DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT ); DEBUG_DRAW.SetScreenSpace( true ); DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) ); DEBUG_DRAW.Text( 10, 10, "Current FPS:" + Ogre::StringConverter::toString( stats.lastFPS ) ); } return true; }
//------------------------------------------------------------------------------ void Background2D::UpdateDebug() { // is this necessary? does it cost to apply camera 2d Scroll? // if so maybe move this check to applyScroll if( m_PositionReal != GetScreenScroll() ) { applyScroll(); } if( cv_debug_background2d.GetB() == true ) { DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT ); DEBUG_DRAW.SetScreenSpace( true ); DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.0, 0.8, 0.8, 1 ) ); for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i ) { DEBUG_DRAW.Text( 150, 34 + i * 12, "Background 2D animation: " + m_AnimationPlayed[ i ].name ); } } }