Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
MeshComponent Class Reference

MeshComponent is a renderable component that holds a reference to a Mesh. It is responsible for rendering the mesh using the transform of its owning actor. This component also supports texture selection via index and texture tiling adjustments. More...

#include <MeshComponent.h>

Inheritance diagram for MeshComponent:
RenderComponent Component

Public Member Functions

 MeshComponent (Actor *pOwner, Mesh *pMesh)
 Constructs a MeshComponent and assigns it to an owning Actor.
 
void Render (IRenderer *rRenderer) override
 Renders the mesh using the renderer interface. Applies the world transform of the owning actor and texture tiling before rendering.
 
RenderType GetRenderType () override
 Returns the render type of the component, which is World for MeshComponent. Used to determine how and where in the pipeline the object should be rendered.
 
virtual void SetMesh (Mesh &pMesh)
 Sets the mesh that this component will render.
 
void SetTextureIndex (size_t pTextureIndex)
 Sets the index of the texture to be used from the mesh's texture list.
 
void SetTextureTiling (float x, float y)
 Sets the tiling factor for the mesh's texture. This controls how many times the texture is repeated across the surface.
 
- Public Member Functions inherited from RenderComponent
 RenderComponent (Actor *pOwner)
 Constructs the RenderComponent and assigns it to the owning Actor.
 
void OnStart () override
 Called when the component is started. Registers the component with the scene's renderer for drawing.
 
void OnEnd () override
 Called when the component is removed or destroyed. Unregisters the component from the renderer.
 
virtual int GetDrawOrder () const
 
- Public Member Functions inherited from Component
 Component (Actor *pOwner, int pUpdateOrder=100)
 Constructor for Component.
 
virtual ~Component ()
 
virtual void Update ()
 Called every frame to update the component. This can be used to perform actions that need to be updated periodically.
 
virtual void OnUpdateWorldTrandform ()
 Called when the world transform of the actor is updated. This allows the component to react to changes in the actor's world transform.
 
void SetActive (bool isActive)
 Sets the active status of the component.
 
void SetOwner (Actor *pOwner)
 Sets the actor that owns this component.
 
int GetUpdateOrder () const
 Returns the update order of the component. Components with lower update orders are updated first.
 
ActorGetOwner () const
 Returns the actor that owns this component.
 

Protected Attributes

MeshmMesh
 Pointer to the mesh to render.
 
size_t mTextureIndex
 Index of the texture to apply from the mesh's texture list.
 
Vector2 mTiling = Vector2::ONE
 Texture tiling factor (1,1 means no tiling)
 
- Protected Attributes inherited from Component
ActormOwner = nullptr
 The actor that owns this component.
 

Additional Inherited Members

- Public Attributes inherited from RenderComponent
Color mColor { 255,255,255,255 }
 

Detailed Description

MeshComponent is a renderable component that holds a reference to a Mesh. It is responsible for rendering the mesh using the transform of its owning actor. This component also supports texture selection via index and texture tiling adjustments.

Constructor & Destructor Documentation

◆ MeshComponent()

MeshComponent::MeshComponent ( Actor * pOwner,
Mesh * pMesh )

Constructs a MeshComponent and assigns it to an owning Actor.

Parameters
pOwnerPointer to the Actor that owns this component.
pMeshPointer to the Mesh to render.

Member Function Documentation

◆ GetRenderType()

RenderType MeshComponent::GetRenderType ( )
overridevirtual

Returns the render type of the component, which is World for MeshComponent. Used to determine how and where in the pipeline the object should be rendered.

Returns
RenderType::World

Implements RenderComponent.

◆ Render()

void MeshComponent::Render ( IRenderer * rRenderer)
overridevirtual

Renders the mesh using the renderer interface. Applies the world transform of the owning actor and texture tiling before rendering.

Parameters
rRendererReference to the renderer responsible for drawing.

Implements RenderComponent.

◆ SetMesh()

void MeshComponent::SetMesh ( Mesh & pMesh)
virtual

Sets the mesh that this component will render.

Parameters
pMeshReference to the Mesh object.

◆ SetTextureIndex()

void MeshComponent::SetTextureIndex ( size_t pTextureIndex)

Sets the index of the texture to be used from the mesh's texture list.

Parameters
pTextureIndexThe index of the texture to use.

◆ SetTextureTiling()

void MeshComponent::SetTextureTiling ( float x,
float y )

Sets the tiling factor for the mesh's texture. This controls how many times the texture is repeated across the surface.

Parameters
xTiling amount in the X direction.
yTiling amount in the Y direction.

Member Data Documentation

◆ mMesh

Mesh* MeshComponent::mMesh
protected

Pointer to the mesh to render.

◆ mTextureIndex

size_t MeshComponent::mTextureIndex
protected

Index of the texture to apply from the mesh's texture list.

◆ mTiling

Vector2 MeshComponent::mTiling = Vector2::ONE
protected

Texture tiling factor (1,1 means no tiling)


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