Unravel Engine C++ Reference
Loading...
Searching...
No Matches
model_component.h
Go to the documentation of this file.
1#pragma once
5namespace unravel
6{
7class material;
8
13class model_component : public component_crtp<model_component, owned_component>
14{
15public:
21 static void on_create_component(entt::registry& r, entt::entity e);
22
28 static void on_destroy_component(entt::registry& r, entt::entity e);
29
34 void set_enabled(bool enabled);
39 void set_casts_shadow(bool cast_shadow);
40
46
51 void set_static(bool is_static);
52
57 auto is_enabled() const -> bool;
58
63 auto casts_shadow() const -> bool;
64
69 auto casts_reflection() const -> bool;
70
75 auto is_static() const -> bool;
76
81 auto get_model() const -> const model&;
82
87 void set_model(const model& model);
88
93 auto get_bone_transforms() const -> const pose_mat4&;
94
99 auto get_submesh_transforms() const -> const pose_mat4&;
100
105 auto get_armature_entities() const -> const std::vector<entt::handle>&;
106 auto get_armature_by_id(const std::string& node_id) const -> entt::handle;
107 auto get_armature_index_by_id(const std::string& node_id) const -> int;
108 auto get_armature_by_index(size_t index) const -> entt::handle;
109 auto get_skinning_transforms() const -> const std::vector<pose_mat4>&;
110
114 auto init_armature(bool force) -> bool;
115 auto update_armature() -> bool;
116
121 void set_armature_entities(const std::vector<entt::handle>& submesh_entities);
122
128 auto get_world_bounds() const -> const math::bbox&;
129 auto get_world_bounds_transform() const -> const math::transform&;
130
131 void update_world_bounds(const math::transform& bounds);
132 auto get_local_bounds() const -> const math::bbox&;
133
134 void set_last_render_frame(uint64_t frame);
135 auto get_last_render_frame() const noexcept -> uint64_t;
136 auto was_used_last_frame() const noexcept -> bool;
137
138 auto is_skinned() const -> bool;
139 auto get_bind_pose() const -> const animation_pose&;
140
141private:
142 auto create_armature(bool force) -> bool;
143
147 bool enabled_ = true;
148
152 bool static_ = true;
153
157 bool casts_shadow_ = true;
158
162 bool casts_reflection_ = true;
163
167 model model_;
168
172 std::vector<entt::handle> armature_entities_;
173
177 animation_pose bind_pose_;
181 pose_mat4 bone_pose_;
182
186 pose_mat4 submesh_pose_;
187
191 std::vector<pose_mat4> skinning_pose_;
192
196 math::bbox world_bounds_;
197
201 math::transform world_bounds_transform_;
202
206 uint64_t last_render_frame_{};
207};
208
209struct bone_component : public component_crtp<bone_component>
210{
211 uint32_t bone_index{};
212};
213
214struct submesh_component : public component_crtp<submesh_component>
215{
216 std::vector<uint32_t> submeshes{};
217};
218
219} // namespace unravel
General purpose transformation class designed to maintain each component of the transformation separa...
Definition transform.hpp:27
Class that contains core data for meshes.
static void on_create_component(entt::registry &r, entt::entity e)
Called when the component is created.
auto was_used_last_frame() const noexcept -> bool
auto get_armature_by_index(size_t index) const -> entt::handle
auto get_last_render_frame() const noexcept -> uint64_t
auto get_bone_transforms() const -> const pose_mat4 &
Gets the bone transforms.
void set_enabled(bool enabled)
Sets whether the model is enabled.
void update_world_bounds(const math::transform &bounds)
auto get_armature_index_by_id(const std::string &node_id) const -> int
auto is_static() const -> bool
Checks if the model is static.
auto get_armature_by_id(const std::string &node_id) const -> entt::handle
auto get_bind_pose() const -> const animation_pose &
auto casts_shadow() const -> bool
Checks if the model casts shadows.
auto init_armature(bool force) -> bool
Updates the armature of the model.
auto get_local_bounds() const -> const math::bbox &
static void on_destroy_component(entt::registry &r, entt::entity e)
Called when the component is destroyed.
auto get_model() const -> const model &
Gets the model.
auto get_submesh_transforms() const -> const pose_mat4 &
Gets the submesh transforms.
auto is_enabled() const -> bool
Checks if the model is enabled.
auto is_skinned() const -> bool
auto get_skinning_transforms() const -> const std::vector< pose_mat4 > &
void set_model(const model &model)
Sets the model.
auto get_world_bounds_transform() const -> const math::transform &
auto casts_reflection() const -> bool
Checks if the model casts reflections.
void set_casts_reflection(bool casts_reflection)
Sets whether the model casts reflections.
auto get_armature_entities() const -> const std::vector< entt::handle > &
Gets the armature entities.
void set_static(bool is_static)
Sets whether the model is static.
auto get_world_bounds() const -> const math::bbox &
Gets the local bounding box for this mesh.
void set_armature_entities(const std::vector< entt::handle > &submesh_entities)
Sets the armature entities.
void set_last_render_frame(uint64_t frame)
void set_casts_shadow(bool cast_shadow)
Sets whether the model casts shadows.
Structure describing a LOD group (set of meshes), LOD transitions, and their materials.
Definition model.h:42
uint32_t frame
Definition graphics.cpp:21
Storage for box vector values and wraps up common functionality.
Definition bbox.h:21
CRTP (Curiously Recurring Template Pattern) base structure for components.
std::vector< uint32_t > submeshes