Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
rendering_engine::StaticMesh Class Reference

3D drawable component for rendering static (non-animated) meshes. More...

#include <static_mesh.hpp>

Inherits rendering_engine::Drawable3D.

Public Member Functions

 StaticMesh (RenderResourceContext renderContext, Scene &scene, StaticMeshParams params)
 Constructs a StaticMesh component associated with a given render context. More...
 
void Initialize () override
 Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names. More...
 
void Update (float deltaTime) override
 Updates logic (animation, movement, etc.) for this drawable. More...
 
void Draw (const Camera &camera) override
 Submits this mesh to the renderer for drawing. More...
 
 StaticMesh (const StaticMesh &rhs)=delete
 
StaticMeshoperator= (const StaticMesh &rhs)=delete
 
- Public Member Functions inherited from rendering_engine::Drawable3D
 Drawable3D (RenderResourceContext renderContext, Scene &scene)
 Constructs the Drawable3D with a render context. More...
 
void Initialize () override
 Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names. More...
 
void Update (float deltaTime) override
 Updates logic (animation, movement, etc.) for this drawable. More...
 
virtual void Draw (const Camera &camera)=0
 Submits this mesh to the renderer for drawing. More...
 
void SetPosition (const glm::vec3 &position)
 Sets the mesh position in world space. More...
 
void SetRotation (const glm::vec3 &rotation)
 Sets the mesh rotation in degrees. More...
 
void SetScale (const glm::vec3 &scale)
 Sets the mesh scale along each axis. More...
 
const glm::vec3 & GetPosition () const
 Gets the mesh position. More...
 
const glm::vec3 & GetRotation () const
 Gets the mesh rotation (pitch, yaw, roll in degrees). More...
 
const glm::vec3 & GetScale () const
 Gets the mesh scale. More...
 
SceneComponentGetTransform ()
 Access to the underlying SceneComponent (transform). More...
 
const SceneComponentGetTransform () const
 
void Destroy () override
 Requests destruction of this drawable. More...
 
 Drawable3D (const Drawable3D &rhs)=delete
 
Drawable3Doperator= (const Drawable3D &rhs)=delete
 
- Public Member Functions inherited from rendering_engine::DrawableComponent
 DrawableComponent (RenderResourceContext renderContext, Scene &scene)
 Constructs the DrawableComponent with a resource context. More...
 
virtual ~DrawableComponent ()=default
 Virtual destructor. More...
 
virtual void Initialize ()
 Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names. More...
 
virtual void Update (float deltaTime)=0
 Updates logic (animation, movement, etc.) for this drawable. More...
 
virtual void Shutdown ()
 Releases all render resources owned by this drawable. More...
 
virtual void Destroy ()
 Requests destruction of this drawable. More...
 
void UpdateOnTick (bool in)
 
 DrawableComponent (const DrawableComponent &)=delete
 
DrawableComponentoperator= (const DrawableComponent &)=delete
 

Protected Attributes

StaticMeshParams mParams
 
- Protected Attributes inherited from rendering_engine::Drawable3D
SceneComponent mSceneComponent
 
- Protected Attributes inherited from rendering_engine::DrawableComponent
RenderResourceContext mRenderContext
 
ScenemScene
 
std::vector< RenderBatchmRenderBatches
 
bool bUpdateOnTick
 

Additional Inherited Members

- Protected Member Functions inherited from rendering_engine::DrawableComponent
void AddRenderBatch (std::string meshName, std::string materialName)
 

Detailed Description

3D drawable component for rendering static (non-animated) meshes.

Note
Not copyable or assignable.
See also
Drawable3D, DrawableComponent, SceneComponent, Camera

Definition at line 36 of file static_mesh.hpp.

Constructor & Destructor Documentation

◆ StaticMesh() [1/2]

rendering_engine::StaticMesh::StaticMesh ( RenderResourceContext  renderContext,
Scene scene,
StaticMeshParams  params 
)

Constructs a StaticMesh component associated with a given render context.

Parameters
renderContextRendering resource context for material and mesh initialization.

Definition at line 13 of file static_mesh.cpp.

14 :
15 Drawable3D(renderContext, scene),
16 mParams(params)
17{
18}
Drawable3D(RenderResourceContext renderContext, Scene &scene)
Constructs the Drawable3D with a render context.
Definition: drawable_3d.cpp:7

◆ StaticMesh() [2/2]

rendering_engine::StaticMesh::StaticMesh ( const StaticMesh rhs)
delete

Member Function Documentation

◆ Draw()

void rendering_engine::StaticMesh::Draw ( const Camera camera)
overridevirtual

Submits this mesh to the renderer for drawing.

Implements rendering_engine::Drawable3D.

Definition at line 31 of file static_mesh.cpp.

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}
SceneComponent mSceneComponent
Definition: drawable_3d.hpp:99
std::vector< RenderBatch > mRenderBatches
const glm::mat4 & GetWorldMatrix()
Returns the world transformation matrix (model matrix).

◆ Initialize()

void rendering_engine::StaticMesh::Initialize ( )
overridevirtual

Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names.

Reimplemented from rendering_engine::Drawable3D.

Definition at line 20 of file static_mesh.cpp.

21{
24}
void Initialize() override
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
Definition: drawable_3d.cpp:11
void AddRenderBatch(std::string meshName, std::string materialName)
std::unordered_map< uint32_t, std::string > materials
Definition: static_mesh.hpp:23

◆ operator=()

StaticMesh & rendering_engine::StaticMesh::operator= ( const StaticMesh rhs)
delete

◆ Update()

void rendering_engine::StaticMesh::Update ( float  deltaTime)
overridevirtual

Updates logic (animation, movement, etc.) for this drawable.

Parameters
deltaTimeTime step (seconds).

Reimplemented from rendering_engine::Drawable3D.

Definition at line 26 of file static_mesh.cpp.

27{
28 Drawable3D::Update(deltaTime);
29}
void Update(float deltaTime) override
Updates logic (animation, movement, etc.) for this drawable.
Definition: drawable_3d.cpp:16

Member Data Documentation

◆ mParams

StaticMeshParams rendering_engine::StaticMesh::mParams
protected

Definition at line 64 of file static_mesh.hpp.


The documentation for this class was generated from the following files: