Model

template<IsSpectral TSpectral>
class Model : public huira::SceneObject<Model<TSpectral>>

Represents a loaded 3D model with its own isolated detached graph.

Model contains a root FrameNode representing the model’s local coordinate system, a collection of Meshes owned by this model, and the original file path for reference. The Model’s scene graph is disconnected from the main Scene graph. To place a Model into the Scene, use Instance with a Model reference.

Template Parameters:

TSpectral – The spectral representation type.

Public Functions

inline Model()
~Model() override = default
Model(const Model&) = delete
Model &operator=(const Model&) = delete
Model(Model&&) = default
Model &operator=(Model&&) = default
inline const fs::path &source_path() const noexcept
inline virtual std::uint64_t id() const override

Get the object’s unique ID.

Returns:

std::uint64_t ID

inline virtual std::string type() const override

Get the object’s type string.

Returns:

std::string Type

void print_graph() const

Prints the model’s scene graph hierarchy to stdout.

Outputs the source file path and a tree-structured visualization of the model’s node hierarchy starting from the root node.

MaterialHandle<TSpectral> get_material_by_id(std::uint64_t material_id) const

Searches the model’s scene graph for a material with the specified ID.

Parameters:

material_id – The ID of the material to search for.

Throws:

std::runtime_error – if the material is not found.

Returns:

MaterialHandle<TSpectral> Handle to the found material.

void set_all_bsdfs(const BSDF<TSpectral> &bsdf)

Sets the given BSDF on all materials used by meshes in the model.

Parameters:

bsdf – The BSDF to set on all materials. The BSDF will be cloned for each material.

Throws:

std::runtime_error – if the model has no root node.

inline bool is_scene_owned() const

Check if the object is owned by the scene.

Returns:

bool True if owned

inline void set_scene_owned(bool owned)

Set scene ownership flag.

Parameters:

owned – True if owned

inline std::string name() const

Get the object’s name.

Returns:

std::string Name

inline virtual std::string get_info() const

Get a descriptive info string for the object.

Returns:

std::string Info string