Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
static_mesh.cpp
Go to the documentation of this file.
1#include "static_mesh.hpp"
2#include "drawable_3d.hpp"
3#include "camera.hpp"
5#include "scene_component.hpp"
6#include "scene.hpp"
7
8#include <unordered_map>
9
10namespace rendering_engine
11{
12
14 :
15 Drawable3D(renderContext, scene),
16 mParams(params)
17{
18}
19
21{
24}
25
26void StaticMesh::Update(float deltaTime)
27{
28 Drawable3D::Update(deltaTime);
29}
30
31void StaticMesh::Draw(const Camera& camera)
32{
33 Transformations3D transformations;
34 transformations.model = mSceneComponent.GetWorldMatrix();
35 transformations.view = camera.ViewMatrix();
36 transformations.proj = camera.ProjectionMatrix();
37
38 for (auto& renderBatch : mRenderBatches)
39 {
40 renderBatch.renderResources->SubmitResources(transformations, renderBatch.materialParameters);
41 }
42}
43
44} // namespace rendering_engine
Represents a 3D perspective camera with world transform and projection settings.
Definition: camera.hpp:48
const glm::mat4 & ViewMatrix() const
Gets the camera view matrix.
Definition: camera.cpp:71
const glm::mat4 & ProjectionMatrix() const
Gets the camera projection matrix.
Definition: camera.cpp:75
3D drawable component for rendering objects in 3D space.
Definition: drawable_3d.hpp:27
SceneComponent mSceneComponent
Definition: drawable_3d.hpp:99
void Initialize() override
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
Definition: drawable_3d.cpp:11
void Update(float deltaTime) override
Updates logic (animation, movement, etc.) for this drawable.
Definition: drawable_3d.cpp:16
std::vector< RenderBatch > mRenderBatches
void AddRenderBatch(std::string meshName, std::string materialName)
const glm::mat4 & GetWorldMatrix()
Returns the world transformation matrix (model matrix).
Base class representing a renderable scene.
Definition: scene.hpp:44
StaticMesh(RenderResourceContext renderContext, Scene &scene, StaticMeshParams params)
Constructs a StaticMesh component associated with a given render context.
Definition: static_mesh.cpp:13
void Initialize() override
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
Definition: static_mesh.cpp:20
void Update(float deltaTime) override
Updates logic (animation, movement, etc.) for this drawable.
Definition: static_mesh.cpp:26
void Draw(const Camera &camera) override
Submits this mesh to the renderer for drawing.
Definition: static_mesh.cpp:31
Aggregates pointers to global rendering resource managers.
std::unordered_map< uint32_t, std::string > materials
Definition: static_mesh.hpp:23
Contains model, view, and projection matrices for 3D rendering.
glm::mat4 proj
Projection transformation matrix.
glm::mat4 model
Model transformation matrix.
glm::mat4 view
View (camera) transformation matrix.