Path: blob/master/modules/gltf/structures/gltf_accessor.cpp
10278 views
/**************************************************************************/1/* gltf_accessor.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "gltf_accessor.h"31#include "gltf_accessor.compat.inc"3233void GLTFAccessor::_bind_methods() {34BIND_ENUM_CONSTANT(TYPE_SCALAR);35BIND_ENUM_CONSTANT(TYPE_VEC2);36BIND_ENUM_CONSTANT(TYPE_VEC3);37BIND_ENUM_CONSTANT(TYPE_VEC4);38BIND_ENUM_CONSTANT(TYPE_MAT2);39BIND_ENUM_CONSTANT(TYPE_MAT3);40BIND_ENUM_CONSTANT(TYPE_MAT4);4142BIND_ENUM_CONSTANT(COMPONENT_TYPE_NONE);43BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_BYTE);44BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_BYTE);45BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_SHORT);46BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_SHORT);47BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_INT);48BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_INT);49BIND_ENUM_CONSTANT(COMPONENT_TYPE_SINGLE_FLOAT);50BIND_ENUM_CONSTANT(COMPONENT_TYPE_DOUBLE_FLOAT);51BIND_ENUM_CONSTANT(COMPONENT_TYPE_HALF_FLOAT);52BIND_ENUM_CONSTANT(COMPONENT_TYPE_SIGNED_LONG);53BIND_ENUM_CONSTANT(COMPONENT_TYPE_UNSIGNED_LONG);5455ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view);56ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view);57ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset);58ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset);59ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type);60ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type);61ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized);62ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized);63ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count);64ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count);65ClassDB::bind_method(D_METHOD("get_accessor_type"), &GLTFAccessor::get_accessor_type);66ClassDB::bind_method(D_METHOD("set_accessor_type", "accessor_type"), &GLTFAccessor::set_accessor_type);67ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type);68ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type);69ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min);70ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min);71ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max);72ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max);73ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count);74ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count);75ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view);76ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view);77ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset);78ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset);79ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type);80ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type);81ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view);82ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view);83ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset);84ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset);8586ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex87ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int88ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int89ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool90ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int91ADD_PROPERTY(PropertyInfo(Variant::INT, "accessor_type"), "set_accessor_type", "get_accessor_type"); // GLTFAccessor::GLTFAccessorType92ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_type", "get_type"); // Deprecated, int for GLTFAccessor::GLTFAccessorType93ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>94ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>95ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int96ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int97ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int98ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int99ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int100ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int101}102103GLTFBufferViewIndex GLTFAccessor::get_buffer_view() const {104return buffer_view;105}106107void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) {108buffer_view = p_buffer_view;109}110111int64_t GLTFAccessor::get_byte_offset() const {112return byte_offset;113}114115void GLTFAccessor::set_byte_offset(int64_t p_byte_offset) {116byte_offset = p_byte_offset;117}118119GLTFAccessor::GLTFComponentType GLTFAccessor::get_component_type() const {120return component_type;121}122123void GLTFAccessor::set_component_type(GLTFComponentType p_component_type) {124component_type = (GLTFComponentType)p_component_type;125}126127bool GLTFAccessor::get_normalized() const {128return normalized;129}130131void GLTFAccessor::set_normalized(bool p_normalized) {132normalized = p_normalized;133}134135int64_t GLTFAccessor::get_count() const {136return count;137}138139void GLTFAccessor::set_count(int64_t p_count) {140count = p_count;141}142143GLTFAccessor::GLTFAccessorType GLTFAccessor::get_accessor_type() const {144return accessor_type;145}146147void GLTFAccessor::set_accessor_type(GLTFAccessorType p_accessor_type) {148accessor_type = p_accessor_type;149}150151int GLTFAccessor::get_type() const {152return (int)accessor_type;153}154155void GLTFAccessor::set_type(int p_accessor_type) {156accessor_type = (GLTFAccessorType)p_accessor_type; // TODO: Register enum157}158159Vector<double> GLTFAccessor::get_min() const {160return min;161}162163void GLTFAccessor::set_min(Vector<double> p_min) {164min = p_min;165}166167Vector<double> GLTFAccessor::get_max() const {168return max;169}170171void GLTFAccessor::set_max(Vector<double> p_max) {172max = p_max;173}174175int64_t GLTFAccessor::get_sparse_count() const {176return sparse_count;177}178179void GLTFAccessor::set_sparse_count(int64_t p_sparse_count) {180sparse_count = p_sparse_count;181}182183GLTFBufferViewIndex GLTFAccessor::get_sparse_indices_buffer_view() const {184return sparse_indices_buffer_view;185}186187void GLTFAccessor::set_sparse_indices_buffer_view(GLTFBufferViewIndex p_sparse_indices_buffer_view) {188sparse_indices_buffer_view = p_sparse_indices_buffer_view;189}190191int64_t GLTFAccessor::get_sparse_indices_byte_offset() const {192return sparse_indices_byte_offset;193}194195void GLTFAccessor::set_sparse_indices_byte_offset(int64_t p_sparse_indices_byte_offset) {196sparse_indices_byte_offset = p_sparse_indices_byte_offset;197}198199GLTFAccessor::GLTFComponentType GLTFAccessor::get_sparse_indices_component_type() const {200return sparse_indices_component_type;201}202203void GLTFAccessor::set_sparse_indices_component_type(GLTFComponentType p_sparse_indices_component_type) {204sparse_indices_component_type = (GLTFComponentType)p_sparse_indices_component_type;205}206207GLTFBufferViewIndex GLTFAccessor::get_sparse_values_buffer_view() const {208return sparse_values_buffer_view;209}210211void GLTFAccessor::set_sparse_values_buffer_view(GLTFBufferViewIndex p_sparse_values_buffer_view) {212sparse_values_buffer_view = p_sparse_values_buffer_view;213}214215int64_t GLTFAccessor::get_sparse_values_byte_offset() const {216return sparse_values_byte_offset;217}218219void GLTFAccessor::set_sparse_values_byte_offset(int64_t p_sparse_values_byte_offset) {220sparse_values_byte_offset = p_sparse_values_byte_offset;221}222223224