gltf_accessor.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*************************************************************************/
  2. /* gltf_accessor.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "gltf_accessor.h"
  31. void GLTFAccessor::_bind_methods() {
  32. ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view);
  33. ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view);
  34. ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset);
  35. ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset);
  36. ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type);
  37. ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type);
  38. ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized);
  39. ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized);
  40. ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count);
  41. ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count);
  42. ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type);
  43. ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type);
  44. ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min);
  45. ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min);
  46. ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max);
  47. ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max);
  48. ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count);
  49. ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count);
  50. ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view);
  51. ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view);
  52. ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset);
  53. ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset);
  54. ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type);
  55. ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type);
  56. ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view);
  57. ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view);
  58. ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset);
  59. ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset);
  60. ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex
  61. ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int
  62. ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int
  63. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool
  64. ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int
  65. ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFDocument::GLTFType
  66. ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
  67. ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
  68. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int
  69. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int
  70. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int
  71. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int
  72. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int
  73. ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int
  74. }
  75. GLTFBufferViewIndex GLTFAccessor::get_buffer_view() {
  76. return buffer_view;
  77. }
  78. void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) {
  79. buffer_view = p_buffer_view;
  80. }
  81. int GLTFAccessor::get_byte_offset() {
  82. return byte_offset;
  83. }
  84. void GLTFAccessor::set_byte_offset(int p_byte_offset) {
  85. byte_offset = p_byte_offset;
  86. }
  87. int GLTFAccessor::get_component_type() {
  88. return component_type;
  89. }
  90. void GLTFAccessor::set_component_type(int p_component_type) {
  91. component_type = p_component_type;
  92. }
  93. bool GLTFAccessor::get_normalized() {
  94. return normalized;
  95. }
  96. void GLTFAccessor::set_normalized(bool p_normalized) {
  97. normalized = p_normalized;
  98. }
  99. int GLTFAccessor::get_count() {
  100. return count;
  101. }
  102. void GLTFAccessor::set_count(int p_count) {
  103. count = p_count;
  104. }
  105. int GLTFAccessor::get_type() {
  106. return (int)type;
  107. }
  108. void GLTFAccessor::set_type(int p_type) {
  109. type = (GLTFDocument::GLTFType)p_type; // TODO: Register enum
  110. }
  111. PoolVector<float> GLTFAccessor::get_min() {
  112. return min;
  113. }
  114. void GLTFAccessor::set_min(PoolVector<float> p_min) {
  115. min = p_min;
  116. }
  117. PoolVector<float> GLTFAccessor::get_max() {
  118. return max;
  119. }
  120. void GLTFAccessor::set_max(PoolVector<float> p_max) {
  121. max = p_max;
  122. }
  123. int GLTFAccessor::get_sparse_count() {
  124. return sparse_count;
  125. }
  126. void GLTFAccessor::set_sparse_count(int p_sparse_count) {
  127. sparse_count = p_sparse_count;
  128. }
  129. int GLTFAccessor::get_sparse_indices_buffer_view() {
  130. return sparse_indices_buffer_view;
  131. }
  132. void GLTFAccessor::set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view) {
  133. sparse_indices_buffer_view = p_sparse_indices_buffer_view;
  134. }
  135. int GLTFAccessor::get_sparse_indices_byte_offset() {
  136. return sparse_indices_byte_offset;
  137. }
  138. void GLTFAccessor::set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset) {
  139. sparse_indices_byte_offset = p_sparse_indices_byte_offset;
  140. }
  141. int GLTFAccessor::get_sparse_indices_component_type() {
  142. return sparse_indices_component_type;
  143. }
  144. void GLTFAccessor::set_sparse_indices_component_type(int p_sparse_indices_component_type) {
  145. sparse_indices_component_type = p_sparse_indices_component_type;
  146. }
  147. int GLTFAccessor::get_sparse_values_buffer_view() {
  148. return sparse_values_buffer_view;
  149. }
  150. void GLTFAccessor::set_sparse_values_buffer_view(int p_sparse_values_buffer_view) {
  151. sparse_values_buffer_view = p_sparse_values_buffer_view;
  152. }
  153. int GLTFAccessor::get_sparse_values_byte_offset() {
  154. return sparse_values_byte_offset;
  155. }
  156. void GLTFAccessor::set_sparse_values_byte_offset(int p_sparse_values_byte_offset) {
  157. sparse_values_byte_offset = p_sparse_values_byte_offset;
  158. }