![]() |
V-Gears 0
Free Final Fantasy VII engine.
|
A field background. More...
#include <Background2D.h>
Classes | |
struct | AnimationPlayed |
State of an animation. More... | |
struct | Tile |
Represents a tile. More... | |
Public Types | |
enum | SCROLL_TYPE { NONE , LINEAR , SMOOTH } |
How to scroll the background. More... | |
typedef VGears::Blending | Blending |
typedef std::vector< Tile > | TileList |
Public Member Functions | |
Background2D () | |
Constructor. More... | |
virtual | ~Background2D () |
Destructor. More... | |
void | InputDebug (const VGears::Event &event) |
void | Hide () |
Hides the background. More... | |
void | Show () |
Shows the background. More... | |
void | Update () |
Run each frame. More... | |
void | UpdateDebug () |
Debug inormation about changes in the background. More... | |
void | OnResize () |
Called on window resize. More... | |
void | Clear () |
Removes the background and it's animations. More... | |
void | ScriptAutoScrollToEntity (Entity *entity) |
Flags the background to automatically scroll to an entity position. More... | |
Entity * | GetAutoScrollEntity () const |
Retrieves the entity currently being tracked for autoscroll. More... | |
void | ScriptScrollToPlayer (const SCROLL_TYPE type, const unsigned int seconds) |
Scrolls the background to the position of the playable character. More... | |
void | ScriptScrollToPosition (const float x, const float y, const SCROLL_TYPE type, const float seconds) |
Scrolls the background to a position. More... | |
int | ScriptScrollSync () |
Waits for the scroll to complete. More... | |
void | ScriptOffset (const float x, const float y) |
Offsets the background to a position. More... | |
void | UnsetScroll () |
Stops the current scrolling. More... | |
const Ogre::Vector2 & | GetScrollPositionStart () const |
Retrieves the initial position of the current scroll action. More... | |
const Ogre::Vector2 & | GetScrollPositionEnd () const |
Retrieves the final position of the current scroll action. More... | |
SCROLL_TYPE | GetScrollType () const |
Retrieves the type of the current scroll action. More... | |
float | GetScrollSeconds () const |
Retrieves the total duration the current scroll action. More... | |
void | SetScrollCurrentSeconds (const float seconds) |
Sets the time taken by the current scroll action. More... | |
float | GetScrollCurrentSeconds () const |
Retrieves the time taken by the current scroll action. More... | |
void | SetScreenScroll (const Ogre::Vector2 &position) |
Scroll position in screen coordinates. More... | |
const Ogre::Vector2 | GetScreenScroll () const |
Retrieves the scroll position in screen coordinates. More... | |
void | SetScroll (const Ogre::Vector2 &position) |
Sets the scroll in game internal screen coordinates. More... | |
const Ogre::Vector2 & | GetScroll () const |
Retrieves the scroll position in game internal screen coordinates. More... | |
void | SetImage (const Ogre::String &image) |
Sets the background image. More... | |
void | SetRange (const int min_x, const int min_y, const int max_x, const int max_y) |
Set the background scrolling range. More... | |
void | SetRange (const Ogre::Vector4 &range) |
Set the background scrolling range. More... | |
void | 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) |
Adds a tile to the background. More... | |
void | AddTile (const Ogre::Vector2 &destination, const int width, const int height, const float depth, const Ogre::Vector4 &uv, const Blending blending) |
Adds a tile to the background. More... | |
void | AddTile (const VGears::Tile &tile) |
Adds a tile to the background. More... | |
void | UpdateTileUV (const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2) |
Updates the UV vector of a tile. More... | |
void | AddAnimation (Background2DAnimation *animation) |
Adds an animation to the background. More... | |
void | PlayAnimation (const Ogre::String &animation, const Background2DAnimation::State state) |
Plays an animation. More... | |
void | ScriptPlayAnimationLooped (const char *name) |
Plays an animation in a loop. More... | |
void | ScriptPlayAnimationOnce (const char *name) |
Plays an animation once, then stops. More... | |
int | ScriptAnimationSync (const char *name) |
Plays an animation once, then stops. More... | |
void | renderQueueEnded (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation) override |
Ends the render queue. More... | |
virtual void | load (const VGears::Background2DFilePtr &background) |
Loads a background. More... | |
Protected Types | |
enum | { TILE_VERTEX_COUNT = 6 , TILE_VERTEX_INDEX_SIZE = TILE_VERTEX_COUNT + 3 } |
Tile vertex properties. More... | |
Protected Member Functions | |
virtual void | load (const VGears::Background2DFile::TileList &tiles) |
Loads a tile list to the background. More... | |
virtual void | load (const size_t tile_index, const VGears::AnimationMap &animations) |
Loads an animation list to the background. More... | |
virtual void | applyScroll () |
Apply the camera position to match the current scroll. More... | |
virtual void | calculateScreenScale () |
Calculates the screen scale. More... | |
virtual void | virtualScreenToWorldSpace (Ogre::Vector2 &pos) const |
Sets the virtual screen to world space. More... | |
Private Member Functions | |
void | CreateVertexBuffers () |
Creates all vertex buffers. More... | |
void | DestroyVertexBuffers () |
Destroys all vertex buffers. More... | |
Private Attributes | |
Ogre::SceneManager * | scene_manager_ |
The scene manager. More... | |
Ogre::RenderSystem * | render_system_ |
The render system. More... | |
TileList | tiles_ |
The list of tiles in the background. More... | |
Ogre::RenderOperation | alpha_render_op_ |
Alpha blending render operation. More... | |
Ogre::HardwareVertexBufferSharedPtr | alpha_vertex_buffer_ |
Alpha blending vertex buffer. More... | |
unsigned int | alpha_max_vertex_count_ |
Alpha blending max vertex count. More... | |
Ogre::MaterialPtr | alpha_material_ |
Alpha blending material. More... | |
Ogre::RenderOperation | add_render_op_ |
Add blending render operation. More... | |
Ogre::HardwareVertexBufferSharedPtr | add_vertex_buffer_ |
Add blending vertex buffer. More... | |
unsigned int | add_max_vertex_count_ |
Add blending max vertex count. More... | |
Ogre::MaterialPtr | add_material |
Add blending material. More... | |
Ogre::RenderOperation | subtract_render_op_ |
Substract blending render operation. More... | |
Ogre::HardwareVertexBufferSharedPtr | subtract_vertex_buffer_ |
Substract blending vertex buffer. More... | |
unsigned int | subtract_max_vertex_count_ |
Substract blending max vertex count. More... | |
Ogre::MaterialPtr | subtract_material_ |
Substract blending material. More... | |
Entity * | scroll_entity_ |
The entity to keep track of with the scroll. More... | |
Ogre::Vector2 | scroll_position_start_ |
Starting position of the current scroll action. More... | |
Ogre::Vector2 | scroll_position_end_ |
Final position of the current scroll action. More... | |
SCROLL_TYPE | scroll_type_ |
Type of the current scroll action. More... | |
float | scroll_seconds_ |
Total duration of the current scroll action, in seconds. More... | |
float | scroll_current_seconds_ |
Secund the currens scroll action has taken so far. More... | |
std::vector< ScriptId > | scroll_sync_ |
Ogre::Vector2 | position_ |
The current scroll position, virtual screen size. More... | |
Ogre::Vector2 | offset_ |
The current background offset, virtual screen size. More... | |
Ogre::Vector2 | position_real_ |
The current scroll position, viewport size. More... | |
Ogre::Real | screen_scale_ |
The scale of the screen. More... | |
Ogre::Vector2 | screen_proportion_ |
Screen aspect ration. More... | |
Ogre::Vector2 | virtual_screen_size_ |
The size of the virtual screen. More... | |
Ogre::AxisAlignedBox | range_ |
std::vector< AnimationPlayed > | animation_played_ |
std::vector< Background2DAnimation * > | animations_ |
List of animations. More... | |
A field background.
typedef std::vector<Tile> Background2D::TileList |
|
protected |
Background2D::Background2D | ( | ) |
Constructor.
|
virtual |
Destructor.
void Background2D::AddAnimation | ( | Background2DAnimation * | animation | ) |
Adds an animation to the background.
[in] | animation | Animation to add. |
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 | ||
) |
void Background2D::AddTile | ( | const Ogre::Vector2 & | destination, |
const int | width, | ||
const int | height, | ||
const float | depth, | ||
const Ogre::Vector4 & | uv, | ||
const Blending | blending | ||
) |
void Background2D::AddTile | ( | const VGears::Tile & | tile | ) |
Adds a tile to the background.
[in] | tile | The tile to add. |
|
protectedvirtual |
Apply the camera position to match the current scroll.
|
protectedvirtual |
Calculates the screen scale.
The scale is calculated as the proportion between the viewport and the virtual screen.
void Background2D::Clear | ( | ) |
Removes the background and it's animations.
|
private |
Creates all vertex buffers.
|
private |
Destroys all vertex buffers.
Entity * Background2D::GetAutoScrollEntity | ( | ) | const |
Retrieves the entity currently being tracked for autoscroll.
const Ogre::Vector2 Background2D::GetScreenScroll | ( | ) | const |
Retrieves the scroll position in screen coordinates.
const Ogre::Vector2 & Background2D::GetScroll | ( | ) | const |
Retrieves the scroll position in game internal screen coordinates.
float Background2D::GetScrollCurrentSeconds | ( | ) | const |
Retrieves the time taken by the current scroll action.
It represents the time the current scroll action has been going on for.
const Ogre::Vector2 & Background2D::GetScrollPositionEnd | ( | ) | const |
Retrieves the final position of the current scroll action.
const Ogre::Vector2 & Background2D::GetScrollPositionStart | ( | ) | const |
Retrieves the initial position of the current scroll action.
float Background2D::GetScrollSeconds | ( | ) | const |
Retrieves the total duration the current scroll action.
Background2D::SCROLL_TYPE Background2D::GetScrollType | ( | ) | const |
Retrieves the type of the current scroll action.
void Background2D::Hide | ( | ) |
Hides the background.
Once called, the background will not be rendered until {
void Background2D::InputDebug | ( | const VGears::Event & | event | ) |
[in] | event | Event. |
|
protectedvirtual |
Loads an animation list to the background.
[in] | tile_index | The index of the tile. |
[in] | animations | List of animations to load. |
|
protectedvirtual |
Loads a tile list to the background.
[in] | tiles | The list of tiles to load. |
|
virtual |
Loads a background.
[in] | background | The background to load. |
void Background2D::OnResize | ( | ) |
Called on window resize.
Resizes the background, keeping the ratio.
void Background2D::PlayAnimation | ( | const Ogre::String & | animation, |
const Background2DAnimation::State | state | ||
) |
Plays an animation.
[in] | animation | The animation to play. |
[in] | state | Animation state. |
|
override |
Ends the render queue.
[in] | queueGroupId | The group id of the queue to end. |
[in] | invocation | |
[in] | repeatThisInvocation | Indicates if the invocation must be repeated. |
int Background2D::ScriptAnimationSync | ( | const char * | name | ) |
Plays an animation once, then stops.
The animation is played synchronously, and the thread is locked until it ends.
[in] | name | Animation name. |
void Background2D::ScriptAutoScrollToEntity | ( | Entity * | entity | ) |
Flags the background to automatically scroll to an entity position.
[in] | entity | The entity to track. |
void Background2D::ScriptOffset | ( | const float | x, |
const float | y | ||
) |
Offsets the background to a position.
[in] | x | X coordinate to scroll to. |
[in] | y | Y coordinate to scroll to. |
void Background2D::ScriptPlayAnimationLooped | ( | const char * | name | ) |
Plays an animation in a loop.
The animation is played asynchronously.
[in] | name | Animation name. |
void Background2D::ScriptPlayAnimationOnce | ( | const char * | name | ) |
Plays an animation once, then stops.
The animation is played asynchronously.
[in] | name | Animation name. |
int Background2D::ScriptScrollSync | ( | ) |
Waits for the scroll to complete.
void Background2D::ScriptScrollToPlayer | ( | const SCROLL_TYPE | type, |
const unsigned int | seconds | ||
) |
Scrolls the background to the position of the playable character.
[in] | type | Scroll type. |
[in] | seconds | Scroll duration. |
void Background2D::ScriptScrollToPosition | ( | const float | x, |
const float | y, | ||
const SCROLL_TYPE | type, | ||
const float | seconds | ||
) |
Scrolls the background to a position.
[in] | x | X coordinate to scroll to. |
[in] | y | Y coordinate to scroll to. |
[in] | type | Scroll type. |
[in] | seconds | Duration of the scroll. |
void Background2D::SetImage | ( | const Ogre::String & | image | ) |
Sets the background image.
[in] | image | Image name. |
void Background2D::SetRange | ( | const int | min_x, |
const int | min_y, | ||
const int | max_x, | ||
const int | max_y | ||
) |
Set the background scrolling range.
The range is applied in game internal screen coordinates.
[in] | min_x | Min scrollabe x coordinate. |
[in] | min_y | Min scrollabe y coordinate. |
[in] | max_x | Max scrollabe x coordinate. |
[in] | max_y | Max scrollabe y coordinate. |
void Background2D::SetRange | ( | const Ogre::Vector4 & | range | ) |
Set the background scrolling range.
The range is applied in game internal screen coordinates.
[in] | range | Range bounds vector. |
void Background2D::SetScreenScroll | ( | const Ogre::Vector2 & | position | ) |
Scroll position in screen coordinates.
[in] | position | Position to set the scroll. |
void Background2D::SetScroll | ( | const Ogre::Vector2 & | position | ) |
Sets the scroll in game internal screen coordinates.
[in] | position | Position to set the scroll. |
void Background2D::SetScrollCurrentSeconds | ( | const float | seconds | ) |
Sets the time taken by the current scroll action.
It represents the time the current scroll action has been going on for.
[in] | seconds | Time taken by the current scroll action. |
void Background2D::Show | ( | ) |
Shows the background.
Once called, the background will start rendered until {
void Background2D::UnsetScroll | ( | ) |
Stops the current scrolling.
void Background2D::Update | ( | ) |
Run each frame.
Updates animations and changes in the background.
void Background2D::UpdateDebug | ( | ) |
Debug inormation about changes in the background.
void Background2D::UpdateTileUV | ( | const unsigned int | tile_id, |
const float | u1, | ||
const float | v1, | ||
const float | u2, | ||
const float | v2 | ||
) |
Updates the UV vector of a tile.
[in] | tile_id | ID of the tile to update. |
[in] | u1 | |
[in] | v1 | |
[in] | u2 | |
[in] | v2 |
|
protectedvirtual |
|
private |
Add blending material.
|
private |
Add blending max vertex count.
|
private |
Add blending render operation.
|
private |
Add blending vertex buffer.
|
private |
Alpha blending material.
|
private |
Alpha blending max vertex count.
|
private |
Alpha blending render operation.
|
private |
Alpha blending vertex buffer.
|
private |
|
private |
List of animations.
|
private |
The current background offset, virtual screen size.
|
private |
The current scroll position, virtual screen size.
|
private |
The current scroll position, viewport size.
Includes the offset.
|
private |
|
private |
The render system.
|
private |
The scene manager.
|
private |
Screen aspect ration.
|
private |
The scale of the screen.
|
private |
Secund the currens scroll action has taken so far.
|
private |
The entity to keep track of with the scroll.
|
private |
Final position of the current scroll action.
|
private |
Starting position of the current scroll action.
|
private |
Total duration of the current scroll action, in seconds.
|
private |
Type of the current scroll action.
|
private |
Substract blending material.
|
private |
Substract blending max vertex count.
|
private |
Substract blending render operation.
|
private |
Substract blending vertex buffer.
|
private |
The list of tiles in the background.
|
private |
The size of the virtual screen.