NDEVR
API Documentation
Model.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Model
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/DesignObject.h>
34namespace NDEVR
35{
36 enum class UVType;
37 enum class PrimitiveProperty;
38 enum class WindingMode;
39 class Scene;
40 class Database;
41 class File;
42#if NDEVR_SUPPORTS_BONES
43 class Bone;
44#endif
45 class Log;
46 class InfoPipe;
47 template<class t_type>
48 class Set;
78
80 template<> struct PropertySpec<NDPN::type> { using type = StringView; };
82 template<> struct PropertySpec<NDPN::fixed_bounding_box> { using type = Bounds<3, fltp08>; };
84 template<> struct PropertySpec<NDPN::visible_box> { using type = Bounds<3, fltp08>; };
86 template<> struct PropertySpec<NDPN::calculation_ignored> { using type = bool; };
88 template<> struct PropertySpec<NDPN::can_select_children> { using type = bool; };
90 template<> struct PropertySpec<NDPN::complete_transform> { using type = Matrix<fltp08>; };
92 template<> struct PropertySpec<NDPN::material_mode> { using type = uint01; };
94 template<> struct PropertySpec<NDPN::parent_matrix_flags> { using type = BitFlag; };
96 template<> struct PropertySpec<NDPN::global_bounds> { using type = Bounds<3, fltp08>; };
98 template<> struct PropertySpec<NDPN::global_selection_bounds> { using type = Bounds<3, fltp08>; };
100 template<> struct PropertySpec<NDPN::model_color> { using type = RGBColor; };
102 template<> struct PropertySpec<NDPN::inherited_flags> { using type = Vector<32, bool>; };
104 template<> struct PropertySpec<NDPN::personal_inherited_flags> { using type = Vector<32, bool>; };
106 template<> struct PropertySpec<NDPN::export_ignored> { using type = bool; };
108 template<> struct PropertySpec<NDPN::child_base_ptr> { using type = DesignObjectBase*; };
110 template<> struct PropertySpec<NDPN::parent_base_ptr> { using type = DesignObjectBase*; };
112 template<> struct PropertySpec<NDPN::material_base_ptr> { using type = DesignObjectBase*; };
114 template<> struct PropertySpec<NDPN::geometry_base_ptr> { using type = DesignObjectBase*; };
115
122 template<>
124 {
125 public:
132 template<class t_valutype>
133 static decltype(auto) Get(const DesignInfo* object, NDPN property)
134 {
135 return column(object, property)->get<t_valutype>(object->m_design_index);
136 }
137
142 template<NDPN t_property, class t_valutype>
143 static decltype(auto) Get(const DesignInfo* object)
144 {
145 return column(object, t_property)->get<t_valutype>(object->m_design_index);
146 }
147
153 template<class t_valutype>
154 static void Set(DesignInfo* object, NDPN property, const t_valutype& value)
155 {
156 column(object, property)->set(object->m_design_index, value);
157 }
158
167 template<NDPN t_property, class t_valutype>
168 static inline void Set(DesignInfo* object, const t_valutype& value)
169 {
170 if constexpr (t_property == NDPN::type)
171 object->m_base->model_type[object->m_design_index] = value;
172 else if constexpr (t_property == NDPN::visible_box)
173 object->m_base->visible_box[object->m_design_index] = rcast<Vector<6, fltp08>>(value);
174 else if constexpr (t_property == NDPN::global_bounds)
175 object->m_base->global_bounds[object->m_design_index] = rcast<Vector<6, fltp08>>(value);
176 else if constexpr (t_property == NDPN::global_selection_bounds)
178 else if constexpr (t_property == NDPN::complete_transform)
180 else if constexpr (t_property == NDPN::child_base_ptr)
181 object->m_base->child_base_ptr[object->m_design_index] = (uint08)value;
182 else if constexpr (t_property == NDPN::parent_base_ptr)
183 object->m_base->parent_base_ptr[object->m_design_index] = (uint08)value;
184 else if constexpr (t_property == NDPN::material_base_ptr)
185 object->m_base->material_base_ptr[object->m_design_index] = (uint08)value;
186 else if constexpr (t_property == NDPN::geometry_base_ptr)
187 object->m_base->geometry_base_ptr[object->m_design_index] = (uint08)value;
188 else if constexpr (t_property == NDPN::inherited_flags)
189 object->m_base->inherited_flags[object->m_design_index] = rcast<uint04>(value);
190 else if constexpr (t_property == NDPN::personal_inherited_flags)
192 else
193 column(object, t_property)->set(object->m_design_index, value);
194 }
195
201 static constexpr TableColumn* column(const DesignInfo* object, NDPN property)
202 {
203 return object->m_base->model_properties[eint01(property)];
204 }
205
213 static bool IsSame(const DesignInfo* object, NDPN property, const StringView& value)
214 {
215 return column(object, property)->isSame(object->m_design_index, value);
216 }
217
225 template<NDPN t_property>
226 static decltype(auto) Get(const DesignInfo* object)
227 {
228 if constexpr (t_property == NDPN::type)
229 return object->m_base->model_type[object->m_design_index];
230 else if constexpr (t_property == NDPN::visible_box)
231 return *reinterpret_cast<Bounds<3, fltp08>*>(&object->m_base->visible_box[object->m_design_index]);
232 else if constexpr (t_property == NDPN::global_bounds)
233 return *reinterpret_cast<Bounds<3, fltp08>*>(&object->m_base->global_bounds[object->m_design_index]);
234 else if constexpr (t_property == NDPN::global_selection_bounds)
235 return *reinterpret_cast<Bounds<3, fltp08>*>(&object->m_base->global_selection_bounds[object->m_design_index]);
236 else if constexpr (t_property == NDPN::complete_transform)
237 return *reinterpret_cast<Matrix<fltp08>*>(&object->m_base->complete_transform[object->m_design_index]);
238 else if constexpr (t_property == NDPN::child_base_ptr)
239 return object->m_base->child_base_ptr[object->m_design_index];
240 else if constexpr (t_property == NDPN::parent_base_ptr)
241 return object->m_base->parent_base_ptr[object->m_design_index];
242 else if constexpr (t_property == NDPN::inherited_flags)
243 return *reinterpret_cast<Vector<32, bool>*>(&object->m_base->inherited_flags[object->m_design_index]);
244 else if constexpr (t_property == NDPN::personal_inherited_flags)
245 return *reinterpret_cast<Vector<32, bool>*>(&object->m_base->personal_inherited_flags[object->m_design_index]);
246 else if constexpr (t_property == NDPN::material_base_ptr)
247 return object->m_base->material_base_ptr[object->m_design_index];
248 else if constexpr (t_property == NDPN::geometry_base_ptr)
249 return object->m_base->geometry_base_ptr[object->m_design_index];
250 else
251 return column(object, t_property)->get<typename PropertySpec<t_property>::type>(object->m_design_index);
252 }
253 };
254
261 template<>
263 {
264 public:
271 static constexpr TableColumn* column(const DesignInfo* object, NDPN property)
272 {
273 return object->m_base->model_properties[eint01(property)];
274 }
275
280 static constexpr uint04 index(const DesignInfo* object, NDPN)
281 {
282 return object->m_design_index;
283 }
284 };
285
291 class NDEVR_DESIGN_API Model : public DesignObject
292 {
293 public:
297 enum class MaterialMode
298 {
299 e_by_parent
300 , e_by_layer
301 , e_custom
302 , e_hidden
303 };
304
321
341
352
356 enum class ModelColorMode
357 {
358 e_direct
359 , e_by_selectable_children
360 , e_by_material_root
361 , e_by_layer
362 };
363 public:
365 Model(){};
366
372
379
384 explicit Model(const DesignInfo& obj);
385
388
394 void restoreModel(Model& parent, uint04 index = Constant<uint04>::Invalid);
395
398
404 void deleteModel(bool deletchildren, bool removfrom_parent = true);
405
408 [[nodiscard]] bool isSelected() const;
409
412 [[nodiscard]] bool isApplicationOwned() const;
413
416 [[nodiscard]] bool isLocked() const;
417
420 [[nodiscard]] bool canInteract() const;
421
424 [[nodiscard]] bool hasSelectedDescendent() const;
425
428 [[nodiscard]] bool isVisible() const;
429
432 [[nodiscard]] bool isTreeVisible() const;
433
436 [[nodiscard]] bool hasFocus() const;
437
440 [[nodiscard]] bool exportIgnored() const;
441
444 [[nodiscard]] bool canExplode() const;
445
448 [[nodiscard]] bool isDeleted() const;
449
452 [[nodiscard]] bool isScene() const;
453
456 [[nodiscard]] TranslatedString displayName() const;
457
463 [[nodiscard]] TranslatedString displayNamePath(const StringView& seperator = ":") const;
464
470 bool setModelVisible(bool is_visible);
471
479 template<class t_type>
480
481 [[nodiscard]] bool doesModelPropertyContain(NDPN property, const StringView& value, bool ignorcase) const
482 {
483 return m_base->model_properties[eint01(property)]->contains(m_design_index, value, ignorcase);
484 }
485
493 [[nodiscard]] bool doesModelPropertyContain(NDPN property, const char* value, bool ignorcase) const
494 {
495 return m_base->model_properties[eint01(property)]->contains(m_design_index, value, ignorcase);
496 }
497
503
509 template<class t_buffer_type>
510 [[nodiscard]] bool isType(const Buffer<t_buffer_type>& types) const
511 {
512 for (const t_buffer_type& iter : types)
513 {
514 if (is<NDPN::type>(iter))
515 return true;
516 }
517 return false;
518 }
519
525 void updateFrom(const Model& model, bool check_resources);
526
535 void copyFrom(const Model& model, bool deep_copy, bool copy_ids = false, bool recursive = true, bool keep_root_properties = false);
536
542 void updateModelTransform(const Matrix<fltp08>& transform, const void* lock = nullptr);
543
548 void setModelTransform(const Matrix<fltp08>& transform);
549
554 void updateVisibleRecursive(bool is_visible);
555
561 [[nodiscard]] RGBColor customModelColor(ModelColorMode mode) const;
562
565 [[nodiscard]] StringView getModelIcon() const;
566
570
573 [[nodiscard]] Bounds<3, fltp08> getBounds() const;
574
577 [[nodiscard]] Bounds<3, fltp08> globalBounds() const;
578
582
586
590
593
597
600 [[nodiscard]] Vector<3, fltp08> size() const;
601
607
608 //-------- Children --------
609
613
620
625 void createChildren(uint04 child_size);
626
630
637
642 void addChild(Model& child);
643
649 void addChild(uint04 child_idx, Model& child);
650
655 void addChild(uint04 child_index);
656
662
668
674 void setChildIndex(uint04 child, uint04 id);
675
681 void updateAscTime(const Time& time, bool includself);
682
688 void updateAscGeometryTime(const Time& time, bool include_self);
689
695 void updateDescTime(const Time& time, bool include_self);
696
702 void updateDescGeometryTime(const Time& time, bool include_self);
703
709 [[nodiscard]] Model getChild(uint04 child) const;
710
716 [[nodiscard]] uint04 getChildIndex(uint04 child) const;
717
723 [[nodiscard]] bool hasChild(uint04 child_index = 0U) const;
724
727 [[nodiscard]] ModelBuffer getChildren() const;
728
733 void getChildren(ModelBuffer& children) const;
734
740 [[nodiscard]] Model getChild(UUID id) const;
741
744 [[nodiscard]] Buffer<UUID> getChildrenIDs() const;
745
748 [[nodiscard]] Buffer<uint04> getChildIndices() const;
749
755 [[nodiscard]] ModelBuffer getChildrenByType(const StringView& type) const;
756
762 [[nodiscard]] ModelBuffer getChildrenByType(const Buffer<String>& type) const;
763
769 template<class t_type>
770 [[nodiscard]] Buffer<t_type> getTypeChildren(const StringView& type) const
771 {
773 Buffer<t_type> values(models.size());
774 for (uint04 i = 0; i < models.size(); i++)
775 {
776 values.add(t_type(models[i]));
777 }
778 return values;
779 }
780
786 [[nodiscard]] ModelBuffer getChildrenByName(const StringView& name) const;
787
794 [[nodiscard]] ModelBuffer getDescendantsByType(const StringView& type, uint04 max_count = Constant<uint04>::Max) const;
795
801 template<class t_type>
802 [[nodiscard]] Buffer<t_type> getTypeDescendants(const StringView& type) const
803 {
804 auto models = getDescendantsByType(type);
805 Buffer<t_type> values(models.size());
806 for (uint04 i = 0; i < models.size(); i++)
807 {
808 values.add(t_type(models[i]));
809 }
810 return values;
811 }
812
819 [[nodiscard]] ModelBuffer getDescendantsByName(const StringView& name, uint04 max_count = Constant<uint04>::Max) const;
820
828 [[nodiscard]] ModelBuffer getDescendantsByNameAndType(const StringView& name, const StringView& type, uint04 max_count = Constant<uint04>::Max) const;
829
832 [[nodiscard]] uint04 childCount() const;
833
840
847 [[nodiscard]] ModelBuffer getSceneModels(bool include_deleted = false, bool local_only = false) const;
848
856 [[nodiscard]] ModelBuffer getSceneModelsByType(const StringView& type, uint04 max_count = Constant<uint04>::Max, bool includdeleted = false) const;
857
865 [[nodiscard]] ModelBuffer getSceneModelsByName(const StringView& name, uint04 max_count = Constant<uint04>::Max, bool includdeleted = false) const;
866
873 [[nodiscard]] ModelBuffer getDescendants(bool include_deleted = false, bool local_only = false) const;
874
881 void getDescendants(ModelBuffer& buffer, bool include_deleted = false, bool local_only = false) const;
882
885
888
893 void removeChild(const Model& model);
894
901 [[nodiscard]] Model getFamilyMember(uint04 index) const;
902
908 [[nodiscard]] Model findDescendentByName(const StringView& name) const;
909
915 [[nodiscard]] Model findDescendentByType(const StringView& type) const;
916
922 [[nodiscard]] bool hasDescendent(const Model& model) const;
923
929 [[nodiscard]] bool hasDescendent(const UUID& id) const;
930
931 //-------- Parent functions --------
932
938
945
948 [[nodiscard]] BitFlag parentMatrixFlags() const;
949
952 [[nodiscard]] Model getParent() const;
953
956 [[nodiscard]] Model getRoot() const;
957
960 [[nodiscard]] uint04 getParentIndex() const;
961
967
973
979
985
993
994 //-------- Effect --------
995
998 [[nodiscard]] EffectBuffer getEffectChildren() const;
999
1002 [[nodiscard]] EffectBuffer getEffectDescendants() const;
1003
1006 [[nodiscard]] EffectBuffer getSceneEffects() const;
1007
1013 [[nodiscard]] Effect getEffect(uint04 index = 0) const;
1014
1017 [[nodiscard]] Effect createSceneEffect() const;
1018
1022
1025 [[nodiscard]] uint04 getNumOfEffects() const;
1026
1032 [[nodiscard]] bool hasEffect(uint04 index = 0) const;
1033
1039 [[nodiscard]] Effect getSceneEffect(UUID id) const;
1040
1046 [[nodiscard]] uint04 getEffectIndex(uint04 child_index = 0) const;
1047
1052 void setChildEffectSize(uint04 child_size);
1053
1059 void setEffectIndex(uint04 material_index, uint04 sub_index = 0);
1060
1061 //-------- Layer Logic --------
1062
1068 [[nodiscard]] ModelBuffer getSceneLayers(bool include_deleted = false) const;
1069
1074 void setLayer(Model layer);
1075
1080 void setIsLayer(bool is_layer);
1081
1084
1087 [[nodiscard]] bool isLayer() const;
1088
1091 [[nodiscard]] bool hasLayer() const;
1092
1095 [[nodiscard]] bool hasDirectLayer() const;
1096
1099 [[nodiscard]] Model getLayer() const;
1100
1103 [[nodiscard]] uint04 getDirectLayerIndex() const;
1104
1107 [[nodiscard]] Model directLayer() const;
1108
1111 [[nodiscard]] uint04 getChildIndex() const;
1112
1115 [[nodiscard]] uint04 getChildLayerIndex() const;
1116
1119 [[nodiscard]] Model createSceneLayer() const;
1120
1126 [[nodiscard]] Model getSceneLayer(UUID id) const;
1127
1128 //-------- Geometry --------
1129
1134 void setGeometryIndex(uint04 geo_index);
1135
1138 [[nodiscard]] uint04 getGeometryIndex() const;
1139
1145
1149
1152 [[nodiscard]] Geometry getGeometry() const;
1153
1160
1166 [[nodiscard]] Geometry getSceneGeometry(UUID id) const;
1167
1170 [[nodiscard]] GeometryBuffer getSceneGeometries() const;
1171
1174 [[nodiscard]] PrimitiveAlignedBuffer<std::pair<Model, Geometry>, 32> getClippingGeometry() const;
1175
1182 [[nodiscard]] GeometryBuffer getGeometryDescendants(bool remove_redundant = true, uint04 max_count = Constant<uint04>::Max) const;
1183
1186 [[nodiscard]] Geometry createSceneGeometry() const;
1187
1190 [[nodiscard]] bool hasGeometryDescendent() const;
1191
1194 [[nodiscard]] bool hasMeshDescendent() const;
1195
1198 [[nodiscard]] bool hasLinearDescendent() const;
1199
1202 [[nodiscard]] bool hasPointsDescendent() const;
1203
1206
1214 void hasDescendants(bool& has_point, bool& has_line, bool& has_mesh, bool only_user_objects) const;
1215
1218
1224
1230 void calculateNormals(NormalMode mode, Angle<fltp08> smoothing_angle);
1231
1238 void removeDuplicateVertices(fltp08 epsilon, void* lock, InfoPipe* log = nullptr);
1239
1245
1248 [[nodiscard]] uint04 visibleVertexCount() const;
1249
1252 [[nodiscard]] uint04 vertexCount() const;
1253
1259 [[nodiscard]] bool hasHoles(PrimitiveProperty property) const;
1260
1266 void ensureTangentSpace(bool ensure_tan, bool ensure_bitan);
1267
1273 void calculateTangentSpace(bool calc_tan, bool calc_bitan);
1274
1281
1288 void setNormalMode(NormalMode mode, Angle<fltp08> smoothing_angle, InfoPipe* log);
1289
1295
1301 [[nodiscard]] fltp08 calculateVolume(const Matrix<fltp08>& transform = Constant<Matrix<fltp08>>::Invalid) const;
1302
1308 [[nodiscard]] fltp08 calculateSurfaceArea(const Matrix<fltp08>& transform = Constant<Matrix<fltp08>>::Invalid) const;
1309
1316 [[nodiscard]] Vector<2, fltp08> calculateVolumeAndSurfaceArea(const Matrix<fltp08>& transform = Constant<Matrix<fltp08>>::Invalid, const void* lock = nullptr) const;
1317
1323 [[nodiscard]] fltp08 calculateLength(const Matrix<fltp08>& transform = Constant<Matrix<fltp08>>::Invalid) const;
1324
1330 [[nodiscard]] Vector<3, fltp08> calculateAverageDirection(const Matrix<fltp08>& parent_transform = Constant<Matrix<fltp08>>::Invalid) const;
1331
1337 [[nodiscard]] Vector<2, fltp08> calculateHVLength(const Matrix<fltp08>& parent_transform = Constant<Matrix<fltp08>>::Invalid) const;
1338
1339 //-------- Material --------
1340
1343 [[nodiscard]] MaterialMode getMaterialMode() const;
1344
1350 [[nodiscard]] Material createChildMaterial(bool copy_child = false);
1351
1354 [[nodiscard]] bool hasMaterial() const;
1355
1358 [[nodiscard]] Material getMaterial() const;
1359
1362 [[nodiscard]] uint04 getMaterialIdx() const;
1363
1370
1373 [[nodiscard]] Material getRootMaterial() const;
1374
1377 [[nodiscard]] bool hasRootMaterial() const;
1378
1384 [[nodiscard]] Material getSceneMaterial(UUID id) const;
1385
1388 [[nodiscard]] bool hasLayerRootMaterial() const;
1389
1392 [[nodiscard]] Material createSceneMaterial() const;
1393
1399 [[nodiscard]] MaterialBuffer getMaterialDescendants(bool local_only = false) const;
1400
1406 void getMaterialDescendants(MaterialBuffer& materials, bool local_only = false) const;
1407
1413 void getMaterialDescendants(Set<Material>& materials, bool local_only = false) const;
1414
1421 [[nodiscard]] MaterialBuffer getMaterialDescendantsByName(const StringView& name, uint04 max_count = Constant<uint04>::Max) const;
1422
1425 [[nodiscard]] MaterialBuffer getSceneMaterials() const;
1426
1432
1435
1438
1444
1449 void setMaterial(const Material& material);
1450
1457 void colorByChannel(Material& mat, const StringView& channel, fltp08 avg = Constant<fltp08>::Invalid) const;
1458
1461
1466 void copyMaterialProperties(const Model& model);
1467
1468#if NDEVR_SUPPORTS_BONES
1471 Bone createSceneBone() const;
1472
1478 bool hasBone(uint04 index = 0) const;
1479
1482 uint04 getNumOfBones() const;
1483
1489 Bone getBone(uint04 index = 0) const;
1490
1496 Bone getSceneBone(UUID id) const;
1497
1501
1507 Matrix<fltp08> getBoneTransform(uint04 index = 0) const;
1508
1514 uint04 getBoneGroupIndex(uint04 child_index = 0) const;
1515
1521 void setBoneGroupIndex(uint04 bone_group_index, uint04 sub_index = 0);
1522#endif
1523
1527
1530 [[nodiscard]] Matrix<fltp08> getParentTransform() const;
1531
1538 [[nodiscard]] Matrix<fltp08> applyTransformToParent(Matrix<fltp08> mat, const Matrix<fltp08>& parent_mat) const;
1539
1545 [[nodiscard]] Time getDescModifiedTime(bool includself) const;
1546
1553 [[nodiscard]] Time getAscModifiedTime(bool include_self, bool include_layer = true) const;
1554
1559 void validate(bool validate_children = true) const;
1560
1566 void setOrientation(const Vector<3, Angle<sint04>>& new_orientation, const void* lock = nullptr);
1567
1573 void setOrientation(const Vector<3, Angle<fltp08>>& new_orientation, const void* lock = nullptr);
1574
1580 void updateInheritedFlagsCache(bool force_update_all = false, bool update_personal_flags = false);
1581
1584
1587
1590
1593
1596
1599 [[nodiscard]] Vector<32, bool> inheritedFlags() const;
1600
1604
1608
1614 [[nodiscard]] Vector<32, bool> inheritedFlagsNoCache(bool complete_cache_ignore) const;
1615
1619
1623
1626 [[nodiscard]] BitFlag personalDescendedFlags() const;
1627
1633 [[nodiscard]] BitFlag descendedFlagsNoCache(bool complete_cache_ignore) const;
1634
1636 operator bool() const
1637 {
1638 return isValid();
1639 }
1640
1650 const ModelBuffer& children
1651 , const std::function<bool(const Model&, const Set<Model>&)>& filter);
1652 protected:
1655 ColumnT<uint04>& childToParentReference() const;
1656
1659 ColumnT<Buffer<uint04>>& parentToChildReference() const;
1660
1664
1668
1672
1676 private:
1683 Model getRootMaterialModel(const Model& value_to_return, bool allow_layer) const;
1684
1687 Vertex<3, fltp08> _center();
1688
1695 Bounds<3, fltp08> _bounds(bool usselection_bounds, bool get_global) const;
1696
1701 void setChildSize(uint04 child_size);
1702
1707 void setMaterialIndex(uint04 material_index);
1708
1713 void setPersonalInheritedFlags(const Vector<32, bool>& flags);
1714
1720 void setPersonalInheritedFlag(InheritedFlags flag, bool value);
1721
1732 void _copyFrom(const Model& model, bool deep_copy, bool copy_ids, bool recursive_copy, Dictionary<UUID, DesignObject>& copy_to_index, bool is_root_copy, bool keep_root_properties);
1733 };
1734
1738 template<>
1739 struct ObjectInfo<Model, false, false>
1740 {
1741 static const uint01 Dimensions = 0;
1742 static const bool Vector = false;
1743 static const bool Buffer = false;
1744 static const bool Primitive = true;
1745 static const bool Pointer = false;
1746 static const bool Unsigned = false;
1747 static const bool Float = false;
1748 static const bool Integer = false;
1749 static const bool Number = false;
1750 static const bool Enum = false;
1751 static const bool String = false;
1752 static const bool Color = false;
1753 static const bool Boolean = false;
1756 };
1757#ifndef _DEBUG
1758 static_assert(!std::is_polymorphic<Model>(), "Model should not be polymorphic");
1759 static_assert(std::is_trivially_destructible<Model>(), "Model should not be polymorphic");
1760#endif
1761
1765 template<>
1766 struct NDEVR_DESIGN_API Constant<Model>
1767 {
1768 static const Model Invalid;
1769 };
1770
1772 template class NDEVR_DESIGN_API StringStream<NDPN>;
1774 template class NDEVR_DESIGN_API StringStream<Model::MaterialMode>;
1775}
1776namespace std//Define things to allow use within std libs
1777{
1783 template <>
1784 struct hash<Model>
1785 {
1791 std::size_t operator()(const Model& d) const noexcept
1792 {
1793 UUID s = d.get<NDPO::guid>();
1794 std::size_t value = 0;
1795 for (uint01 i = 0; i < 8; i++)
1796 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
1797 return value;
1798 }
1799 };
1800};
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:190
Provides access to a set of named database tables.
Definition Database.h:44
Base information class for all design objects in the NDEVR property database.
uint04 m_design_index
Index of the parent design that owns this object.
DesignObjectBase * m_base
Pointer to the owning DesignObjectBase property database.
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
ColumnT< uint08 > geometry_base_ptr
Column storing a pointer or handle to the geometry DesignObjectBase.
ColumnT< Bounds< 3, fltp08 > > visible_box
Column storing the visible bounding box for culling.
ColumnT< uint08 > parent_base_ptr
Column storing a pointer or handle to the parent DesignObjectBase.
ColumnT< uint08 > child_base_ptr
Column storing a pointer or handle to the child DesignObjectBase.
ColumnT< Bounds< 3, fltp08 > > global_bounds
Column storing the world-space axis-aligned bounding box.
ColumnT< String > model_type
Column storing the model type string identifier.
ColumnT< Bounds< 3, fltp08 > > global_selection_bounds
Column storing the world-space selection bounding box.
ColumnT< Matrix< fltp08 > > complete_transform
Column storing the fully composed world-space transform matrix.
ColumnT< uint04 > inherited_flags
Column storing flags inherited from ancestors (visibility, lock, etc.).
ColumnT< uint04 > personal_inherited_flags
Column storing flags set on this model that propagate to children.
ColumnT< uint08 > material_base_ptr
Column storing a pointer or handle to the material DesignObjectBase.
DesignObject()=default
Creates an "invalid" design object.
constexpr decltype(auto) get(t_property_type property) const
Retrieves a property value from the database, cast to the requested type.
void scale(Vector< 3, fltp08 > scale, Vertex< 3, fltp08 > center_of_scale=Constant< Vertex< 3, fltp08 > >::Invalid)
Scales this design object's geometry and transform by the given scale factors around a center point.
uint04 index() const
Returns the primary row index of this object within the DesignObjectBase property table.
bool isValid() const
Checks whether this design object has a valid index into the database.
bool is(t_property_type property, const StringView &value) const
Checks whether a string property matches the given StringView value.
DesignObjectBase & base() const
Returns a reference to the underlying DesignObjectBase database.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
A core class that provides a dynamic effect to an object in a model hierarchy.
Definition Effect.h:158
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
A light-weight base class for Log that allows processes to update, without the need for additional in...
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:50
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
bool hasFocus() const
Checks whether this model currently has focus.
PrimitiveAlignedBuffer< std::pair< Model, Geometry >, 32 > getClippingGeometry() const
Returns model-geometry pairs used for clipping operations.
ModelBuffer getDescendants(bool include_deleted=false, bool local_only=false) const
Returns all descendant models recursively.
Buffer< t_type > getTypeChildren(const StringView &type) const
Returns children of a specific type, cast to the requested derived type.
Definition Model.h:770
void calculateSmoothTextures(Vector< 3, fltp08 > origin, fltp08 scale)
Calculates smooth texture coordinates based on a projection origin and scale.
uint04 visibleVertexCount() const
Returns the total number of visible vertices across all descendant geometries.
ParentMatrixFlags
Flags controlling which components of the parent's transformation matrix are applied to this model.
Definition Model.h:311
@ e_ignore_scale_distortion
Ignore non-uniform scale distortion from parent.
Definition Model.h:315
@ e_use_only_for_offset
Use parent transform only for translation (ignore scale and rotation).
Definition Model.h:316
@ e_follow_camera
Follow the camera position.
Definition Model.h:318
@ e_orient_to_camera
Orient this model to always face the camera (billboard).
Definition Model.h:317
@ e_scale_to_camera
Scale relative to camera distance for constant apparent size.
Definition Model.h:319
@ e_ignore_scale
Ignore parent scale.
Definition Model.h:313
@ e_ignore_rotation
Ignore parent rotation.
Definition Model.h:314
@ e_ignore_offset
Ignore parent translation.
Definition Model.h:312
void updateModifiedTime(Time time=Time::SystemTime())
Updates the modified timestamp for this model.
StringView getModelIcon() const
Returns the icon identifier string for this model's type.
bool isApplicationOwned() const
Checks whether this model is owned by the application (not user-created).
ModelBuffer getChildrenByType(const Buffer< String > &type) const
Returns all direct children whose type matches any of the given strings.
void hasDescendants(bool &has_point, bool &has_line, bool &has_mesh, bool only_user_objects) const
Checks which types of geometry primitives exist among descendants.
void clearMaterialDescendants()
Removes all descendant material assignments without deleting the materials.
Model createSceneModel() const
Creates a new model in the scene database associated with this model.
Vector< 2, fltp08 > calculateVolumeAndSurfaceArea(const Matrix< fltp08 > &transform=Constant< Matrix< fltp08 > >::Invalid, const void *lock=nullptr) const
Calculates both volume and surface area in a single pass for efficiency.
ColumnT< Buffer< uint04 > > & parentToChildReference() const
Returns the column mapping parent indices to child index lists.
uint04 getMaterialIdx() const
Returns the database index of the material assigned to this model.
bool hasGeometryDescendent() const
Checks whether any descendant has geometry data.
void restoreModel()
Restores a previously deleted model, re-adding it to the scene.
Vector< 3, fltp08 > size() const
Returns the size (extents) of the model's bounding box.
fltp08 calculateLength(const Matrix< fltp08 > &transform=Constant< Matrix< fltp08 > >::Invalid) const
Calculates the total length of all descendant linear geometries.
void calculateTangentSpace(bool calc_tan, bool calc_bitan)
Calculates tangent and/or bitangent vectors for all descendant geometries.
MaterialBuffer getMaterialDescendants(bool local_only=false) const
Recursively collects all descendant materials.
Model getLayer() const
Returns the layer model assigned to this model (direct or inherited).
Time getAscModifiedTime(bool include_self, bool include_layer=true) const
Returns the greatest modified time of this model and all ancestors.
bool hasEffect(uint04 index=0) const
Checks whether an effect exists at the given child index.
ModelColorMode
Determines how the model color is resolved for display purposes.
Definition Model.h:357
void setNormalMode(NormalMode mode, Angle< fltp08 > smoothing_angle, InfoPipe *log)
Sets the normal mode and recalculates normals with progress logging.
Geometry getGeometry() const
Returns the geometry attached to this model.
void setChildEffectSize(uint04 child_size)
Sets the number of child effect slots for this model.
Material getSceneMaterial(uint04 index) const
Returns a scene material by database index.
Effect createSceneEffect() const
Creates a new effect in the scene database.
Model(const DesignInfo &obj)
Constructs a Model from an existing DesignInfo descriptor.
void invalidateBounds()
Invalidates all cached bounding boxes, forcing recalculation on next access.
ModelBuffer getChildrenByType(const StringView &type) const
Returns all direct children whose type matches the given string.
DesignObjectBase * parentBase() const
Returns the DesignObjectBase used for parent model storage.
void addChild(uint04 child_idx, Model &child)
Adds an existing model as a child at a specific index.
RGBColor customModelColor(ModelColorMode mode) const
Returns the resolved model color based on the specified color mode.
void validate(bool validate_children=true) const
Validates this model's internal state for consistency.
void calculateNormals(NormalMode mode, Angle< fltp08 > smoothing_angle)
Recalculates normals for all descendant geometries.
bool doesModelPropertyContain(NDPN property, const StringView &value, bool ignorcase) const
Checks whether a model property contains a given substring.
Definition Model.h:481
Vector< 32, bool > inheritedFlagsNoCache(bool complete_cache_ignore) const
Computes inherited flags without using the cache.
ModelBuffer explodeModel()
Explodes this model, promoting its children to siblings in the parent.
void clearChildren()
Removes all children from this model without deleting them.
bool hasLinearDescendent() const
Checks whether any descendant has linear (line/polyline) geometry.
bool doesModelPropertyContain(NDPN property, const char *value, bool ignorcase) const
Checks whether a model property contains a given C-string substring.
Definition Model.h:493
BitFlag descendedFlagsNoCache(bool complete_cache_ignore) const
Computes descended flags without using the cache.
TranslatedString displayName() const
Returns the translated display name for this model.
void deleteModel(bool deletchildren, bool removfrom_parent=true)
Deletes this model from the scene.
void copyMaterialProperties(const Model &model)
Copies material properties from another model to this model.
void getChildren(ModelBuffer &children) const
Appends all direct children of this model to the provided buffer.
Vector< 32, bool > inheritedPersonalFlagsNoCache() const
Computes inherited personal flags without using the cache.
Material getSceneMaterial(UUID id) const
Returns a scene material by UUID.
EffectBuffer getEffectDescendants() const
Returns all descendant effects recursively.
bool hasMaterial() const
Checks whether this model has a material assigned.
void setParentMatrixFlags(BitFlag flags)
Sets the parent matrix flags controlling which parent transform components to inherit.
Time getDescModifiedTime(bool includself) const
Returns the greatest modified time of this model and all descendants.
TranslatedString displayNamePath(const StringView &seperator=":") const
Returns the full display name path from root to this model.
void updateDescGeometryTime(const Time &time, bool include_self)
Updates the geometry-modified timestamp for this model and all descendants.
void overrideMaterialDescendants(MaterialMode override_desc)
Overrides material mode for all descendants.
Bounds< 3, fltp08 > getBoundsOfVisible() const
Returns the bounding box of all visible descendants.
void setChildApplicationConstructed(DesignObjectBase *base)
Sets the child database to use an application-constructed DesignObjectBase.
void setIsLayer(bool is_layer)
Marks or unmarks this model as a layer definition.
DesignObjectBase * geometryBase() const
Returns the DesignObjectBase used for geometry storage.
Model getParent() const
Returns the parent model of this model.
MaterialMode
Determines how a model resolves its material for rendering.
Definition Model.h:298
Vector< 32, bool > inheritedFlags() const
Returns the cached inherited flags vector for this model.
bool isVisible() const
Checks whether this model is visible (accounting for inherited visibility).
bool hasChild(uint04 child_index=0U) const
Checks whether this model has a child at the given slot.
Geometry getSceneGeometry(UUID id) const
Returns a scene geometry by UUID.
Effect getSceneEffect(UUID id) const
Returns a scene effect by its UUID.
Vertex< 3, fltp08 > globalCenterOfRotation() const
Returns the center of rotation in global coordinates.
bool isSelected() const
Checks whether this model is currently selected.
bool hasRootMaterial() const
Checks whether a root material can be resolved through the hierarchy.
static ModelBuffer ReduceToRoots(const ModelBuffer &children, const std::function< bool(const Model &, const Set< Model > &)> &filter)
Reduces a collection of models to only root-level models (removing any that are descendants of others...
Model createChild(uint04 child_slot)
Creates a new child model at a specific child slot index.
bool setModelVisible(bool is_visible)
Sets the visibility of this model.
bool hasDirectLayer() const
Checks whether this model has a directly assigned layer (not inherited).
uint04 childCount() const
Returns the number of direct children this model has.
void updateGeometryTime(Time time=Time::SystemTime())
Updates the geometry-modified timestamp for this model.
bool isType(const Buffer< t_buffer_type > &types) const
Checks whether the model's type matches any type in the given buffer.
Definition Model.h:510
void setLayer(Model layer)
Assigns this model to a specific layer.
void getMaterialDescendants(MaterialBuffer &materials, bool local_only=false) const
Appends all descendant materials to the provided buffer.
EffectBuffer getEffectChildren() const
Returns all direct child effects of this model.
void invalidateTransformCache()
Invalidates the cached transformation matrix, forcing recomputation.
bool hasSelectedDescendent() const
Checks whether any descendant of this model is selected.
Model getRootMaterialModel()
Returns the ancestor model that determines the root material for this model.
Model findDescendentByType(const StringView &type) const
Recursively searches descendants for a model with the given type.
void removeChild(const Model &model)
Removes a specific child model from this model's child list.
Model createChild()
Creates a new child model and appends it to this model's child list.
bool isScene() const
Checks whether this model represents a scene root node.
void getDescendants(ModelBuffer &buffer, bool include_deleted=false, bool local_only=false) const
Appends all descendant models recursively to the provided buffer.
bool hasLayerRootMaterial() const
Checks whether a root material exists through the layer hierarchy.
bool hasDescendent(const UUID &id) const
Checks whether a model with the given UUID is a descendant of this model.
void updateDescTime(const Time &time, bool include_self)
Updates the modified timestamp for this model and all descendants.
Model getSceneLayer(UUID id) const
Returns a scene layer by its UUID.
void setMaterialApplicationConstructed(const StringView &database_name=StringView())
Sets the material database to an application-constructed database by name.
Buffer< t_type > getTypeDescendants(const StringView &type) const
Recursively searches descendants for models of a specific type, cast to a derived type.
Definition Model.h:802
fltp08 calculateVolume(const Matrix< fltp08 > &transform=Constant< Matrix< fltp08 > >::Invalid) const
Calculates the volume of all descendant mesh geometries.
Effect createChildEffect()
Creates a new child effect attached to this model.
void eraseModel()
Erases this model from the database without removing children.
uint04 getGeometryIndex() const
Returns the database index of the geometry associated with this model.
void setWindingMode(WindingMode mode)
Sets the winding mode for all descendant geometries.
ModelBuffer getSceneModelsByName(const StringView &name, uint04 max_count=Constant< uint04 >::Max, bool includdeleted=false) const
Returns scene models filtered by name.
InheritedFlags
Flags that are recursively inherited from ancestor models down through the hierarchy.
Definition Model.h:327
@ e_inherited_exportable
Whether this model is exportable (inherited).
Definition Model.h:339
@ e_inherited_does_not_follow_camera
Whether this model does not follow the camera (inherited).
Definition Model.h:334
@ e_inherited_is_tree_visible
Whether this model is visible in the tree view (inherited).
Definition Model.h:330
@ e_inherited_is_visible
Whether this model is visible (inherited from ancestors).
Definition Model.h:328
@ e_inherited_does_not_scale_to_camera
Whether this model does not scale to camera (inherited).
Definition Model.h:336
@ e_inherited_not_deleted
Whether this model is not deleted (inherited).
Definition Model.h:337
@ e_inherited_not_application_owned
Whether this model is not application-owned (inherited).
Definition Model.h:338
@ e_inherited_can_delete
Whether this model can be deleted (inherited).
Definition Model.h:333
@ e_inherited_not_selected
Whether this model is not selected (inherited).
Definition Model.h:331
@ e_placholder
Reserved placeholder flag.
Definition Model.h:332
@ e_inherited_does_not_orient_to_camera
Whether this model does not orient to camera (inherited).
Definition Model.h:335
@ e_inherited_has_no_focus
Whether this model lacks focus (inherited).
Definition Model.h:329
void invalidateVisibleBounds()
Invalidates the cached visible bounding box.
ModelBuffer getDescendantsByType(const StringView &type, uint04 max_count=Constant< uint04 >::Max) const
Recursively searches all descendants for models matching the given type.
bool hasMeshDescendent() const
Checks whether any descendant has mesh (triangle) geometry.
bool hasPointsDescendent() const
Checks whether any descendant has point geometry.
bool hasDescendent(const Model &model) const
Checks whether a given model is a descendant of this model.
bool isTreeVisible() const
Checks whether this model is visible in the model tree view.
void setMaterialMode(MaterialMode option)
Sets the material mode for this model.
MaterialMode getMaterialMode() const
Returns the material mode determining how materials are resolved for this model.
bool isLocked() const
Checks whether this model is locked against editing.
Matrix< fltp08 > applyTransformToParent(Matrix< fltp08 > mat, const Matrix< fltp08 > &parent_mat) const
Applies a transformation matrix to the parent transform, respecting parent matrix flags.
Geometry createChildGeometry()
Creates a new child geometry for this model.
void setMaterial(const Material &material)
Assigns a material to this model.
Model getFamilyMember(uint04 index) const
Returns a model from the family tree (ancestors + descendants) by flat index.
void addPerVertexColorFromMaterialConstant(UVType constant_index)
Adds per-vertex color data derived from a material constant UV channel.
void colorByChannel(Material &mat, const StringView &channel, fltp08 avg=Constant< fltp08 >::Invalid) const
Colors geometry vertices by a data channel value from a material.
Effect getEffect(uint04 index=0) const
Returns the effect at the specified child index.
Vector< 3, fltp08 > calculateAverageDirection(const Matrix< fltp08 > &parent_transform=Constant< Matrix< fltp08 > >::Invalid) const
Calculates the average direction vector of descendant linear geometries.
DescendedFlags
Flags that propagate upward from descendant models to ancestors, indicating aggregate states of the s...
Definition Model.h:347
@ e_descendent_focussed
At least one descendant has focus.
Definition Model.h:349
@ e_descendent_selected
At least one descendant is selected.
Definition Model.h:348
@ e_descendent_deletion_blocked
At least one descendant blocks deletion.
Definition Model.h:350
ModelBuffer getSceneModelsByType(const StringView &type, uint04 max_count=Constant< uint04 >::Max, bool includdeleted=false) const
Returns scene models filtered by type.
uint04 vertexCount() const
Returns the total number of vertices across all descendant geometries.
DesignObjectBase * childBase() const
Returns the DesignObjectBase used for child model storage.
void removeMaterial()
Removes the material from this model.
bool isDeleted() const
Checks whether this model has been deleted.
ModelBuffer getDescendantsByName(const StringView &name, uint04 max_count=Constant< uint04 >::Max) const
Recursively searches all descendants for models matching the given name.
void calculateIndexNeighborList()
Calculates the index neighbor list for geometry processing.
void setChildApplicationConstructed(const StringView &database_name=StringView())
Sets the child database to an application-constructed database by name.
ModelBuffer getSceneModels(bool include_deleted=false, bool local_only=false) const
Returns all models in the scene database.
bool isLayer() const
Checks whether this model is a layer definition.
ModelBuffer getDescendantsByNameAndType(const StringView &name, const StringView &type, uint04 max_count=Constant< uint04 >::Max) const
Recursively searches all descendants for models matching both name and type.
MaterialBuffer getMaterialDescendantsByName(const StringView &name, uint04 max_count=Constant< uint04 >::Max) const
Returns descendant materials filtered by name.
uint04 getDirectLayerIndex() const
Returns the database index of the directly assigned layer.
ModelBuffer getChildrenByName(const StringView &name) const
Returns all direct children whose name matches the given string.
BitFlag parentMatrixFlags() const
Returns the parent matrix flags for this model.
Matrix< fltp08 > getCompleteTransform() const
Returns the fully composed local-to-global transform matrix for this model.
void setModelTransform(const Matrix< fltp08 > &transform)
Sets the model's local transformation matrix, replacing the current one.
void addChild(Model &child)
Adds an existing model as a child of this model.
Model()
Default constructor. Creates an uninitialized Model.
Definition Model.h:365
Bounds< 3, fltp08 > globalBounds() const
Returns the global bounding box of this model (including transform).
ModelBuffer getChildren() const
Returns a buffer containing all direct children of this model.
bool canExplode() const
Checks whether this model can be exploded into its constituent children.
void addChild(uint04 child_index)
Adds a child by its database index.
void ensureTangentSpace(bool ensure_tan, bool ensure_bitan)
Ensures that tangent and/or bitangent data exists, calculating if needed.
uint04 getParentIndex() const
Returns the database index of this model's parent.
ColumnT< uint04 > & childToParentReference() const
Returns the column mapping child indices to parent indices.
Buffer< UUID > getChildrenIDs() const
Returns the UUIDs of all direct children.
Vertex< 3, fltp08 > centerAlignModel()
Centers the model geometry at the origin and returns the offset applied.
bool exportIgnored() const
Checks whether this model is excluded from export operations.
MaterialBuffer getSceneMaterials() const
Returns all materials in the scene database.
Material getMaterial() const
Returns the material assigned to this model.
void setChildIndex(uint04 child, uint04 id)
Sets the database index for a specific child slot.
void restoreModel(Model &parent, uint04 index=Constant< uint04 >::Invalid)
Restores a previously deleted model under a specific parent.
Bounds< 3, fltp08 > getSelectionBounds() const
Returns the selection-specific bounding box in local space.
EffectBuffer getSceneEffects() const
Returns all effects in the scene database.
void updateInheritedFlagsCache(bool force_update_all=false, bool update_personal_flags=false)
Recalculates and caches the inherited flags for this model.
Buffer< uint04 > getChildIndices() const
Returns the database indices of all direct children.
uint04 getEffectIndex(uint04 child_index=0) const
Returns the database index of the effect at the given child slot.
void updateModelTransform(const Matrix< fltp08 > &transform, const void *lock=nullptr)
Applies a delta transform to the current model transform.
BitFlag descendedPersonalFlagsNoCache() const
Computes descended personal flags without using the cache.
void setParentMatrixFlag(ParentMatrixFlags flag, bool value)
Sets or clears a specific parent matrix flag.
void removeDuplicateVertices(fltp08 epsilon, void *lock, InfoPipe *log=nullptr)
Removes duplicate vertices from all descendant geometries.
Material createSceneMaterial() const
Creates a new material in the scene database.
DesignObjectBase * materialBase() const
Returns the DesignObjectBase used for material storage.
Model(DesignObjectBase *base)
Constructs a Model from a design object base, using the next available index.
Model getChild(uint04 child) const
Returns the child model at the given child slot index.
void clearMaterial()
Removes the material assignment from this model.
Geometry createSceneGeometry() const
Creates a new geometry in the scene database.
Model(uint04 index, DesignObjectBase *base)
Constructs a Model at a specific index within the design object base.
Model getChild(UUID id) const
Returns the child model with the specified UUID.
void descendentGeometryTypes(Set< GeometryType > &buffer) const
Collects all unique geometry types from descendants into the provided set.
void deleteChildren()
Deletes all children of this model.
void invalidateSelectionBounds()
Invalidates the cached selection bounding box.
Model getSceneModel(UUID id) const
Retrieves a scene model by its UUID.
void setOrientation(const Vector< 3, Angle< sint04 > > &new_orientation, const void *lock=nullptr)
Sets the orientation of this model using integer-precision angles.
void removeGeometry()
Removes the geometry reference from this model (does not delete the geometry).
Model createSceneLayer() const
Creates a new layer model in the scene database.
void setGeometryChild(Geometry &geo)
Sets the geometry child of this model to an existing Geometry object.
void setEffectIndex(uint04 material_index, uint04 sub_index=0)
Sets the effect database index at a given sub-index.
void ensureVisibleChildren(uint04 count)
Hides children whos child index is greater than size, or creates/shows children if needed such that t...
Geometry getSceneGeometry(uint04 index) const
Returns a scene geometry by database index.
void invalidateGlobalBoundsDesc()
Invalidates global bounding boxes for this model and all descendants.
void setGeometryApplicationConstructed(const StringView &database_name=StringView())
Sets the geometry database to an application-constructed database by name.
Matrix< fltp08 > getParentTransform() const
Returns the parent's transformation matrix as seen by this model.
void updateFrom(const Model &model, bool check_resources)
Updates this model's properties from another model, optionally checking resources.
void swapChildren(uint04 a, uint04 b)
Swaps the positions of two children in the child list.
bool hasHoles(PrimitiveProperty property) const
Checks whether the geometry has holes (missing primitives) for a given property.
void clearLayer()
Removes the layer assignment from this model.
void setSize(const Vector< 3, fltp08 > &size)
Sets the model size by scaling its transform to match the desired dimensions.
void getMaterialDescendants(Set< Material > &materials, bool local_only=false) const
Appends all descendant materials to the provided set (deduplicating).
fltp08 calculateSurfaceArea(const Matrix< fltp08 > &transform=Constant< Matrix< fltp08 > >::Invalid) const
Calculates the surface area of all descendant mesh geometries.
uint04 getChildIndex() const
Returns this model's index within its parent's child list.
BitFlag personalDescendedFlags() const
Returns the cached personal descended flags.
void updateAscTime(const Time &time, bool includself)
Updates the modified timestamp for this model and all ancestors.
Bounds< 3, fltp08 > globalSelectionBounds() const
Returns the global selection bounding box.
uint04 getChildLayerIndex() const
Returns this model's index within its parent's layer child list.
GeometryBuffer getGeometryDescendants(bool remove_redundant=true, uint04 max_count=Constant< uint04 >::Max) const
Recursively collects all descendant geometries.
Bounds< 3, fltp08 > getBounds() const
Returns the local bounding box of this model.
GeometryBuffer getSceneGeometries() const
Returns all geometries in the scene database.
Vector< 2, fltp08 > calculateHVLength(const Matrix< fltp08 > &parent_transform=Constant< Matrix< fltp08 > >::Invalid) const
Calculates horizontal and vertical length components of descendant linear geometries.
void setGeometryIndex(uint04 geo_index)
Sets the geometry database index for this model.
Vector< 32, bool > personalInheritedFlags() const
Returns the personal inherited flags from the cache.
void setOrientation(const Vector< 3, Angle< fltp08 > > &new_orientation, const void *lock=nullptr)
Sets the orientation of this model using floating-point angles.
uint04 getChildIndex(uint04 child) const
Returns the database index of the child at the given slot.
uint04 getNumOfEffects() const
Returns the number of effects attached to this model.
void updateAscGeometryTime(const Time &time, bool include_self)
Updates the geometry-modified timestamp for this model and all ancestors.
void copyFrom(const Model &model, bool deep_copy, bool copy_ids=false, bool recursive=true, bool keep_root_properties=false)
Copies data from another model into this model.
Model findDescendentByName(const StringView &name) const
Recursively searches descendants for a model with the given name.
bool canInteract() const
Checks whether this model can be interacted with (visible, not locked, etc.).
ModelBuffer getSceneLayers(bool include_deleted=false) const
Returns all layer models in the scene.
void checkBounds()
Validates and recalculates cached bounding boxes if needed.
void updateVisibleRecursive(bool is_visible)
Recursively updates visibility for this model and all descendants.
bool hasLayer() const
Checks whether this model has a layer (directly or inherited).
Model getRoot() const
Returns the root ancestor of this model's hierarchy.
Material createChildMaterial(bool copy_child=false)
Creates a new child material for this model.
void createChildren(uint04 child_size)
Creates multiple children at once.
Model directLayer() const
Returns the directly assigned layer model.
Material getRootMaterial() const
Returns the root material resolved through the hierarchy.
static constexpr TableColumn * column(const DesignInfo *object, NDPN property)
Returns the TableColumn pointer for a given NDPN property.
Definition Model.h:271
static constexpr uint04 index(const DesignInfo *object, NDPN)
Returns the row index for the given design object.
Definition Model.h:280
Provides access to the TableColumn and row index for a given property enum value.
static decltype(auto) Get(const DesignInfo *object)
Retrieves a model property value at compile time by template property enum.
Definition Model.h:143
static decltype(auto) Get(const DesignInfo *object, NDPN property)
Retrieves a model property value at runtime by property enum and requested type.
Definition Model.h:133
static void Set(DesignInfo *object, NDPN property, const t_valutype &value)
Sets a model property value at runtime by property enum.
Definition Model.h:154
static decltype(auto) Get(const DesignInfo *object)
Retrieves a model property at compile time with optimized direct member access.
Definition Model.h:226
static void Set(DesignInfo *object, const t_valutype &value)
Sets a model property value at compile time with optimized direct member access.
Definition Model.h:168
static constexpr TableColumn * column(const DesignInfo *object, NDPN property)
Returns the TableColumn pointer for a given NDPN property.
Definition Model.h:201
static bool IsSame(const DesignInfo *object, NDPN property, const StringView &value)
Checks whether the stored property value matches a given string.
Definition Model.h:213
Typed interface for getting and setting design object properties by enum.
static TableColumn * column(const DesignInfo *object, t_property_enum property)
Retrieves the TableColumn pointer for a given property on the specified design object.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
Definition StringView.h:58
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
virtual bool isSame(uint04 index, const StringView &value) const =0
Checks whether the stored string at the given row is exactly equal to the given value.
std::enable_if<!ObjectInfo< t_class >::Enum >::type set(uint04 index, const t_class &value)
Sets the value at the given row index from a non-enum type.
void get(uint04 index, Vector< 1, t_class > &vector) const
Retrieves a 1D vector value at the given row index by delegating to the scalar get.
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
NormalMode
Describes how surface normals are computed or stored for a Geometry object.
NDPN
NDPN - NDEVR Design Property Node: Values stored in the model database.
Definition Model.h:57
@ calculation_ignored
Whether this model is ignored in calculations (e.g., volume, area).
Definition Model.h:61
@ geometry_base_ptr
Pointer to the DesignObjectBase that stores geometry data.
Definition Model.h:75
@ material_mode
How the material is resolved for this model (see Model::MaterialMode).
Definition Model.h:64
@ visible_box
The cached visible bounding box in local coordinates.
Definition Model.h:60
@ model_property_size
Sentinel value marking the end of the property enum (always last).
Definition Model.h:76
@ type
The type identifier string for this model node.
Definition Model.h:58
@ child_base_ptr
Pointer to the DesignObjectBase that stores child model data.
Definition Model.h:72
@ inherited_flags
Cached flags recursively inherited from ancestors.
Definition Model.h:69
@ model_color
The color assigned directly to this model node.
Definition Model.h:68
@ parent_matrix_flags
Flags controlling which parent transform components to inherit.
Definition Model.h:65
@ export_ignored
Whether this item should be excluded from file export.
Definition Model.h:71
@ complete_transform
The fully composed local-to-global transformation matrix.
Definition Model.h:63
@ material_base_ptr
Pointer to the DesignObjectBase that stores material data.
Definition Model.h:74
@ personal_inherited_flags
This node's own contribution to inherited flags (before recursion).
Definition Model.h:70
@ fixed_bounding_box
A user-defined fixed bounding box override for this model.
Definition Model.h:59
@ global_selection_bounds
Cached selection bounding box in global coordinates.
Definition Model.h:67
@ can_select_children
Whether children of this model can be individually selected.
Definition Model.h:62
@ parent_base_ptr
Pointer to the DesignObjectBase that stores parent model data.
Definition Model.h:73
@ global_bounds
Cached axis-aligned bounding box in global coordinates.
Definition Model.h:66
PrimitiveAlignedBuffer< Effect, 16 > EffectBuffer
Aligned buffer of Effect objects with 16-byte alignment.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
constexpr t_to & rcast(t_from &value)
Casts the given value.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ guid
A 128-bit globally unique identifier for the object.
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
PrimitiveAlignedBuffer< Model, 16 > ModelBuffer
Aligned buffer of Model objects with 16-byte alignment.
WindingMode
Describes the vertex winding order used to determine front-facing direction of polygons.
PrimitiveAlignedBuffer< Geometry, 16 > GeometryBuffer
Aligned buffer of Geometry objects with 16-byte alignment.
UVType
Channels that describe how an object should interact with light.
PrimitiveAlignedBuffer< Material, 16 > MaterialBuffer
Aligned buffer of Material objects with 16-byte alignment.
STL namespace.
static const Model Invalid
The invalid (null) Model sentinel value.
Definition Model.h:1768
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
static const bool Buffer
Whether this is a buffer type.
Definition Model.h:1743
static const bool Primitive
Whether this is a primitive type.
Definition Model.h:1744
static const bool Number
Whether this is a numeric type.
Definition Model.h:1749
static const bool Float
Whether this is a floating-point type.
Definition Model.h:1747
static const bool Vector
Whether this is a vector type.
Definition Model.h:1742
static constexpr ObjectInfo< Model, false, false > VectorSub()
Returns the vector sub-info (identity for non-vector types).
Definition Model.h:1755
static const uint01 Dimensions
Number of dimensions (0 for non-spatial types).
Definition Model.h:1741
static const bool Integer
Whether this is an integer type.
Definition Model.h:1748
static const bool Boolean
Whether this is a boolean type.
Definition Model.h:1753
static const bool Unsigned
Whether this is an unsigned numeric type.
Definition Model.h:1746
static const bool String
Whether this is a string type.
Definition Model.h:1751
static const bool Color
Whether this is a color type.
Definition Model.h:1752
static const bool Enum
Whether this is an enum type.
Definition Model.h:1750
static const bool Pointer
Whether this is a pointer type.
Definition Model.h:1745
Information about the object.
Definition ObjectInfo.h:55
Maps a compile-time property enum value to its corresponding C++ storage type.