Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/gltf/structures/gltf_accessor.cpp
10278 views
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
#include "gltf_accessor.compat.inc"
33
34
void GLTFAccessor::_bind_methods() {
35
BIND_ENUM_CONSTANT(TYPE_SCALAR);
36
BIND_ENUM_CONSTANT(TYPE_VEC2);
37
BIND_ENUM_CONSTANT(TYPE_VEC3);
38
BIND_ENUM_CONSTANT(TYPE_VEC4);
39
BIND_ENUM_CONSTANT(TYPE_MAT2);
40
BIND_ENUM_CONSTANT(TYPE_MAT3);
41
BIND_ENUM_CONSTANT(TYPE_MAT4);
42
43
BIND_ENUM_CONSTANT(COMPONENT_TYPE_NONE);
44
BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_BYTE);
45
BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_BYTE);
46
BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_SHORT);
47
BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_SHORT);
48
BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_INT);
49
BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_INT);
50
BIND_ENUM_CONSTANT(COMPONENT_TYPE_SINGLE_FLOAT);
51
BIND_ENUM_CONSTANT(COMPONENT_TYPE_DOUBLE_FLOAT);
52
BIND_ENUM_CONSTANT(COMPONENT_TYPE_HALF_FLOAT);
53
BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_LONG);
54
BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_LONG);
55
56
ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view);
57
ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view);
58
ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset);
59
ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset);
60
ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type);
61
ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type);
62
ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized);
63
ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized);
64
ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count);
65
ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count);
66
ClassDB::bind_method(D_METHOD("get_accessor_type"), &GLTFAccessor::get_accessor_type);
67
ClassDB::bind_method(D_METHOD("set_accessor_type", "accessor_type"), &GLTFAccessor::set_accessor_type);
68
ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type);
69
ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type);
70
ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min);
71
ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min);
72
ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max);
73
ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max);
74
ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count);
75
ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count);
76
ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view);
77
ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view);
78
ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset);
79
ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset);
80
ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type);
81
ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type);
82
ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view);
83
ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view);
84
ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset);
85
ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset);
86
87
ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex
88
ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int
89
ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int
90
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool
91
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int
92
ADD_PROPERTY(PropertyInfo(Variant::INT, "accessor_type"), "set_accessor_type", "get_accessor_type"); // GLTFAccessor::GLTFAccessorType
93
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_type", "get_type"); // Deprecated, int for GLTFAccessor::GLTFAccessorType
94
ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
95
ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
96
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int
97
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int
98
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int
99
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int
100
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int
101
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int
102
}
103
104
GLTFBufferViewIndex GLTFAccessor::get_buffer_view() const {
105
return buffer_view;
106
}
107
108
void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) {
109
buffer_view = p_buffer_view;
110
}
111
112
int64_t GLTFAccessor::get_byte_offset() const {
113
return byte_offset;
114
}
115
116
void GLTFAccessor::set_byte_offset(int64_t p_byte_offset) {
117
byte_offset = p_byte_offset;
118
}
119
120
GLTFAccessor::GLTFComponentType GLTFAccessor::get_component_type() const {
121
return component_type;
122
}
123
124
void GLTFAccessor::set_component_type(GLTFComponentType p_component_type) {
125
component_type = (GLTFComponentType)p_component_type;
126
}
127
128
bool GLTFAccessor::get_normalized() const {
129
return normalized;
130
}
131
132
void GLTFAccessor::set_normalized(bool p_normalized) {
133
normalized = p_normalized;
134
}
135
136
int64_t GLTFAccessor::get_count() const {
137
return count;
138
}
139
140
void GLTFAccessor::set_count(int64_t p_count) {
141
count = p_count;
142
}
143
144
GLTFAccessor::GLTFAccessorType GLTFAccessor::get_accessor_type() const {
145
return accessor_type;
146
}
147
148
void GLTFAccessor::set_accessor_type(GLTFAccessorType p_accessor_type) {
149
accessor_type = p_accessor_type;
150
}
151
152
int GLTFAccessor::get_type() const {
153
return (int)accessor_type;
154
}
155
156
void GLTFAccessor::set_type(int p_accessor_type) {
157
accessor_type = (GLTFAccessorType)p_accessor_type; // TODO: Register enum
158
}
159
160
Vector<double> GLTFAccessor::get_min() const {
161
return min;
162
}
163
164
void GLTFAccessor::set_min(Vector<double> p_min) {
165
min = p_min;
166
}
167
168
Vector<double> GLTFAccessor::get_max() const {
169
return max;
170
}
171
172
void GLTFAccessor::set_max(Vector<double> p_max) {
173
max = p_max;
174
}
175
176
int64_t GLTFAccessor::get_sparse_count() const {
177
return sparse_count;
178
}
179
180
void GLTFAccessor::set_sparse_count(int64_t p_sparse_count) {
181
sparse_count = p_sparse_count;
182
}
183
184
GLTFBufferViewIndex GLTFAccessor::get_sparse_indices_buffer_view() const {
185
return sparse_indices_buffer_view;
186
}
187
188
void GLTFAccessor::set_sparse_indices_buffer_view(GLTFBufferViewIndex p_sparse_indices_buffer_view) {
189
sparse_indices_buffer_view = p_sparse_indices_buffer_view;
190
}
191
192
int64_t GLTFAccessor::get_sparse_indices_byte_offset() const {
193
return sparse_indices_byte_offset;
194
}
195
196
void GLTFAccessor::set_sparse_indices_byte_offset(int64_t p_sparse_indices_byte_offset) {
197
sparse_indices_byte_offset = p_sparse_indices_byte_offset;
198
}
199
200
GLTFAccessor::GLTFComponentType GLTFAccessor::get_sparse_indices_component_type() const {
201
return sparse_indices_component_type;
202
}
203
204
void GLTFAccessor::set_sparse_indices_component_type(GLTFComponentType p_sparse_indices_component_type) {
205
sparse_indices_component_type = (GLTFComponentType)p_sparse_indices_component_type;
206
}
207
208
GLTFBufferViewIndex GLTFAccessor::get_sparse_values_buffer_view() const {
209
return sparse_values_buffer_view;
210
}
211
212
void GLTFAccessor::set_sparse_values_buffer_view(GLTFBufferViewIndex p_sparse_values_buffer_view) {
213
sparse_values_buffer_view = p_sparse_values_buffer_view;
214
}
215
216
int64_t GLTFAccessor::get_sparse_values_byte_offset() const {
217
return sparse_values_byte_offset;
218
}
219
220
void GLTFAccessor::set_sparse_values_byte_offset(int64_t p_sparse_values_byte_offset) {
221
sparse_values_byte_offset = p_sparse_values_byte_offset;
222
}
223
224