18#include <OgreHardwareVertexBuffer.h>
19#include <OgreRenderQueueListener.h>
147 const float x,
const float y,
const SCROLL_TYPE type,
const float seconds
261 void SetRange(
const int min_x,
const int min_y,
const int max_x,
const int max_y);
270 void SetRange(
const Ogre::Vector4& range);
289 const int x,
const int y,
const int width,
const int height,
const float depth,
290 const float u1,
const float v1,
const float u2,
const float v2,
const Blending blending
306 const Ogre::Vector2& destination,
const int width,
const int height,
307 const float depth,
const Ogre::Vector4& uv,
const Blending blending
328 const unsigned int tile_id,
const float u1,
const float v1,
const float u2,
const float v2
float * position
Used to keep track of the skeleton and it's bones positions.
Definition: DrawSkeleton.cpp:33
An animation in the background of a field.
Definition: Background2DAnimation.h:28
State
Repetition status of the animation.
Definition: Background2DAnimation.h:52
A field background.
Definition: Background2D.h:29
Ogre::MaterialPtr add_material
Add blending material.
Definition: Background2D.h:553
Ogre::AxisAlignedBox range_
Definition: Background2D.h:645
void Hide()
Hides the background.
Definition: Background2D.cpp:117
const Ogre::Vector2 & GetScrollPositionEnd() const
Retrieves the final position of the current scroll action.
Definition: Background2D.cpp:332
void DestroyVertexBuffers()
Destroys all vertex buffers.
Definition: Background2D.cpp:737
int ScriptAnimationSync(const char *name)
Plays an animation once, then stops.
Definition: Background2D.cpp:633
void InputDebug(const VGears::Event &event)
Definition: Background2D.cpp:107
SCROLL_TYPE GetScrollType() const
Retrieves the type of the current scroll action.
Definition: Background2D.cpp:334
unsigned int alpha_max_vertex_count_
Alpha blending max vertex count.
Definition: Background2D.h:528
float GetScrollCurrentSeconds() const
Retrieves the time taken by the current scroll action.
Definition: Background2D.cpp:340
Ogre::HardwareVertexBufferSharedPtr alpha_vertex_buffer_
Alpha blending vertex buffer.
Definition: Background2D.h:523
void AddAnimation(Background2DAnimation *animation)
Adds an animation to the background.
Definition: Background2D.cpp:598
float scroll_current_seconds_
Secund the currens scroll action has taken so far.
Definition: Background2D.h:603
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.
Definition: Background2D.cpp:563
void ScriptScrollToPosition(const float x, const float y, const SCROLL_TYPE type, const float seconds)
Scrolls the background to a position.
Definition: Background2D.cpp:282
std::vector< Tile > TileList
Definition: Background2D.h:422
void OnResize()
Called on window resize.
Definition: Background2D.cpp:188
Background2D()
Constructor.
Definition: Background2D.cpp:34
unsigned int add_max_vertex_count_
Add blending max vertex count.
Definition: Background2D.h:548
Entity * GetAutoScrollEntity() const
Retrieves the entity currently being tracked for autoscroll.
Definition: Background2D.cpp:267
Ogre::HardwareVertexBufferSharedPtr subtract_vertex_buffer_
Substract blending vertex buffer.
Definition: Background2D.h:563
void ScriptOffset(const float x, const float y)
Offsets the background to a position.
Definition: Background2D.cpp:312
void ScriptScrollToPlayer(const SCROLL_TYPE type, const unsigned int seconds)
Scrolls the background to the position of the playable character.
Definition: Background2D.cpp:269
const Ogre::Vector2 & GetScrollPositionStart() const
Retrieves the initial position of the current scroll action.
Definition: Background2D.cpp:330
Entity * scroll_entity_
The entity to keep track of with the scroll.
Definition: Background2D.h:578
void Update()
Run each frame.
Definition: Background2D.cpp:121
void Clear()
Removes the background and it's animations.
Definition: Background2D.cpp:243
virtual ~Background2D()
Destructor.
Definition: Background2D.cpp:101
Ogre::SceneManager * scene_manager_
The scene manager.
Definition: Background2D.h:503
Ogre::Vector2 position_
The current scroll position, virtual screen size.
Definition: Background2D.h:613
void SetScrollCurrentSeconds(const float seconds)
Sets the time taken by the current scroll action.
Definition: Background2D.cpp:338
Ogre::MaterialPtr subtract_material_
Substract blending material.
Definition: Background2D.h:573
std::vector< Background2DAnimation * > animations_
List of animations.
Definition: Background2D.h:676
Ogre::RenderOperation subtract_render_op_
Substract blending render operation.
Definition: Background2D.h:558
void SetScreenScroll(const Ogre::Vector2 &position)
Scroll position in screen coordinates.
Definition: Background2D.cpp:342
Ogre::Vector2 scroll_position_end_
Final position of the current scroll action.
Definition: Background2D.h:588
std::vector< AnimationPlayed > animation_played_
Definition: Background2D.h:671
Ogre::Vector2 virtual_screen_size_
The size of the virtual screen.
Definition: Background2D.h:640
const Ogre::Vector2 & GetScroll() const
Retrieves the scroll position in game internal screen coordinates.
Definition: Background2D.cpp:369
void CreateVertexBuffers()
Creates all vertex buffers.
Definition: Background2D.cpp:683
Ogre::RenderSystem * render_system_
The render system.
Definition: Background2D.h:508
void ScriptPlayAnimationOnce(const char *name)
Plays an animation once, then stops.
Definition: Background2D.cpp:629
virtual void calculateScreenScale()
Calculates the screen scale.
Definition: Background2D.cpp:177
void UpdateDebug()
Debug inormation about changes in the background.
Definition: Background2D.cpp:160
int ScriptScrollSync()
Waits for the scroll to complete.
Definition: Background2D.cpp:302
Ogre::Vector2 screen_proportion_
Screen aspect ration.
Definition: Background2D.h:635
SCROLL_TYPE
How to scroll the background.
Definition: Background2D.h:38
@ SMOOTH
Smooth (soft in, soft out) scroll.
Definition: Background2D.h:57
@ LINEAR
Linearly scroll.
Definition: Background2D.h:51
@ NONE
Don't scroll the background.
Definition: Background2D.h:43
SCROLL_TYPE scroll_type_
Type of the current scroll action.
Definition: Background2D.h:593
void PlayAnimation(const Ogre::String &animation, const Background2DAnimation::State state)
Plays an animation.
Definition: Background2D.cpp:600
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.
Definition: Background2D.cpp:438
Ogre::Vector2 offset_
The current background offset, virtual screen size.
Definition: Background2D.h:618
virtual void load(const VGears::Background2DFilePtr &background)
Loads a background.
Definition: Background2D.cpp:752
Ogre::MaterialPtr alpha_material_
Alpha blending material.
Definition: Background2D.h:533
void SetImage(const Ogre::String &image)
Sets the background image.
Definition: Background2D.cpp:373
void Show()
Shows the background.
Definition: Background2D.cpp:119
virtual void applyScroll()
Apply the camera position to match the current scroll.
Definition: Background2D.cpp:360
void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation) override
Ends the render queue.
Definition: Background2D.cpp:644
unsigned int subtract_max_vertex_count_
Substract blending max vertex count.
Definition: Background2D.h:568
void ScriptPlayAnimationLooped(const char *name)
Plays an animation in a loop.
Definition: Background2D.cpp:624
@ TILE_VERTEX_INDEX_SIZE
Tile vertex index size.
Definition: Background2D.h:485
@ TILE_VERTEX_COUNT
Tile vertex count.
Definition: Background2D.h:480
virtual void virtualScreenToWorldSpace(Ogre::Vector2 &pos) const
Sets the virtual screen to world space.
Definition: Background2D.cpp:431
Ogre::RenderOperation alpha_render_op_
Alpha blending render operation.
Definition: Background2D.h:518
VGears::Blending Blending
Definition: Background2D.h:33
Ogre::Vector2 position_real_
The current scroll position, viewport size.
Definition: Background2D.h:625
const Ogre::Vector2 GetScreenScroll() const
Retrieves the scroll position in screen coordinates.
Definition: Background2D.cpp:371
void ScriptAutoScrollToEntity(Entity *entity)
Flags the background to automatically scroll to an entity position.
Definition: Background2D.cpp:265
TileList tiles_
The list of tiles in the background.
Definition: Background2D.h:513
std::vector< ScriptId > scroll_sync_
Definition: Background2D.h:608
Ogre::RenderOperation add_render_op_
Add blending render operation.
Definition: Background2D.h:538
Ogre::HardwareVertexBufferSharedPtr add_vertex_buffer_
Add blending vertex buffer.
Definition: Background2D.h:543
float scroll_seconds_
Total duration of the current scroll action, in seconds.
Definition: Background2D.h:598
void SetScroll(const Ogre::Vector2 &position)
Sets the scroll in game internal screen coordinates.
Definition: Background2D.cpp:346
void UnsetScroll()
Stops the current scrolling.
Definition: Background2D.cpp:323
void SetRange(const int min_x, const int min_y, const int max_x, const int max_y)
Set the background scrolling range.
Definition: Background2D.cpp:390
Ogre::Vector2 scroll_position_start_
Starting position of the current scroll action.
Definition: Background2D.h:583
Ogre::Real screen_scale_
The scale of the screen.
Definition: Background2D.h:630
float GetScrollSeconds() const
Retrieves the total duration the current scroll action.
Definition: Background2D.cpp:336
Any entity in a field.
Definition: Entity.h:101
std::vector< Tile > TileList
Definition: VGearsBackground2DFile.h:63
Ogre::SharedPtr< Background2DFile > Background2DFilePtr
Definition: VGearsBackground2DFile.h:217
std::map< String, Animation > AnimationMap
Definition: VGearsTile.h:77
Ogre::String String
Definition: TypeDefine.h:37
Blending
Definition: VGearsTile.h:23
unsigned char uint8
Definition: scummsys.h:431
State of an animation.
Definition: Background2D.h:650
Ogre::String name
Animation name.
Definition: Background2D.h:655
std::vector< ScriptId > sync
Definition: Background2D.h:660
Background2DAnimation::State state
Animation state.
Definition: Background2D.h:665
Represents a tile.
Definition: Background2D.h:389
size_t start_vertex_index
Definition: Background2D.h:414
int height
Tile height.
Definition: Background2D.h:409
int x
Tile X coordinate.
Definition: Background2D.h:394
Blending blending
Tile blending mode.
Definition: Background2D.h:419
int y
Tile Y coordinate.
Definition: Background2D.h:399
int width
Tile width.
Definition: Background2D.h:404
An input event.
Definition: Event.h:84
A tile.
Definition: VGearsTile.h:82