class hiro::draw::Scene
Overview
Defines rendering viewport, contains multiple object instances and a camera. More…
#include <Scene.h> class Scene { public: // structs struct Instance; // fields static const int32_t INVALID_INSTANCE_INDEX; bool render_world_axes = true; hiro::draw::GroundGrid render_ground_grid = hiro::draw::GroundGrid::none; float ground_grid_scale = 1.0f; // construction Scene(); Scene(int32_t x, int32_t y, int32_t width, int32_t height); Scene(const Scene&); // methods glm::vec3 MoveInProjectionSpace(const glm::vec3& point, const glm::vec2& proj_move_origin, const glm::vec2& proj_move_end); hiro::draw::VisualCamera* GetCamera(); uint32_t GetInstanceCount(); int32_t AddInstance(const hiro::draw::PRenderer object, const hiro::draw::PStyle style, const uint8_t layer = 0); void RemoveInstance(int32_t index); void ClearInstances(); void AddLight(const uint32_t& light); void SetLights(const std::vector<uint32_t>& lights); void SetProjectionPersp(float fov, float near_plane = 0.01f, float far_plane = 1000.0f); void SetProjectionOrtho(float sizing, float near_plane = 0.01f, float far_plane = 1000.0f); void SetProjectionCustom(const glm::mat4& proj_matrix); void SetProjectionCameraParams(const glm::uvec2& resolution, float fx, float fy, float cx, float cy, float near_plane = 0.01f, float far_plane = 1000.0f); void SetProjMatrix(const glm::mat4& proj_mat); const glm_ext::TransMat4& GetProjectionMat() const; glm_ext::TransMat4 GetViewProjMat() const; glm_ext::TransMat4 GetViewMat() const; void SetViewport(int32_t x, int32_t y, int32_t width, int32_t height); const geom::IRect& GetViewport() const; float GetNearDistance() const; float GetFarDistance() const; float GetFovX() const; float GetFovY() const; float GetAspectRatio() const; ProjectionParams GetProjectionParams() const; };
Detailed Documentation
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.
Fields
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.
Construction
Scene()
Size of an ground grid cell.
Creates a scene.
Scene(int32_t x, int32_t y, int32_t width, int32_t height)
Creates a scene and initializes viewport to the specified values.
Methods
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.
Parameters:
point |
Point for which the resulting movement vector will be calculated. |
proj_move_origin |
Screen-space movement start. |
proj_move_end |
Screen-space movement end. |
Returns:
World-space movement vector.
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.
Parameters:
layer |
Specifies 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.
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.