Unravel Engine C++ Reference
Loading...
Searching...
No Matches
model_component.cpp
Go to the documentation of this file.
1#include "model_component.hpp"
2
7
11
12namespace unravel
13{
14
16{
17 entt::meta_factory<model_component>{}
18 .type("model_component"_hs)
20 entt::attribute{"name", "model_component"},
21 entt::attribute{"category", "RENDERING"},
22 entt::attribute{"pretty_name", "Model"},
23 })
24 .func<&component_meta<model_component>::exists>("component_exists"_hs)
25 .func<&component_meta<model_component>::add>("component_add"_hs)
26 .func<&component_meta<model_component>::remove>("component_remove"_hs)
27 .func<&component_meta<model_component>::save>("component_save"_hs)
28 .func<&component_meta<model_component>::load>("component_load"_hs)
30 .custom<entt::attributes>(entt::attributes{
31 entt::attribute{"name", "enabled"},
32 entt::attribute{"pretty_name", "Enabled"},
33 entt::attribute{"tooltip", "Is the model visible?"},
34 })
35 .data<&model_component::set_static, &model_component::is_static>("static"_hs)
37 entt::attribute{"name", "static"},
38 entt::attribute{"pretty_name", "Static"},
39 entt::attribute{"tooltip", "Is the model static?"},
40 })
41 .data<&model_component::set_casts_shadow, &model_component::casts_shadow>("casts_shadow"_hs)
43 entt::attribute{"name", "casts_shadow"},
44 entt::attribute{"pretty_name", "Casts Shadow"},
45 entt::attribute{"tooltip", "Is the model casting shadows?"},
46 })
47 .data<&model_component::set_casts_reflection, &model_component::casts_reflection>("casts_reflection"_hs)
49 entt::attribute{"name", "casts_reflection"},
50 entt::attribute{"pretty_name", "Casts Reflection"},
51 entt::attribute{"tooltip", "Is the model participating in reflection generation?"},
52 })
53 .data<&model_component::set_model, &model_component::get_model>("model"_hs)
55 entt::attribute{"name", "model"},
56 entt::attribute{"pretty_name", "Model"},
57 });
58}
59
61{
62 try_save(ar, ser20::make_nvp("enabled", obj.is_enabled()));
63 try_save(ar, ser20::make_nvp("static", obj.is_static()));
64 try_save(ar, ser20::make_nvp("casts_shadow", obj.casts_shadow()));
65 try_save(ar, ser20::make_nvp("casts_reflection", obj.casts_reflection()));
66 try_save(ar, ser20::make_nvp("model", obj.get_model()));
67}
70
72{
73 bool is_enabled{true};
74 if(try_load(ar, ser20::make_nvp("enabled", is_enabled)))
75 {
76 obj.set_enabled(is_enabled);
77 }
78
79 bool is_static{};
80 if(try_load(ar, ser20::make_nvp("static", is_static)))
81 {
82 obj.set_static(is_static);
83 }
84
85 bool casts_shadow{};
86 if(try_load(ar, ser20::make_nvp("casts_shadow", casts_shadow)))
87 {
88 obj.set_casts_shadow(casts_shadow);
89 }
90
91 bool casts_reflection{};
92 if(try_load(ar, ser20::make_nvp("casts_reflection", casts_reflection)))
93 {
94 obj.set_casts_reflection(casts_reflection);
95 }
96
97 auto mod = obj.get_model();
98 if(try_load(ar, ser20::make_nvp("model", mod)))
99 {
100 obj.set_model(mod);
101 }
102}
105
107{
108 entt::meta_factory<bone_component>{}
109 .type("bone_component"_hs)
111 entt::attribute{"name", "bone_component"},
112 entt::attribute{"category", "RENDERING"},
113 entt::attribute{"pretty_name", "Bone"},
114 })
115 .func<&component_meta<bone_component>::exists>("component_exists"_hs)
116 .func<&component_meta<bone_component>::add>("component_add"_hs)
117 .func<&component_meta<bone_component>::save>("component_save"_hs)
118 .func<&component_meta<bone_component>::load>("component_load"_hs)
119 .func<&component_meta<bone_component>::remove>("component_remove"_hs)
120 .data<nullptr, &bone_component::bone_index>("bone_index"_hs)
121 .custom<entt::attributes>(entt::attributes{
122 entt::attribute{"name", "bone_index"},
123 entt::attribute{"pretty_name", "Bone Index"},
124 entt::attribute{"tooltip", "The bone index this object represents."},
125 });
126}
127
129{
130 try_save(ar, ser20::make_nvp("bone_index", obj.bone_index));
131}
134
136{
137 try_load(ar, ser20::make_nvp("bone_index", obj.bone_index));
138}
141
143{
144 entt::meta_factory<submesh_component>{}
145 .type("submesh_component"_hs)
147 entt::attribute{"name", "submesh_component"},
148 entt::attribute{"category", "RENDERING"},
149 entt::attribute{"pretty_name", "Submesh"},
150 })
151 .func<&component_meta<submesh_component>::exists>("component_exists"_hs)
152 .func<&component_meta<submesh_component>::add>("component_add"_hs)
153 .func<&component_meta<submesh_component>::remove>("component_remove"_hs)
154 .func<&component_meta<submesh_component>::save>("component_save"_hs)
155 .func<&component_meta<submesh_component>::load>("component_load"_hs)
156 .data<nullptr, &submesh_component::submeshes>("submeshes"_hs)
157 .custom<entt::attributes>(entt::attributes{
158 entt::attribute{"name", "submeshes"},
159 entt::attribute{"pretty_name", "Submeshes"},
160 entt::attribute{"tooltip", "Submeshes affected by this node."},
161 });
162}
163
165{
166 try_save(ar, ser20::make_nvp("submeshes", obj.submeshes));
167}
170
172{
173 try_load(ar, ser20::make_nvp("submeshes", obj.submeshes));
174}
177
178} // namespace unravel
Class that contains core data for meshes.
void set_enabled(bool enabled)
Sets whether the model is enabled.
auto is_enabled() const -> bool
Checks if the model is enabled.
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
#define REFLECT(cls)
Definition reflection.h:133
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
std::vector< uint32_t > submeshes