[godot] Add mix-and-match example

This commit is contained in:
Mario Zechner 2022-04-04 16:31:46 +02:00
parent b267c8ebc4
commit 7ed0d41cf6
9 changed files with 8463 additions and 6 deletions

View File

@ -0,0 +1,16 @@
extends SpineSprite
func _ready():
var data = get_skeleton().get_data()
var customSkin = SpineSkin.new()
var skinBase = data.find_skin("skin-base")
#customSkin.add_skin()
#customSkin.add_skin(data.find_skin("nose/short"))
#customSkin.add_skin(data.find_skin("eyelids/girly"))
#customSkin.add_skin(data.find_skin("eyes/violet"))
#customSkin.add_skin(data.find_skin("hair/brown"))
#customSkin.add_skin(data.find_skin("clothes/hoodie-orange"))
#customSkin.add_skin(data.find_skin("legs/pants-jeans"))
#customSkin.add_skin(data.find_skin("accessories/bag"))
#customSkin.add_skin(data.find_skin("accessories/hat-red-yellow"))
get_skeleton().set_skin(customSkin);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
[remap]
importer="spine.json"
type="SpineSkeletonJsonDataResource"
path="res://.import/mix-and-match-pro.json-5ca1b9fd6cb1c37bf492ced0be2e27b8.spjson"
[deps]
source_file="res://mix-and-match/mix-and-match-pro.json"
dest_files=[ "res://.import/mix-and-match-pro.json-5ca1b9fd6cb1c37bf492ced0be2e27b8.spjson" ]
[params]

View File

@ -0,0 +1,362 @@
mix-and-match.png
size: 1024, 512
filter: Linear, Linear
scale: 0.5
base-head
bounds: 587, 2, 95, 73
boy/arm-front
bounds: 558, 271, 36, 115
boy/backpack
bounds: 235, 109, 119, 153
boy/backpack-pocket
bounds: 328, 73, 34, 62
rotate: 90
boy/backpack-strap-front
bounds: 665, 79, 38, 88
boy/backpack-up
bounds: 395, 364, 21, 70
rotate: 90
boy/body
bounds: 251, 264, 97, 132
rotate: 90
boy/boot-ribbon-front
bounds: 648, 131, 9, 11
boy/collar
bounds: 744, 4, 73, 29
rotate: 90
boy/ear
bounds: 383, 109, 19, 23
rotate: 90
boy/eye-back-low-eyelid
bounds: 739, 284, 17, 6
rotate: 90
boy/eye-back-pupil
bounds: 832, 443, 8, 9
rotate: 90
boy/eye-back-up-eyelid
bounds: 558, 264, 23, 5
boy/eye-back-up-eyelid-back
bounds: 802, 491, 19, 10
rotate: 90
boy/eye-front-low-eyelid
bounds: 386, 363, 22, 7
rotate: 90
boy/eye-front-pupil
bounds: 816, 389, 9, 9
boy/eye-front-up-eyelid
bounds: 160, 71, 31, 6
rotate: 90
boy/eye-front-up-eyelid-back
bounds: 801, 434, 26, 9
rotate: 90
boy/eye-iris-back
bounds: 618, 264, 17, 17
boy/eye-iris-front
bounds: 727, 264, 18, 18
boy/eye-white-back
bounds: 580, 131, 20, 12
boy/eye-white-front
bounds: 510, 130, 27, 13
boy/eyebrow-back
bounds: 751, 88, 20, 11
rotate: 90
boy/eyebrow-front
bounds: 483, 130, 25, 11
boy/hair-back
bounds: 494, 388, 122, 81
rotate: 90
boy/hair-bangs
bounds: 667, 284, 70, 37
boy/hair-side
bounds: 789, 374, 25, 43
boy/hand-backfingers
bounds: 467, 364, 19, 21
boy/hand-front-fingers
bounds: 488, 364, 19, 21
boy/hat
bounds: 615, 417, 93, 56
rotate: 90
boy/leg-front
bounds: 138, 104, 31, 158
boy/mouth-close
bounds: 551, 365, 21, 5
rotate: 90
girl-blue-cape/mouth-close
bounds: 551, 365, 21, 5
rotate: 90
girl-spring-dress/mouth-close
bounds: 551, 365, 21, 5
rotate: 90
girl/mouth-close
bounds: 551, 365, 21, 5
rotate: 90
boy/mouth-smile
bounds: 705, 79, 29, 7
boy/nose
bounds: 836, 473, 17, 10
rotate: 90
boy/pompom
bounds: 747, 273, 48, 43
rotate: 90
boy/zip
bounds: 648, 144, 14, 23
girl-blue-cape/back-eyebrow
bounds: 602, 131, 18, 12
girl-blue-cape/body-dress
bounds: 2, 264, 109, 246
girl-blue-cape/body-ribbon
bounds: 615, 283, 50, 38
girl-blue-cape/cape-back
bounds: 2, 69, 134, 193
girl-blue-cape/cape-back-up
bounds: 386, 387, 123, 106
rotate: 90
girl-blue-cape/cape-ribbon
bounds: 675, 264, 50, 18
girl-blue-cape/cape-shoulder-back
bounds: 751, 110, 49, 59
girl-blue-cape/cape-shoulder-front
bounds: 113, 264, 62, 76
rotate: 90
girl-blue-cape/cape-up-front
bounds: 399, 264, 98, 117
rotate: 90
girl-blue-cape/ear
bounds: 775, 2, 19, 23
girl-spring-dress/ear
bounds: 775, 2, 19, 23
girl/ear
bounds: 775, 2, 19, 23
girl-blue-cape/eye-back-low-eyelid
bounds: 802, 463, 17, 6
girl-spring-dress/eye-back-low-eyelid
bounds: 802, 463, 17, 6
girl/eye-back-low-eyelid
bounds: 802, 463, 17, 6
girl-blue-cape/eye-back-pupil
bounds: 816, 367, 8, 9
girl-spring-dress/eye-back-pupil
bounds: 816, 367, 8, 9
girl/eye-back-pupil
bounds: 816, 367, 8, 9
girl-blue-cape/eye-back-up-eyelid
bounds: 554, 131, 24, 12
girl-spring-dress/eye-back-up-eyelid
bounds: 554, 131, 24, 12
girl/eye-back-up-eyelid
bounds: 554, 131, 24, 12
girl-blue-cape/eye-back-up-eyelid-back
bounds: 832, 453, 17, 11
rotate: 90
girl-spring-dress/eye-back-up-eyelid-back
bounds: 832, 453, 17, 11
rotate: 90
girl/eye-back-up-eyelid-back
bounds: 832, 453, 17, 11
rotate: 90
girl-blue-cape/eye-front-low-eyelid
bounds: 739, 303, 18, 6
rotate: 90
girl-spring-dress/eye-front-low-eyelid
bounds: 739, 303, 18, 6
rotate: 90
girl/eye-front-low-eyelid
bounds: 739, 303, 18, 6
rotate: 90
girl-blue-cape/eye-front-pupil
bounds: 816, 378, 9, 9
girl-spring-dress/eye-front-pupil
bounds: 816, 378, 9, 9
girl/eye-front-pupil
bounds: 816, 378, 9, 9
girl-blue-cape/eye-front-up-eyelid
bounds: 392, 77, 30, 14
rotate: 90
girl-spring-dress/eye-front-up-eyelid
bounds: 392, 77, 30, 14
rotate: 90
girl/eye-front-up-eyelid
bounds: 392, 77, 30, 14
rotate: 90
girl-blue-cape/eye-front-up-eyelid-back
bounds: 455, 130, 26, 11
girl-spring-dress/eye-front-up-eyelid-back
bounds: 455, 130, 26, 11
girl/eye-front-up-eyelid-back
bounds: 455, 130, 26, 11
girl-blue-cape/eye-iris-back
bounds: 637, 264, 17, 17
girl-blue-cape/eye-iris-front
bounds: 802, 471, 18, 18
girl-blue-cape/eye-white-back
bounds: 596, 264, 20, 16
girl-spring-dress/eye-white-back
bounds: 596, 264, 20, 16
girl-blue-cape/eye-white-front
bounds: 796, 5, 20, 16
rotate: 90
girl-spring-dress/eye-white-front
bounds: 796, 5, 20, 16
rotate: 90
girl/eye-white-front
bounds: 796, 5, 20, 16
rotate: 90
girl-blue-cape/front-eyebrow
bounds: 608, 149, 18, 12
rotate: 90
girl-blue-cape/hair-back
bounds: 508, 145, 117, 98
rotate: 90
girl-blue-cape/hair-bangs
bounds: 673, 419, 91, 40
rotate: 90
girl-blue-cape/hair-head-side-back
bounds: 196, 331, 30, 52
rotate: 90
girl-blue-cape/hair-head-side-front
bounds: 738, 323, 41, 42
girl-blue-cape/hair-side
bounds: 473, 3, 36, 71
girl-blue-cape/hand-front-fingers
bounds: 509, 365, 19, 21
girl-spring-dress/hand-front-fingers
bounds: 509, 365, 19, 21
girl-blue-cape/leg-front
bounds: 168, 72, 30, 158
rotate: 90
girl-blue-cape/mouth-smile
bounds: 736, 79, 29, 7
girl-spring-dress/mouth-smile
bounds: 736, 79, 29, 7
girl/mouth-smile
bounds: 736, 79, 29, 7
girl-blue-cape/nose
bounds: 747, 264, 11, 7
girl-spring-dress/nose
bounds: 747, 264, 11, 7
girl/nose
bounds: 747, 264, 11, 7
girl-blue-cape/sleeve-back
bounds: 767, 79, 42, 29
girl-blue-cape/sleeve-front
bounds: 408, 76, 52, 119
rotate: 90
girl-spring-dress/arm-front
bounds: 596, 282, 17, 111
girl-spring-dress/back-eyebrow
bounds: 801, 420, 18, 12
girl-spring-dress/body-up
bounds: 179, 4, 64, 66
girl-spring-dress/cloak-down
bounds: 775, 27, 50, 50
girl-spring-dress/cloak-up
bounds: 360, 7, 64, 58
rotate: 90
girl-spring-dress/eye-iris-back
bounds: 656, 264, 17, 17
girl-spring-dress/eye-iris-front
bounds: 814, 492, 18, 18
girl-spring-dress/front-eyebrow
bounds: 822, 472, 18, 12
rotate: 90
girl-spring-dress/hair-back
bounds: 196, 363, 147, 93
rotate: 90
girl-spring-dress/hair-bangs
bounds: 696, 326, 91, 40
rotate: 90
girl-spring-dress/hair-head-side-back
bounds: 529, 76, 30, 52
girl-spring-dress/hair-head-side-front
bounds: 781, 323, 41, 42
girl-spring-dress/hair-side
bounds: 511, 3, 36, 71
girl-spring-dress/leg-front
bounds: 171, 104, 30, 158
girl-spring-dress/neck
bounds: 138, 70, 20, 32
girl-spring-dress/shoulder-ribbon
bounds: 622, 131, 36, 24
rotate: 90
girl-spring-dress/skirt
bounds: 113, 328, 182, 81
rotate: 90
girl-spring-dress/underskirt
bounds: 2, 2, 175, 65
girl/arm-front
bounds: 577, 395, 36, 115
girl/back-eyebrow
bounds: 834, 492, 18, 12
rotate: 90
girl/bag-base
bounds: 191, 264, 62, 58
rotate: 90
girl/bag-strap-front
bounds: 385, 265, 12, 96
girl/bag-top
bounds: 738, 367, 49, 50
girl/body
bounds: 356, 130, 97, 132
girl/boot-ribbon-front
bounds: 539, 130, 13, 13
girl/eye-iris-back
bounds: 821, 424, 17, 17
girl/eye-iris-front
bounds: 812, 443, 18, 18
girl/eye-white-back
bounds: 814, 5, 20, 16
rotate: 90
girl/front-eyebrow
bounds: 816, 400, 18, 12
rotate: 90
girl/hair-back
bounds: 291, 363, 147, 93
rotate: 90
girl/hair-bangs
bounds: 715, 419, 91, 40
rotate: 90
girl/hair-flap-down-front
bounds: 288, 5, 70, 65
girl/hair-head-side-back
bounds: 561, 77, 30, 52
girl/hair-head-side-front
bounds: 757, 419, 41, 42
rotate: 90
girl/hair-patch
bounds: 245, 4, 66, 41
rotate: 90
girl/hair-side
bounds: 549, 3, 36, 71
girl/hair-strand-back-1
bounds: 684, 3, 58, 74
girl/hair-strand-back-2
bounds: 692, 171, 91, 58
rotate: 90
girl/hair-strand-back-3
bounds: 615, 323, 92, 79
rotate: 90
girl/hair-strand-front-1
bounds: 518, 269, 38, 94
girl/hair-strand-front-2
bounds: 593, 79, 70, 50
girl/hair-strand-front-3
bounds: 705, 88, 44, 81
girl/hand-front-fingers
bounds: 530, 365, 19, 21
girl/hat
bounds: 608, 169, 93, 82
rotate: 90
girl/leg-front
bounds: 203, 104, 30, 158
girl/pompom
bounds: 757, 462, 48, 43
rotate: 90
girl/scarf
bounds: 455, 143, 119, 51
rotate: 90
girl/scarf-back
bounds: 420, 2, 72, 51
rotate: 90
girl/zip
bounds: 356, 109, 19, 25
rotate: 90

View File

@ -0,0 +1,14 @@
[remap]
importer="spine.atlas"
type="SpineAtlasResource"
path="res://.import/mix-and-match.atlas-0bbed47d1d8e8f4ac037195dc25c9fd9.spatlas"
[deps]
source_file="res://mix-and-match/mix-and-match.atlas"
dest_files=[ "res://.import/mix-and-match.atlas-0bbed47d1d8e8f4ac037195dc25c9fd9.spatlas" ]
[params]
normal_texture_prefix="n"

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

View File

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

View File

@ -1,15 +1,32 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Spineboy.gd" type="Script" id=1]
[ext_resource path="res://spineboy/spineboy-data.tres" type="SpineSkeletonDataResource" id=2]
[ext_resource path="res://mix-and-match/mix-and-match-pro.json" type="SpineSkeletonJsonDataResource" id=3]
[ext_resource path="res://mix-and-match/mix-and-match.atlas" type="SpineAtlasResource" id=4]
[ext_resource path="res://mix-and-match.gd" type="Script" id=5]
[sub_resource type="SpineAnimationStateDataResource" id=2]
skeleton = ExtResource( 2 )
[sub_resource type="SpineSkeletonDataResource" id=4]
atlas_res = ExtResource( 4 )
skeleton_json_res = ExtResource( 3 )
animations = null
skins = null
[sub_resource type="SpineAnimationStateDataResource" id=3]
skeleton = SubResource( 4 )
[node name="Node2D" type="Node2D"]
[node name="Spineboy" type="SpineSprite" parent="."]
position = Vector2( 504, 622 )
position = Vector2( 721.498, 460.558 )
scale = Vector2( 0.5, 0.5 )
animation_state_data_res = SubResource( 2 )
current_animations = [ "walk" ]
script = ExtResource( 1 )
[node name="MixAndMatch" type="SpineSprite" parent="."]
position = Vector2( 309.431, 511.233 )
animation_state_data_res = SubResource( 3 )
script = ExtResource( 5 )

View File

@ -82,7 +82,6 @@ void SpineSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "overlap"), "set_overlap", "get_overlap");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "bind_slot_nodes"), "set_bind_slot_nodes", "get_bind_slot_nodes");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_skin_resource", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineCustomSkinResource"), "set_skin", "get_skin");
ADD_GROUP("animation", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Process,Physics,Manually"), "set_process_mode", "get_process_mode");
@ -94,8 +93,9 @@ void SpineSprite::_bind_methods() {
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual);
}
SpineSprite::SpineSprite() : select_track_id(0), empty_animation_duration(0.2f), skeleton_clipper(NULL),
SpineSprite::SpineSprite() : select_track_id(0), empty_animation_duration(0.2f),
overlap(false),
skeleton_clipper(NULL),
process_mode(ProcessMode_Process) {
skeleton_clipper = new spine::SkeletonClipping();
}
@ -346,7 +346,6 @@ void SpineSprite::remove_redundant_mesh_instances() {
void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
static const unsigned short VERTEX_STRIDE = 2;
static const unsigned short UV_STRIDE = 2;
static unsigned short quad_indices[] = {0, 1, 2, 2, 3, 0};
auto sk = s->get_spine_object();