|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <ModelLoader.hpp>
Static Public Member Functions | |
| static GameObject * | Load (const std::string &filePath, const ModelLoadOptions &options={}) |
| Imports a model file and returns the root of the resulting GameObject hierarchy. | |
| static std::vector< AnimationClip * > | LoadAnimationsOnly (const std::string &filePath, Skeleton *skeleton) |
| Load only animations from an FBX, reusing an existing skeleton. | |
Assimp-backed importer that builds a GameObject hierarchy (meshes, materials, optionally a skeleton) from a model file.
Load() reads any format Assimp supports (FBX, glTF, OBJ, and the rest) and returns the root of a ready-to-use GameObject tree with meshes, materials, and textures attached. Rigged files also get a Skeleton and an AnimatorComponent. The caller owns the returned root: hand it to SceneBase::AddObject() and the scene takes over. Load() returns nullptr on failure, so always check.
ModelLoadOptions covers the adjustments every import pipeline eventually needs. scaleFactor converts source units to meters (0.01 for a centimeter-based rig). flipUVs defaults to true because most exporters disagree with the engine's texture origin. flipNormals and flipWinding fix models that import inside out or with black faces, which is nearly always an exporter handedness mismatch rather than a shading problem.
When your mesh and your animations ship as separate files, load the mesh once and pull the clips in with LoadAnimationsOnly(), passing the skeleton the mesh import produced. Textures are cached for the duration of a single Load(), so a model reusing one texture across many materials reads it from disk once.
Definition at line 94 of file ModelLoader.hpp.
|
static |
Imports a model file and returns the root of the resulting GameObject hierarchy.
Definition at line 52 of file ModelLoader.cpp.
|
static |
Load only animations from an FBX, reusing an existing skeleton.
Definition at line 590 of file ModelLoader.cpp.