HIRO_DRAW
Computer Graphics Structures library
hiro::draw::Scene Class Reference

Defines rendering viewport, contains multiple object instances and a camera. More...

Public Member Functions

 Scene ()=default
 Size of an ground grid cell. More...
 
 Scene (int32_t x, int32_t y, int32_t width, int32_t height)
 Creates a scene and initializes viewport to the specified values.
 
 Scene (const Scene &)=delete
 
glm::vec3 MoveInProjectionSpace (const glm::vec3 &point, const glm::vec2 &proj_move_origin, const glm::vec2 &proj_move_end)
 For a 3D point, transfers screen movement into world, in parallel to camera projection plane. More...
 
hiro::draw::VisualCamera * GetCamera ()
 Returns camera object.
 
uint32_t GetInstanceCount ()
 Returns number of instances added to the scene.
 
int32_t AddInstance (const hiro::draw::PRenderer object, const hiro::draw::PStyle style, const uint8_t layer=0)
 Adds new instance to the scene. More...
 
void RemoveInstance (int32_t index)
 Removes instance by its index.
 
void ClearInstances ()
 Removes all instances.
 
void AddLight (const uint32_t &light)
 Add index of renderer light into scene, which should influence rendered objects.
 
void SetLights (const std::vector< uint32_t > &lights)
 Set indices of renderer lights into scene, which should influence rendered objects.
 
void SetProjectionPersp (float fov, float near_plane=0.01f, float far_plane=1000.0f)
 Setup scene projection matrix into perspective projection.
 
void SetProjectionOrtho (float sizing, float near_plane=0.01f, float far_plane=1000.0f)
 Setup scene projection matrix into orthographic projection.
 
void SetProjectionCustom (const glm::mat4 &proj_matrix)
 Setup scene projection matrix into orthographic projection.
 
void SetProjectionCameraParams (const glm::uvec2 &resolution, float fx, float fy, float cx, float cy, float near_plane=0.01f, float far_plane=1000.0f)
 Setup scene projection matrix based on camera intrinsic parameters.
 
void SetProjMatrix (const glm::mat4 &proj_mat)
 Set scene projection matrix to custom matrix.
 
const glm_ext::TransMat4 & GetProjectionMat () const
 Returns current projection matrix of a scene.
 
glm_ext::TransMat4 GetViewProjMat () const
 Returns current view and projection matrix of a scene.
 
glm_ext::TransMat4 GetViewMat () const
 Returns current view matrix of a scene.
 
void SetViewport (int32_t x, int32_t y, int32_t width, int32_t height)
 Sets up rendering viewport for a scene.
 
const geom::IRect & GetViewport () const
 Returns rendering viewport for a scene.
 
float GetNearDistance () const
 Returns near plane distance.
 
float GetFarDistance () const
 Returns far plane distance.
 
float GetFovX () const
 Returns the camera's field of view angle in x (camera right) direction.
 
float GetFovY () const
 Returns the camera's field of view angle in y (camera up) direction.
 
float GetAspectRatio () const
 Compute the camera's aspect ratio (w/h);.
 
ProjectionParams GetProjectionParams () const
 Returns projection parameters of this scene.
 

Data Fields

bool render_world_axes = true
 
hiro::draw::GroundGrid render_ground_grid = hiro::draw::GroundGrid::none
 Whether to render world axes in this scene view.
 
float ground_grid_scale = 1.0f
 Current ground grid render mode.
 

Static Public Attributes

static const int32_t INVALID_INSTANCE_INDEX
 

Friends

class RenderSystem
 

Detailed Description

Defines rendering viewport, contains multiple object instances and a camera.

A scene represents single viewport and can hold multiple pointers to object instances with accoring styles, to be rendered in hiro::draw::Renderer. Additionally, it contains internal hiro::draw::Camera object and projection matrix.

Constructor & Destructor Documentation

◆ Scene()

hiro::draw::Scene::Scene ( )
default

Size of an ground grid cell.

Creates a scene.

Member Function Documentation

◆ AddInstance()

int32_t hiro::draw::Scene::AddInstance ( const hiro::draw::PRenderer  object,
const hiro::draw::PStyle  style,
const uint8_t  layer = 0 
)

Adds new instance to the scene.

Parameters
layerSpecifies rendering order. Objects on larger layers are rendered on top. Default layer is 0.
Returns
A non-negative index of instance. This index is unique for each instance in a single scene. If instance addition fails, function returns -1.

◆ MoveInProjectionSpace()

glm::vec3 hiro::draw::Scene::MoveInProjectionSpace ( const glm::vec3 &  point,
const glm::vec2 &  proj_move_origin,
const glm::vec2 &  proj_move_end 
)

For a 3D point, transfers screen movement into world, in parallel to camera projection plane.

Parameters
pointPoint for which the resulting movement vector will be calculated.
proj_move_originScreen-space movement start.
proj_move_endScreen-space movement end.
Returns
World-space movement vector.