Docs

Model

Inherits: Mesh
C++ type: Model

Description

Loads and displays 3D model files in a scene. Model extends Mesh and adds support for loading OBJ and GLTF files (including binary GLB), including skeletal animation (via Animation / Bone), blend-shape morph targets, and PBR materials.

A single GLTF file can contain multiple meshes, materials, textures, skeletons, and animations; Doriax imports all of them into the scene hierarchy and makes each accessible through the API. Use getAnimation() and getBone() to drive skeletal playback, and setMorphWeight() to control blend shapes.

Methods

Type Name Langs
bool loadModel C++ | Lua
bool loadOBJ C++ | Lua
bool loadGLTF C++ | Lua
Animation getAnimation C++ | Lua
Animation findAnimation C++ | Lua
Bone getBone C++ | Lua
float getMorphWeight C++ | Lua
void setMorphWeight C++ | Lua
void resetToBindPose C++ | Lua

Method details

loadModel

  • bool loadModel(const std::string& filename)

Loads a 3D model file from disk. Doriax automatically detects the format based on file extension:

  • .obj — Wavefront OBJ
  • .gltf / .glb — GL Transmission Format (GLTF 2.0 / binary GLB)

Returns true on success. On failure, check the log for details.

Model character(&scene);
if (!character.loadModel("characters/hero.glb")) {
    Log::error("Failed to load hero model");
}
local character = Model(scene)
if not character:loadModel("characters/hero.glb") then
    Log.error("Failed to load hero model")
end

loadOBJ / loadGLTF

  • bool loadOBJ(const std::string& filename)
  • bool loadGLTF(const std::string& filename)

Format-specific loaders. Use these when you want to be explicit about the format, or when the file extension is non-standard. loadGLTF() accepts both text .gltf and binary .glb files.


getAnimation / findAnimation

Retrieve a skeletal or morph-target animation embedded in the loaded model. getAnimation() accesses by zero-based index; findAnimation() searches by name as exported from the DCC tool. Both return an Animation object that can be started, stopped, and configured for looping.

Model soldier(&scene);
soldier.loadModel("soldiers/rifleman.glb");

Animation walkAnim = soldier.findAnimation("Walk");
walkAnim.setLoop(true);
walkAnim.start();
local soldier = Model(scene)
soldier:loadModel("soldiers/rifleman.glb")

local walkAnim = soldier:findAnimation("Walk")
walkAnim:setLoop(true)
walkAnim:start()

getBone

  • Bone getBone(const std::string& name)
  • Bone getBone(int id)

Returns a Bone handle by name or by index. A Bone inherits Object so you can read and write its local transform to override the skeleton. For example, you can aim a character's head bone toward a target while the rest of the body plays a walk cycle.

Bone head = soldier.getBone("Head");
head.setRotation(targetRotation);
local head = soldier:getBone("Head")
head:setRotation(targetRotation)

getMorphWeight / setMorphWeight

  • float getMorphWeight(const std::string& name)
  • float getMorphWeight(int id)
  • void setMorphWeight(const std::string& name, float value)
  • void setMorphWeight(int id, float value)

Read or write the weight of a blend-shape morph target. Weights range from 0.0 (no influence) to 1.0 (full influence). Multiple morphs can be active simultaneously. Access by exported name or by zero-based index.

Model face(&scene);
face.loadModel("characters/face.glb");
face.setMorphWeight("Smile", 0.8f);
face.setMorphWeight("Blink_L", 1.0f);
local face = Model(scene)
face:loadModel("characters/face.glb")
face:setMorphWeight("Smile", 0.8)
face:setMorphWeight("Blink_L", 1.0)

resetToBindPose

  • void resetToBindPose()

Resets all bones back to the bind pose defined in the model file, clearing any programmatic or animation-driven overrides. Useful when switching between animations or when stopping all playback.