My Project
Loading...
Searching...
No Matches
MeshAsset Class Reference

Asset representing a 3D mesh. Handles CPU and GPU data, including vertex and index buffers. More...

#include <MeshAsset.hpp>

Inheritance diagram for MeshAsset:
Asset

Public Member Functions

const Maths::Vec3fGetColor () const
 Returns the mesh color.
void SetColor (float r, float g, float b)
 Sets the mesh color.
void Load () override
 Loads the mesh from file and prepares CPU data.
void Unload () override
 Frees CPU and GPU resources.
void CreateBuffers (ID3D11Device *device) override
 Creates GPU vertex and index buffers.
void Bind (ID3D11DeviceContext *context) const override
 Binds the mesh buffers to the pipeline for rendering.
bool IsReady () const
 Checks if the mesh is ready to be rendered.
UINT GetIndexCount () const
 Returns the number of indices used for DrawIndexed.
Public Member Functions inherited from Asset
virtual ~Asset ()=default
 Virtual destructor.

Public Attributes

std::vector< Vertexvertices
 Vertex data stored on CPU.
std::vector< uint32_t > indices
 Index data stored on CPU.
wrl::ComPtr< ID3D11Buffer > vertexBuffer = nullptr
 Vertex buffer on GPU.
wrl::ComPtr< ID3D11Buffer > indexBuffer = nullptr
 Index buffer on GPU.
Public Attributes inherited from Asset
AssetID id
 Unique identifier of the asset.
std::string path
 File path of the source asset.

Detailed Description

Asset representing a 3D mesh. Handles CPU and GPU data, including vertex and index buffers.

Member Function Documentation

◆ Bind()

void MeshAsset::Bind ( ID3D11DeviceContext * context) const
overridevirtual

Binds the mesh buffers to the pipeline for rendering.

Parameters
contextDevice context used for rendering

Reimplemented from Asset.

◆ CreateBuffers()

void MeshAsset::CreateBuffers ( ID3D11Device * device)
overridevirtual

Creates GPU vertex and index buffers.

Parameters
deviceD3D11 device used for buffer creation

Reimplemented from Asset.

◆ GetColor()

const Maths::Vec3f & MeshAsset::GetColor ( ) const
inline

Returns the mesh color.

Returns
Current mesh color

◆ GetIndexCount()

UINT MeshAsset::GetIndexCount ( ) const

Returns the number of indices used for DrawIndexed.

Returns
Index count

◆ IsReady()

bool MeshAsset::IsReady ( ) const

Checks if the mesh is ready to be rendered.

Returns
True if GPU buffers are valid

◆ Load()

void MeshAsset::Load ( )
overridevirtual

Loads the mesh from file and prepares CPU data.

Implements Asset.

◆ SetColor()

void MeshAsset::SetColor ( float r,
float g,
float b )
inline

Sets the mesh color.

Parameters
rRed component (0..1)
gGreen component (0..1)
bBlue component (0..1)

◆ Unload()

void MeshAsset::Unload ( )
overridevirtual

Frees CPU and GPU resources.

Implements Asset.

Member Data Documentation

◆ indexBuffer

wrl::ComPtr<ID3D11Buffer> MeshAsset::indexBuffer = nullptr

Index buffer on GPU.

◆ indices

std::vector<uint32_t> MeshAsset::indices

Index data stored on CPU.

◆ vertexBuffer

wrl::ComPtr<ID3D11Buffer> MeshAsset::vertexBuffer = nullptr

Vertex buffer on GPU.

◆ vertices

std::vector<Vertex> MeshAsset::vertices

Vertex data stored on CPU.


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