|
|
@@ -10,76 +10,74 @@
|
|
|
#include "core/Logger.h"
|
|
|
#include "core/Timer.h"
|
|
|
|
|
|
-//------------------------------------------------------------------------------
|
|
|
|
|
|
-ConfigVar cv_debug_background2d( "debug_background2d", "Draw background debug info", "false" );
|
|
|
-ConfigVar cv_show_background2d( "show_background2d", "Draw background", "true" );
|
|
|
-ConfigVar cv_background2d_manual( "background2d_manual", "Manual scrolling for 2d background", "false" );
|
|
|
+ConfigVar cv_debug_background2d("debug_background2d", "Draw background debug info", "false");
|
|
|
+ConfigVar cv_show_background2d("show_background2d", "Draw background", "true");
|
|
|
+ConfigVar cv_background2d_manual("background2d_manual", "Manual scrolling for 2d background", "false");
|
|
|
+
|
|
|
|
|
|
-//------------------------------------------------------------------------------
|
|
|
Background2D::Background2D():
|
|
|
- m_AlphaMaxVertexCount( 0 ),
|
|
|
- m_AddMaxVertexCount( 0 ),
|
|
|
-
|
|
|
- m_ScrollEntity( NULL ),
|
|
|
- m_ScrollPositionStart( Ogre::Vector2::ZERO ),
|
|
|
- m_ScrollPositionEnd( Ogre::Vector2::ZERO ),
|
|
|
- m_ScrollType( Background2D::NONE ),
|
|
|
- m_ScrollSeconds( 0 ),
|
|
|
- m_ScrollCurrentSeconds( 0 ),
|
|
|
- m_Position( Ogre::Vector2::ZERO ),
|
|
|
- m_PositionReal( Ogre::Vector2::ZERO )
|
|
|
-
|
|
|
- ,m_range( Ogre::AxisAlignedBox::BOX_INFINITE )
|
|
|
+ m_AlphaMaxVertexCount(0),
|
|
|
+ m_AddMaxVertexCount(0),
|
|
|
+
|
|
|
+ m_ScrollEntity(NULL),
|
|
|
+ m_ScrollPositionStart(Ogre::Vector2::ZERO),
|
|
|
+ m_ScrollPositionEnd(Ogre::Vector2::ZERO),
|
|
|
+ m_ScrollType(Background2D::NONE),
|
|
|
+ m_ScrollSeconds(0),
|
|
|
+ m_ScrollCurrentSeconds(0),
|
|
|
+ m_Position(Ogre::Vector2::ZERO),
|
|
|
+ m_PositionReal(Ogre::Vector2::ZERO),
|
|
|
+ m_range(Ogre::AxisAlignedBox::BOX_INFINITE),
|
|
|
// for ffvii
|
|
|
- ,m_virtual_screen_size( 320, 240 )
|
|
|
+ m_virtual_screen_size(320, 240)
|
|
|
{
|
|
|
- m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
|
|
|
+ m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
|
|
|
m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
|
|
|
|
|
|
CreateVertexBuffers();
|
|
|
|
|
|
- m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAlpha", "General" );
|
|
|
- Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
|
|
|
- pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
|
|
|
- pass->setCullingMode( Ogre::CULL_NONE );
|
|
|
- pass->setDepthCheckEnabled( true );
|
|
|
- pass->setDepthWriteEnabled( true );
|
|
|
- pass->setLightingEnabled( false );
|
|
|
- pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
|
|
|
- pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
|
|
|
- pass->setAlphaRejectValue( 0 );
|
|
|
+ m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create("Background2DAlpha", "General");
|
|
|
+ Ogre::Pass* pass = m_AlphaMaterial->getTechnique(0)->getPass(0);
|
|
|
+ pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
|
|
|
+ pass->setCullingMode(Ogre::CULL_NONE);
|
|
|
+ pass->setDepthCheckEnabled(true);
|
|
|
+ pass->setDepthWriteEnabled(true);
|
|
|
+ pass->setLightingEnabled(false);
|
|
|
+ pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
|
|
|
+ pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
|
|
|
+ pass->setAlphaRejectValue(0);
|
|
|
Ogre::TextureUnitState* tex = pass->createTextureUnitState();
|
|
|
- tex->setTextureName( "system/blank.png" );
|
|
|
- tex->setNumMipmaps( -1 );
|
|
|
- tex->setTextureFiltering( Ogre::TFO_NONE );
|
|
|
-
|
|
|
- m_AddMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAdd", "General" );
|
|
|
- pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
|
|
|
- pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
|
|
|
- pass->setCullingMode( Ogre::CULL_NONE );
|
|
|
- pass->setDepthCheckEnabled( true );
|
|
|
- pass->setDepthWriteEnabled( true );
|
|
|
- pass->setLightingEnabled( false );
|
|
|
- pass->setSceneBlending( Ogre::SBT_ADD );
|
|
|
- pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
|
|
|
- pass->setAlphaRejectValue( 0 );
|
|
|
+ tex->setTextureName("system/blank.png");
|
|
|
+ tex->setNumMipmaps(-1);
|
|
|
+ tex->setTextureFiltering(Ogre::TFO_NONE);
|
|
|
+
|
|
|
+ m_AddMaterial = Ogre::MaterialManager::getSingleton().create("Background2DAdd", "General");
|
|
|
+ pass = m_AddMaterial->getTechnique(0)->getPass(0);
|
|
|
+ pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
|
|
|
+ pass->setCullingMode(Ogre::CULL_NONE);
|
|
|
+ pass->setDepthCheckEnabled(true);
|
|
|
+ pass->setDepthWriteEnabled(true);
|
|
|
+ pass->setLightingEnabled(false);
|
|
|
+ pass->setSceneBlending(Ogre::SBT_ADD);
|
|
|
+ pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
|
|
|
+ pass->setAlphaRejectValue(0);
|
|
|
tex = pass->createTextureUnitState();
|
|
|
- tex->setTextureName( "system/blank.png" );
|
|
|
- tex->setNumMipmaps( -1 );
|
|
|
- tex->setTextureFiltering( Ogre::TFO_NONE );
|
|
|
+ tex->setTextureName("system/blank.png");
|
|
|
+ tex->setNumMipmaps(-1);
|
|
|
+ tex->setTextureFiltering(Ogre::TFO_NONE);
|
|
|
|
|
|
- m_SceneManager->addRenderQueueListener( this );
|
|
|
+ m_SceneManager->addRenderQueueListener(this);
|
|
|
}
|
|
|
|
|
|
|
|
|
Background2D::~Background2D()
|
|
|
{
|
|
|
- m_SceneManager->removeRenderQueueListener( this );
|
|
|
+ m_SceneManager->removeRenderQueueListener(this);
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_Animations.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_Animations.size(); ++i)
|
|
|
{
|
|
|
- delete m_Animations[ i ];
|
|
|
+ delete m_Animations[i];
|
|
|
}
|
|
|
|
|
|
DestroyVertexBuffers();
|
|
|
@@ -89,7 +87,7 @@ Background2D::~Background2D()
|
|
|
void
|
|
|
Background2D::InputDebug(const QGears::Event& event)
|
|
|
{
|
|
|
- if( cv_background2d_manual.GetB() == true )
|
|
|
+ if(cv_background2d_manual.GetB() == true)
|
|
|
{
|
|
|
if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_W)
|
|
|
{
|
|
|
@@ -108,7 +106,7 @@ Background2D::InputDebug(const QGears::Event& event)
|
|
|
m_PositionReal.x -= 2;
|
|
|
}
|
|
|
|
|
|
- CameraManager::getSingleton().Set2DScroll( m_PositionReal );
|
|
|
+ CameraManager::getSingleton().Set2DScroll(m_PositionReal);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -116,55 +114,55 @@ Background2D::InputDebug(const QGears::Event& event)
|
|
|
void
|
|
|
Background2D::Update()
|
|
|
{
|
|
|
- for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
|
|
|
{
|
|
|
for( unsigned int j = 0; j < m_Animations.size(); ++j )
|
|
|
{
|
|
|
- if( m_Animations[ j ]->GetName() == m_AnimationPlayed[ i ].name )
|
|
|
+ if( m_Animations[j]->GetName() == m_AnimationPlayed[i].name)
|
|
|
{
|
|
|
float delta_time = Timer::getSingleton().GetGameTimeDelta();
|
|
|
- float time = m_Animations[ j ]->GetTime();
|
|
|
- float end_time = m_Animations[ j ]->GetLength();
|
|
|
+ float time = m_Animations[j]->GetTime();
|
|
|
+ float end_time = m_Animations[j]->GetLength();
|
|
|
|
|
|
// if animation ended
|
|
|
- if( time + delta_time >= end_time )
|
|
|
+ if(time + delta_time >= end_time)
|
|
|
{
|
|
|
// set to last frame of animation
|
|
|
- if( time != end_time )
|
|
|
+ if(time != end_time)
|
|
|
{
|
|
|
- m_Animations[ j ]->SetTime( end_time );
|
|
|
+ m_Animations[j]->SetTime(end_time);
|
|
|
}
|
|
|
|
|
|
- if( m_AnimationPlayed[ i ].state == Background2DAnimation::ONCE )
|
|
|
+ if(m_AnimationPlayed[i].state == Background2DAnimation::ONCE)
|
|
|
{
|
|
|
- for( unsigned int k = 0; k < m_AnimationPlayed[ i ].sync.size(); ++k )
|
|
|
+ for(unsigned int k = 0; k < m_AnimationPlayed[i].sync.size(); ++k)
|
|
|
{
|
|
|
- ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationPlayed[ i ].sync[ k ] );
|
|
|
+ ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationPlayed[i].sync[k]);
|
|
|
}
|
|
|
- m_AnimationPlayed[ i ].sync.clear();
|
|
|
- m_AnimationPlayed[ i ].name = ""; // mark to erase this way
|
|
|
+ m_AnimationPlayed[i].sync.clear();
|
|
|
+ m_AnimationPlayed[i].name = ""; // mark to erase this way
|
|
|
}
|
|
|
else // LOOPED
|
|
|
{
|
|
|
// in case of looped we need to sync with end
|
|
|
- m_Animations[ j ]->SetTime( time + delta_time - end_time );
|
|
|
+ m_Animations[j]->SetTime(time + delta_time - end_time);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_Animations[ j ]->AddTime( delta_time );
|
|
|
+ m_Animations[j]->AddTime(delta_time);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// remove stopped animations
|
|
|
- std::vector< AnimationPlayed >::iterator i = m_AnimationPlayed.begin();
|
|
|
- for( ; i != m_AnimationPlayed.end(); )
|
|
|
+ std::vector<AnimationPlayed>::iterator i = m_AnimationPlayed.begin();
|
|
|
+ for(; i != m_AnimationPlayed.end();)
|
|
|
{
|
|
|
- if( ( *i ).name == "" )
|
|
|
+ if((*i).name == "")
|
|
|
{
|
|
|
- i = m_AnimationPlayed.erase( i );
|
|
|
+ i = m_AnimationPlayed.erase(i);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -177,30 +175,30 @@ Background2D::Update()
|
|
|
void
|
|
|
Background2D::UpdateDebug()
|
|
|
{
|
|
|
- // is this necessary? does it cost to apply camera 2d Scroll?
|
|
|
+ // TODO: is this necessary? does it cost to apply camera 2d Scroll?
|
|
|
// if so maybe move this check to applyScroll
|
|
|
- if( m_PositionReal != GetScreenScroll() )
|
|
|
+ if(m_PositionReal != GetScreenScroll())
|
|
|
{
|
|
|
applyScroll();
|
|
|
}
|
|
|
|
|
|
- if( cv_debug_background2d.GetB() == true )
|
|
|
+ if(cv_debug_background2d.GetB() == true)
|
|
|
{
|
|
|
- DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
|
|
|
- DEBUG_DRAW.SetScreenSpace( true );
|
|
|
- DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.0f, 0.8f, 0.8f, 1.0f ) );
|
|
|
- for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
|
|
|
+ DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
|
|
|
+ DEBUG_DRAW.SetScreenSpace(true);
|
|
|
+ DEBUG_DRAW.SetColour(Ogre::ColourValue(0.0f, 0.8f, 0.8f, 1.0f));
|
|
|
+ for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
|
|
|
{
|
|
|
- DEBUG_DRAW.Text( 150.0f, static_cast<float>(34 + i * 12), "Background 2D animation: " + m_AnimationPlayed[ i ].name );
|
|
|
+ DEBUG_DRAW.Text(150.0f, static_cast<float>(34 + i * 12), "Background 2D animation: " + m_AnimationPlayed[i].name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::calculateScreenScale( void )
|
|
|
+Background2D::calculateScreenScale()
|
|
|
{
|
|
|
- Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
|
|
|
+ Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
|
|
|
Ogre::Real scale_width = static_cast<Ogre::Real>(viewport->getActualWidth());
|
|
|
Ogre::Real scale_height = static_cast<Ogre::Real>(viewport->getActualHeight());
|
|
|
|
|
|
@@ -218,18 +216,18 @@ Background2D::OnResize()
|
|
|
{
|
|
|
calculateScreenScale();
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_Tiles.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_Tiles.size(); ++i)
|
|
|
{
|
|
|
- Tile &tile( m_Tiles[ i ] );
|
|
|
+ Tile &tile(m_Tiles[ i ]);
|
|
|
Ogre::Vector2 top_left(static_cast<Ogre::Real>(tile.x), static_cast<Ogre::Real>(- tile.y));
|
|
|
Ogre::Vector2 top_right(static_cast<Ogre::Real>(tile.x + tile.width), static_cast<Ogre::Real>(top_left.y));
|
|
|
Ogre::Vector2 bottom_right(static_cast<Ogre::Real>(top_right.x), static_cast<Ogre::Real>(-(tile.y + tile.height)));
|
|
|
Ogre::Vector2 bottom_left(static_cast<Ogre::Real>(top_left.x), static_cast<Ogre::Real>(bottom_right.y));
|
|
|
|
|
|
- virtualScreenToWorldSpace( top_left );
|
|
|
- virtualScreenToWorldSpace( top_right );
|
|
|
- virtualScreenToWorldSpace( bottom_right );
|
|
|
- virtualScreenToWorldSpace( bottom_left );
|
|
|
+ virtualScreenToWorldSpace(top_left);
|
|
|
+ virtualScreenToWorldSpace(top_right);
|
|
|
+ virtualScreenToWorldSpace(bottom_right);
|
|
|
+ virtualScreenToWorldSpace(bottom_left);
|
|
|
|
|
|
float new_x1 = top_left.x;
|
|
|
float new_y1 = top_left.y;
|
|
|
@@ -245,18 +243,18 @@ Background2D::OnResize()
|
|
|
|
|
|
Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
|
|
|
|
|
|
- if( m_Tiles[ i ].blending == QGears::B_ALPHA )
|
|
|
+ if(m_Tiles[i].blending == QGears::B_ALPHA)
|
|
|
{
|
|
|
vertex_buffer = m_AlphaVertexBuffer;
|
|
|
}
|
|
|
- else if( m_Tiles[ i ].blending == QGears::B_ADD )
|
|
|
+ else if(m_Tiles[i].blending == QGears::B_ADD )
|
|
|
{
|
|
|
vertex_buffer = m_AddVertexBuffer;
|
|
|
}
|
|
|
|
|
|
- float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
|
|
|
+ float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
|
|
|
|
|
|
- writeIterator += m_Tiles[ i ].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
|
|
|
+ writeIterator += m_Tiles[i].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
|
|
|
|
|
|
*writeIterator++ = new_x1;
|
|
|
*writeIterator++ = new_y1;
|
|
|
@@ -303,17 +301,17 @@ Background2D::Clear()
|
|
|
m_range = Ogre::AxisAlignedBox::BOX_INFINITE;
|
|
|
UnsetScroll();
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_Animations.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_Animations.size(); ++i)
|
|
|
{
|
|
|
- delete m_Animations[ i ];
|
|
|
+ delete m_Animations[i];
|
|
|
}
|
|
|
m_Animations.clear();
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
|
|
|
{
|
|
|
- for( unsigned int j = 0; j < m_AnimationPlayed[ i ].sync.size(); ++j )
|
|
|
+ for(unsigned int j = 0; j < m_AnimationPlayed[i].sync.size(); ++j)
|
|
|
{
|
|
|
- ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationPlayed[ i ].sync[ j ] );
|
|
|
+ ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationPlayed[i].sync[j]);
|
|
|
}
|
|
|
}
|
|
|
m_AnimationPlayed.clear();
|
|
|
@@ -325,7 +323,7 @@ Background2D::Clear()
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::ScriptAutoScrollToEntity( Entity* entity )
|
|
|
+Background2D::ScriptAutoScrollToEntity(Entity* entity)
|
|
|
{
|
|
|
m_ScrollEntity = entity;
|
|
|
}
|
|
|
@@ -339,17 +337,17 @@ Background2D::GetAutoScrollEntity() const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::ScriptScrollToPosition( const float x, const float y, const ScrollType type, const float seconds )
|
|
|
+Background2D::ScriptScrollToPosition(const float x, const float y, const ScrollType type, const float seconds)
|
|
|
{
|
|
|
- LOG_TRIVIAL( "[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString( Ogre::Vector2( x, y ) ) + "\"." );
|
|
|
+ LOG_TRIVIAL("[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString(Ogre::Vector2(x, y)) + "\".");
|
|
|
|
|
|
- Ogre::Vector2 position = Ogre::Vector2( x, y );
|
|
|
+ Ogre::Vector2 position = Ogre::Vector2(x, y);
|
|
|
|
|
|
m_ScrollEntity = NULL;
|
|
|
|
|
|
- if( type == Background2D::NONE )
|
|
|
+ if(type == Background2D::NONE)
|
|
|
{
|
|
|
- SetScroll( position );
|
|
|
+ SetScroll(position);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -366,9 +364,9 @@ Background2D::ScriptScrollSync()
|
|
|
{
|
|
|
ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
|
|
|
|
|
|
- LOG_TRIVIAL( "[SCRIPT] Wait Background2d scroll for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
|
|
|
+ LOG_TRIVIAL("[SCRIPT] Wait Background2d scroll for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
|
|
|
|
|
|
- m_ScrollSync.push_back( script );
|
|
|
+ m_ScrollSync.push_back(script);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
@@ -378,9 +376,9 @@ Background2D::UnsetScroll()
|
|
|
{
|
|
|
m_ScrollType = Background2D::NONE;
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_ScrollSync.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_ScrollSync.size(); ++i)
|
|
|
{
|
|
|
- ScriptManager::getSingleton().ContinueScriptExecution( m_ScrollSync[ i ] );
|
|
|
+ ScriptManager::getSingleton().ContinueScriptExecution(m_ScrollSync[i]);
|
|
|
}
|
|
|
m_ScrollSync.clear();
|
|
|
}
|
|
|
@@ -415,7 +413,7 @@ Background2D::GetScrollSeconds() const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetScrollCurrentSeconds( const float seconds )
|
|
|
+Background2D::SetScrollCurrentSeconds(const float seconds)
|
|
|
{
|
|
|
m_ScrollCurrentSeconds = seconds;
|
|
|
}
|
|
|
@@ -429,26 +427,26 @@ Background2D::GetScrollCurrentSeconds() const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetScreenScroll( const Ogre::Vector2& position )
|
|
|
+Background2D::SetScreenScroll(const Ogre::Vector2& position)
|
|
|
{
|
|
|
- SetScroll( position / m_screen_scale );
|
|
|
+ SetScroll(position / m_screen_scale);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetScroll( const Ogre::Vector2& position )
|
|
|
+Background2D::SetScroll(const Ogre::Vector2& position)
|
|
|
{
|
|
|
m_Position = position;
|
|
|
- Ogre::Vector3 pos_3d( m_Position.x, m_Position.y, 0 );
|
|
|
+ Ogre::Vector3 pos_3d(m_Position.x, m_Position.y, 0);
|
|
|
|
|
|
- if( !m_range.contains( pos_3d ) )
|
|
|
+ if( !m_range.contains(pos_3d))
|
|
|
{
|
|
|
- Ogre::Vector3 max_3d( m_range.getMaximum() );
|
|
|
- Ogre::Vector3 min_3d( m_range.getMinimum() );
|
|
|
- Ogre::Vector2 max( max_3d.x, max_3d.y );
|
|
|
- Ogre::Vector2 min( min_3d.x, min_3d.y );
|
|
|
- m_Position.makeCeil( min );
|
|
|
- m_Position.makeFloor( max );
|
|
|
+ Ogre::Vector3 max_3d(m_range.getMaximum());
|
|
|
+ Ogre::Vector3 min_3d(m_range.getMinimum());
|
|
|
+ Ogre::Vector2 max(max_3d.x, max_3d.y);
|
|
|
+ Ogre::Vector2 min(min_3d.x, min_3d.y);
|
|
|
+ m_Position.makeCeil(min);
|
|
|
+ m_Position.makeFloor(max);
|
|
|
}
|
|
|
|
|
|
applyScroll();
|
|
|
@@ -458,10 +456,10 @@ Background2D::SetScroll( const Ogre::Vector2& position )
|
|
|
void
|
|
|
Background2D::applyScroll()
|
|
|
{
|
|
|
- if( cv_background2d_manual.GetB() != true )
|
|
|
+ if(cv_background2d_manual.GetB() != true)
|
|
|
{
|
|
|
m_PositionReal = GetScreenScroll();
|
|
|
- CameraManager::getSingleton().Set2DScroll( m_PositionReal );
|
|
|
+ CameraManager::getSingleton().Set2DScroll(m_PositionReal);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -481,36 +479,36 @@ Background2D::GetScreenScroll() const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetImage( const Ogre::String& image )
|
|
|
+Background2D::SetImage(const Ogre::String& image)
|
|
|
{
|
|
|
Ogre::LogManager::getSingleton().stream()
|
|
|
<< "Background2D::SetImage " << image;
|
|
|
- Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
|
|
|
- Ogre::TextureUnitState* tex = pass->getTextureUnitState( 0 );
|
|
|
- tex->setTextureName( image );
|
|
|
- pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
|
|
|
- tex = pass->getTextureUnitState( 0 );
|
|
|
- tex->setTextureName( image );
|
|
|
+ Ogre::Pass* pass = m_AlphaMaterial->getTechnique(0)->getPass(0);
|
|
|
+ Ogre::TextureUnitState* tex = pass->getTextureUnitState(0);
|
|
|
+ tex->setTextureName(image);
|
|
|
+ pass = m_AddMaterial->getTechnique(0)->getPass(0);
|
|
|
+ tex = pass->getTextureUnitState(0);
|
|
|
+ tex->setTextureName(image);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetRange( const Ogre::Vector4& range )
|
|
|
+Background2D::SetRange(const Ogre::Vector4& range)
|
|
|
{
|
|
|
- SetRange( ( int )range.x, ( int )range.y, ( int )range.z, ( int )range.w );
|
|
|
+ SetRange((int)range.x, (int)range.y, (int)range.z, (int)range.w);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::SetRange( const int min_x, const int min_y, const int max_x, const int max_y )
|
|
|
+Background2D::SetRange(const int min_x, const int min_y, const int max_x, const int max_y)
|
|
|
{
|
|
|
Ogre::LogManager::getSingleton().stream()
|
|
|
<< "Background2D::SetRange " << min_x << " " << min_y << " " << max_x << " " << max_y;
|
|
|
|
|
|
- Ogre::Vector2 half_virtual_screen_size( m_virtual_screen_size / 2 );
|
|
|
+ Ogre::Vector2 half_virtual_screen_size(m_virtual_screen_size / 2);
|
|
|
half_virtual_screen_size /= m_screen_proportion;
|
|
|
- m_range.setMaximum( max_x - half_virtual_screen_size.x , max_y - half_virtual_screen_size.y, 1 );
|
|
|
- m_range.setMinimum( min_x + half_virtual_screen_size.x , min_y + half_virtual_screen_size.y, 0 );
|
|
|
+ m_range.setMaximum(max_x - half_virtual_screen_size.x , max_y - half_virtual_screen_size.y, 1);
|
|
|
+ m_range.setMinimum(min_x + half_virtual_screen_size.x , min_y + half_virtual_screen_size.y, 0);
|
|
|
|
|
|
Ogre::LogManager::getSingleton().stream()
|
|
|
<< "Background2D::SetRange " << m_range;
|
|
|
@@ -520,17 +518,17 @@ Background2D::SetRange( const int min_x, const int min_y, const int max_x, const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::AddTile( const QGears::Tile& tile )
|
|
|
+Background2D::AddTile(const QGears::Tile& tile)
|
|
|
{
|
|
|
// TODO: move depth calculation to flevelBackgroundLoader maybe? and let Backgorund2D only handle 0 <= depth <= 1 or so?
|
|
|
// maybe just move the < 4095 part to flevel background loader?
|
|
|
- Ogre::Real depth( 0.0001f );
|
|
|
- if( tile.depth >= 1 )
|
|
|
+ Ogre::Real depth(0.0001f);
|
|
|
+ if(tile.depth >= 1)
|
|
|
{
|
|
|
- if( tile.depth < 4095 )
|
|
|
+ if(tile.depth < 4095)
|
|
|
{
|
|
|
- const Ogre::Matrix4 &cam_projection( CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth() );
|
|
|
- Ogre::Vector4 res( 0, 0, -tile.depth, 1 );
|
|
|
+ const Ogre::Matrix4 &cam_projection(CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth());
|
|
|
+ Ogre::Vector4 res(0, 0, -tile.depth, 1);
|
|
|
res = cam_projection * res;
|
|
|
res /= res.w;
|
|
|
depth = res.z;
|
|
|
@@ -540,19 +538,19 @@ Background2D::AddTile( const QGears::Tile& tile )
|
|
|
depth = 0.9999f;
|
|
|
}
|
|
|
}
|
|
|
- AddTile( tile.destination, tile.width, tile.height, depth, tile.uv, tile.blending );
|
|
|
+ AddTile(tile.destination, tile.width, tile.height, depth, tile.uv, tile.blending);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::AddTile( const Ogre::Vector2& destination, const int width, const int height, const float depth, const Ogre::Vector4& uv, const Blending blending )
|
|
|
+Background2D::AddTile(const Ogre::Vector2& destination, const int width, const int height, const float depth, const Ogre::Vector4& uv, const Blending blending)
|
|
|
{
|
|
|
- AddTile( static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, depth, uv.x, uv.y, uv.z, uv.w, blending );
|
|
|
+ AddTile(static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, depth, uv.x, uv.y, uv.z, uv.w, blending);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::virtualScreenToWorldSpace( Ogre::Vector2& pos ) const
|
|
|
+Background2D::virtualScreenToWorldSpace(Ogre::Vector2& pos) const
|
|
|
{
|
|
|
pos.x /= m_virtual_screen_size.x / 2;
|
|
|
pos.y /= m_virtual_screen_size.y / 2;
|
|
|
@@ -563,19 +561,19 @@ Background2D::virtualScreenToWorldSpace( Ogre::Vector2& pos ) const
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::AddTile( const int x, const int y, const int width, const int height, const float depth, const float u1, const float v1, const float u2, const float v2, const Blending blending )
|
|
|
+Background2D::AddTile(const int x, const int y, const int width, const int height, const float depth, const float u1, const float v1, const float u2, const float v2, const Blending blending)
|
|
|
{
|
|
|
Ogre::RenderOperation render_op;
|
|
|
Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
|
|
|
unsigned int max_vertex_count;
|
|
|
|
|
|
- if( blending == QGears::B_ALPHA )
|
|
|
+ if(blending == QGears::B_ALPHA)
|
|
|
{
|
|
|
render_op = m_AlphaRenderOp;
|
|
|
vertex_buffer = m_AlphaVertexBuffer;
|
|
|
max_vertex_count = m_AlphaMaxVertexCount;
|
|
|
}
|
|
|
- else if( blending == QGears::B_ADD )
|
|
|
+ else if(blending == QGears::B_ADD)
|
|
|
{
|
|
|
render_op = m_AddRenderOp;
|
|
|
vertex_buffer = m_AddVertexBuffer;
|
|
|
@@ -583,13 +581,13 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LOG_ERROR( "Unknown blending type." );
|
|
|
+ LOG_ERROR("Unknown blending type.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if( render_op.vertexData->vertexCount + TILE_VERTEX_COUNT > max_vertex_count )
|
|
|
+ if(render_op.vertexData->vertexCount + TILE_VERTEX_COUNT > max_vertex_count)
|
|
|
{
|
|
|
- LOG_ERROR( "Max number of tiles reached. Can't create more than " + Ogre::StringConverter::toString( max_vertex_count / TILE_VERTEX_COUNT ) + " tiles." );
|
|
|
+ LOG_ERROR("Max number of tiles reached. Can't create more than " + Ogre::StringConverter::toString( max_vertex_count / TILE_VERTEX_COUNT ) + " tiles.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -600,18 +598,18 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
|
|
|
tile.height = height;
|
|
|
tile.start_vertex_index = render_op.vertexData->vertexCount;
|
|
|
tile.blending = blending;
|
|
|
- size_t index( m_Tiles.size() );
|
|
|
- m_Tiles.push_back( tile );
|
|
|
+ size_t index(m_Tiles.size());
|
|
|
+ m_Tiles.push_back(tile);
|
|
|
|
|
|
Ogre::Vector2 top_left(static_cast<Ogre::Real>(x), static_cast<Ogre::Real>(-y));
|
|
|
Ogre::Vector2 top_right(static_cast<Ogre::Real>(x + width), static_cast<Ogre::Real>(top_left.y));
|
|
|
Ogre::Vector2 bottom_right(static_cast<Ogre::Real>(top_right.x), static_cast<Ogre::Real>(-(y + height)));
|
|
|
- Ogre::Vector2 bottom_left( top_left.x, bottom_right.y );
|
|
|
+ Ogre::Vector2 bottom_left(top_left.x, bottom_right.y);
|
|
|
|
|
|
- virtualScreenToWorldSpace( top_left );
|
|
|
- virtualScreenToWorldSpace( top_right );
|
|
|
- virtualScreenToWorldSpace( bottom_right );
|
|
|
- virtualScreenToWorldSpace( bottom_left );
|
|
|
+ virtualScreenToWorldSpace(top_left);
|
|
|
+ virtualScreenToWorldSpace(top_right);
|
|
|
+ virtualScreenToWorldSpace(bottom_right);
|
|
|
+ virtualScreenToWorldSpace(bottom_left);
|
|
|
|
|
|
float new_x1 = top_left.x;
|
|
|
float new_y1 = top_left.y;
|
|
|
@@ -625,9 +623,10 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
|
|
|
float new_x4 = bottom_left.x;
|
|
|
float new_y4 = bottom_left.y;
|
|
|
|
|
|
- float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
|
|
|
+ float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
|
|
|
writeIterator += render_op.vertexData->vertexCount * TILE_VERTEX_INDEX_SIZE;
|
|
|
|
|
|
+ // TODO: Can use WriteGlyph
|
|
|
*writeIterator++ = new_x1;
|
|
|
*writeIterator++ = new_y1;
|
|
|
*writeIterator++ = depth;
|
|
|
@@ -695,28 +694,28 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::UpdateTileUV( const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2 )
|
|
|
+Background2D::UpdateTileUV(const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2)
|
|
|
{
|
|
|
- if( tile_id >= m_Tiles.size() )
|
|
|
+ if(tile_id >= m_Tiles.size())
|
|
|
{
|
|
|
- LOG_ERROR( "Tile with id " + Ogre::StringConverter::toString( tile_id ) + " doesn't exist." );
|
|
|
+ LOG_ERROR("Tile with id " + Ogre::StringConverter::toString( tile_id ) + " doesn't exist.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
|
|
|
|
|
|
- if( m_Tiles[ tile_id ].blending == QGears::B_ALPHA )
|
|
|
+ if(m_Tiles[tile_id].blending == QGears::B_ALPHA)
|
|
|
{
|
|
|
vertex_buffer = m_AlphaVertexBuffer;
|
|
|
}
|
|
|
- else if( m_Tiles[ tile_id ].blending == QGears::B_ADD )
|
|
|
+ else if(m_Tiles[tile_id].blending == QGears::B_ADD)
|
|
|
{
|
|
|
vertex_buffer = m_AddVertexBuffer;
|
|
|
}
|
|
|
|
|
|
- float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
|
|
|
+ float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
|
|
|
|
|
|
- writeIterator += m_Tiles[ tile_id ].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
|
|
|
+ writeIterator += m_Tiles[tile_id].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
|
|
|
|
|
|
writeIterator += 7;
|
|
|
*writeIterator++ = u1;
|
|
|
@@ -742,72 +741,72 @@ Background2D::UpdateTileUV( const unsigned int tile_id, const float u1, const fl
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::AddAnimation( Background2DAnimation* animation )
|
|
|
+Background2D::AddAnimation(Background2DAnimation* animation)
|
|
|
{
|
|
|
- m_Animations.push_back( animation );
|
|
|
+ m_Animations.push_back(animation);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::PlayAnimation( const Ogre::String& animation, const Background2DAnimation::State state )
|
|
|
+Background2D::PlayAnimation(const Ogre::String& animation, const Background2DAnimation::State state)
|
|
|
{
|
|
|
bool found = false;
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_Animations.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_Animations.size(); ++i)
|
|
|
{
|
|
|
- if( m_Animations[ i ]->GetName() == animation )
|
|
|
+ if(m_Animations[i]->GetName() == animation)
|
|
|
{
|
|
|
found = true;
|
|
|
- m_Animations[ i ]->SetTime( 0 );
|
|
|
- m_Animations[ i ]->AddTime( 0 );
|
|
|
+ m_Animations[i]->SetTime(0);
|
|
|
+ m_Animations[i]->AddTime(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
|
|
|
{
|
|
|
- if( m_AnimationPlayed[ i ].name == animation )
|
|
|
+ if(m_AnimationPlayed[i].name == animation)
|
|
|
{
|
|
|
- m_AnimationPlayed.erase( m_AnimationPlayed.begin() + i );
|
|
|
+ m_AnimationPlayed.erase(m_AnimationPlayed.begin() + i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if( found == true )
|
|
|
+ if(found == true)
|
|
|
{
|
|
|
AnimationPlayed anim;
|
|
|
anim.name = animation;
|
|
|
anim.state = state;
|
|
|
- m_AnimationPlayed.push_back( anim );
|
|
|
+ m_AnimationPlayed.push_back(anim);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LOG_ERROR( "Background2D doesn't has animation \"" + animation + "\"." );
|
|
|
+ LOG_ERROR("Background2D doesn't has animation \"" + animation + "\".");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::ScriptPlayAnimationLooped( const char* name )
|
|
|
+Background2D::ScriptPlayAnimationLooped(const char* name)
|
|
|
{
|
|
|
- PlayAnimation( Ogre::String( name ), Background2DAnimation::LOOPED );
|
|
|
+ PlayAnimation(Ogre::String(name), Background2DAnimation::LOOPED);
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::ScriptPlayAnimationOnce( const char* name )
|
|
|
+Background2D::ScriptPlayAnimationOnce(const char* name)
|
|
|
{
|
|
|
- PlayAnimation( Ogre::String( name ), Background2DAnimation::ONCE );
|
|
|
+ PlayAnimation(Ogre::String(name), Background2DAnimation::ONCE);
|
|
|
}
|
|
|
|
|
|
|
|
|
int
|
|
|
-Background2D::ScriptAnimationSync( const char* animation )
|
|
|
+Background2D::ScriptAnimationSync(const char* animation)
|
|
|
{
|
|
|
- for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
|
|
|
+ for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
|
|
|
{
|
|
|
- if( m_AnimationPlayed[ i ].name == animation )
|
|
|
+ if(m_AnimationPlayed[i].name == animation)
|
|
|
{
|
|
|
ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
|
|
|
- m_AnimationPlayed[ i ].sync.push_back( script );
|
|
|
+ m_AnimationPlayed[i].sync.push_back(script);
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
@@ -817,37 +816,36 @@ Background2D::ScriptAnimationSync( const char* animation )
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation )
|
|
|
+Background2D::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
|
|
|
{
|
|
|
- if( cv_show_background2d.GetB() == false )
|
|
|
+ if(cv_show_background2d.GetB() == false)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- if( queueGroupId == Ogre::RENDER_QUEUE_MAIN )
|
|
|
+ if(queueGroupId == Ogre::RENDER_QUEUE_MAIN)
|
|
|
{
|
|
|
- m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
|
|
|
- m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
|
|
|
+ m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
|
|
|
+ m_RenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
|
|
|
|
|
|
- Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
|
|
|
+ Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
|
|
|
float width = static_cast<float>(viewport->getActualWidth());
|
|
|
float height = static_cast<float>(viewport->getActualHeight());
|
|
|
+
|
|
|
Ogre::Matrix4 view;
|
|
|
- view.makeTrans( Ogre::Vector3( m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0 ) );
|
|
|
- m_RenderSystem->_setViewMatrix( 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 )
|
|
|
+ if(m_AlphaRenderOp.vertexData->vertexCount != 0)
|
|
|
{
|
|
|
- m_SceneManager->_setPass( m_AlphaMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
|
|
|
- m_RenderSystem->_render( m_AlphaRenderOp );
|
|
|
+ m_SceneManager->_setPass(m_AlphaMaterial->getTechnique(0)->getPass(0), true, false);
|
|
|
+ m_RenderSystem->_render(m_AlphaRenderOp);
|
|
|
}
|
|
|
|
|
|
- if( m_AddRenderOp.vertexData->vertexCount != 0 )
|
|
|
+ if(m_AddRenderOp.vertexData->vertexCount != 0)
|
|
|
{
|
|
|
- m_SceneManager->_setPass( m_AddMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
|
|
|
- m_RenderSystem->_render( m_AddRenderOp );
|
|
|
+ m_SceneManager->_setPass(m_AddMaterial->getTechnique(0)->getPass(0), true, false);
|
|
|
+ m_RenderSystem->_render(m_AddRenderOp);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -863,20 +861,18 @@ Background2D::CreateVertexBuffers()
|
|
|
Ogre::VertexDeclaration* vDecl = m_AlphaRenderOp.vertexData->vertexDeclaration;
|
|
|
|
|
|
size_t offset = 0;
|
|
|
- vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
|
|
|
- offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
|
|
|
- vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
|
|
|
- offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
|
|
|
- vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
|
|
|
+ vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
|
|
|
+ offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
|
|
|
+ vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
|
|
|
+ offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
|
|
|
+ vDecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
|
|
|
|
|
|
- m_AlphaVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AlphaMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
|
|
|
+ m_AlphaVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_AlphaMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
|
|
|
|
|
|
- m_AlphaRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AlphaVertexBuffer );
|
|
|
+ m_AlphaRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_AlphaVertexBuffer);
|
|
|
m_AlphaRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
|
|
|
m_AlphaRenderOp.useIndexes = false;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
m_AddMaxVertexCount = 256 * TILE_VERTEX_COUNT;
|
|
|
m_AddRenderOp.vertexData = new Ogre::VertexData;
|
|
|
m_AddRenderOp.vertexData->vertexStart = 0;
|
|
|
@@ -884,15 +880,15 @@ Background2D::CreateVertexBuffers()
|
|
|
vDecl = m_AddRenderOp.vertexData->vertexDeclaration;
|
|
|
|
|
|
offset = 0;
|
|
|
- vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
|
|
|
- offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
|
|
|
- vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
|
|
|
- offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
|
|
|
- vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
|
|
|
+ vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
|
|
|
+ offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
|
|
|
+ vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
|
|
|
+ offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
|
|
|
+ vDecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
|
|
|
|
|
|
- m_AddVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AddMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
|
|
|
+ m_AddVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_AddMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
|
|
|
|
|
|
- m_AddRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AddVertexBuffer );
|
|
|
+ m_AddRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_AddVertexBuffer);
|
|
|
m_AddRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
|
|
|
m_AddRenderOp.useIndexes = false;
|
|
|
}
|
|
|
@@ -914,56 +910,56 @@ Background2D::DestroyVertexBuffers()
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::load( const QGears::Background2DFilePtr& background )
|
|
|
+Background2D::load(const QGears::Background2DFilePtr& background)
|
|
|
{
|
|
|
- assert( !background.isNull() );
|
|
|
+ assert(!background.isNull());
|
|
|
background->load();
|
|
|
- SetImage( background->getTextureName() );
|
|
|
+ SetImage(background->getTextureName());
|
|
|
m_virtual_screen_size = background->getClip();
|
|
|
- SetRange( background->getRange() );
|
|
|
+ SetRange(background->getRange());
|
|
|
|
|
|
- const Ogre::Vector3& position( background->getPosition() );
|
|
|
- const Ogre::Quaternion& orientation( background->getOrientation() );
|
|
|
- const Ogre::Radian& fov( background->getFov() );
|
|
|
- CameraManager::getSingleton().Set2DCamera( position, orientation, fov );
|
|
|
- load( background->getTiles() );
|
|
|
+ const Ogre::Vector3& position(background->getPosition());
|
|
|
+ const Ogre::Quaternion& orientation(background->getOrientation());
|
|
|
+ const Ogre::Radian& fov(background->getFov());
|
|
|
+ CameraManager::getSingleton().Set2DCamera(position, orientation, fov);
|
|
|
+ load(background->getTiles());
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::load( const QGears::Background2DFile::TileList& tiles )
|
|
|
+Background2D::load(const QGears::Background2DFile::TileList& tiles)
|
|
|
{
|
|
|
- QGears::Background2DFile::TileList::const_iterator it( tiles.begin() );
|
|
|
- QGears::Background2DFile::TileList::const_iterator it_end( tiles.end() );
|
|
|
- size_t tile_index( 0 );
|
|
|
- while( it != it_end )
|
|
|
+ QGears::Background2DFile::TileList::const_iterator it(tiles.begin());
|
|
|
+ QGears::Background2DFile::TileList::const_iterator it_end(tiles.end());
|
|
|
+ size_t tile_index(0);
|
|
|
+ while(it != it_end)
|
|
|
{
|
|
|
- AddTile( *it );
|
|
|
- load( tile_index++, it->animations );
|
|
|
+ AddTile(*it);
|
|
|
+ load(tile_index++, it->animations);
|
|
|
++it;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void
|
|
|
-Background2D::load( const size_t tile_index, const QGears::AnimationMap& animations )
|
|
|
+Background2D::load(const size_t tile_index, const QGears::AnimationMap& animations)
|
|
|
{
|
|
|
- QGears::AnimationMap::const_iterator it( animations.begin() );
|
|
|
- QGears::AnimationMap::const_iterator it_end( animations.end() );
|
|
|
+ QGears::AnimationMap::const_iterator it(animations.begin());
|
|
|
+ QGears::AnimationMap::const_iterator it_end(animations.end());
|
|
|
|
|
|
- while( it != it_end )
|
|
|
+ while(it != it_end)
|
|
|
{
|
|
|
- const QGears::String& name( it->first );
|
|
|
- const QGears::Animation& animation( it->second );
|
|
|
- Background2DAnimation* anim( new Background2DAnimation( name, this, tile_index ) );
|
|
|
- anim->SetLength( animation.length );
|
|
|
- QGears::KeyFrameList::const_iterator itk( animation.key_frames.begin() );
|
|
|
- QGears::KeyFrameList::const_iterator itk_end( animation.key_frames.end() );
|
|
|
- while( itk != itk_end )
|
|
|
+ const QGears::String& name(it->first);
|
|
|
+ const QGears::Animation& animation(it->second);
|
|
|
+ Background2DAnimation* anim(new Background2DAnimation(name, this, tile_index));
|
|
|
+ anim->SetLength(animation.length);
|
|
|
+ QGears::KeyFrameList::const_iterator itk(animation.key_frames.begin());
|
|
|
+ QGears::KeyFrameList::const_iterator itk_end(animation.key_frames.end());
|
|
|
+ while(itk != itk_end)
|
|
|
{
|
|
|
- anim->AddUVKeyFrame( *(itk++) );
|
|
|
+ anim->AddUVKeyFrame(*(itk++));
|
|
|
}
|
|
|
- AddAnimation( anim );
|
|
|
+ AddAnimation(anim);
|
|
|
++it;
|
|
|
}
|
|
|
}
|