Vp::Scene
A scene representing a "game world" that contains entities and is viewed by a camera. More...
#include "Viewport/scene/Scene.h"
Inherited by Vp::MainScene, Vp::PreviewScene
Public Functions
Name | |
---|---|
Scene(Viewport * viewport) | |
virtual | ~Scene() =default |
template <typename T ,typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true> <br>std::weak_ptr< T > | addEntity(std::shared_ptr< T > entity)<br>Adds entity to the scene. |
void | addSelectionCallback(std::function< void(Entity *)> callback) |
virtual Ptr< SceneRenderTarget > | createRenderTarget(const RenderOptions & options)<br>Create and populates a SceneRenderTarget object with expected framebuffer objects for the scenes render pass. |
virtual void | draw(int width, int height, const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions)<br>Draw the scene using the provided view and projection matrices. |
virtual void | draw(int width, int height, const glm::mat4 & model, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions)<br>Draw the scene using the scene's camera. |
virtual void | draw(int width, int height, const std::shared_ptr< AbstractCamera > & camera, const glm::mat4 & model, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions)<br>Draw the scene using a provided camera. |
const std::vector< std::shared_ptr< Entity > > & | getEntities() const |
virtual void | init()<br>Initialises the scene. |
void | processInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize)<br>Update input logic. |
void | processSelection(SceneRenderTarget & renderTarget, glm::vec2 mousePos, glm::ivec2 windowSize)<br>Update selection logic. |
template <typename T ,typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true> <br>void | removeEntity(std::weak_ptr< T > entity)<br>Remove entity from the scene. |
void | triggerSelectionCallbacks(Entity * entity) |
virtual void | update(double dt)<br>Update entity logic. |
Protected Functions
Name | |
---|---|
void | drawHighlight(int width, int height, const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions, ViewportSettings & stg, const Ptr< Framebuffer > & mainFBO, const Ptr< Framebuffer > & selectionFBO, const Ptr< Framebuffer > & selectionBlurFBO, const Ptr< Framebuffer > & selectionBlurSecondPassFBO) |
void | drawStandard(int width, int height, const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions, RenderOptions renderOptions, bool alpha, glm::vec3 clearColor, const Ptr< Framebuffer > & mainFBO) |
void | drawWboit(int width, int height, const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, SceneRenderTarget & renderTarget, const DisplayOptions & displayOptions, RenderOptions renderOptions, bool alpha, glm::vec3 clearColor, const Ptr< Framebuffer > & mainFBO, const Ptr< Framebuffer > & transparentFBO) |
void | renderSortedTransparentEntities(const std::vector< Entity * > & entities, const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, const DisplayOptions & displayOptions) const |
void | sortExplicitlyOrderedTransparentEntities(std::vector< Entity * > & entities) |
void | sortUnorderedTransparentEntities(std::vector< Entity * > & entities, const glm::mat4 & model, const glm::mat4 & view) |
Public Attributes
Name | |
---|---|
std::shared_ptr< AbstractCamera > | m_camera |
std::shared_ptr< Lighting > | m_lighting |
std::shared_ptr< SelectStencil > | m_selectStencil |
Viewport * | m_viewport |
Protected Attributes
Name | |
---|---|
std::vector< std::shared_ptr< Entity > > | m_entities |
std::vector< Entity * > | m_explicitTransparencyOrderEntitiesFirst |
std::vector< Entity * > | m_explicitTransparencyOrderEntitiesLast |
std::vector< Entity * > | m_highlightedEntities |
Entity * | m_selectedEntity |
std::vector< std::function< void(Entity *)> > | m_selectionCallbacks <br>Callbacks that get triggered on entity selection. |
std::vector< Entity * > | m_unorderedTransparentEntities |
Friends
Name | |
---|---|
class | Viewport |
Detailed Description
class Vp::Scene;
class Vp::Scene;
A scene representing a "game world" that contains entities and is viewed by a camera.
Handles drawing and logic updates.
Public Functions Documentation
function Scene
explicit Scene(
Viewport * viewport
)
explicit Scene(
Viewport * viewport
)
function ~Scene
virtual ~Scene() =default
virtual ~Scene() =default
function addEntity
template <typename T ,
typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true>
inline std::weak_ptr< T > addEntity(
std::shared_ptr< T > entity
)
template <typename T ,
typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true>
inline std::weak_ptr< T > addEntity(
std::shared_ptr< T > entity
)
Adds entity to the scene.
Parameters:
- entity A shared pointer to the entity to add. This pointer should be destroyed afterwards.
Template Parameters:
- T Any derived type of Entity
Return: A weak pointer to the added entity of said type.
Entity is added via a shared pointer which is copied and stored. The original pointer should be discarded after this call and the weak reference can be further used.
function addSelectionCallback
inline void addSelectionCallback(
std::function< void(Entity *)> callback
)
inline void addSelectionCallback(
std::function< void(Entity *)> callback
)
function createRenderTarget
virtual Ptr< SceneRenderTarget > createRenderTarget(
const RenderOptions & options
)
virtual Ptr< SceneRenderTarget > createRenderTarget(
const RenderOptions & options
)
Create and populates a SceneRenderTarget object with expected framebuffer objects for the scenes render pass.
Parameters:
- options Relevant render options to take into account during render target creation
Return: Owning pointer to the created render target object
Individual framebuffers are only identified by their index in the render target framebuffer array. It is expected that these indexes are kept track of somewhere else, or just expected to be a certain way.
function draw
virtual void draw(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
virtual void draw(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
Draw the scene using the provided view and projection matrices.
Parameters:
- width Desired framebuffer pixel width
- height Desired framebuffer pixel height
- model Implicit model matrix, multiplies all model transforms from the left.
Reimplemented by: Vp::MainScene::draw, Vp::MainScene::draw
function draw
virtual void draw(
int width,
int height,
const glm::mat4 & model,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
virtual void draw(
int width,
int height,
const glm::mat4 & model,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
Draw the scene using the scene's camera.
Parameters:
- width Desired framebuffer pixel width
- height Desired framebuffer pixel height
- model Implicit model matrix, multiplies all model transforms from the left.
Reimplemented by: Vp::MainScene::draw
function draw
virtual void draw(
int width,
int height,
const std::shared_ptr< AbstractCamera > & camera,
const glm::mat4 & model,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
virtual void draw(
int width,
int height,
const std::shared_ptr< AbstractCamera > & camera,
const glm::mat4 & model,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions
)
Draw the scene using a provided camera.
Parameters:
- width Desired framebuffer pixel width
- height Desired framebuffer pixel height
- camera The camera to render the scene with
- model Implicit model matrix, multiplies all model transforms from the left.
Reimplemented by: Vp::MainScene::draw
function getEntities
inline const std::vector< std::shared_ptr< Entity > > & getEntities() const
inline const std::vector< std::shared_ptr< Entity > > & getEntities() const
function init
inline virtual void init()
inline virtual void init()
Initialises the scene.
Reimplemented by: Vp::MainScene::init, Vp::PreviewScene::init
Should be called before any draw operations.
function processInput
void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
)
void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
)
Update input logic.
Parameters:
- dt Time since last frame
- mousePos Current mouse position relative to the window
- windowSize Current window size
function processSelection
void processSelection(
SceneRenderTarget & renderTarget,
glm::vec2 mousePos,
glm::ivec2 windowSize
)
void processSelection(
SceneRenderTarget & renderTarget,
glm::vec2 mousePos,
glm::ivec2 windowSize
)
Update selection logic.
Parameters:
- diwne
- renderTarget Scene's render target
- mousePos Current mouse position relative to the window
- windowSize Current window size
function removeEntity
template <typename T ,
typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true>
inline void removeEntity(
std::weak_ptr< T > entity
)
template <typename T ,
typename std::enable_if< std::is_base_of< Entity, T >::value, bool >::type =true>
inline void removeEntity(
std::weak_ptr< T > entity
)
Remove entity from the scene.
Parameters:
- entity
Template Parameters:
- T Any derived type of Entity
The entity is passed as a weak pointer previously acquired by addEntity()
function triggerSelectionCallbacks
void triggerSelectionCallbacks(
Entity * entity
)
void triggerSelectionCallbacks(
Entity * entity
)
function update
virtual void update(
double dt
)
virtual void update(
double dt
)
Update entity logic.
Reimplemented by: Vp::MainScene::update
Protected Functions Documentation
function drawHighlight
void drawHighlight(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
ViewportSettings & stg,
const Ptr< Framebuffer > & mainFBO,
const Ptr< Framebuffer > & selectionFBO,
const Ptr< Framebuffer > & selectionBlurFBO,
const Ptr< Framebuffer > & selectionBlurSecondPassFBO
)
void drawHighlight(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
ViewportSettings & stg,
const Ptr< Framebuffer > & mainFBO,
const Ptr< Framebuffer > & selectionFBO,
const Ptr< Framebuffer > & selectionBlurFBO,
const Ptr< Framebuffer > & selectionBlurSecondPassFBO
)
function drawStandard
void drawStandard(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
RenderOptions renderOptions,
bool alpha,
glm::vec3 clearColor,
const Ptr< Framebuffer > & mainFBO
)
void drawStandard(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
RenderOptions renderOptions,
bool alpha,
glm::vec3 clearColor,
const Ptr< Framebuffer > & mainFBO
)
function drawWboit
void drawWboit(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
RenderOptions renderOptions,
bool alpha,
glm::vec3 clearColor,
const Ptr< Framebuffer > & mainFBO,
const Ptr< Framebuffer > & transparentFBO
)
void drawWboit(
int width,
int height,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
SceneRenderTarget & renderTarget,
const DisplayOptions & displayOptions,
RenderOptions renderOptions,
bool alpha,
glm::vec3 clearColor,
const Ptr< Framebuffer > & mainFBO,
const Ptr< Framebuffer > & transparentFBO
)
function renderSortedTransparentEntities
void renderSortedTransparentEntities(
const std::vector< Entity * > & entities,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const DisplayOptions & displayOptions
) const
void renderSortedTransparentEntities(
const std::vector< Entity * > & entities,
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const DisplayOptions & displayOptions
) const
function sortExplicitlyOrderedTransparentEntities
void sortExplicitlyOrderedTransparentEntities(
std::vector< Entity * > & entities
)
void sortExplicitlyOrderedTransparentEntities(
std::vector< Entity * > & entities
)
function sortUnorderedTransparentEntities
void sortUnorderedTransparentEntities(
std::vector< Entity * > & entities,
const glm::mat4 & model,
const glm::mat4 & view
)
void sortUnorderedTransparentEntities(
std::vector< Entity * > & entities,
const glm::mat4 & model,
const glm::mat4 & view
)
Public Attributes Documentation
variable m_camera
std::shared_ptr< AbstractCamera > m_camera;
std::shared_ptr< AbstractCamera > m_camera;
variable m_lighting
std::shared_ptr< Lighting > m_lighting;
std::shared_ptr< Lighting > m_lighting;
variable m_selectStencil
std::shared_ptr< SelectStencil > m_selectStencil;
std::shared_ptr< SelectStencil > m_selectStencil;
variable m_viewport
Viewport * m_viewport;
Viewport * m_viewport;
Protected Attributes Documentation
variable m_entities
std::vector< std::shared_ptr< Entity > > m_entities;
std::vector< std::shared_ptr< Entity > > m_entities;
variable m_explicitTransparencyOrderEntitiesFirst
std::vector< Entity * > m_explicitTransparencyOrderEntitiesFirst;
std::vector< Entity * > m_explicitTransparencyOrderEntitiesFirst;
variable m_explicitTransparencyOrderEntitiesLast
std::vector< Entity * > m_explicitTransparencyOrderEntitiesLast;
std::vector< Entity * > m_explicitTransparencyOrderEntitiesLast;
variable m_highlightedEntities
std::vector< Entity * > m_highlightedEntities;
std::vector< Entity * > m_highlightedEntities;
variable m_selectedEntity
Entity * m_selectedEntity = nullptr;
Entity * m_selectedEntity = nullptr;
variable m_selectionCallbacks
std::vector< std::function< void(Entity *)> > m_selectionCallbacks;
std::vector< std::function< void(Entity *)> > m_selectionCallbacks;
Callbacks that get triggered on entity selection.
variable m_unorderedTransparentEntities
std::vector< Entity * > m_unorderedTransparentEntities;
std::vector< Entity * > m_unorderedTransparentEntities;
Friends
friend Viewport
friend class Viewport(
Viewport
);
friend class Viewport(
Viewport
);
Updated on 2025-05-31 at 12:55:31 +0000