Path: blob/master/modules/gltf/structures/gltf_buffer_view.h
21101 views
/**************************************************************************/1/* gltf_buffer_view.h */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#pragma once3132#include "../gltf_defines.h"3334#include "core/io/resource.h"3536class GLTFBufferView : public Resource {37GDCLASS(GLTFBufferView, Resource);38friend class GLTFDocument;3940public:41// When a buffer view is used by vertex indices or attribute accessors it SHOULD specify42// "target" with a value of ELEMENT_ARRAY_BUFFER (34963) or ARRAY_BUFFER (34962) respectively.43// This is only used for mesh data. For non-mesh buffer views, the target should be left blank.44// https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#buffers-and-buffer-views-overview45enum ArrayBufferTarget {46TARGET_NONE = 0,47TARGET_ARRAY_BUFFER = 34962,48TARGET_ELEMENT_ARRAY_BUFFER = 34963,49};5051private:52GLTFBufferIndex buffer = -1;53int64_t byte_offset = 0;54int64_t byte_length = 0;55int64_t byte_stride = -1;56bool indices = false; // True for TARGET_ELEMENT_ARRAY_BUFFER.57bool vertex_attributes = false; // True for TARGET_ARRAY_BUFFER.5859protected:60static void _bind_methods();6162#ifndef DISABLE_DEPRECATED63// Non-const versions for compatibility.64GLTFBufferIndex _get_buffer_bind_compat_86907();65int _get_byte_offset_bind_compat_86907();66int _get_byte_length_bind_compat_86907();67int _get_byte_stride_bind_compat_86907();68bool _get_indices_bind_compat_86907();69static void _bind_compatibility_methods();70#endif // DISABLE_DEPRECATED7172public:73GLTFBufferIndex get_buffer() const;74void set_buffer(GLTFBufferIndex p_buffer);7576int64_t get_byte_offset() const;77void set_byte_offset(int64_t p_byte_offset);7879int64_t get_byte_length() const;80void set_byte_length(int64_t p_byte_length);8182int64_t get_byte_stride() const;83void set_byte_stride(int64_t p_byte_stride);8485bool get_indices() const;86void set_indices(bool p_indices);8788bool get_vertex_attributes() const;89void set_vertex_attributes(bool p_attributes);9091Vector<uint8_t> load_buffer_view_data(const Ref<GLTFState> p_gltf_state) const;92static GLTFBufferViewIndex write_new_buffer_view_into_state(const Ref<GLTFState> &p_gltf_state, const PackedByteArray &p_input_data, const int64_t p_alignment = 1, const ArrayBufferTarget p_target = TARGET_NONE, const int64_t p_byte_stride = -1, const GLTFBufferIndex p_buffer_index = 0, const bool p_deduplicate = true);9394static Ref<GLTFBufferView> from_dictionary(const Dictionary &p_dict);95Dictionary to_dictionary() const;96};979899