gltf_object_model_property.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**************************************************************************/
  2. /* gltf_object_model_property.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef GLTF_OBJECT_MODEL_PROPERTY_H
  31. #define GLTF_OBJECT_MODEL_PROPERTY_H
  32. #include "core/math/expression.h"
  33. #include "core/variant/typed_array.h"
  34. #include "gltf_accessor.h"
  35. // Object model: https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/ObjectModel.adoc
  36. // KHR_animation_pointer: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_animation_pointer
  37. class GLTFObjectModelProperty : public RefCounted {
  38. GDCLASS(GLTFObjectModelProperty, RefCounted);
  39. public:
  40. enum GLTFObjectModelType {
  41. GLTF_OBJECT_MODEL_TYPE_UNKNOWN,
  42. GLTF_OBJECT_MODEL_TYPE_BOOL,
  43. GLTF_OBJECT_MODEL_TYPE_FLOAT,
  44. GLTF_OBJECT_MODEL_TYPE_FLOAT_ARRAY,
  45. GLTF_OBJECT_MODEL_TYPE_FLOAT2,
  46. GLTF_OBJECT_MODEL_TYPE_FLOAT3,
  47. GLTF_OBJECT_MODEL_TYPE_FLOAT4,
  48. GLTF_OBJECT_MODEL_TYPE_FLOAT2X2,
  49. GLTF_OBJECT_MODEL_TYPE_FLOAT3X3,
  50. GLTF_OBJECT_MODEL_TYPE_FLOAT4X4,
  51. GLTF_OBJECT_MODEL_TYPE_INT,
  52. };
  53. private:
  54. Ref<Expression> gltf_to_godot_expr;
  55. Ref<Expression> godot_to_gltf_expr;
  56. TypedArray<NodePath> node_paths;
  57. GLTFObjectModelType object_model_type = GLTF_OBJECT_MODEL_TYPE_UNKNOWN;
  58. Vector<PackedStringArray> json_pointers;
  59. Variant::Type variant_type = Variant::NIL;
  60. protected:
  61. static void _bind_methods();
  62. public:
  63. void append_node_path(const NodePath &p_node_path);
  64. void append_path_to_property(const NodePath &p_node_path, const StringName &p_prop_name);
  65. GLTFAccessor::GLTFAccessorType get_accessor_type() const;
  66. Ref<Expression> get_gltf_to_godot_expression() const;
  67. void set_gltf_to_godot_expression(Ref<Expression> p_gltf_to_godot_expr);
  68. Ref<Expression> get_godot_to_gltf_expression() const;
  69. void set_godot_to_gltf_expression(Ref<Expression> p_godot_to_gltf_expr);
  70. TypedArray<NodePath> get_node_paths() const;
  71. bool has_node_paths() const;
  72. void set_node_paths(TypedArray<NodePath> p_node_paths);
  73. GLTFObjectModelType get_object_model_type() const;
  74. void set_object_model_type(GLTFObjectModelType p_type);
  75. Vector<PackedStringArray> get_json_pointers() const;
  76. bool has_json_pointers() const;
  77. void set_json_pointers(const Vector<PackedStringArray> &p_json_pointers);
  78. TypedArray<PackedStringArray> get_json_pointers_bind() const;
  79. void set_json_pointers_bind(const TypedArray<PackedStringArray> &p_json_pointers);
  80. Variant::Type get_variant_type() const;
  81. void set_variant_type(Variant::Type p_variant_type);
  82. void set_types(Variant::Type p_variant_type, GLTFObjectModelType p_obj_model_type);
  83. };
  84. VARIANT_ENUM_CAST(GLTFObjectModelProperty::GLTFObjectModelType);
  85. #endif // GLTF_OBJECT_MODEL_PROPERTY_H