utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::graphic::Model Class Reference

The Model class represents a 3D model in the graphics application. More...

#include <headers/utility/graphic/model.hpp>

Inheritance diagram for utility::graphic::Model:
Collaboration diagram for utility::graphic::Model:

Public Types

enum class  ModelType { OBJ , FBX , GLTF }
 The ModelType enum represents the different types of 3D models that can be loaded and rendered in the graphics application. It currently includes OBJ, FBX, and GLTF model formats, allowing for flexibility in the types of models that can be used within the application. Additional model types can be added to this enum as needed to support more formats in the future. More...
 

Public Member Functions

 Model (std::shared_ptr< utility::File > modelAsset, const PoseF &pose, uint32_t materialID)
 Constructs a Model object from a given File containing the model data.
 
 Model (std::shared_ptr< utility::File > modelAsset, ModelType type, const PoseF &pose, uint32_t materialID)
 Constructs a Model object from a given File containing the model data and a specified ModelType.
 
 ~Model ()=default
 Destructs the Model object, releasing any allocated resources.
 
ModelType type () const
 Get the type of the model.
 
utility::graphic::SizeF computeBoundingSize (void)
 Computes the bounding size of the model.
 
uint32_t getMaterialID (void) const
 Get the material ID associated with the model.
 
- Public Member Functions inherited from utility::graphic::Renderable
 Renderable (const PoseF &pose, const Color32Bit &color)
 Default constructor for Renderable.
 
virtual ~Renderable ()=default
 Virtual destructor for Renderable.
 
RenderablesetPose (const PoseF &pose)
 Set the text pose.
 
void setPose (PoseF &&pose)
 Set the text pose.
 
const PoseFgetPose (void) const
 Get the text pose.
 
glm::mat4 getModelMatrix (void) const
 Get the object-to-world model matrix of this renderable.
 
RenderablesetColor (const graphic::Color32Bit &color)
 Set the text color.
 
void setColor (graphic::Color32Bit &&color)
 Set the text color.
 
const graphic::Color32BitgetColor (void) const
 Get the text color.].
 
std::vector< std::shared_ptr< Mesh > > getMeshes () const
 Get the meshes associated with this renderable object.
 

Protected Member Functions

void loadOBJ (std::shared_ptr< utility::File > modelAsset)
 Loads a model from a given File containing the model data.
 
- Protected Member Functions inherited from utility::logging::Loggable< Model, utility::logging::DefaultLogger >
 Loggable (void)
 Construct a Loggable with the specified LoggerType.
 
 Loggable (Loggable &&other) noexcept
 Move constructor for Loggable.
 
Loggableoperator= (Loggable &&other) noexcept
 Move assignment operator for Loggable.
 
LoggerType & getLogger (void)
 Get the internal logger.
 
LoggerType & getLogger (void) const
 Get the internal logger.
 
virtual ~Loggable (void)=default
 Virtual destructor for proper cleanup.
 

Protected Attributes

ModelType _type
 The type of the model (e.g., OBJ, FBX, GLTF)
 
utility::graphic::SizeF _boundingBox {}
 The bounding box of the model.
 
uint32_t _materialID
 The material associated with the model.
 
- Protected Attributes inherited from utility::graphic::Renderable
std::vector< std::shared_ptr< Mesh > > _meshes
 Meshes associated with this renderable object.
 
Color32Bit _color
 Text RGBA color.
 
PoseF _pose
 World pose (position and orientation) of the text.
 

Detailed Description

The Model class represents a 3D model in the graphics application.

The Model class is responsible for storing the data and properties of a 3D model, including its vertices, textures, materials, and other relevant information. It provides methods to load and manage the model's data, allowing for efficient rendering and manipulation within the graphics application.

Definition at line 37 of file model.hpp.

Member Enumeration Documentation

◆ ModelType

The ModelType enum represents the different types of 3D models that can be loaded and rendered in the graphics application. It currently includes OBJ, FBX, and GLTF model formats, allowing for flexibility in the types of models that can be used within the application. Additional model types can be added to this enum as needed to support more formats in the future.

Definition at line 52 of file model.hpp.

Constructor & Destructor Documentation

◆ Model() [1/2]

utility::graphic::Model::Model ( std::shared_ptr< utility::File modelAsset,
const PoseF pose,
uint32_t  materialID 
)

Constructs a Model object from a given File containing the model data.

Parameters
modelAssetA shared pointer to the File object containing the model data to be loaded. This constructor is responsible for initializing the Model object by loading the model data from the provided File. It processes the model data and populates the necessary properties of the Model object, such as vertices, textures, and materials, based on the content of the File.
poseThe initial position and orientation for the model.
materialIDThe ID of the material associated with the model.
Note
This implementation will parse the model according to the extensions of the file (e.g., .obj, .fbx, .gltf) and set the appropriate ModelType based on the file format.

Definition at line 12 of file model.cpp.

Here is the call graph for this function:

◆ Model() [2/2]

utility::graphic::Model::Model ( std::shared_ptr< utility::File modelAsset,
ModelType  type,
const PoseF pose,
uint32_t  materialID 
)

Constructs a Model object from a given File containing the model data and a specified ModelType.

Parameters
modelAssetA shared pointer to the File object containing the model data to be loaded.
typeThe type of the model (e.g., OBJ, FBX, GLTF) to be loaded.
poseThe initial position and orientation for the model.
materialIDThe ID of the material associated with the model.

This constructor is responsible for initializing the Model object by loading the model data from the provided File and setting the ModelType based on the specified type parameter.

Definition at line 38 of file model.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ computeBoundingSize()

utility::graphic::SizeF utility::graphic::Model::computeBoundingSize ( void  )

Computes the bounding size of the model.

Returns
The bounding size of the model.

Definition at line 73 of file model.cpp.

◆ getMaterialID()

uint32_t utility::graphic::Model::getMaterialID ( void  ) const

Get the material ID associated with the model.

Returns
The material ID as a uint32_t value.

Definition at line 78 of file model.cpp.

◆ loadOBJ()

void utility::graphic::Model::loadOBJ ( std::shared_ptr< utility::File modelAsset)
protected

Loads a model from a given File containing the model data.

Parameters
modelAssetA shared pointer to the File object containing the model data to be loaded.

This method is responsible for parsing the model data from the provided File and populating the necessary properties of the Model object, such as vertices, textures, and materials, based on the content of the File. The parsing process will depend on the format of the model data (e.g., OBJ, FBX, GLTF) and will set the appropriate ModelType based on the file format.

Note
This method is called internally by the constructors to load the model data when a Model object is created.

Definition at line 87 of file model.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

Model::ModelType utility::graphic::Model::type ( ) const

Get the type of the model.

Returns
The ModelType enum value representing the type of the model (e.g., OBJ, FBX, GLTF).

Definition at line 68 of file model.cpp.

Member Data Documentation

◆ _boundingBox

utility::graphic::SizeF utility::graphic::Model::_boundingBox {}
protected

The bounding box of the model.

Definition at line 144 of file model.hpp.

◆ _materialID

uint32_t utility::graphic::Model::_materialID
protected

The material associated with the model.

Definition at line 146 of file model.hpp.

◆ _type

ModelType utility::graphic::Model::_type
protected

The type of the model (e.g., OBJ, FBX, GLTF)

Definition at line 142 of file model.hpp.


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