6 #ifndef HIRO_DRAW_SCENE_H 7 #define HIRO_DRAW_SCENE_H 10 #include <Utils/GeometryStructures.h> 12 #include <HIRO_DRAW/VisualCamera.h> 13 #include <HIRO_DRAW/Renderer.h> 14 #include <HIRO_DRAW/ShaderApi.h> 60 glm::vec3 CastRay(
const glm::vec2 &clip_coords)
const;
68 glm::vec2 ScreenToClipCoords(
float x,
float y)
const;
71 geom::IRect GetViewport()
const;
97 static const int32_t INVALID_INSTANCE_INDEX;
99 bool render_world_axes =
true;
101 float ground_grid_scale = 1.0f;
106 Scene(int32_t x, int32_t y, int32_t width, int32_t height);
121 glm::vec3 MoveInProjectionSpace(
const glm::vec3 &point,
const glm::vec2 &proj_move_origin,
const glm::vec2 &proj_move_end);
127 uint32_t GetInstanceCount();
138 int32_t AddInstance(
const hiro::draw::PRenderer
object,
const hiro::draw::PStyle style,
const uint8_t layer = 0);
141 void RemoveInstance(int32_t index);
144 void ClearInstances();
147 void AddLight(
const uint32_t &light);
150 void SetLights(
const std::vector<uint32_t> &lights);
153 void SetProjectionPersp(
float fov,
float near_plane = 0.01f,
float far_plane = 1000.0f);
156 void SetProjectionOrtho(
float sizing,
float near_plane = 0.01f,
float far_plane = 1000.0f);
159 void SetProjectionCustom(
const glm::mat4 &proj_matrix);
162 void SetProjectionCameraParams(
const glm::uvec2 &resolution,
float fx,
float fy,
float cx,
float cy,
float near_plane = 0.01f,
float far_plane = 1000.0f);
165 void SetProjMatrix(
const glm::mat4 &proj_mat);
168 const glm_ext::TransMat4 &GetProjectionMat()
const;
171 glm_ext::TransMat4 GetViewProjMat()
const;
174 glm_ext::TransMat4 GetViewMat()
const;
177 void SetViewport(int32_t x, int32_t y, int32_t width, int32_t height);
180 const geom::IRect &GetViewport()
const;
188 float GetFovX()
const;
190 float GetFovY()
const;
193 float GetAspectRatio()
const;
200 struct HIRO_DRAW_API Instance
204 hiro::draw::PRenderer object;
205 hiro::draw::PStyle style;
209 enum class ProjectionType
216 int32_t next_index_ = 0;
217 std::deque<hiro::draw::Scene::Instance> instances_;
219 geom::IRect viewport_;
223 hiro::draw::Scene::ProjectionType proj_type_ = hiro::draw::Scene::ProjectionType::perspective;
224 float proj_ortho_sizing_ = 1.0f;
225 float proj_fov_ = QUAT_PI;
226 float proj_near_plane_ = 0.01f;
227 float proj_far_plane_ = 1000.0f;
228 glm_ext::TransMat4 projection_;
230 std::vector<uint32_t> lights_;
232 bool data_has_changed_ =
true;
235 void RecalculateProjection();
238 using PScene = std::shared_ptr<hiro::draw::Scene>;
float aspect
Aspect ratio of a viewport (width/height);.
Definition: Scene.h:49
glm_ext::TransMat4 proj
Projection matrix.
Definition: Scene.h:43
GroundGrid
Mode for rendering ground grid lines.
Definition: Scene.h:77
int32_t right
Viewport offset from the right window border. In pixels.
Definition: Scene.h:31
Render ground grid aligned with zx plane, and y normal.
Projection, camera and viewport parameters.
Definition: Scene.h:22
int32_t left
Viewport offset from the left window border. In pixels.
Definition: Scene.h:27
Render ground grid aligned with yz plane, and x normal.
float fov_x
Horizontal view angle. In radians.
Definition: Scene.h:33
Render ground grid aligned with xy plane, and z normal.
float near_distance
Distance to near projection plane.
Definition: Scene.h:37
int32_t top
Viewport offset from the top window border. In pixels.
Definition: Scene.h:25
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
int32_t bottom
Viewport offset from the bottom window border. In pixels.
Definition: Scene.h:29
float height
Vertical pixel resolution of viewport.
Definition: Scene.h:47
float fov_y
Vertical view angle, In radians.
Definition: Scene.h:35
float GetFarDistance() const
Returns far plane distance.
Definition: Scene.h:185
float far_distance
Distance to far projection plane.
Definition: Scene.h:39
float GetNearDistance() const
Returns near plane distance.
Definition: Scene.h:183
float width
Horizontal pixel resolution of viewport.
Definition: Scene.h:45
glm_ext::TransMat4 view
Camera view matrix.
Definition: Scene.h:41
A wrapper over view matrix, providing intuitive control.
Definition: VisualCamera.h:27
Class responsible for rendering loop implementation and its optimization.
Definition: RenderSystem.h:42
Defines rendering viewport, contains multiple object instances and a camera.
Definition: Scene.h:92