2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
2020-03-26 21:49:16 +00:00
|
|
|
/* skeleton_3d.h */
|
2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
#ifndef SKELETON_3D_H
|
|
|
|
#define SKELETON_3D_H
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
#include "scene/3d/node_3d.h"
|
2021-08-13 16:42:45 +00:00
|
|
|
#include "scene/resources/3d/skin.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-03 16:49:32 +00:00
|
|
|
typedef int BoneId;
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
class Skeleton3D;
|
2024-01-28 00:11:43 +00:00
|
|
|
class SkeletonModifier3D;
|
2019-09-18 22:46:32 +00:00
|
|
|
|
2021-06-04 16:03:15 +00:00
|
|
|
class SkinReference : public RefCounted {
|
|
|
|
GDCLASS(SkinReference, RefCounted)
|
2020-03-26 21:49:16 +00:00
|
|
|
friend class Skeleton3D;
|
2019-09-18 22:46:32 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Skeleton3D *skeleton_node = nullptr;
|
2019-09-18 22:46:32 +00:00
|
|
|
RID skeleton;
|
|
|
|
Ref<Skin> skin;
|
|
|
|
uint32_t bind_count = 0;
|
2020-02-21 10:27:48 +00:00
|
|
|
uint64_t skeleton_version = 0;
|
|
|
|
Vector<uint32_t> skin_bone_indices;
|
2022-04-04 13:06:57 +00:00
|
|
|
uint32_t *skin_bone_indices_ptrs = nullptr;
|
2019-09-18 22:46:32 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2020-12-06 15:09:18 +00:00
|
|
|
// Public for use with callable_mp.
|
|
|
|
void _skin_changed();
|
|
|
|
|
2019-09-18 22:46:32 +00:00
|
|
|
RID get_skeleton() const;
|
|
|
|
Ref<Skin> get_skin() const;
|
|
|
|
~SkinReference();
|
|
|
|
};
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
class Skeleton3D : public Node3D {
|
|
|
|
GDCLASS(Skeleton3D, Node3D);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
2024-07-13 00:20:40 +00:00
|
|
|
bool animate_physical_bones = true;
|
2024-01-28 00:11:43 +00:00
|
|
|
Node *simulator = nullptr;
|
|
|
|
void setup_simulator();
|
|
|
|
#endif // _DISABLE_DEPRECATED
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum ModifierCallbackModeProcess {
|
|
|
|
MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS,
|
|
|
|
MODIFIER_CALLBACK_MODE_PROCESS_IDLE,
|
|
|
|
};
|
|
|
|
|
2019-09-18 22:46:32 +00:00
|
|
|
private:
|
|
|
|
friend class SkinReference;
|
|
|
|
|
2024-06-23 06:15:43 +00:00
|
|
|
enum UpdateFlag {
|
|
|
|
UPDATE_FLAG_NONE = 1,
|
|
|
|
UPDATE_FLAG_MODIFIER = 2,
|
|
|
|
UPDATE_FLAG_POSE = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
void _update_deferred(UpdateFlag p_update_flag = UPDATE_FLAG_POSE);
|
|
|
|
uint8_t update_flags = UPDATE_FLAG_NONE;
|
2024-01-28 00:11:43 +00:00
|
|
|
bool updating = false; // Is updating now?
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
struct Bone {
|
|
|
|
String name;
|
|
|
|
|
2024-04-11 06:16:13 +00:00
|
|
|
int parent = -1;
|
2024-01-28 00:11:43 +00:00
|
|
|
Vector<int> child_bones;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D rest;
|
2022-04-17 12:07:46 +00:00
|
|
|
Transform3D global_rest;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2024-04-11 06:16:13 +00:00
|
|
|
bool enabled = true;
|
2024-01-28 00:11:43 +00:00
|
|
|
bool pose_cache_dirty = true;
|
2024-04-11 06:16:13 +00:00
|
|
|
Transform3D pose_cache;
|
2024-01-28 00:11:43 +00:00
|
|
|
Vector3 pose_position;
|
|
|
|
Quaternion pose_rotation;
|
|
|
|
Vector3 pose_scale = Vector3(1, 1, 1);
|
|
|
|
Transform3D global_pose;
|
|
|
|
|
|
|
|
void update_pose_cache() {
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-11 22:20:58 +00:00
|
|
|
if (pose_cache_dirty) {
|
|
|
|
pose_cache.basis.set_quaternion_scale(pose_rotation, pose_scale);
|
|
|
|
pose_cache.origin = pose_position;
|
|
|
|
pose_cache_dirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D pose_global_no_override;
|
2021-01-30 00:55:54 +00:00
|
|
|
real_t global_pose_override_amount = 0.0;
|
2021-02-07 21:29:31 +00:00
|
|
|
bool global_pose_override_reset = false;
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D global_pose_override;
|
2024-01-28 00:11:43 +00:00
|
|
|
#endif // _DISABLE_DEPRECATED
|
2024-04-11 06:16:13 +00:00
|
|
|
};
|
New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
* This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
* This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in it's own file
* Several changes to Skeletons, listed below:
* Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
* So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
* Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
* Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
* New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
* Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
* BoneAttachment3D node is now completely standalone in its functionality.
* This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
* BoneAttachment3D now can be set either using the index or the bone name.
* BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
* BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
2020-08-03 21:22:34 +00:00
|
|
|
|
2024-04-11 06:16:13 +00:00
|
|
|
struct BonePoseBackup {
|
|
|
|
Transform3D pose_cache;
|
|
|
|
Vector3 pose_position;
|
|
|
|
Quaternion pose_rotation;
|
|
|
|
Vector3 pose_scale = Vector3(1, 1, 1);
|
|
|
|
Transform3D global_pose;
|
|
|
|
|
|
|
|
void save(const Bone &p_bone) {
|
|
|
|
pose_cache = p_bone.pose_cache;
|
|
|
|
pose_position = p_bone.pose_position;
|
|
|
|
pose_rotation = p_bone.pose_rotation;
|
|
|
|
pose_scale = p_bone.pose_scale;
|
|
|
|
global_pose = p_bone.global_pose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void restore(Bone &r_bone) {
|
|
|
|
r_bone.pose_cache = pose_cache;
|
|
|
|
r_bone.pose_position = pose_position;
|
|
|
|
r_bone.pose_rotation = pose_rotation;
|
|
|
|
r_bone.pose_scale = pose_scale;
|
|
|
|
r_bone.global_pose = global_pose;
|
New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
* This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
* This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in it's own file
* Several changes to Skeletons, listed below:
* Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
* So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
* Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
* Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
* New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
* Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
* BoneAttachment3D node is now completely standalone in its functionality.
* This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
* BoneAttachment3D now can be set either using the index or the bone name.
* BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
* BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
2020-08-03 21:22:34 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2022-05-19 15:00:06 +00:00
|
|
|
HashSet<SkinReference *> skin_bindings;
|
2020-05-26 18:17:11 +00:00
|
|
|
void _skin_changed();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Vector<Bone> bones;
|
2022-05-02 14:28:25 +00:00
|
|
|
bool process_order_dirty = false;
|
New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
* This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
* This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in it's own file
* Several changes to Skeletons, listed below:
* Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
* So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
* Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
* Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
* New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
* Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
* BoneAttachment3D node is now completely standalone in its functionality.
* This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
* BoneAttachment3D now can be set either using the index or the bone name.
* BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
* BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
2020-08-03 21:22:34 +00:00
|
|
|
|
|
|
|
Vector<int> parentless_bones;
|
2023-05-21 12:42:32 +00:00
|
|
|
HashMap<String, int> name_to_bone_index;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2024-06-09 03:47:48 +00:00
|
|
|
mutable StringName concatenated_bone_names = StringName();
|
|
|
|
void _update_bone_names() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _make_dirty();
|
2021-02-07 21:29:31 +00:00
|
|
|
bool dirty = false;
|
2022-04-17 12:07:46 +00:00
|
|
|
bool rest_dirty = false;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-02-04 08:20:26 +00:00
|
|
|
bool show_rest_only = false;
|
2022-07-26 09:48:08 +00:00
|
|
|
float motion_scale = 1.0;
|
2021-02-04 08:20:26 +00:00
|
|
|
|
2021-02-07 21:29:31 +00:00
|
|
|
uint64_t version = 1;
|
2020-02-21 10:27:48 +00:00
|
|
|
|
2018-08-07 01:35:09 +00:00
|
|
|
void _update_process_order();
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
// To process modifiers.
|
|
|
|
ModifierCallbackModeProcess modifier_callback_mode_process = MODIFIER_CALLBACK_MODE_PROCESS_IDLE;
|
|
|
|
LocalVector<ObjectID> modifiers;
|
|
|
|
bool modifiers_dirty = false;
|
|
|
|
void _find_modifiers();
|
|
|
|
void _process_modifiers();
|
|
|
|
void _process_changed();
|
|
|
|
void _make_modifiers_dirty();
|
2024-04-11 06:16:13 +00:00
|
|
|
LocalVector<BonePoseBackup> bones_backup;
|
2024-01-28 00:11:43 +00:00
|
|
|
|
2024-02-24 23:44:26 +00:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
void _add_bone_bind_compat_88791(const String &p_name);
|
|
|
|
|
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif // DISABLE_DEPRECATED
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
2017-08-11 19:10:05 +00:00
|
|
|
bool _get(const StringName &p_path, Variant &r_ret) const;
|
|
|
|
bool _set(const StringName &p_path, const Variant &p_value);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
2022-08-12 20:57:11 +00:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
virtual void add_child_notify(Node *p_child) override;
|
|
|
|
virtual void move_child_notify(Node *p_child) override;
|
|
|
|
virtual void remove_child_notify(Node *p_child) override;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
NOTIFICATION_UPDATE_SKELETON = 50
|
|
|
|
};
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
// Skeleton creation API
|
2023-01-10 00:32:36 +00:00
|
|
|
uint64_t get_version() const;
|
2024-02-24 23:44:26 +00:00
|
|
|
int add_bone(const String &p_name);
|
2018-05-10 11:23:05 +00:00
|
|
|
int find_bone(const String &p_name) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_bone_name(int p_bone) const;
|
2020-10-15 14:53:18 +00:00
|
|
|
void set_bone_name(int p_bone, const String &p_name);
|
2024-06-09 03:47:48 +00:00
|
|
|
StringName get_concatenated_bone_names() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2018-05-10 11:23:05 +00:00
|
|
|
bool is_bone_parent_of(int p_bone_id, int p_parent_bone_id) const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_bone_parent(int p_bone, int p_parent);
|
|
|
|
int get_bone_parent(int p_bone) const;
|
|
|
|
|
2017-08-11 19:10:05 +00:00
|
|
|
void unparent_bone_and_rest(int p_bone);
|
2015-09-24 21:06:15 +00:00
|
|
|
|
2022-08-30 13:48:06 +00:00
|
|
|
Vector<int> get_bone_children(int p_bone) const;
|
|
|
|
Vector<int> get_parentless_bones() const;
|
New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
* This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
* This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in it's own file
* Several changes to Skeletons, listed below:
* Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
* So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
* Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
* Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
* New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
* Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
* BoneAttachment3D node is now completely standalone in its functionality.
* This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
* BoneAttachment3D now can be set either using the index or the bone name.
* BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
* BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
2020-08-03 21:22:34 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
int get_bone_count() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
void set_bone_rest(int p_bone, const Transform3D &p_rest);
|
|
|
|
Transform3D get_bone_rest(int p_bone) const;
|
2022-04-17 12:07:46 +00:00
|
|
|
Transform3D get_bone_global_rest(int p_bone) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void set_bone_enabled(int p_bone, bool p_enabled);
|
|
|
|
bool is_bone_enabled(int p_bone) const;
|
2021-02-04 08:20:26 +00:00
|
|
|
|
|
|
|
void set_show_rest_only(bool p_enabled);
|
|
|
|
bool is_show_rest_only() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
void clear_bones();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2022-07-26 09:48:08 +00:00
|
|
|
void set_motion_scale(float p_motion_scale);
|
|
|
|
float get_motion_scale() const;
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
// Posing API
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D get_bone_pose(int p_bone) const;
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-11 22:20:58 +00:00
|
|
|
Vector3 get_bone_pose_position(int p_bone) const;
|
|
|
|
Quaternion get_bone_pose_rotation(int p_bone) const;
|
|
|
|
Vector3 get_bone_pose_scale(int p_bone) const;
|
2024-01-28 00:11:43 +00:00
|
|
|
void set_bone_pose(int p_bone, const Transform3D &p_pose);
|
|
|
|
void set_bone_pose_position(int p_bone, const Vector3 &p_position);
|
|
|
|
void set_bone_pose_rotation(int p_bone, const Quaternion &p_rotation);
|
|
|
|
void set_bone_pose_scale(int p_bone, const Vector3 &p_scale);
|
|
|
|
|
|
|
|
Transform3D get_bone_global_pose(int p_bone) const;
|
|
|
|
void set_bone_global_pose(int p_bone, const Transform3D &p_pose);
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-11 22:20:58 +00:00
|
|
|
|
2022-07-26 09:46:28 +00:00
|
|
|
void reset_bone_pose(int p_bone);
|
|
|
|
void reset_bone_poses();
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
void localize_rests(); // Used for loaders and tools.
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-10-13 12:37:40 +00:00
|
|
|
Ref<Skin> create_skin_from_rest_transforms();
|
|
|
|
|
2019-09-18 22:46:32 +00:00
|
|
|
Ref<SkinReference> register_skin(const Ref<Skin> &p_skin);
|
2019-03-03 15:23:03 +00:00
|
|
|
|
2021-02-04 08:20:26 +00:00
|
|
|
void force_update_all_dirty_bones();
|
New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
* This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
* This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in it's own file
* Several changes to Skeletons, listed below:
* Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
* So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
* Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
* Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
* New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
* Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
* BoneAttachment3D node is now completely standalone in its functionality.
* This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
* BoneAttachment3D now can be set either using the index or the bone name.
* BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
* BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
2020-08-03 21:22:34 +00:00
|
|
|
void force_update_all_bone_transforms();
|
|
|
|
void force_update_bone_children_transforms(int bone_idx);
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
void set_modifier_callback_mode_process(ModifierCallbackModeProcess p_mode);
|
|
|
|
ModifierCallbackModeProcess get_modifier_callback_mode_process() const;
|
|
|
|
|
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
Transform3D get_bone_global_pose_no_override(int p_bone) const;
|
|
|
|
void clear_bones_global_pose_override();
|
|
|
|
Transform3D get_bone_global_pose_override(int p_bone) const;
|
|
|
|
void set_bone_global_pose_override(int p_bone, const Transform3D &p_pose, real_t p_amount, bool p_persistent = false);
|
2017-10-03 16:49:32 +00:00
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
Node *get_simulator();
|
2021-10-08 21:26:13 +00:00
|
|
|
void set_animate_physical_bones(bool p_enabled);
|
2020-02-08 08:52:58 +00:00
|
|
|
bool get_animate_physical_bones() const;
|
2018-05-10 11:23:05 +00:00
|
|
|
void physical_bones_stop_simulation();
|
2020-04-21 15:16:45 +00:00
|
|
|
void physical_bones_start_simulation_on(const TypedArray<StringName> &p_bones);
|
2017-10-03 16:49:32 +00:00
|
|
|
void physical_bones_add_collision_exception(RID p_exception);
|
|
|
|
void physical_bones_remove_collision_exception(RID p_exception);
|
2024-01-28 00:11:43 +00:00
|
|
|
#endif // _DISABLE_DEPRECATED
|
2017-10-03 16:49:32 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-26 21:49:16 +00:00
|
|
|
Skeleton3D();
|
|
|
|
~Skeleton3D();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2024-01-28 00:11:43 +00:00
|
|
|
VARIANT_ENUM_CAST(Skeleton3D::ModifierCallbackModeProcess);
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // SKELETON_3D_H
|