Model
SafiEngine::Model loads and renders 3D models from glTF/GLB files using modern OpenGL (VAOs + shaders).
Header: Core/include/Core/Model.h
MeshData
A plain data struct holding raw vertex data for constructing a Model programmatically. Used internally by ProceduralMesh to generate primitive shapes.
Methods
Load
Loads a .glb (binary glTF) file. For each mesh primitive, it creates a VAO and extracts:
- POSITION: vertex positions → VBO, vertex attrib location 0
- NORMAL: vertex normals → VBO, vertex attrib location 1
- TEXCOORD_0: texture coordinates → VBO, vertex attrib location 2
- Indices: uploaded to an EBO (supports u8, u16, u32)
- Material: PBR base color factor and base color texture
Returns true on success, false on failure (prints error to stderr).
GetCenter
Returns the geometric center of the model's bounding box, computed from glTF accessor min/max values during Load(). The render system uses this to rotate entities around their visual center rather than the model origin.
Draw
Renders all loaded meshes using the provided shader:
- Sets
uBaseColoruniform per mesh from the material's base color factor - Sets
uHasTextureand binds the base color texture to sampleruTexture - Binds the mesh VAO and calls
glDrawElements
CreateFromMeshData
Creates a Model from raw vertex data without loading any file. This is used internally by ProceduralMesh to build primitive shapes, but can also be used directly to create custom geometry.
Returns a shared_ptr<Model> ready for rendering, or nullptr on failure.