1/**************************************************************************/
2/* gltf_accessor.cpp */
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
31#include "gltf_accessor.h"
32
33void GLTFAccessor::_bind_methods() {
34 ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view);
35 ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view);
36 ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset);
37 ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset);
38 ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type);
39 ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type);
40 ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized);
41 ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized);
42 ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count);
43 ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count);
44 ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type);
45 ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type);
46 ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min);
47 ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min);
48 ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max);
49 ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max);
50 ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count);
51 ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count);
52 ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view);
53 ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view);
54 ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset);
55 ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset);
56 ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type);
57 ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type);
58 ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view);
59 ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view);
60 ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset);
61 ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset);
62
63 ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex
64 ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int
65 ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int
66 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool
67 ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int
68 ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFType
69 ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
70 ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
71 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int
72 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int
73 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int
74 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int
75 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int
76 ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int
77}
78
79GLTFBufferViewIndex GLTFAccessor::get_buffer_view() {
80 return buffer_view;
81}
82
83void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) {
84 buffer_view = p_buffer_view;
85}
86
87int GLTFAccessor::get_byte_offset() {
88 return byte_offset;
89}
90
91void GLTFAccessor::set_byte_offset(int p_byte_offset) {
92 byte_offset = p_byte_offset;
93}
94
95int GLTFAccessor::get_component_type() {
96 return component_type;
97}
98
99void GLTFAccessor::set_component_type(int p_component_type) {
100 component_type = p_component_type;
101}
102
103bool GLTFAccessor::get_normalized() {
104 return normalized;
105}
106
107void GLTFAccessor::set_normalized(bool p_normalized) {
108 normalized = p_normalized;
109}
110
111int GLTFAccessor::get_count() {
112 return count;
113}
114
115void GLTFAccessor::set_count(int p_count) {
116 count = p_count;
117}
118
119int GLTFAccessor::get_type() {
120 return (int)type;
121}
122
123void GLTFAccessor::set_type(int p_type) {
124 type = (GLTFType)p_type; // TODO: Register enum
125}
126
127Vector<double> GLTFAccessor::get_min() {
128 return min;
129}
130
131void GLTFAccessor::set_min(Vector<double> p_min) {
132 min = p_min;
133}
134
135Vector<double> GLTFAccessor::get_max() {
136 return max;
137}
138
139void GLTFAccessor::set_max(Vector<double> p_max) {
140 max = p_max;
141}
142
143int GLTFAccessor::get_sparse_count() {
144 return sparse_count;
145}
146
147void GLTFAccessor::set_sparse_count(int p_sparse_count) {
148 sparse_count = p_sparse_count;
149}
150
151int GLTFAccessor::get_sparse_indices_buffer_view() {
152 return sparse_indices_buffer_view;
153}
154
155void GLTFAccessor::set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view) {
156 sparse_indices_buffer_view = p_sparse_indices_buffer_view;
157}
158
159int GLTFAccessor::get_sparse_indices_byte_offset() {
160 return sparse_indices_byte_offset;
161}
162
163void GLTFAccessor::set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset) {
164 sparse_indices_byte_offset = p_sparse_indices_byte_offset;
165}
166
167int GLTFAccessor::get_sparse_indices_component_type() {
168 return sparse_indices_component_type;
169}
170
171void GLTFAccessor::set_sparse_indices_component_type(int p_sparse_indices_component_type) {
172 sparse_indices_component_type = p_sparse_indices_component_type;
173}
174
175int GLTFAccessor::get_sparse_values_buffer_view() {
176 return sparse_values_buffer_view;
177}
178
179void GLTFAccessor::set_sparse_values_buffer_view(int p_sparse_values_buffer_view) {
180 sparse_values_buffer_view = p_sparse_values_buffer_view;
181}
182
183int GLTFAccessor::get_sparse_values_byte_offset() {
184 return sparse_values_byte_offset;
185}
186
187void GLTFAccessor::set_sparse_values_byte_offset(int p_sparse_values_byte_offset) {
188 sparse_values_byte_offset = p_sparse_values_byte_offset;
189}
190