Removed the bone_editor addon, as now the engine has a skeleton editor built in.

This commit is contained in:
Relintai 2021-09-26 17:23:00 +02:00
parent cdee4cb3fa
commit eee70dac69
13 changed files with 0 additions and 580 deletions

View File

@ -9,8 +9,6 @@
!gdpose/**
!mesh_data_resource_editor
!mesh_data_resource_editor/**
!bone_editor
!bone_editor/**
!multirun
!multirun/**
!addon_versions

View File

@ -1,4 +1,3 @@
Godotxel 6e3b61c2887e51c767d0c2417e0b293a35f904ac from https://github.com/aaronfranke/GraphicsEditor
gdpose ba80c648b04d5dc416f69d1d3bac280a2e02b3a0 from https://github.com/BastiaanOlij/gdpose
godot-plugin-refresher e2b12f448b9fc112fd0f4acdc6de8df6180b464e from https://github.com/godot-extended-libraries/godot-plugin-refresher

View File

@ -1,64 +0,0 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "tool
extends CenterContainer
var bone_editor
func _on_Button_pressed( ):
if self.bone_editor == null:
return
self.bone_editor.save_poses( )
func _on_Button2_pressed():
if self.bone_editor == null:
return
self.bone_editor.init_poses( )
func _on_Button3_pressed():
if self.bone_editor == null:
return
self.bone_editor.load_poses( )
"
[node name="CenterContainer" type="CenterContainer"]
margin_right = 40.0
margin_bottom = 40.0
script = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_left = 44.0
margin_top = 10.0
margin_right = 324.0
margin_bottom = 30.0
[node name="Button" type="Button" parent="HBoxContainer"]
margin_right = 84.0
margin_bottom = 20.0
text = "Insert Keys"
flat = true
[node name="Button3" type="Button" parent="HBoxContainer"]
margin_left = 88.0
margin_right = 198.0
margin_bottom = 20.0
text = "Load from Keys"
flat = true
[node name="Button2" type="Button" parent="HBoxContainer"]
margin_left = 202.0
margin_right = 280.0
margin_bottom = 20.0
text = "Init Bones"
flat = true
[connection signal="pressed" from="HBoxContainer/Button" to="." method="_on_Button_pressed"]
[connection signal="pressed" from="HBoxContainer/Button3" to="." method="_on_Button3_pressed"]
[connection signal="pressed" from="HBoxContainer/Button2" to="." method="_on_Button2_pressed"]

View File

@ -1,258 +0,0 @@
tool
extends Spatial
export(NodePath) var control_skeleton:NodePath setget set_control_skeleton
export(NodePath) var edit_animation_player:NodePath setget set_edit_animation_player
export(bool) var enabled:bool = true
export(bool) var edit_bone_hierarchy : bool = false
export(String) var add_bone_name : String = ""
export(bool) var add_bone : bool = false setget set_add_bone, get_add_bone
export(bool) var set_pose_as_rest : bool = false setget set_set_pose_as_rest, get_add_bone
var skeleton:Skeleton = null
var animation_player:AnimationPlayer = null
var first_call:bool = true
var bone_handle_nodes:Array = []
func _ready( ):
pass
func set_control_skeleton( path:NodePath ):
control_skeleton = path
if self.first_call:
return
var node:Node = self.get_node( control_skeleton )
if node is Skeleton:
self.skeleton = node
else:
self.skeleton = null
push_error( str(path) + " does not Skeleton!" )
self._generate_bone_handles( )
func set_edit_animation_player( path:NodePath ):
edit_animation_player = path
if self.first_call:
return
var node:Node = self.get_node( edit_animation_player )
if node is AnimationPlayer:
self.animation_player = node
else:
self.animation_player = null
push_error( str(path) + " does not Animation Player!" )
func _generate_bone_handles( ):
for child in self.get_children( ):
self.remove_child( child )
if self.skeleton == null:
return
self.bone_handle_nodes = []
var bone_handle: = preload( "BoneHandle.tscn" )
for bone_id in range( self.skeleton.get_bone_count( ) ):
var bone_name:String = self.skeleton.get_bone_name( bone_id )
var bone_handle_node:BoneHandle = bone_handle.instance( )
bone_handle_node.bone_editor = self
bone_handle_node.name = bone_name
bone_handle_node.skeleton = self.skeleton
bone_handle_node.bone_id = bone_id
bone_handle_node.bone_name = bone_name
var parent_bone_id:int = self.skeleton.get_bone_parent( bone_id )
if parent_bone_id == -1:
self.add_child( bone_handle_node )
else:
self.bone_handle_nodes[parent_bone_id].add_child( bone_handle_node )
if Engine.editor_hint == true:
var tree:SceneTree = self.get_tree( )
if tree != null:
if tree.edited_scene_root != null:
bone_handle_node.set_owner( tree.edited_scene_root )
self.bone_handle_nodes.append( bone_handle_node )
func _process( delta:float ):
if self.first_call:
self.first_call = false
self.set_control_skeleton( self.control_skeleton )
self.set_edit_animation_player( self.edit_animation_player )
for handle_bone in self.bone_handle_nodes:
handle_bone.enabled = self.enabled
func init_poses( ):
for handle_bone in self.bone_handle_nodes:
handle_bone.init_pose( )
func load_poses( ):
if self.animation_player == null:
push_error( "Animation player is null." )
return
var assigned_animation:String = self.animation_player.assigned_animation
var animation:Animation = self.animation_player.get_animation( assigned_animation )
var time:float = self.animation_player.current_animation_position
for track_idx in animation.get_track_count( ):
var target_bone:BoneHandle = null
for handle_bone in self.bone_handle_nodes:
var path:NodePath = NodePath( "%s:%s" % [ self.get_node( self.animation_player.root_node ).get_path_to( self.skeleton ), handle_bone.name ] )
if animation.track_get_path( track_idx ) == path:
target_bone = handle_bone
break
if target_bone == null:
continue
var bone:Array = animation.transform_track_interpolate( track_idx, time )
target_bone.set_pose( Basis( bone[1] ), bone[0] )
func save_poses( ):
if self.animation_player == null:
push_error( "Animation player is null." )
return
var assigned_animation:String = self.animation_player.assigned_animation
var animation:Animation = self.animation_player.get_animation( assigned_animation )
if animation == null:
push_error( "animation does not selected on Animation player." )
return
# 足りないボーンがあれば追加する
self._add_bone_tracks( animation )
# ポーズを保存
self._save_poses_to_animation( animation )
func _add_bone_tracks( animation:Animation ):
var founded_bone_tracks:Array = []
for track_idx in animation.get_track_count( ):
founded_bone_tracks.append( animation.track_get_path( track_idx ) )
for handle_bone in self.bone_handle_nodes:
var path:NodePath = NodePath( "%s:%s" % [ self.get_node( self.animation_player.root_node ).get_path_to( self.skeleton ), handle_bone.name ] )
if founded_bone_tracks.find( path ) == -1:
var new_track_idx:int = animation.add_track( Animation.TYPE_TRANSFORM )
animation.track_set_path( new_track_idx, path )
print( "added new track for ", path )
func _save_poses_to_animation( animation:Animation ):
var time:float = self.animation_player.current_animation_position
for track_idx in animation.get_track_count( ):
var target_bone:BoneHandle = null
for handle_bone in self.bone_handle_nodes:
var path:NodePath = NodePath( "%s:%s" % [ self.get_node( self.animation_player.root_node ).get_path_to( self.skeleton ), handle_bone.name ] )
if animation.track_get_path( track_idx ) == path:
target_bone = handle_bone
break
if target_bone == null:
continue
# すでに同じ位置にモノが存在するなら削除する
for key_idx in animation.track_get_key_count( track_idx ):
if animation.track_get_key_time( track_idx, key_idx ) == time:
animation.track_remove_key( track_idx, key_idx )
break
animation.transform_track_insert_key(
track_idx,
time,
target_bone.pose.origin,
target_bone.pose.basis.get_rotation_quat( ),
target_bone.pose.basis.get_scale( )
)
print( "* added new key for ", target_bone.name )
func set_bone_parent(bone_id, parent_bone_id):
ensure_nodes()
if !skeleton:
return
skeleton.set_bone_parent(bone_id, parent_bone_id)
func ensure_nodes():
if !skeleton:
skeleton = get_node(control_skeleton)
if !animation_player:
animation_player = get_node(edit_animation_player)
func set_add_bone(val):
if val:
if add_bone_name == "":
return
ensure_nodes()
if skeleton == null:
return
skeleton.add_bone(add_bone_name)
var bone_id : int = skeleton.find_bone(add_bone_name)
var bone_handle: = preload( "BoneHandle.tscn" )
var bone_name:String = add_bone_name
var bone_handle_node:BoneHandle = bone_handle.instance( )
bone_handle_node.bone_editor = self
bone_handle_node.name = bone_name
bone_handle_node.skeleton = self.skeleton
bone_handle_node.bone_id = bone_id
bone_handle_node.bone_name = bone_name
var parent_bone_id:int = self.skeleton.get_bone_parent( bone_id )
if parent_bone_id == -1:
self.add_child( bone_handle_node )
if Engine.editor_hint == true:
var tree:SceneTree = self.get_tree( )
if tree != null:
if tree.edited_scene_root != null:
bone_handle_node.set_owner( tree.edited_scene_root )
self.bone_handle_nodes.append( bone_handle_node )
add_bone_name = ""
func get_add_bone():
return false
func is_done_editor():
return true
func evaluate_rest_pose(n : Spatial):
if !n:
return
n.set_as_rest_pose()
for ch in n.get_children():
evaluate_rest_pose(ch as Spatial)
func set_set_pose_as_rest(val):
if val:
for ch in get_children():
evaluate_rest_pose(ch as Spatial)
#for n in bone_handle_nodes:
# n.set_as_rest_pose()
for n in bone_handle_nodes:
n._ready()
#load_poses()

View File

@ -1,93 +0,0 @@
tool
extends Spatial
class_name BoneHandle
var bone_editor
var skeleton:Skeleton = null
var bone_id:int = -1
var bone_name:String = ""
var original_rest:Transform
var original_parent_rest:Transform
var original_global_rest_origin:Vector3
var enabled:bool = true
var pose:Transform
func _ready( ):
if self.skeleton == null or self.bone_id == -1:
return
self.original_rest = self.skeleton.get_bone_rest( self.bone_id )
var parent_bone_id:int = self.skeleton.get_bone_parent( self.bone_id )
if parent_bone_id != -1:
self.original_parent_rest = self.skeleton.get_bone_global_pose( parent_bone_id )
self.transform.basis = Basis( )
self.transform.origin = self.original_parent_rest.basis.xform( self.original_rest.origin )
self.original_global_rest_origin = self.transform.origin
func init_pose( ):
self.transform.basis = Basis( )
self.transform.origin = self.original_parent_rest.basis.xform( self.original_rest.origin )
func set_pose( basis:Basis, origin:Vector3 ):
self.transform.basis = basis
self.transform.origin = self.original_global_rest_origin + self.original_parent_rest.basis.xform( origin )
# printt( self.bone_name, basis, origin )
func set_as_rest_pose():
self.skeleton.set_bone_rest(self.bone_id, transform)
self.skeleton.set_bone_pose( self.bone_id, Transform( ))
transform = Transform()
self.original_rest = self.skeleton.get_bone_rest( self.bone_id )
var parent_bone_id:int = self.skeleton.get_bone_parent( self.bone_id )
if parent_bone_id != -1:
self.original_parent_rest = self.skeleton.get_bone_global_pose( parent_bone_id )
self.transform.basis = Basis( )
self.transform.origin = self.original_parent_rest.basis.xform( self.original_rest.origin )
self.original_global_rest_origin = self.transform.origin
func _process( delta:float ):
if self.skeleton == null or self.bone_id == -1:
return
if self.enabled:
var t:Transform = Transform( )
t.basis = self.transform.basis
t.origin = self.original_parent_rest.basis.xform_inv( self.transform.origin - self.original_global_rest_origin )
self.skeleton.set_bone_pose( self.bone_id, t )
self.pose = t
func ensure_bone_editor():
if !bone_editor:
var n : Node = get_parent()
while n:
if n.has_method("is_done_editor"):
bone_editor = n
return
n = n.get_parent()
func _notification(what):
if what == NOTIFICATION_PARENTED:
ensure_bone_editor()
if !bone_editor:
return
if !bone_editor.edit_bone_hierarchy:
return
var n : Node = get_parent()
if n == bone_editor:
bone_editor.set_bone_parent(bone_id, -1)
else:
bone_editor.set_bone_parent(bone_id, n.bone_id)

View File

@ -1,6 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/bone_editor/BoneHandle.gd" type="Script" id=1]
[node name="BoneHandle" type="Spatial"]
script = ExtResource( 1 )

View File

@ -1,19 +0,0 @@
Copyright (c) 2020 Yui Kinomoto
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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-98dd89b353351f2740f1a21c6c925c32.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/bone_editor/icon.png"
dest_files=[ "res://.import/icon.png-98dd89b353351f2740f1a21c6c925c32.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=1
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -1,7 +0,0 @@
[plugin]
name="bone-editor"
description="A bone editor on the editor for Godot Engine 3.2 later"
author="arlez80"
version="0.0.1"
script="plugin.gd"

View File

@ -1,41 +0,0 @@
tool
extends EditorPlugin
const BoneDock = preload( "BoneDock.tscn" )
var bone_dock_instance
var bone_editor
func _enter_tree( ):
self.bone_dock_instance = BoneDock.instance( )
self.add_control_to_container( CONTAINER_SPATIAL_EDITOR_MENU, self.bone_dock_instance )
self.add_custom_type( "BoneEditor", "Spatial", preload("BoneEditor.gd"), preload("icon.png") )
func _exit_tree( ):
self.remove_custom_type( "BoneEditor" )
self.remove_control_from_container( CONTAINER_SPATIAL_EDITOR_MENU, self.bone_dock_instance )
self.bone_dock_instance.queue_free( )
func handles( obj ):
if obj is preload("BoneEditor.gd"):
self.bone_editor = obj
if self.bone_dock_instance != null:
self.bone_dock_instance.bone_editor = obj
self.bone_dock_instance.visible = true
return true
elif obj is preload("BoneHandle.gd"):
self.bone_editor = obj.bone_editor
if self.bone_dock_instance != null:
self.bone_dock_instance.bone_editor = obj.bone_editor
self.bone_dock_instance.visible = true
return true
self.bone_editor = null
if self.bone_dock_instance != null:
self.bone_dock_instance.bone_editor = null
self.bone_dock_instance.visible = false
return false
func get_plugin_name( ):
return "Bone Editor"

View File

@ -14,11 +14,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scripts/auras/aura_script.gd"
}, {
"base": "Spatial",
"class": "BoneHandle",
"language": "GDScript",
"path": "res://addons/bone_editor/BoneHandle.gd"
}, {
"base": "Reference",
"class": "BrushPrefabs",
"language": "GDScript",
@ -206,7 +201,6 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"AuraGD": "",
"BoneHandle": "",
"BrushPrefabs": "",
"CharacterSkeketonAttachPoint": "",
"DisplayPlayerGD": "",

View File

@ -1,49 +0,0 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/bone_editor/BoneEditor.gd" type="Script" id=1]
[ext_resource path="res://addons/bone_editor/BoneHandle.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/bone_editor/BoneHandle.gd" type="Script" id=3]
[node name="Spatial" type="Spatial"]
[node name="Skeleton" type="Skeleton" parent="."]
bones/0/name = "asdasd"
bones/0/parent = -1
bones/0/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2631, 1.85548, 0 )
bones/0/enabled = true
bones/0/bound_children = [ ]
bones/1/name = "qdqd"
bones/1/parent = 0
bones/1/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
bones/1/enabled = true
bones/1/bound_children = [ ]
bones/2/name = "qqq"
bones/2/parent = 1
bones/2/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
bones/2/enabled = true
bones/2/bound_children = [ ]
bones/3/name = "qqqqqw"
bones/3/parent = 2
bones/3/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
bones/3/enabled = true
bones/3/bound_children = [ ]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
[node name="BE" type="Spatial" parent="."]
script = ExtResource( 1 )
control_skeleton = NodePath("../Skeleton")
edit_animation_player = NodePath("../AnimationPlayer")
[node name="asdasd" type="Spatial" parent="BE" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2631, 1.85548, 0 )
script = ExtResource( 3 )
[node name="qdqd" type="Spatial" parent="BE/asdasd" instance=ExtResource( 2 )]
script = ExtResource( 3 )
[node name="qqq" type="Spatial" parent="BE/asdasd/qdqd" instance=ExtResource( 2 )]
script = ExtResource( 3 )
[node name="qqqqqw" type="Spatial" parent="BE/asdasd/qdqd/qqq" instance=ExtResource( 2 )]
script = ExtResource( 3 )