MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::Model Class Reference

#include <model.hpp>

Inheritance diagram for mage::rendering::Model:
mage::Component

Public Member Functions

 Model (ID3D11Device &device)
 
 Model (const Model &model)=delete
 
 Model (Model &&model) noexcept
 
virtual ~Model ()
 
Model & operator= (const Model &model)=delete
 
Model & operator= (Model &&model) noexcept
 
void SetMesh (SharedPtr< const Mesh > mesh, std::size_t start_index, std::size_t nb_indices, AABB aabb, BoundingSphere bs)
 
const AABB & GetAABB () const noexcept
 
const BoundingSphere & GetBoundingSphere () const noexcept
 
std::size_t GetStartIndex () const noexcept
 
std::size_t GetNumberOfIndices () const noexcept
 
void BindMesh (ID3D11DeviceContext &device_context) const noexcept
 
void BindMesh (ID3D11DeviceContext &device_context, D3D11_PRIMITIVE_TOPOLOGY topology) const noexcept
 
void Draw (ID3D11DeviceContext &device_context) const noexcept
 
TextureTransform2D & GetTextureTransform () noexcept
 
const TextureTransform2D & GetTextureTransform () const noexcept
 
Material & GetMaterial () noexcept
 
const Material & GetMaterial () const noexcept
 
bool OccludesLight () const noexcept
 
void EnableLightOcclusion () noexcept
 
void DissableLightOcclusion () noexcept
 
void ToggleLightOcclusion () noexcept
 
void SetLightOcclusion (bool light_occlusion) noexcept
 
void UpdateBuffer (ID3D11DeviceContext &device_context) const
 
template<typename PipelineStageT >
void BindBuffer (ID3D11DeviceContext &device_context, U32 slot) const noexcept
 
- Public Member Functions inherited from mage::Component
virtual ~Component ()
 
Component & operator= (const Component &component) noexcept
 
Component & operator= (Component &&component) noexcept
 
State GetState () const noexcept
 
void SetState (State state) noexcept
 
U64 GetGuid () const noexcept
 
bool HasOwner () const noexcept
 
ProxyPtr< Node > GetOwner () noexcept
 
ProxyPtr< const Node > GetOwner () const noexcept
 

Private Attributes

ConstantBuffer< ModelBuffer > m_buffer
 
AABB m_aabb
 
BoundingSphere m_sphere
 
SharedPtr< const Mesh > m_mesh
 
std::size_t m_start_index
 
std::size_t m_nb_indices
 
TextureTransform2D m_texture_transform
 
Material m_material
 
bool m_light_occlusion
 

Additional Inherited Members

- Protected Member Functions inherited from mage::Component
 Component () noexcept
 
 Component (const Component &component) noexcept
 
 Component (Component &&component) noexcept
 

Detailed Description

A class of models.

Constructor & Destructor Documentation

◆ Model() [1/3]

mage::rendering::Model::Model ( ID3D11Device &  device)
explicit

Constructs a model.

Parameters
[in,out]deviceA reference to the device.

◆ Model() [2/3]

mage::rendering::Model::Model ( const Model &  model)
delete

Constructs a model from the given model.

Parameters
[in]modelA reference to the model to copy.

◆ Model() [3/3]

mage::rendering::Model::Model ( Model &&  model)
defaultnoexcept

Constructs a model by moving the given model.

Parameters
[in]modelA reference to the model to move.

◆ ~Model()

mage::rendering::Model::~Model ( )
virtualdefault

Destructs this model.

Member Function Documentation

◆ BindBuffer()

template<typename PipelineStageT >
void mage::rendering::Model::BindBuffer ( ID3D11DeviceContext &  device_context,
U32  slot 
) const
noexcept

Binds the buffer of this model to the given pipeline stage.

Template Parameters
PipelineStageTThe pipeline stage type.
Parameters
[in,out]device_contextA reference to the device context.
[in]slotThe index into the device's zero-based array to set the constant buffer to (ranges from 0 to D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1).

◆ BindMesh() [1/2]

void mage::rendering::Model::BindMesh ( ID3D11DeviceContext &  device_context) const
noexcept

Binds the mesh of this model.

Parameters
[in,out]device_contextA reference to the device context.

◆ BindMesh() [2/2]

void mage::rendering::Model::BindMesh ( ID3D11DeviceContext &  device_context,
D3D11_PRIMITIVE_TOPOLOGY  topology 
) const
noexcept

Binds the mesh of this model with given primitive topology.

Parameters
[in,out]device_contextA reference to the device context.
[in]topologyThe primitive topology.

◆ DissableLightOcclusion()

void mage::rendering::Model::DissableLightOcclusion ( )
noexcept

Dissables the occlusion of light by this model.

◆ Draw()

void mage::rendering::Model::Draw ( ID3D11DeviceContext &  device_context) const
noexcept

Draws this model.

Parameters
[in,out]device_contextA reference to the device context.

◆ EnableLightOcclusion()

void mage::rendering::Model::EnableLightOcclusion ( )
noexcept

Enbales the occlusion of light by this model.

◆ GetAABB()

const AABB& mage::rendering::Model::GetAABB ( ) const
noexcept

Returns the AABB of this model.

Returns
A reference to the AABB of this model.

◆ GetBoundingSphere()

const BoundingSphere& mage::rendering::Model::GetBoundingSphere ( ) const
noexcept

Returns the bounding sphere of this model.

Returns
A reference to the bounding sphere of this model.

◆ GetMaterial() [1/2]

Material& mage::rendering::Model::GetMaterial ( )
noexcept

Returns the material of this model.

Returns
A reference to the material of this model.

◆ GetMaterial() [2/2]

const Material& mage::rendering::Model::GetMaterial ( ) const
noexcept

Returns the material of this model.

Returns
A reference to the material of this model.

◆ GetNumberOfIndices()

std::size_t mage::rendering::Model::GetNumberOfIndices ( ) const
noexcept

Returns the number of indices of this model in the mesh of this model.

Returns
The number of indices of this model in the mesh of this model.

◆ GetStartIndex()

std::size_t mage::rendering::Model::GetStartIndex ( ) const
noexcept

Returns the start index of this model in the mesh of this model.

Returns
The start index of this model in the mesh of this model.

◆ GetTextureTransform() [1/2]

TextureTransform2D& mage::rendering::Model::GetTextureTransform ( )
noexcept

Returns the texture transform of this model.

Returns
A reference to the texture transform of this model.

◆ GetTextureTransform() [2/2]

const TextureTransform2D& mage::rendering::Model::GetTextureTransform ( ) const
noexcept

Returns the texture transform of this model.

Returns
A reference to the texture transform of this model.

◆ OccludesLight()

bool mage::rendering::Model::OccludesLight ( ) const
noexcept

Checks whether this model occludes light.

Returns
true if this model occludes light. false otherwise.

◆ operator=() [1/2]

Model& mage::rendering::Model::operator= ( const Model &  model)
delete

Copies the given model to this model.

Parameters
[in]modelA reference to the model to copy.
Returns
A reference to the copy of the given model (i.e. this model).

◆ operator=() [2/2]

Model & mage::rendering::Model::operator= ( Model &&  model)
defaultnoexcept

Moves the given model to this model.

Parameters
[in]modelA reference to the model to move.
Returns
A reference to the moved model (i.e. this model).

◆ SetLightOcclusion()

void mage::rendering::Model::SetLightOcclusion ( bool  light_occlusion)
noexcept

Sets the occlusion of light by this model to the given value.

Parameters
[in]light_occlusiontrue if this model needs to occlude light. false otherwise.

◆ SetMesh()

void mage::rendering::Model::SetMesh ( SharedPtr< const Mesh >  mesh,
std::size_t  start_index,
std::size_t  nb_indices,
AABB  aabb,
BoundingSphere  bs 
)

Sets the mesh of this model to the given mesh.

Parameters
[in]meshA pointer to the mesh.
[in]start_indexThe start index in the mesh.
[in]nb_indicesThe number of indices in the mesh.
[in]aabbThe AABB.
[in]bsThe bounding sphere.

◆ ToggleLightOcclusion()

void mage::rendering::Model::ToggleLightOcclusion ( )
noexcept

Toggles the occlusion of light by this model.

◆ UpdateBuffer()

void mage::rendering::Model::UpdateBuffer ( ID3D11DeviceContext &  device_context) const

Updates the buffer of this model.

Parameters
[in,out]device_contextA reference to the device context.

Member Data Documentation

◆ m_aabb

AABB mage::rendering::Model::m_aabb
private

The AABB of this model.

◆ m_buffer

ConstantBuffer< ModelBuffer > mage::rendering::Model::m_buffer
mutableprivate

The buffer of this model.

◆ m_light_occlusion

bool mage::rendering::Model::m_light_occlusion
private

A flag indicating whether this model occludes light.

◆ m_material

Material mage::rendering::Model::m_material
private

The material of this model.

◆ m_mesh

SharedPtr< const Mesh > mage::rendering::Model::m_mesh
private

A pointer to the mesh of this model.

◆ m_nb_indices

std::size_t mage::rendering::Model::m_nb_indices
private

The number of indices of this model in the mesh of this model.

◆ m_sphere

BoundingSphere mage::rendering::Model::m_sphere
private

The bounding sphere of this model.

◆ m_start_index

std::size_t mage::rendering::Model::m_start_index
private

The start index of this model in the mesh of this model.

◆ m_texture_transform

TextureTransform2D mage::rendering::Model::m_texture_transform
private

The texture transform of this model.