Path: blob/master/modules/gltf/structures/gltf_skeleton.cpp
10278 views
/**************************************************************************/1/* gltf_skeleton.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_skeleton.h"3132#include "../gltf_template_convert.h"3334#include "scene/3d/bone_attachment_3d.h"3536void GLTFSkeleton::_bind_methods() {37ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkeleton::get_joints);38ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkeleton::set_joints);39ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkeleton::get_roots);40ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkeleton::set_roots);41ClassDB::bind_method(D_METHOD("get_godot_skeleton"), &GLTFSkeleton::get_godot_skeleton);42ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFSkeleton::get_unique_names);43ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFSkeleton::set_unique_names);44ClassDB::bind_method(D_METHOD("get_godot_bone_node"), &GLTFSkeleton::get_godot_bone_node);45ClassDB::bind_method(D_METHOD("set_godot_bone_node", "godot_bone_node"), &GLTFSkeleton::set_godot_bone_node);46ClassDB::bind_method(D_METHOD("get_bone_attachment_count"), &GLTFSkeleton::get_bone_attachment_count);47ClassDB::bind_method(D_METHOD("get_bone_attachment", "idx"), &GLTFSkeleton::get_bone_attachment);4849ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector<GLTFNodeIndex>50ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector<GLTFNodeIndex>51ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_names", "get_unique_names"); // Set<String>52ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "godot_bone_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_godot_bone_node", "get_godot_bone_node"); // RBMap<int32_t,53}5455Vector<GLTFNodeIndex> GLTFSkeleton::get_joints() {56return joints;57}5859void GLTFSkeleton::set_joints(Vector<GLTFNodeIndex> p_joints) {60joints = p_joints;61}6263Vector<GLTFNodeIndex> GLTFSkeleton::get_roots() {64return roots;65}6667void GLTFSkeleton::set_roots(Vector<GLTFNodeIndex> p_roots) {68roots = p_roots;69}7071Skeleton3D *GLTFSkeleton::get_godot_skeleton() {72return godot_skeleton;73}7475TypedArray<String> GLTFSkeleton::get_unique_names() {76return GLTFTemplateConvert::to_array(unique_names);77}7879void GLTFSkeleton::set_unique_names(TypedArray<String> p_unique_names) {80GLTFTemplateConvert::set_from_array(unique_names, p_unique_names);81}8283Dictionary GLTFSkeleton::get_godot_bone_node() {84return GLTFTemplateConvert::to_dictionary(godot_bone_node);85}8687void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) {88GLTFTemplateConvert::set_from_dictionary(godot_bone_node, p_indict);89}9091BoneAttachment3D *GLTFSkeleton::get_bone_attachment(int idx) {92ERR_FAIL_INDEX_V(idx, bone_attachments.size(), nullptr);93return bone_attachments[idx];94}9596int32_t GLTFSkeleton::get_bone_attachment_count() {97return bone_attachments.size();98}99100101