group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
AssetLoader Class Reference

Loads 3D models via Assimp and populates the global Asset registries. More...

#include <AssetLoader.hpp>

Static Public Member Functions

static bool loadModel (const ModelIdInt id, const std::string &modelFileName, const std::vector< std::string > &texFileNames, const bool k_flatten, const bool flipUVs)
 Load a single model from file and register it in Asset::models_.
static void updateModelTransformCache (const ModelIdInt id)

Static Private Member Functions

static bool loadMesh (MeshIdInt id, const aiMesh &asimpMeshResult)
 Import a single Assimp mesh into the global Asset::meshes_ registry.
static const aiScene * loadAsset (Assimp::Importer &importer, const std::string &fileName, const bool flipUVs)
 Read a file from disk through Assimp and return the parsed scene.
static glm::mat4 glmFromAiTransform (const aiMatrix4x4 &transformAi)
 Convert an Assimp 4x4 matrix to a glm::mat4.
static void pushAiNodeMeshesToModelElements (const std::string &meshNameSpace, const aiNode &nodeAi, const aiScene &sceneAi, const ModelIdInt k_modelId, const uint32_t modelIndexNode)
 Recursively extract meshes from an Assimp node and add them as ModelElements.

Detailed Description

Loads 3D models via Assimp and populates the global Asset registries.

Member Function Documentation

◆ glmFromAiTransform()

glm::mat4 AssetLoader::glmFromAiTransform ( const aiMatrix4x4 & transformAi)
staticprivate

Convert an Assimp 4x4 matrix to a glm::mat4.

Parameters
transformAiThe Assimp transform matrix.
Returns
The equivalent glm::mat4.
Here is the caller graph for this function:

◆ loadAsset()

const aiScene * AssetLoader::loadAsset ( Assimp::Importer & importer,
const std::string & fileName,
const bool flipUVs )
staticprivate

Read a file from disk through Assimp and return the parsed scene.

Parameters
importerAssimp importer instance (owns the scene lifetime).
fileNamePath to the asset file.
flipUVs
Returns
Pointer to the loaded scene, or nullptr on failure.
Here is the caller graph for this function:

◆ loadMesh()

bool AssetLoader::loadMesh ( MeshIdInt id,
const aiMesh & asimpMeshResult )
staticprivate

Import a single Assimp mesh into the global Asset::meshes_ registry.

Parameters
idUnique mesh identifier.
asimpMeshResultThe Assimp mesh to import.
Returns
True on success.
Here is the caller graph for this function:

◆ loadModel()

bool AssetLoader::loadModel ( const ModelIdInt id,
const std::string & modelFileName,
const std::vector< std::string > & texFileNames,
const bool k_flatten,
const bool flipUVs )
static

Load a single model from file and register it in Asset::models_.

Parameters
idUnique model identifier.
modelFileNamePath to the model file.
texFileNamesPaths to associated texture files.
k_flattenIf true, flatten the scene hierarchy via Assimp pre-transform.
flipUVs
Returns
True on success.

FLATTEN AISCENE

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

◆ pushAiNodeMeshesToModelElements()

void AssetLoader::pushAiNodeMeshesToModelElements ( const std::string & meshNameSpace,
const aiNode & nodeAi,
const aiScene & sceneAi,
const ModelIdInt k_modelId,
const uint32_t modelIndexNode )
staticprivate

Recursively extract meshes from an Assimp node and add them as ModelElements.

Parameters
meshNameSpaceNamespace prefix for generating unique mesh IDs.
nodeAiThe current Assimp scene node.
sceneAiThe full Assimp scene.
k_modelIdThe model ID to attach extracted elements to.
modelIndexNode
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateModelTransformCache()

void AssetLoader::updateModelTransformCache ( const ModelIdInt id)
static
Here is the caller graph for this function:

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