Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/gltf/structures/gltf_skeleton.cpp
10278 views
1
/**************************************************************************/
2
/* gltf_skeleton.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_skeleton.h"
32
33
#include "../gltf_template_convert.h"
34
35
#include "scene/3d/bone_attachment_3d.h"
36
37
void GLTFSkeleton::_bind_methods() {
38
ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkeleton::get_joints);
39
ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkeleton::set_joints);
40
ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkeleton::get_roots);
41
ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkeleton::set_roots);
42
ClassDB::bind_method(D_METHOD("get_godot_skeleton"), &GLTFSkeleton::get_godot_skeleton);
43
ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFSkeleton::get_unique_names);
44
ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFSkeleton::set_unique_names);
45
ClassDB::bind_method(D_METHOD("get_godot_bone_node"), &GLTFSkeleton::get_godot_bone_node);
46
ClassDB::bind_method(D_METHOD("set_godot_bone_node", "godot_bone_node"), &GLTFSkeleton::set_godot_bone_node);
47
ClassDB::bind_method(D_METHOD("get_bone_attachment_count"), &GLTFSkeleton::get_bone_attachment_count);
48
ClassDB::bind_method(D_METHOD("get_bone_attachment", "idx"), &GLTFSkeleton::get_bone_attachment);
49
50
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector<GLTFNodeIndex>
51
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector<GLTFNodeIndex>
52
ADD_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>
53
ADD_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,
54
}
55
56
Vector<GLTFNodeIndex> GLTFSkeleton::get_joints() {
57
return joints;
58
}
59
60
void GLTFSkeleton::set_joints(Vector<GLTFNodeIndex> p_joints) {
61
joints = p_joints;
62
}
63
64
Vector<GLTFNodeIndex> GLTFSkeleton::get_roots() {
65
return roots;
66
}
67
68
void GLTFSkeleton::set_roots(Vector<GLTFNodeIndex> p_roots) {
69
roots = p_roots;
70
}
71
72
Skeleton3D *GLTFSkeleton::get_godot_skeleton() {
73
return godot_skeleton;
74
}
75
76
TypedArray<String> GLTFSkeleton::get_unique_names() {
77
return GLTFTemplateConvert::to_array(unique_names);
78
}
79
80
void GLTFSkeleton::set_unique_names(TypedArray<String> p_unique_names) {
81
GLTFTemplateConvert::set_from_array(unique_names, p_unique_names);
82
}
83
84
Dictionary GLTFSkeleton::get_godot_bone_node() {
85
return GLTFTemplateConvert::to_dictionary(godot_bone_node);
86
}
87
88
void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) {
89
GLTFTemplateConvert::set_from_dictionary(godot_bone_node, p_indict);
90
}
91
92
BoneAttachment3D *GLTFSkeleton::get_bone_attachment(int idx) {
93
ERR_FAIL_INDEX_V(idx, bone_attachments.size(), nullptr);
94
return bone_attachments[idx];
95
}
96
97
int32_t GLTFSkeleton::get_bone_attachment_count() {
98
return bone_attachments.size();
99
}
100
101