From 47c687c870457c86fa465c9bb6582d22755edbc1 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Thu, 5 Jun 2025 15:06:37 +0200 Subject: [PATCH] [haxe] Port to 4.3 (WIP) --- examples/export/runtimes.sh | 746 ---------- .../src/flixelExamples/ControlBonesExample.hx | 6 +- .../src/flixelExamples/EventsExample.hx | 2 +- .../example/src/flixelExamples/FlixelState.hx | 4 +- .../starlingExamples/ControlBonesExample.hx | 6 +- spine-haxe/spine-haxe/spine/Color.hx | 6 +- spine-haxe/spine-haxe/spine/Event.hx | 2 +- spine-haxe/spine-haxe/spine/PathConstraint.hx | 2 +- spine-haxe/spine-haxe/spine/SkeletonBinary.hx | 529 +++---- spine-haxe/spine-haxe/spine/SkeletonData.hx | 4 +- spine-haxe/spine-haxe/spine/SkeletonJson.hx | 1220 +++++++++-------- spine-haxe/spine-haxe/spine/Skin.hx | 2 +- spine-haxe/spine-haxe/spine/Slider.hx | 23 +- spine-haxe/spine-haxe/spine/SliderData.hx | 3 + spine-haxe/spine-haxe/spine/SliderPose.hx | 3 + .../spine/TransformConstraintData.hx | 6 + .../spine/animation/AnimationState.hx | 8 +- .../spine-haxe/spine/flixel/SkeletonSprite.hx | 37 +- .../spine/starling/SkeletonSprite.hx | 46 +- 19 files changed, 1043 insertions(+), 1612 deletions(-) diff --git a/examples/export/runtimes.sh b/examples/export/runtimes.sh index cc1dc378f..5368c2a8e 100755 --- a/examples/export/runtimes.sh +++ b/examples/export/runtimes.sh @@ -9,550 +9,6 @@ echo "Spine Runtimes path: $ROOT" echo "Copying assets to runtimes..." echo "" -echo "spine-libgdx" -rm "$ROOT/spine-libgdx/spine-libgdx-tests/assets/goblins/"* -cp -f ../goblins/export/*.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/goblins/" -cp -f ../goblins/export/*.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/goblins/" -cp -f ../goblins/export/*-pma.* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/goblins/" - -rm "$ROOT/spine-libgdx/spine-libgdx-tests/assets/raptor/"* -cp -f ../raptor/export/*.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/raptor/" -cp -f ../raptor/export/*.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/raptor/" -cp -f ../raptor/export/*-pma.* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/raptor/" - -rm "$ROOT/spine-libgdx/spine-libgdx-tests/assets/spineboy/"* -cp -f ../spineboy/export/*.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/spineboy/" -cp -r ../spineboy/export/*.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/spineboy/" -cp -r ../spineboy/export/*-pma.* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/spineboy/" - -rm "$ROOT/spine-libgdx/spine-libgdx-tests/assets/coin/"* -cp -f ../coin/export/*.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/coin/" -cp -f ../coin/export/*.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/coin/" -cp -f ../coin/export/*-pma.* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/coin/" - -rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/mix-and-match/"* -cp -f ../mix-and-match/export/*.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/mix-and-match/" -cp -f ../mix-and-match/export/*.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/mix-and-match/" -cp -f ../mix-and-match/export/*-pma.* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/mix-and-match/" - -echo "spine-android" -rm "$ROOT/spine-android/app/src/main/assets/"* -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-android/app/src/main/assets/" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-android/app/src/main/assets" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-android/app/src/main/assets" - -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-android/app/src/main/assets/" -cp -f ../dragon/export/dragon.atlas "$ROOT/spine-android/app/src/main/assets" -cp -f ../dragon/export/dragon.png "$ROOT/spine-android/app/src/main/assets" -cp -f ../dragon/export/dragon_2.png "$ROOT/spine-android/app/src/main/assets" -cp -f ../dragon/export/dragon_3.png "$ROOT/spine-android/app/src/main/assets" -cp -f ../dragon/export/dragon_4.png "$ROOT/spine-android/app/src/main/assets" -cp -f ../dragon/export/dragon_5.png "$ROOT/spine-android/app/src/main/assets" - -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-android/app/src/main/assets/" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-android/app/src/main/assets/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-android/app/src/main/assets/" - -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-android/app/src/main/assets/" -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-android/app/src/main/assets/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-android/app/src/main/assets/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-android/app/src/main/assets/" - -rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/"* -mkdir -p "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/" -cp -f ../sack/export/sack-pro.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/" -cp -f ../sack/export/sack-pro.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/" -cp -f ../sack/export/sack-pma.atlas "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/" -cp -f ../sack/export/sack-pma.png "$ROOT/spine-libgdx/spine-libgdx-tests/assets/sack/" - -rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"* -mkdir -p "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/" -cp -f ../celestial-circus/export/* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/" - -rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/snowglobe/"* -mkdir -p "$ROOT/spine-libgdx/spine-libgdx-tests/assets/snowglobe/" -cp -f ../snowglobe/export/* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/snowglobe/" - -rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/cloud-pot/"* -mkdir -p "$ROOT/spine-libgdx/spine-libgdx-tests/assets/cloud-pot/" -cp -f ../cloud-pot/export/* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/cloud-pot/" - -echo "spine-cocos2dx" -rm -rf "$ROOT/spine-cocos2dx/example/Resources/common/"* - -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../coin/export/coin-pro.skel "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../coin/export/coin.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../coin/export/coin.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../goblins/export/goblins-pro.json "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../goblins/export/goblins.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../goblins/export/goblins.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../tank/export/tank-pro.skel "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../tank/export/tank.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../tank/export/tank.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-cocos2dx/example/Resources/common/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-cocos2dx/example/Resources/common/" - -echo "spine-flutter" -rm -rf "$ROOT/spine-flutter/example/assets/"* -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-flutter/example/assets/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-flutter/example/assets/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-flutter/example/assets/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-flutter/example/assets/" - -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-flutter/example/assets/" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-flutter/example/assets/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-flutter/example/assets/" - -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-flutter/example/assets/" -cp -f ../dragon/export/dragon.atlas "$ROOT/spine-flutter/example/assets/" -cp -f ../dragon/export/dragon.png "$ROOT/spine-flutter/example/assets/" -cp -f ../dragon/export/dragon_*.png "$ROOT/spine-flutter/example/assets/" - -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-flutter/example/assets/" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-flutter/example/assets/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-flutter/example/assets/" - -echo "spine-ios" -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-ios/Example/Spine iOS Example/Assets/celestial/" -cp -f ../celestial-circus/export/celestial-circus-pma.atlas "$ROOT/spine-ios/Example/Spine iOS Example/Assets/celestial/" -cp -f ../celestial-circus/export/celestial-circus-pma.png "$ROOT/spine-ios/Example/Spine iOS Example/Assets/celestial/" - -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-ios/Example/Spine iOS Example/Assets/dragon/" -cp -f ../dragon/export/dragon.atlas "$ROOT/spine-ios/Example/Spine iOS Example/Assets/dragon/" -cp -f ../dragon/export/dragon.png "$ROOT/spine-ios/Example/Spine iOS Example/Assets/dragon/" -cp -f ../dragon/export/dragon_*.png "$ROOT/spine-ios/Example/Spine iOS Example/Assets/dragon/" - -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-ios/Example/Spine iOS Example/Assets/mixandmatch/" -cp -f ../mix-and-match/export/mix-and-match-pma.atlas "$ROOT/spine-ios/Example/Spine iOS Example/Assets/mixandmatch/" -cp -f ../mix-and-match/export/mix-and-match-pma.png "$ROOT/spine-ios/Example/Spine iOS Example/Assets/mixandmatch/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-ios/Example/Spine iOS Example/Assets/spineboy/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ios/Example/Spine iOS Example/Assets/spineboy/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ios/Example/Spine iOS Example/Assets/spineboy/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ios/Example/Spine iOS Example/Assets/spineboy/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-ios/Example - Cocoapods/Spine iOS Example/spineboy/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ios/Example - Cocoapods/Spine iOS Example/spineboy/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ios/Example - Cocoapods/Spine iOS Example/spineboy/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ios/Example - Cocoapods/Spine iOS Example/spineboy/" - -echo "spine-godot" -rm -f "$ROOT"/spine-godot/example/assets/spineboy/*.atlas -rm -f "$ROOT"/spine-godot/example/assets/spineboy/*.png -rm -f "$ROOT"/spine-godot/example/assets/spineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example/assets/spineboy/*.skel -rm -f "$ROOT"/spine-godot/example/assets/raptor/*.atlas -rm -f "$ROOT"/spine-godot/example/assets/raptor/*.png -rm -f "$ROOT"/spine-godot/example/assets/raptor/*.skel -rm -f "$ROOT"/spine-godot/example/assets/mix-and-match/*.atlas -rm -f "$ROOT"/spine-godot/example/assets/mix-and-match/*.png -rm -f "$ROOT"/spine-godot/example/assets/mix-and-match/*.spine-json -rm -f "$ROOT"/spine-godot/example/assets/mix-and-match/*.skel -rm -f "$ROOT"/spine-godot/example/assets/raggedyspineboy/*.atlas -rm -f "$ROOT"/spine-godot/example/assets/raggedyspineboy/*.png -rm -f "$ROOT"/spine-godot/example/assets/raggedyspineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example/assets/celestial-circus/*.atlas -rm -f "$ROOT"/spine-godot/example/assets/celestial-circus/*.png -rm -f "$ROOT"/spine-godot/example/assets/celestial-circus/*.skel - - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-godot/example/assets/spineboy/spineboy-pro.spine-json" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-godot/example/assets/spineboy/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-godot/example/assets/spineboy/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-godot/example/assets/spineboy/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-godot/example/assets/mix-and-match/mix-and-match-pro.spine-json" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-godot/example/assets/mix-and-match/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-godot/example/assets/mix-and-match/" - -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-godot/example/assets/raptor/" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-godot/example/assets/raptor/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-godot/example/assets/raptor/" -cp -f ../raptor/manual-maps/raptor-normals.png "$ROOT/spine-godot/example/assets/raptor/n_raptor.png" -cp -f ../raptor/manual-maps/light-sprite.png "$ROOT/spine-godot/example/assets/raptor/light-sprite.png" - -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-godot/example/assets/celestial-circus/celestial-circus.skel" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-godot/example/assets/celestial-circus/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-godot/example/assets/celestial-circus/" - -rm -f "$ROOT"/spine-godot/example-v4/assets/spineboy/*.atlas -rm -f "$ROOT"/spine-godot/example-v4/assets/spineboy/*.png -rm -f "$ROOT"/spine-godot/example-v4/assets/spineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4/assets/spineboy/*.skel -rm -f "$ROOT"/spine-godot/example-v4/assets/raptor/*.atlas -rm -f "$ROOT"/spine-godot/example-v4/assets/raptor/*.png -rm -f "$ROOT"/spine-godot/example-v4/assets/raptor/*.skel -rm -f "$ROOT"/spine-godot/example-v4/assets/mix-and-match/*.atlas -rm -f "$ROOT"/spine-godot/example-v4/assets/mix-and-match/*.png -rm -f "$ROOT"/spine-godot/example-v4/assets/mix-and-match/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4/assets/mix-and-match/*.skel -rm -f "$ROOT"/spine-godot/example-v4/assets/raggedyspineboy/*.atlas -rm -f "$ROOT"/spine-godot/example-v4/assets/raggedyspineboy/*.png -rm -f "$ROOT"/spine-godot/example-v4/assets/raggedyspineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4/assets/celestial-circus/*.atlas -rm -f "$ROOT"/spine-godot/example-v4/assets/celestial-circus/*.png -rm -f "$ROOT"/spine-godot/example-v4/assets/celestial-circus/*.skel - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-godot/example-v4/assets/spineboy/spineboy-pro.spine-json" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-godot/example-v4/assets/spineboy/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-godot/example-v4/assets/spineboy/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-godot/example-v4/assets/spineboy/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-godot/example-v4/assets/mix-and-match/mix-and-match-pro.spine-json" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-godot/example-v4/assets/mix-and-match/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-godot/example-v4/assets/mix-and-match/" - -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-godot/example-v4/assets/raptor/" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-godot/example-v4/assets/raptor/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-godot/example-v4/assets/raptor/" -cp -f ../raptor/manual-maps/raptor-normals.png "$ROOT/spine-godot/example-v4/assets/raptor/n_raptor.png" -cp -f ../raptor/manual-maps/light-sprite.png "$ROOT/spine-godot/example-v4/assets/raptor/light-sprite.png" - -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-godot/example-v4/assets/celestial-circus/celestial-circus.skel" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-godot/example-v4/assets/celestial-circus/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-godot/example-v4/assets/celestial-circus/" - -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/spineboy/*.atlas -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/spineboy/*.png -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/spineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/spineboy/*.skel -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raptor/*.atlas -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raptor/*.png -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raptor/*.skel -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/mix-and-match/*.atlas -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/mix-and-match/*.png -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/mix-and-match/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/mix-and-match/*.skel -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raggedyspineboy/*.atlas -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raggedyspineboy/*.png -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/raggedyspineboy/*.spine-json -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/celestial-circus/*.atlas -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/celestial-circus/*.png -rm -f "$ROOT"/spine-godot/example-v4-csharp/assets/celestial-circus/*.skel - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-godot/example-v4-csharp/assets/spineboy/spineboy-pro.spine-json" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-godot/example-v4-csharp/assets/spineboy/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-godot/example-v4-csharp/assets/spineboy/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-godot/example-v4-csharp/assets/spineboy/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-godot/example-v4-csharp/assets/mix-and-match/mix-and-match-pro.spine-json" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-godot/example-v4-csharp/assets/mix-and-match/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-godot/example-v4-csharp/assets/mix-and-match/" - -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-godot/example-v4-csharp/assets/raptor/" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-godot/example-v4-csharp/assets/raptor/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-godot/example-v4-csharp/assets/raptor/" -cp -f ../raptor/manual-maps/raptor-normals.png "$ROOT/spine-godot/example-v4-csharp/assets/raptor/n_raptor.png" -cp -f ../raptor/manual-maps/light-sprite.png "$ROOT/spine-godot/example-v4-csharp/assets/raptor/light-sprite.png" - -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.skel" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-godot/example-v4-csharp/assets/celestial-circus/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-godot/example-v4-csharp/assets/celestial-circus/" - -echo "spine-sdl" -rm -f "$ROOT/spine-sdl/data/"* -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-sdl/data/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-sdl/data/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-sdl/data/" - -echo "spine-glfw" -rm -f "$ROOT/spine-glfw/data/"* -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-glfw/data/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-glfw/data/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-glfw/data/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-glfw/data/" - -echo "spine-sfml-c" -rm "$ROOT/spine-sfml/c/data/"* -cp -f ../coin/export/coin-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../coin/export/coin-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../coin/export/coin-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../coin/export/coin-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../dragon/export/dragon-ess.json "$ROOT/spine-sfml/c/data/" -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-sfml/c/data/" -cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-sfml/c/data/" - -cp -f ../goblins/export/goblins-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../goblins/export/goblins-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../goblins/export/goblins-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../goblins/export/goblins-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../raptor/export/raptor-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../raptor/export/raptor-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../tank/export/tank-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../tank/export/tank-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../tank/export/tank-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../tank/export/tank-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../vine/export/vine-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../vine/export/vine-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../vine/export/vine-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../vine/export/vine-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../stretchyman/export/stretchyman-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../stretchyman/export/stretchyman-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../stretchyman/export/stretchyman-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../stretchyman/export/stretchyman-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../owl/export/owl-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../owl/export/owl-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../owl/export/owl-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../owl/export/owl-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../mix-and-match/export/mix-and-match-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../mix-and-match/export/mix-and-match-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../sack/export/sack-pro.json "$ROOT/spine-sfml/c/data/" -cp -f ../sack/export/sack-pro.skel "$ROOT/spine-sfml/c/data/" -cp -f ../sack/export/sack-pma.atlas "$ROOT/spine-sfml/c/data/" -cp -f ../sack/export/sack-pma.png "$ROOT/spine-sfml/c/data/" - -cp -f ../celestial-circus/export/* "$ROOT/spine-sfml/c/data/" - -cp -f ../snowglobe/export/* "$ROOT/spine-sfml/c/data/" - -cp -f ../cloud-pot/export/* "$ROOT/spine-sfml/c/data/" - -echo "spine-sfml-cpp" -rm "$ROOT/spine-sfml/cpp/data/"* -cp -f ../coin/export/coin-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../coin/export/coin-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../coin/export/coin-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../coin/export/coin-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../dragon/export/dragon-ess.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../goblins/export/goblins-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../goblins/export/goblins-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../goblins/export/goblins-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../goblins/export/goblins-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../raptor/export/raptor-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../raptor/export/raptor-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../tank/export/tank-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../tank/export/tank-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../tank/export/tank-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../tank/export/tank-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../vine/export/vine-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../vine/export/vine-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../vine/export/vine-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../vine/export/vine-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../stretchyman/export/stretchyman-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../stretchyman/export/stretchyman-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../stretchyman/export/stretchyman-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../stretchyman/export/stretchyman-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../owl/export/owl-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../owl/export/owl-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../owl/export/owl-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../owl/export/owl-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../mix-and-match/export/mix-and-match-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../mix-and-match/export/mix-and-match-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../sack/export/sack-pro.json "$ROOT/spine-sfml/cpp/data/" -cp -f ../sack/export/sack-pro.skel "$ROOT/spine-sfml/cpp/data/" -cp -f ../sack/export/sack-pma.atlas "$ROOT/spine-sfml/cpp/data/" -cp -f ../sack/export/sack-pma.png "$ROOT/spine-sfml/cpp/data/" - -cp -f ../celestial-circus/export/* "$ROOT/spine-sfml/cpp/data/" - -cp -f ../snowglobe/export/* "$ROOT/spine-sfml/cpp/data/" - -cp -f ../cloud-pot/export/* "$ROOT/spine-sfml/cpp/data/" - -echo "spine-ts" -rm "$ROOT/spine-ts/assets/"* - -cp -f ../celestial-circus/export/celestial-circus-pro.json "$ROOT/spine-ts/assets/" -cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../celestial-circus/export/celestial-circus-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../celestial-circus/export/celestial-circus-pma.png "$ROOT/spine-ts/assets/" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-ts/assets/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-ts/assets/" - -cp -f ../chibi-stickers/export/chibi-stickers.json "$ROOT/spine-ts/assets/" -cp -f ../chibi-stickers/export/chibi-stickers.skel "$ROOT/spine-ts/assets/" -cp -f ../chibi-stickers/export/chibi-stickers.atlas "$ROOT/spine-ts/assets/" -cp -f ../chibi-stickers/export/chibi-stickers-pma* "$ROOT/spine-ts/assets/" - -cp -f ../cloud-pot/export/cloud-pot.skel "$ROOT/spine-ts/assets/" -cp -f ../cloud-pot/export/cloud-pot-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../cloud-pot/export/cloud-pot-pma.png "$ROOT/spine-ts/assets/" -cp -f ../cloud-pot/export/cloud-pot.atlas "$ROOT/spine-ts/assets/" -cp -f ../cloud-pot/export/cloud-pot.png "$ROOT/spine-ts/assets/" - -cp -f ../coin/export/coin-pro.json "$ROOT/spine-ts/assets/" -cp -f ../coin/export/coin-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../coin/export/coin-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../coin/export/coin-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-ts/assets/" -cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-ts/assets/" - -cp -f ../goblins/export/goblins-pro.json "$ROOT/spine-ts/assets/" -cp -f ../goblins/export/goblins-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../goblins/export/goblins-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../goblins/export/goblins-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-ts/assets/" -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../mix-and-match/export/mix-and-match-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../mix-and-match/export/mix-and-match-pma.png "$ROOT/spine-ts/assets/" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-ts/assets/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-ts/assets/" - -cp -f ../owl/export/owl-pro.json "$ROOT/spine-ts/assets/" -cp -f ../owl/export/owl-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../owl/export/owl-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../owl/export/owl-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-ts/assets/" -cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../raptor/export/raptor-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../raptor/export/raptor-pma.png "$ROOT/spine-ts/assets/" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-ts/assets/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-ts/assets/" -cp -f ../raptor/images/raptor-jaw-tooth.png "$ROOT/spine-ts/assets/" - -cp -f ../sack/export/sack-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../sack/export/sack-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../sack/export/sack-pma.png "$ROOT/spine-ts/assets/" -cp -f ../sack/export/sack.atlas "$ROOT/spine-ts/assets/" -cp -f ../sack/export/sack.png "$ROOT/spine-ts/assets/" - -cp -f ../snowglobe/export/snowglobe-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../snowglobe/export/snowglobe-pma* "$ROOT/spine-ts/assets/" -cp -f ../snowglobe/export/snowglobe* "$ROOT/spine-ts/assets/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy-ess.json "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-ts/assets/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-ts/assets/" - -cp -f ../stretchyman/export/stretchyman-pro.json "$ROOT/spine-ts/assets/" -cp -f ../stretchyman/export/stretchyman-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../stretchyman/export/stretchyman-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../stretchyman/export/stretchyman-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../tank/export/tank-pro.json "$ROOT/spine-ts/assets/" -cp -f ../tank/export/tank-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../tank/export/tank-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../tank/export/tank-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../vine/export/vine-pro.json "$ROOT/spine-ts/assets/" -cp -f ../vine/export/vine-pro.skel "$ROOT/spine-ts/assets/" -cp -f ../vine/export/vine-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../vine/export/vine-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../windmill/export/windmill-ess.json "$ROOT/spine-ts/assets/" -cp -f ../windmill/export/windmill-pma.atlas "$ROOT/spine-ts/assets/" -cp -f ../windmill/export/windmill-pma.png "$ROOT/spine-ts/assets/" - -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-phaser-v3/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-phaser-v3/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-phaser-v3/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-phaser-v4/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-phaser-v4/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-phaser-v4/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-pixi-v7/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-pixi-v7/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-pixi-v7/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-ts/spine-pixi-v8/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.atlas "$ROOT/spine-ts/spine-pixi-v8/example/typescript/assets/" -cp -f ../spineboy/export/spineboy-pma.png "$ROOT/spine-ts/spine-pixi-v8/example/typescript/assets/" - - -echo "spine-monogame" -rm "$ROOT/spine-monogame/spine-monogame-example/data/"* -cp -f ../coin/export/coin-pro.json "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../coin/export/coin-pro.skel "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../coin/export/coin.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../coin/export/coin.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-monogame/spine-monogame-example/data/" -# Note: normalmap need to be created manually. Thus we use a separately prepared atlas and -# diffuse map so that the maps always match. These atlas textures are copied to the target dir. -cp -f ../raptor/manual-maps/raptor.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../raptor/manual-maps/raptor.png "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../raptor/manual-maps/raptor-normals.png "$ROOT/spine-monogame/spine-monogame-example/data/raptor_normals.png" - -cp -f ../spineboy/export/spineboy-pro.skel "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../tank/export/tank-pro.json "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../tank/export/tank.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../tank/export/tank.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../mix-and-match/export/mix-and-match-pro.json "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../celestial-circus/export/celestial-circus-pro.json "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../celestial-circus/export/celestial-circus.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../celestial-circus/export/celestial-circus.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../snowglobe/export/snowglobe-pro.skel "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../snowglobe/export/snowglobe.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../snowglobe/export/snowglobe.png "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../snowglobe/export/snowglobe_*.png "$ROOT/spine-monogame/spine-monogame-example/data/" - -cp -f ../cloud-pot/export/cloud-pot.skel "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../cloud-pot/export/cloud-pot.atlas "$ROOT/spine-monogame/spine-monogame-example/data/" -cp -f ../cloud-pot/export/cloud-pot.png "$ROOT/spine-monogame/spine-monogame-example/data/" - echo "spine-haxe" rm "$ROOT/spine-haxe/example/assets/"* cp -f ../coin/export/coin-pro.json "$ROOT/spine-haxe/example/assets/" @@ -622,208 +78,6 @@ cp -f ../snowglobe/export/snowglobe-pro.json "$ROOT/spine-haxe/example/assets/" cp -f ../snowglobe/export/snowglobe-pro.skel "$ROOT/spine-haxe/example/assets/" cp -f ../snowglobe/export/snowglobe* "$ROOT/spine-haxe/example/assets/" -echo "spine-ue" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/raptor.json" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/raptor-pro.json" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/raptor.atlas" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/raptor.png" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/spineboy.json" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/spineboy-pro.json" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/spineboy.atlas" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/spineboy.png" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match-pro.skel" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match-pro-skeleton.skel" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match-pro.atlas" -rm -f "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match-pro.png" - -cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/raptor-pro.json" -cp -f ../raptor/export/raptor.atlas "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/" -cp -f ../raptor/export/raptor.png "$ROOT/spine-ue/Content/GettingStarted/Assets/Raptor/" - -cp -f ../spineboy/export/spineboy-pro.json "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/spineboy-pro.json" -cp -f ../spineboy/export/spineboy.atlas "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/" -cp -f ../spineboy/export/spineboy.png "$ROOT/spine-ue/Content/GettingStarted/Assets/Spineboy/" - -cp -f ../mix-and-match/export/mix-and-match.png "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match.png" -cp -f ../mix-and-match/export/mix-and-match.atlas "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match.atlas" -cp -f ../mix-and-match/export/mix-and-match-pro.skel "$ROOT/spine-ue/Content/GettingStarted/Assets/mix-and-match/mix-and-match-pro.skel" - -echo "spine-unity" - -# Section of assets specific for the spine-unity runtime. -UNITY_SOURCE_DIR=../spine-unity - -# On macOS, we need gsed for the -i switch to work. Check it's available -# and error out otherwise. -sed="sed" -if [[ $OSTYPE == 'darwin'* ]]; then - if [ ! -f "/opt/homebrew/bin/gsed" ]; then - echo "macOS sed detected. Please install GNU sed via brew install gnu-sed" - exit -1 - fi - sed="/opt/homebrew/bin/gsed" -fi - -# Do not delete everything in unity dirs, especially not .meta files. -# Note: We copy the files following the existing naming scheme (e.g. goblins.json instead of goblins-pro.json) -# to the unity assets directories. This requires to change the png file reference line in the atlas file. -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Dragon" -cp -f ../dragon/export/dragon-ess.json "$UNITY_TARGET_DIR/dragon.json" -cp -f ../dragon/export/dragon-pma.atlas "$UNITY_TARGET_DIR/dragon.atlas.txt" -$sed -i "s/dragon-pma.png/dragon.png/g" "$UNITY_TARGET_DIR/dragon.atlas.txt" -$sed -i "s/dragon-pma_2.png/dragon2.png/g" "$UNITY_TARGET_DIR/dragon.atlas.txt" -$sed -i "s/dragon-pma_3.png/dragon3.png/g" "$UNITY_TARGET_DIR/dragon.atlas.txt" -$sed -i "s/dragon-pma_4.png/dragon4.png/g" "$UNITY_TARGET_DIR/dragon.atlas.txt" -$sed -i "s/dragon-pma_5.png/dragon5.png/g" "$UNITY_TARGET_DIR/dragon.atlas.txt" -cp -f ../dragon/export/dragon-pma.png "$UNITY_TARGET_DIR/dragon.png" -cp -f ../dragon/export/dragon-pma_2.png "$UNITY_TARGET_DIR/dragon2.png" -cp -f ../dragon/export/dragon-pma_3.png "$UNITY_TARGET_DIR/dragon3.png" -cp -f ../dragon/export/dragon-pma_4.png "$UNITY_TARGET_DIR/dragon4.png" -cp -f ../dragon/export/dragon-pma_5.png "$UNITY_TARGET_DIR/dragon5.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Goblins" -cp -f ../goblins/export/goblins-pro.json "$UNITY_TARGET_DIR/goblins.json" -cp -f ../goblins/export/goblins-pma.atlas "$UNITY_TARGET_DIR/goblins.atlas.txt" -$sed -i 's/goblins-pma.png/goblins.png/g' "$UNITY_TARGET_DIR/goblins.atlas.txt" -cp -f ../goblins/export/goblins-pma.png "$UNITY_TARGET_DIR/goblins.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Hero" -cp -f ../hero/export/hero-pro.json "$UNITY_TARGET_DIR/" -cp -f ../hero/export/hero-pma.atlas "$UNITY_TARGET_DIR/hero-pro.atlas.txt" -$sed -i 's/hero-pma.png/hero-pro.png/g' "$UNITY_TARGET_DIR/hero-pro.atlas.txt" -cp -f ../hero/export/hero-pma.png "$UNITY_TARGET_DIR/hero-pro.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/raptor-pro-and-mask" -cp -f ../raptor/export/raptor-pro.json "$UNITY_TARGET_DIR/raptor-pro.json" -cp -f ../raptor/export/raptor-pma.atlas "$UNITY_TARGET_DIR/raptor-pma.atlas.txt" -cp -f ../raptor/export/raptor-pma.png "$UNITY_TARGET_DIR/raptor-pma.png" - -# URP packages -UNITY_TARGET_DIR="$ROOT/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Samples~/Examples/2D/Spine Skeletons/RaptorURP" -cp -f ../raptor/export/raptor-pro.json "$UNITY_TARGET_DIR/" -cp -f ../raptor/manual-maps/raptor.atlas "$UNITY_TARGET_DIR/raptor.atlas.txt" -cp -f ../raptor/manual-maps/raptor.png "$UNITY_TARGET_DIR/" -cp -f ../raptor/manual-maps/raptor-rim-mask.png "$UNITY_TARGET_DIR/" -UNITY_TARGET_DIR="$ROOT/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Samples~/Examples/3D/Spine Skeletons/RaptorURP" -cp -f ../raptor/export/raptor-pro.json "$UNITY_TARGET_DIR/" -cp -f ../raptor/export/raptor.atlas "$UNITY_TARGET_DIR/raptor.atlas.txt" -cp -f ../raptor/export/raptor.png "$UNITY_TARGET_DIR/" -UNITY_TARGET_DIR="$ROOT/spine-unity/Modules/com.esotericsoftware.spine.ui-toolkit/Samples~/Examples/Spine Skeletons/Raptor" -cp -f ../raptor/export/raptor-pro.json "$UNITY_TARGET_DIR/" -cp -f ../raptor/export/raptor.atlas "$UNITY_TARGET_DIR/raptor.atlas.txt" -cp -f ../raptor/export/raptor.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/spineboy-pro" -cp -f ../spineboy/export/spineboy-pro.json "$UNITY_TARGET_DIR/spineboy-pro.json" -cp -f ../spineboy/export/spineboy-pma.atlas "$UNITY_TARGET_DIR/spineboy-pro.atlas.txt" -$sed -i 's/spineboy-pma.png/spineboy-pro.png/g' "$UNITY_TARGET_DIR/spineboy-pro.atlas.txt" -cp -f ../spineboy/export/spineboy-pma.png "$UNITY_TARGET_DIR/spineboy-pro.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/mix-and-match" -cp -f ../mix-and-match/export/mix-and-match-pro.json "$UNITY_TARGET_DIR/" -cp -f ../mix-and-match/export/mix-and-match-pma.atlas "$UNITY_TARGET_DIR/mix-and-match-pma.atlas.txt" -cp -f ../mix-and-match/export/mix-and-match-pma.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Stretchyman" -cp -f ../stretchyman/export/stretchyman-pro.json "$UNITY_TARGET_DIR/stretchyman.json" -# Note: normalmap and emissionmap need to be created manually. Thus we use a separately prepared -# atlas and diffuse map here so that the maps always match. These atlas textures are copied to the target dir. -cp -f ../stretchyman/manual-maps/stretchyman-pma.atlas "$UNITY_TARGET_DIR/stretchyman-diffuse-pma.atlas.txt" -$sed -i 's/stretchyman-pma.png/stretchyman-diffuse-pma.png/g' "$UNITY_TARGET_DIR/stretchyman-diffuse-pma.atlas.txt" -cp -f ../stretchyman/manual-maps/stretchyman-pma.png "$UNITY_TARGET_DIR/stretchyman-diffuse-pma.png" -cp -f ../stretchyman/manual-maps/stretchyman-normals.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-emission.png "$UNITY_TARGET_DIR/" - -# URP packages -UNITY_TARGET_DIR="$ROOT/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Samples~/Examples/2D/Spine Skeletons/StretchymanURP" -cp -f ../stretchyman/export/stretchyman-pro.json "$UNITY_TARGET_DIR/stretchyman.json" -cp -f ../stretchyman/manual-maps/stretchyman.atlas "$UNITY_TARGET_DIR/stretchyman.atlas.txt" -cp -f ../stretchyman/manual-maps/stretchyman.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-normals.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-emission.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-rim-mask.png "$UNITY_TARGET_DIR/" -UNITY_TARGET_DIR="$ROOT/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Samples~/Examples/3D/Spine Skeletons/StretchymanURP" -cp -f ../stretchyman/export/stretchyman-pro.json "$UNITY_TARGET_DIR/stretchyman.json" -cp -f ../stretchyman/manual-maps/stretchyman.atlas "$UNITY_TARGET_DIR/stretchyman.atlas.txt" -cp -f ../stretchyman/manual-maps/stretchyman.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-normals.png "$UNITY_TARGET_DIR/" -cp -f ../stretchyman/manual-maps/stretchyman-emission.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Eyes" -cp -f $UNITY_SOURCE_DIR/eyes/export/eyes.json "$UNITY_TARGET_DIR/eyes.json" -cp -f $UNITY_SOURCE_DIR/eyes/export/eyes-pma.atlas "$UNITY_TARGET_DIR/eyes.atlas.txt" -$sed -i 's/eyes-pma.png/eyes.png/g' "$UNITY_TARGET_DIR/eyes.atlas.txt" -cp -f $UNITY_SOURCE_DIR/eyes/export/eyes-pma.png "$UNITY_TARGET_DIR/eyes.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/FootSoldier" -cp -f $UNITY_SOURCE_DIR/footsoldier/export/footsoldier.json "$UNITY_TARGET_DIR/FootSoldier.json" -cp -f $UNITY_SOURCE_DIR/footsoldier/export/footsoldier-pma.atlas "$UNITY_TARGET_DIR/FS_White.atlas.txt" -$sed -i 's/footsoldier-pma.png/FS_White.png/g' "$UNITY_TARGET_DIR/FS_White.atlas.txt" -cp -f $UNITY_SOURCE_DIR/footsoldier/export/footsoldier-pma.png "$UNITY_TARGET_DIR/FS_White.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Gauge" -cp -f $UNITY_SOURCE_DIR/gauge/export/gauge.json "$UNITY_TARGET_DIR/Gauge.json" -cp -f $UNITY_SOURCE_DIR/gauge/export/gauge-pma.atlas "$UNITY_TARGET_DIR/Gauge.atlas.txt" -$sed -i 's/gauge-pma.png/Gauge.png/g' "$UNITY_TARGET_DIR/Gauge.atlas.txt" -cp -f $UNITY_SOURCE_DIR/gauge/export/gauge-pma.png "$UNITY_TARGET_DIR/Gauge.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Raptor" -cp -f $UNITY_SOURCE_DIR/raptor/export/raptor.json "$UNITY_TARGET_DIR/raptor.json" -cp -f $UNITY_SOURCE_DIR/raptor/export/raptor-pma.atlas "$UNITY_TARGET_DIR/raptor.atlas.txt" -$sed -i 's/raptor-pma.png/raptor.png/g' "$UNITY_TARGET_DIR/raptor.atlas.txt" -cp -f $UNITY_SOURCE_DIR/raptor/export/raptor-pma.png "$UNITY_TARGET_DIR/raptor.png" - - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Raggedy Spineboy" -cp -f $UNITY_SOURCE_DIR/raggedyspineboy/export/raggedyspineboy.json "$UNITY_TARGET_DIR/raggedy spineboy.json" -cp -f $UNITY_SOURCE_DIR/raggedyspineboy/export/raggedyspineboy-pma.atlas "$UNITY_TARGET_DIR/Raggedy Spineboy.atlas.txt" -$sed -i 's/raggedyspineboy-pma.png/Raggedy Spineboy.png/g' "$UNITY_TARGET_DIR/Raggedy Spineboy.atlas.txt" -cp -f $UNITY_SOURCE_DIR/raggedyspineboy/export/raggedyspineboy-pma.png "$UNITY_TARGET_DIR/Raggedy Spineboy.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/spineboy-pro" -cp -f $UNITY_SOURCE_DIR/spineboy-pro/export/spineboy-pro.json "$UNITY_TARGET_DIR/spineboy-pro.json" -cp -f $UNITY_SOURCE_DIR/spineboy-pro/export/spineboy-pma.atlas "$UNITY_TARGET_DIR/spineboy-pro.atlas.txt" -$sed -i 's/spineboy-pma.png/spineboy-pro.png/g' "$UNITY_TARGET_DIR/spineboy-pro.atlas.txt" -cp -f $UNITY_SOURCE_DIR/spineboy-pro/export/spineboy-pma.png "$UNITY_TARGET_DIR/spineboy-pro.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/spineboy-unity" -cp -f $UNITY_SOURCE_DIR/spineboy-unity/export/spineboy-unity.json "$UNITY_TARGET_DIR/spineboy-unity.json" -cp -f $UNITY_SOURCE_DIR/spineboy-unity/export/spineboy-pma.atlas "$UNITY_TARGET_DIR/spineboy.atlas.txt" -$sed -i 's/spineboy-pma.png/spineboy.png/g' "$UNITY_TARGET_DIR/spineboy.atlas.txt" -cp -f $UNITY_SOURCE_DIR/spineboy-unity/export/spineboy-pma.png "$UNITY_TARGET_DIR/spineboy.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Spineunitygirl" -cp -f $UNITY_SOURCE_DIR/spineunitygirl/export/doi.json "$UNITY_TARGET_DIR/Doi.json" -cp -f $UNITY_SOURCE_DIR/spineunitygirl/export/doi-pma.atlas "$UNITY_TARGET_DIR/Doi.atlas.txt" -$sed -i 's/doi-pma.png/Doi.png/g' "$UNITY_TARGET_DIR/Doi.atlas.txt" -cp -f $UNITY_SOURCE_DIR/spineunitygirl/export/doi-pma.png "$UNITY_TARGET_DIR/Doi.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/Whirlyblendmodes" -cp -f $UNITY_SOURCE_DIR/whirlyblendmodes/export/whirlyblendmodes.json "$UNITY_TARGET_DIR/whirlyblendmodes.json" -cp -f $UNITY_SOURCE_DIR/whirlyblendmodes/export/whirlyblendmodes-pma.atlas "$UNITY_TARGET_DIR/whirlyblendmodes.atlas.txt" -$sed -i 's/whirlyblendmodes-pma.png/whirlyblendmodes.png/g' "$UNITY_TARGET_DIR/whirlyblendmodes.atlas.txt" -cp -f $UNITY_SOURCE_DIR/whirlyblendmodes/export/whirlyblendmodes-pma.png "$UNITY_TARGET_DIR/whirlyblendmodes.png" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/celestial-circus" -cp -f ../celestial-circus/export/celestial-circus-pro.json "$UNITY_TARGET_DIR/" -cp -f ../celestial-circus/export/celestial-circus-pma.atlas "$UNITY_TARGET_DIR/celestial-circus-pma.atlas.txt" -cp -f ../celestial-circus/export/celestial-circus-pma*.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/snowglobe" -cp -f ../snowglobe/export/snowglobe-pro.skel "$UNITY_TARGET_DIR/snowglobe-pro.skel.bytes" -cp -f ../snowglobe/export/snowglobe-pma.atlas "$UNITY_TARGET_DIR/snowglobe-pma.atlas.txt" -cp -f ../snowglobe/export/snowglobe-pma*.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/cloud-pot" -cp -f ../cloud-pot/export/cloud-pot.skel "$UNITY_TARGET_DIR/cloud-pot.skel.bytes" -cp -f ../cloud-pot/export/cloud-pot-pma.atlas "$UNITY_TARGET_DIR/cloud-pot-pma.atlas.txt" -cp -f ../cloud-pot/export/cloud-pot-pma.png "$UNITY_TARGET_DIR/" - -UNITY_TARGET_DIR="$ROOT/spine-unity/Assets/Spine Examples/Spine Skeletons/sack" -cp -f ../sack/export/sack-pro.skel "$UNITY_TARGET_DIR/sack-pro.skel.bytes" -cp -f ../sack/export/sack-pma.atlas "$UNITY_TARGET_DIR/sack-pma.atlas.txt" -cp -f ../sack/export/sack-pma.png "$UNITY_TARGET_DIR/" - echo "--" echo "Note regarding spine-xna and spine-unity:" echo "Some textures (normalmap, emission, rim-mask) need manual update." diff --git a/spine-haxe/example/src/flixelExamples/ControlBonesExample.hx b/spine-haxe/example/src/flixelExamples/ControlBonesExample.hx index b69119acb..19a5a1171 100644 --- a/spine-haxe/example/src/flixelExamples/ControlBonesExample.hx +++ b/spine-haxe/example/src/flixelExamples/ControlBonesExample.hx @@ -80,7 +80,7 @@ class ControlBonesExample extends FlxState { var radius = 6; for (boneName in controlBoneNames) { var bone = skeletonSprite.skeleton.findBone(boneName); - var point = [bone.worldX, bone.worldY]; + var point = [bone.applied.worldX, bone.applied.worldY]; skeletonSprite.skeletonToHaxeWorldCoordinates(point); var control = new FlxSprite(); control.makeGraphic(radius * 2, radius * 2, FlxColor.TRANSPARENT, true); @@ -99,8 +99,8 @@ class ControlBonesExample extends FlxState { point[0] = control.x + radius; point[1] = control.y + radius; go.haxeWorldCoordinatesToBone(point, bone); - bone.x = point[0]; - bone.y = point[1]; + bone.pose.x = point[0]; + bone.pose.y = point[1]; } }; diff --git a/spine-haxe/example/src/flixelExamples/EventsExample.hx b/spine-haxe/example/src/flixelExamples/EventsExample.hx index c68fea0d9..9d57e0cad 100644 --- a/spine-haxe/example/src/flixelExamples/EventsExample.hx +++ b/spine-haxe/example/src/flixelExamples/EventsExample.hx @@ -73,7 +73,7 @@ class EventsExample extends FlxState { skeletonSprite.setBoundingBox(); skeletonSprite.screenCenter(); - skeletonSprite.skeleton.setBonesToSetupPose(); + skeletonSprite.skeleton.setupPoseBones(); add(skeletonSprite); trackEntry.onEvent.add( diff --git a/spine-haxe/example/src/flixelExamples/FlixelState.hx b/spine-haxe/example/src/flixelExamples/FlixelState.hx index bd275ee47..9d0215c94 100644 --- a/spine-haxe/example/src/flixelExamples/FlixelState.hx +++ b/spine-haxe/example/src/flixelExamples/FlixelState.hx @@ -141,11 +141,11 @@ class FlixelState extends FlxState var diff = .0; spineSprite.afterUpdateWorldTransforms = spineSprite -> { if (jumping) { - diff -= hip.y; + diff -= hip.pose.y; spineSprite.offsetY -= diff; spineSprite.y += diff; } - diff = hip.y; + diff = hip.pose.y; } // adding spineboy to the stage diff --git a/spine-haxe/example/src/starlingExamples/ControlBonesExample.hx b/spine-haxe/example/src/starlingExamples/ControlBonesExample.hx index 9b787b90c..a1539b799 100644 --- a/spine-haxe/example/src/starlingExamples/ControlBonesExample.hx +++ b/spine-haxe/example/src/starlingExamples/ControlBonesExample.hx @@ -80,7 +80,7 @@ class ControlBonesExample extends Scene { for (boneName in controlBoneNames) { var bone = skeletonSprite.skeleton.findBone(boneName); - var point = [bone.worldX, bone.worldY]; + var point = [bone.applied.worldX, bone.applied.worldY]; skeletonSprite.skeletonToHaxeWorldCoordinates(point); var control:Canvas = new Canvas(); @@ -104,8 +104,8 @@ class ControlBonesExample extends Scene { point[0] = control.x; point[1] = control.y; go.haxeWorldCoordinatesToBone(point, bone); - bone.x = point[0]; - bone.y = point[1]; + bone.pose.x = point[0]; + bone.pose.y = point[1]; } }; diff --git a/spine-haxe/spine-haxe/spine/Color.hx b/spine-haxe/spine-haxe/spine/Color.hx index da8b11f8f..dc8d47683 100644 --- a/spine-haxe/spine-haxe/spine/Color.hx +++ b/spine-haxe/spine-haxe/spine/Color.hx @@ -87,19 +87,21 @@ class Color { return this; } - public function setFromRgba8888(value:Int):Void { + public function setFromRgba8888(value:Int):Color { r = ((value & 0xff000000) >>> 24) / 255; g = ((value & 0x00ff0000) >>> 16) / 255; b = ((value & 0x0000ff00) >>> 8) / 255; a = ((value & 0x000000ff)) / 255; clamp(); + return this; } - public function setFromRgb888(value:Int):Void { + public function setFromRgb888(value:Int):Color { r = ((value & 0x00ff0000) >>> 16) / 255; g = ((value & 0x0000ff00) >>> 8) / 255; b = ((value & 0x000000ff)) / 255; clamp(); + return this; } private function clamp():Color { diff --git a/spine-haxe/spine-haxe/spine/Event.hx b/spine-haxe/spine-haxe/spine/Event.hx index 7744abe26..48a8ee7a1 100644 --- a/spine-haxe/spine-haxe/spine/Event.hx +++ b/spine-haxe/spine-haxe/spine/Event.hx @@ -44,7 +44,7 @@ class Event { public var time = 0.; public var intValue = 0; - public var floatValue = 0; + public var floatValue = 0.; public var stringValue:String; public var volume = 1.; public var balance = 0.; diff --git a/spine-haxe/spine-haxe/spine/PathConstraint.hx b/spine-haxe/spine-haxe/spine/PathConstraint.hx index 0c58822a9..92868fc24 100644 --- a/spine-haxe/spine-haxe/spine/PathConstraint.hx +++ b/spine-haxe/spine-haxe/spine/PathConstraint.hx @@ -207,7 +207,7 @@ class PathConstraint extends Constraint { var position = applied.position; ArrayUtils.resize(positions, spacesCount * 3 + 2, 0); - var out:Array = positions, world:Array; + var out:Array = positions, world = new Array(); var closed = path.closed; var verticesLength = path.worldVerticesLength, curveCount = Std.int(verticesLength / 6), prevCurve = NONE; diff --git a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx index 00489902e..8c636e11f 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx @@ -29,13 +29,16 @@ package spine; +import spine.animation.SliderMixTimeline; +import spine.animation.SliderTimeline; +import spine.TransformConstraintData; import haxe.io.Bytes; import StringTools; import spine.animation.AlphaTimeline; import spine.animation.Animation; import spine.animation.AttachmentTimeline; +import spine.animation.BoneTimeline2; import spine.animation.CurveTimeline1; -import spine.animation.CurveTimeline2; import spine.animation.CurveTimeline; import spine.animation.DeformTimeline; import spine.animation.DrawOrderTimeline; @@ -113,6 +116,12 @@ class SkeletonBinary { private static inline var SLOT_RGB2:Int = 4; private static inline var SLOT_ALPHA:Int = 5; + private static inline var CONSTRAINT_IK = 0; + private static inline var CONSTRAINT_PATH = 1; + private static inline var CONSTRAINT_TRANSFORM = 2; + private static inline var CONSTRAINT_PHYSICS = 3; + private static inline var CONSTRAINT_SLIDER = 4; + private static inline var ATTACHMENT_DEFORM = 0; private static inline var ATTACHMENT_SEQUENCE = 1; @@ -129,6 +138,9 @@ class SkeletonBinary { private static inline var PHYSICS_MIX:Int = 7; private static inline var PHYSICS_RESET:Int = 8; + private static inline var SLIDER_TIME = 0; + private static inline var SLIDER_MIX = 1; + private static inline var CURVE_LINEAR:Int = 0; private static inline var CURVE_STEPPED:Int = 1; private static inline var CURVE_BEZIER:Int = 2; @@ -172,161 +184,225 @@ class SkeletonBinary { } // Bones. + var bones = skeletonData.bones; n = input.readInt(true); for (i in 0...n) { - var boneName:String = input.readString(); - var boneParent:BoneData = i == 0 ? null : skeletonData.bones[input.readInt(true)]; - var boneData:BoneData = new BoneData(i, boneName, boneParent); - boneData.rotation = input.readFloat(); - boneData.x = input.readFloat() * scale; - boneData.y = input.readFloat() * scale; - boneData.scaleX = input.readFloat(); - boneData.scaleY = input.readFloat(); - boneData.shearX = input.readFloat(); - boneData.shearY = input.readFloat(); - boneData.length = input.readFloat() * scale; - boneData.inherit = Inherit.values[input.readInt(true)]; - boneData.skinRequired = input.readBoolean(); + var boneName = input.readString(); + var boneParent:BoneData = i == 0 ? null : bones[input.readInt(true)]; + var data = new BoneData(i, boneName, boneParent); + var setup = data.setup; + setup.rotation = input.readFloat(); + setup.x = input.readFloat() * scale; + setup.y = input.readFloat() * scale; + setup.scaleX = input.readFloat(); + setup.scaleY = input.readFloat(); + setup.shearX = input.readFloat(); + setup.shearY = input.readFloat(); + setup.inherit = Inherit.values[input.readInt(true)]; + data.length = input.readFloat() * scale; + data.skinRequired = input.readBoolean(); if (nonessential) { - boneData.color.setFromRgba8888(input.readInt32()); - boneData.icon = input.readString(); - boneData.visible = input.readBoolean(); + data.color.setFromRgba8888(input.readInt32()); + data.icon = input.readString(); + data.visible = input.readBoolean(); } - skeletonData.bones.push(boneData); + bones.push(data); } // Slots. + var slots = skeletonData.slots; n = input.readInt(true); for (i in 0...n) { - var slotName:String = input.readString(); + var slotName = input.readString(); - var slotBoneData:BoneData = skeletonData.bones[input.readInt(true)]; - var slotData:SlotData = new SlotData(i, slotName, slotBoneData); - slotData.color.setFromRgba8888(input.readInt32()); + var boneData = bones[input.readInt(true)]; + var data = new SlotData(i, slotName, boneData); + data.setup.color.setFromRgba8888(input.readInt32()); - var darkColor:Int = input.readInt32(); - if (darkColor != -1) { - slotData.darkColor = new Color(0, 0, 0); - slotData.darkColor.setFromRgb888(darkColor); + var darkColor = input.readInt32(); + if (darkColor != -1) data.setup.darkColor = new Color(0, 0, 0).setFromRgb888(darkColor); + + data.attachmentName = input.readStringRef(); + data.blendMode = BlendMode.values[input.readInt(true)]; + if (nonessential) data.visible = input.readBoolean(); + slots.push(data); + } + + // Constraints. + var constraintCount = input.readInt(true); + var constraints = skeletonData.constraints; + for (i in 0...constraintCount) { + var name = input.readString(); + var nn = input.readInt(true); + switch (input.readByte()) { + case CONSTRAINT_IK: + var data = new IkConstraintData(name); + var constraintBones = data.bones; + for (ii in 0...nn) + constraintBones.push(bones[input.readInt(true)]); + data.target = bones[input.readInt(true)]; + var flags = input.readByte(); + data.skinRequired = (flags & 1) != 0; + data.uniform = (flags & 2) != 0; + var setup = data.setup; + setup.bendDirection = (flags & 4) != 0 ? 1 : -1; + setup.compress = (flags & 8) != 0; + setup.stretch = (flags & 16) != 0; + if ((flags & 32) != 0) setup.mix = (flags & 64) != 0 ? input.readFloat() : 1; + if ((flags & 128) != 0) setup.softness = input.readFloat() * scale; + constraints[i] = data; + case CONSTRAINT_TRANSFORM: + var data = new TransformConstraintData(name); + var constraintBones = data.bones; + for (ii in 0...nn) + constraintBones.push(bones[input.readInt(true)]); + data.source = bones[input.readInt(true)]; + var flags = input.readByte(); + data.skinRequired = (flags & 1) != 0; + data.localSource = (flags & 2) != 0; + data.localTarget = (flags & 4) != 0; + data.additive = (flags & 8) != 0; + data.clamp = (flags & 16) != 0; + var froms = data.properties; + for (ii in 0...nn) { + var fromScale = 1.; + var from:FromProperty; + switch (input.readByte()) { + case 0: from = new FromRotate(); + case 1: + fromScale = scale; + from = new FromX(); + case 2: + fromScale = scale; + from = new FromY(); + case 3: from = new FromScaleX(); + case 4: from = new FromScaleY(); + case 5: from = new FromShearY(); + default: from = null; + } + from.offset = input.readFloat() * fromScale; + var tn = input.readByte(); + var tos = from.to; + for (t in 0...tn) { + var toScale = 1.; + var to:ToProperty; + switch (input.readByte()) { + case 0: to = new ToRotate(); + case 1: + toScale = scale; + to = new ToX(); + case 2: + toScale = scale; + to = new ToY(); + case 3: to = new ToScaleX(); + case 4: to = new ToScaleY(); + case 5: to = new ToShearY(); + default: to = null; + } + to.offset = input.readFloat() * toScale; + to.max = input.readFloat() * toScale; + to.scale = input.readFloat() * toScale / fromScale; + tos[t] = to; + } + froms[ii] = from; + } + flags = input.readByte(); + if ((flags & 1) != 0) data.offsets[0] = input.readFloat(); + if ((flags & 2) != 0) data.offsets[1] = input.readFloat() * scale; + if ((flags & 4) != 0) data.offsets[2] = input.readFloat() * scale; + if ((flags & 8) != 0) data.offsets[3] = input.readFloat(); + if ((flags & 16) != 0) data.offsets[4] = input.readFloat(); + if ((flags & 32) != 0) data.offsets[5] = input.readFloat(); + flags = input.readByte(); + var setup = data.setup; + if ((flags & 1) != 0) setup.mixRotate = input.readFloat(); + if ((flags & 2) != 0) setup.mixX = input.readFloat(); + if ((flags & 4) != 0) setup.mixY = input.readFloat(); + if ((flags & 8) != 0) setup.mixScaleX = input.readFloat(); + if ((flags & 16) != 0) setup.mixScaleY = input.readFloat(); + if ((flags & 32) != 0) setup.mixShearY = input.readFloat(); + constraints[i] = data; + case CONSTRAINT_PATH: + var data = new PathConstraintData(name); + var constraintBones = data.bones; + for (ii in 0...nn) + constraintBones[ii] = bones[input.readInt(true)]; + data.slot = slots[input.readInt(true)]; + var flags = input.readByte(); + data.skinRequired = (flags & 1) != 0; + data.positionMode = PositionMode.values[(flags >> 1) & 2]; + data.spacingMode = SpacingMode.values[(flags >> 2) & 3]; + data.rotateMode = RotateMode.values[(flags >> 4) & 3]; + if ((flags & 128) != 0) data.offsetRotation = input.readFloat(); + var setup = data.setup; + setup.position = input.readFloat(); + if (data.positionMode == PositionMode.fixed) setup.position *= scale; + setup.spacing = input.readFloat(); + if (data.spacingMode == SpacingMode.length || data.spacingMode == SpacingMode.fixed) setup.spacing *= scale; + setup.mixRotate = input.readFloat(); + setup.mixX = input.readFloat(); + setup.mixY = input.readFloat(); + constraints[i] = data; + case CONSTRAINT_PHYSICS: + var data = new PhysicsConstraintData(name); + data.bone = bones[nn]; + var flags = input.readByte(); + data.skinRequired = (flags & 1) != 0; + if ((flags & 2) != 0) data.x = input.readFloat(); + if ((flags & 4) != 0) data.y = input.readFloat(); + if ((flags & 8) != 0) data.rotate = input.readFloat(); + if ((flags & 16) != 0) data.scaleX = input.readFloat(); + if ((flags & 32) != 0) data.shearX = input.readFloat(); + data.limit = ((flags & 64) != 0 ? input.readFloat() : 5000) * scale; + data.step = .1 / input.readUnsignedByte(); + var setup = data.setup; + setup.inertia = input.readFloat(); + setup.strength = input.readFloat(); + setup.damping = input.readFloat(); + setup.massInverse = (flags & 128) != 0 ? input.readFloat() : 1; + setup.wind = input.readFloat(); + setup.gravity = input.readFloat(); + flags = input.readByte(); + if ((flags & 1) != 0) data.inertiaGlobal = true; + if ((flags & 2) != 0) data.strengthGlobal = true; + if ((flags & 4) != 0) data.dampingGlobal = true; + if ((flags & 8) != 0) data.massGlobal = true; + if ((flags & 16) != 0) data.windGlobal = true; + if ((flags & 32) != 0) data.gravityGlobal = true; + if ((flags & 64) != 0) data.mixGlobal = true; + setup.mix = (flags & 128) != 0 ? input.readFloat() : 1; + constraints[i] = data; + case CONSTRAINT_SLIDER: + var data = new SliderData(name); + data.skinRequired = (nn & 1) != 0; + data.loop = (nn & 2) != 0; + data.additive = (nn & 4) != 0; + if ((nn & 8) != 0) data.setup.time = input.readFloat(); + if ((nn & 16) != 0) data.setup.mix = (nn & 32) != 0 ? input.readFloat() : 1; + if ((nn & 64) != 0) { + data.local = (nn & 128) != 0; + data.bone = bones[input.readInt(true)]; + var offset = input.readFloat(); + switch (input.readByte()) { + case 0: data.property = new FromRotate(); + case 1: + offset *= scale; + data.property = new FromX(); + case 2: + offset *= scale; + data.property = new FromY(); + case 3: data.property = new FromScaleX(); + case 4: data.property = new FromScaleY(); + case 5: data.property = new FromShearY(); + default: data.property = null; + } + data.property.offset = offset; + data.scale = input.readFloat(); + } + constraints[i] = data; } - - slotData.attachmentName = input.readStringRef(); - slotData.blendMode = BlendMode.values[input.readInt(true)]; - if (nonessential) slotData.visible = input.readBoolean(); - skeletonData.slots.push(slotData); } - // IK constraints. - n = input.readInt(true); - for (i in 0...n) { - var ikData:IkConstraintData = new IkConstraintData(input.readString()); - ikData.order = input.readInt(true); - nn = input.readInt(true); - for (ii in 0...nn) { - ikData.bones.push(skeletonData.bones[input.readInt(true)]); - } - ikData.target = skeletonData.bones[input.readInt(true)]; - var flags = input.readByte(); - ikData.skinRequired = (flags & 1) != 0; - ikData.bendDirection = (flags & 2) != 0 ? 1 : -1; - ikData.compress = (flags & 4) != 0; - ikData.stretch = (flags & 8) != 0; - ikData.uniform = (flags & 16) != 0; - if ((flags & 32) != 0) ikData.mix = (flags & 64) != 0 ? input.readFloat() : 1; - if ((flags & 128) != 0) ikData.softness = input.readFloat() * scale; - skeletonData.ikConstraints.push(ikData); - } - - // Transform constraints. - n = input.readInt(true); - for (i in 0...n) { - var transformData:TransformConstraintData = new TransformConstraintData(input.readString()); - transformData.order = input.readInt(true); - nn = input.readInt(true); - for (ii in 0...nn) { - transformData.bones.push(skeletonData.bones[input.readInt(true)]); - } - transformData.target = skeletonData.bones[input.readInt(true)]; - var flags = input.readByte(); - transformData.skinRequired = (flags & 1) != 0; - transformData.local = (flags & 2) != 0; - transformData.relative = (flags & 4) != 0; - if ((flags & 8) != 0) transformData.offsetRotation = input.readFloat(); - if ((flags & 16) != 0) transformData.offsetX = input.readFloat() * scale; - if ((flags & 32) != 0) transformData.offsetY = input.readFloat() * scale; - if ((flags & 64) != 0) transformData.offsetScaleX = input.readFloat(); - if ((flags & 128) != 0) transformData.offsetScaleY = input.readFloat(); - flags = input.readByte(); - if ((flags & 1) != 0) transformData.offsetShearY = input.readFloat(); - if ((flags & 2) != 0) transformData.mixRotate = input.readFloat(); - if ((flags & 4) != 0) transformData.mixX = input.readFloat(); - if ((flags & 8) != 0) transformData.mixY = input.readFloat(); - if ((flags & 16) != 0) transformData.mixScaleX = input.readFloat(); - if ((flags & 32) != 0) transformData.mixScaleY = input.readFloat(); - if ((flags & 64) != 0) transformData.mixShearY = input.readFloat(); - skeletonData.transformConstraints.push(transformData); - } - - // Path constraints. - n = input.readInt(true); - for (i in 0...n) { - var pathData:PathConstraintData = new PathConstraintData(input.readString()); - pathData.order = input.readInt(true); - pathData.skinRequired = input.readBoolean(); - nn = input.readInt(true); - for (ii in 0...nn) { - pathData.bones.push(skeletonData.bones[input.readInt(true)]); - } - pathData.target = skeletonData.slots[input.readInt(true)]; - var flags = input.readByte(); - pathData.positionMode = PositionMode.values[flags & 1]; - pathData.spacingMode = SpacingMode.values[(flags >> 1) & 3]; - pathData.rotateMode = RotateMode.values[(flags >> 3) & 3]; - if ((flags & 128) != 0) pathData.offsetRotation = input.readFloat(); - pathData.position = input.readFloat(); - if (pathData.positionMode == PositionMode.fixed) - pathData.position *= scale; - pathData.spacing = input.readFloat(); - if (pathData.spacingMode == SpacingMode.length || pathData.spacingMode == SpacingMode.fixed) - pathData.spacing *= scale; - pathData.mixRotate = input.readFloat(); - pathData.mixX = input.readFloat(); - pathData.mixY = input.readFloat(); - skeletonData.pathConstraints.push(pathData); - } - - // Physics constraints. - n = input.readInt(true); - for (i in 0...n) { - var physicsData:PhysicsConstraintData = new PhysicsConstraintData(input.readString()); - physicsData.order = input.readInt(true); - physicsData.bone = skeletonData.bones[input.readInt(true)]; - var flags = input.readByte(); - physicsData.skinRequired = (flags & 1) != 0; - if ((flags & 2) != 0) physicsData.x = input.readFloat(); - if ((flags & 4) != 0) physicsData.y = input.readFloat(); - if ((flags & 8) != 0) physicsData.rotate = input.readFloat(); - if ((flags & 16) != 0) physicsData.scaleX = input.readFloat(); - if ((flags & 32) != 0) physicsData.shearX = input.readFloat(); - physicsData.limit = ((flags & 64) != 0 ? input.readFloat() : 5000) * scale; - physicsData.step = 1 / input.readUnsignedByte(); - physicsData.inertia = input.readFloat(); - physicsData.strength = input.readFloat(); - physicsData.damping = input.readFloat(); - physicsData.massInverse = (flags & 128) != 0 ? input.readFloat() : 1; - physicsData.wind = input.readFloat(); - physicsData.gravity = input.readFloat(); - flags = input.readByte(); - if ((flags & 1) != 0) physicsData.inertiaGlobal = true; - if ((flags & 2) != 0) physicsData.strengthGlobal = true; - if ((flags & 4) != 0) physicsData.dampingGlobal = true; - if ((flags & 8) != 0) physicsData.massGlobal = true; - if ((flags & 16) != 0) physicsData.windGlobal = true; - if ((flags & 32) != 0) physicsData.gravityGlobal = true; - if ((flags & 64) != 0) physicsData.mixGlobal = true; - physicsData.mix = (flags & 128) != 0 ? input.readFloat() : 1; - skeletonData.physicsConstraints.push(physicsData); - } // Default skin. var defaultSkin:Skin = readSkin(input, skeletonData, true, nonessential); @@ -374,16 +450,22 @@ class SkeletonBinary { } // Animations. + var animations = skeletonData.animations; n = input.readInt(true); - for (i in 0...n) { - skeletonData.animations.push(readAnimation(input, input.readString(), skeletonData)); - } + for (i in 0...n) + animations[i] = readAnimation(input, input.readString(), skeletonData); + + for (i in 0...constraintCount) + if (Std.isOfType(constraints[i], SliderData)){ + var data = cast(constraints[i], SliderData); + data.animation = animations[input.readInt(true)]; + }; return skeletonData; } private function readSkin(input:BinaryInput, skeletonData:SkeletonData, defaultSkin:Bool, nonessential:Bool):Skin { var skin:Skin = null; - var slotCount:Int = 0; + var slotCount = 0; if (defaultSkin) { slotCount = input.readInt(true); @@ -392,24 +474,21 @@ class SkeletonBinary { skin = new Skin("default"); } else { skin = new Skin(input.readString()); - if (nonessential) skin.color.setFromRgba8888(input.readInt32()); - skin.bones.resize(input.readInt(true)); - for (i in 0...skin.bones.length) { - skin.bones[i] = skeletonData.bones[input.readInt(true)]; - } - for (i in 0...input.readInt(true)) { - skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]); - } - for (i in 0...input.readInt(true)) { - skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]); - } - for (i in 0...input.readInt(true)) { - skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]); - } - for (i in 0...input.readInt(true)) { - skin.constraints.push(skeletonData.physicsConstraints[input.readInt(true)]); - } + if (nonessential) skin.color.setFromRgba8888(input.readInt32()); + + var n:Int; + var from1 = skeletonData.bones; + var to1 = skin.bones; + to1.resize(n = input.readInt(true)); + for (i in 0...n) + to1[i] = from1[input.readInt(true)]; + + var from2 = skeletonData.constraints; + var to2 = skin.constraints; + to2.resize(n = input.readInt(true)); + for (i in 0...n) + to2[i] = from2[input.readInt(true)]; slotCount = input.readInt(true); } @@ -451,9 +530,7 @@ class SkeletonBinary { var mesh:MeshAttachment; var flags = input.readByte(); - var name:String = (flags & 8) != 0 ? input.readStringRef() : attachmentName; - if (name == null) - throw new SpineException("Attachment name must not be null"); + var name = (flags & 8) != 0 ? input.readStringRef() : attachmentName; switch (AttachmentType.values[flags & 7]) { case AttachmentType.region: path = (flags & 16) != 0 ? input.readStringRef() : null; @@ -926,26 +1003,19 @@ class SkeletonBinary { } bezierCount = input.readInt(true); switch (timelineType) { - case BONE_ROTATE: - timelines.push(readTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_TRANSLATE: - timelines.push(readTimeline2(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale)); - case BONE_TRANSLATEX: - timelines.push(readTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale)); - case BONE_TRANSLATEY: - timelines.push(readTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale)); - case BONE_SCALE: - timelines.push(readTimeline2(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_SCALEX: - timelines.push(readTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_SCALEY: - timelines.push(readTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_SHEAR: - timelines.push(readTimeline2(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_SHEARX: - timelines.push(readTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1)); - case BONE_SHEARY: - timelines.push(readTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1)); + case BONE_ROTATE: readTimeline(input, timelines, new RotateTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_TRANSLATE: // + readTimeline2(input, timelines, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale); + case BONE_TRANSLATEX: // + readTimeline(input, timelines, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale); + case BONE_TRANSLATEY: // + readTimeline(input, timelines, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale); + case BONE_SCALE: readTimeline2(input, timelines, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_SCALEX: readTimeline(input, timelines, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_SCALEY: readTimeline(input, timelines, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_SHEAR: readTimeline2(input, timelines, new ShearTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_SHEARX: readTimeline(input, timelines, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1); + case BONE_SHEARY: readTimeline(input, timelines, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1); } } } @@ -1018,8 +1088,7 @@ class SkeletonBinary { mixScaleY2:Float = input.readFloat(), mixShearY2:Float = input.readFloat(); switch (input.readByte()) { - case CURVE_STEPPED: - transformTimeline.setStepped(frame); + case CURVE_STEPPED: transformTimeline.setStepped(frame); case CURVE_BEZIER: setBezier(input, transformTimeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); setBezier(input, transformTimeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); @@ -1045,17 +1114,17 @@ class SkeletonBinary { // Path constraint timelines. for (i in 0...input.readInt(true)) { index = input.readInt(true); - var data:PathConstraintData = skeletonData.pathConstraints[index]; + var data = cast(skeletonData.constraints[index], PathConstraintData); for (ii in 0...input.readInt(true)) { var type:Int = input.readByte(), frameCount:Int = input.readInt(true), bezierCount:Int = input.readInt(true); switch (type) { case PATH_POSITION: - timelines.push(readTimeline(input, new PathConstraintPositionTimeline(frameCount, bezierCount, index), - data.positionMode == PositionMode.fixed ? scale : 1)); + readTimeline(input, timelines, new PathConstraintPositionTimeline(frameCount, bezierCount, index), + data.positionMode == PositionMode.fixed ? scale : 1); case PATH_SPACING: - timelines.push(readTimeline(input, new PathConstraintSpacingTimeline(frameCount, bezierCount, index), + readTimeline(input, timelines, new PathConstraintSpacingTimeline(frameCount, bezierCount, index), data.spacingMode == SpacingMode.length - || data.spacingMode == SpacingMode.fixed ? scale : 1)); + || data.spacingMode == SpacingMode.fixed ? scale : 1); case PATH_MIX: var mixTimeline:PathConstraintMixTimeline = new PathConstraintMixTimeline(frameCount, bezierCount, index); time = input.readFloat(); @@ -1075,8 +1144,7 @@ class SkeletonBinary { mixX2 = input.readFloat(); mixY2 = input.readFloat(); switch (input.readByte()) { - case CURVE_STEPPED: - mixTimeline.setStepped(frame); + case CURVE_STEPPED: mixTimeline.setStepped(frame); case CURVE_BEZIER: setBezier(input, mixTimeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); setBezier(input, mixTimeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); @@ -1107,28 +1175,33 @@ class SkeletonBinary { continue; } var bezierCount = input.readInt(true); + var timeline:CurveTimeline1; switch (type) { - case PHYSICS_INERTIA: - timelines.push(readTimeline(input, new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_STRENGTH: - timelines.push(readTimeline(input, new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_DAMPING: - timelines.push(readTimeline(input, new PhysicsConstraintDampingTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_MASS: - timelines.push(readTimeline(input, new PhysicsConstraintMassTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_WIND: - timelines.push(readTimeline(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_GRAVITY: - timelines.push(readTimeline(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, constraintIndex), 1)); - break; - case PHYSICS_MIX: - timelines.push(readTimeline(input, new PhysicsConstraintMixTimeline(frameCount, bezierCount, constraintIndex), 1)); + case PHYSICS_INERTIA: timeline = new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_STRENGTH: timeline = new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_DAMPING: timeline = new PhysicsConstraintDampingTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_MASS: timeline = new PhysicsConstraintMassTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_WIND: timeline = new PhysicsConstraintWindTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_GRAVITY: timeline = new PhysicsConstraintGravityTimeline(frameCount, bezierCount, constraintIndex); + case PHYSICS_MIX: timeline = new PhysicsConstraintMixTimeline(frameCount, bezierCount, constraintIndex); + default: throw new SpineException("Unknown physics timeline type: " + type); } + readTimeline(input, timelines, timeline, 1); + } + } + + // Slider timelines. + for (i in 0...input.readInt(true)) { + var index = input.readInt(true); + for (ii in 0...input.readInt(true)) { + var type = input.readByte(), frameCount = input.readInt(true), bezierCount = input.readInt(true); + var timeline:CurveTimeline1; + switch (type) { + case SLIDER_TIME: timeline = new SliderTimeline(frameCount, bezierCount, index); + case SLIDER_MIX: timeline = new SliderMixTimeline(frameCount, bezierCount, index); + default: throw new SpineException("Unknown slider timeline type: " + type); + } + readTimeline(input, timelines, timeline, 1); } } @@ -1196,10 +1269,8 @@ class SkeletonBinary { break; time2 = input.readFloat(); switch (input.readByte()) { - case CURVE_STEPPED: - deformTimeline.setStepped(frame); - case CURVE_BEZIER: - SkeletonBinary.setBezier(input, deformTimeline, bezier++, frame, 0, time, time2, 0, 1, 1); + case CURVE_STEPPED: deformTimeline.setStepped(frame); + case CURVE_BEZIER: SkeletonBinary.setBezier(input, deformTimeline, bezier++, frame, 0, time, time2, 0, 1, 1); } time = time2; @@ -1284,13 +1355,12 @@ class SkeletonBinary { } var duration:Float = 0; - for (i in 0...timelines.length) { + for (i in 0...timelines.length) duration = Math.max(duration, timelines[i].getDuration()); - } return new Animation(name, timelines, duration); } - static private function readTimeline(input:BinaryInput, timeline:CurveTimeline1, scale:Float):CurveTimeline1 { + static private function readTimeline(input:BinaryInput, timelines:Array, timeline:CurveTimeline1, scale:Float) { var time:Float = input.readFloat(), value:Float = input.readFloat() * scale; @@ -1305,20 +1375,18 @@ class SkeletonBinary { var time2:Float = input.readFloat(), value2:Float = input.readFloat() * scale; switch (input.readByte()) { - case CURVE_STEPPED: - timeline.setStepped(frame); - case CURVE_BEZIER: - setBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, scale); + case CURVE_STEPPED: timeline.setStepped(frame); + case CURVE_BEZIER: setBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, scale); } time = time2; value = value2; frame++; } - return timeline; + timelines.push(timeline); } - static private function readTimeline2(input:BinaryInput, timeline:CurveTimeline2, scale:Float):CurveTimeline2 { + static private function readTimeline2(input:BinaryInput, timelines:Array, timeline:BoneTimeline2, scale:Float) { var time:Float = input.readFloat(), value1:Float = input.readFloat() * scale, value2:Float = input.readFloat() * scale; @@ -1335,8 +1403,7 @@ class SkeletonBinary { nvalue1:Float = input.readFloat() * scale, nvalue2:Float = input.readFloat() * scale; switch (input.readByte()) { - case CURVE_STEPPED: - timeline.setStepped(frame); + case CURVE_STEPPED: timeline.setStepped(frame); case CURVE_BEZIER: setBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale); setBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale); @@ -1347,7 +1414,7 @@ class SkeletonBinary { frame++; } - return timeline; + timelines.push(timeline); } static private function setBezier(input:BinaryInput, timeline:CurveTimeline, bezier:Int, frame:Int, value:Float, time1:Float, time2:Float, value1:Float, diff --git a/spine-haxe/spine-haxe/spine/SkeletonData.hx b/spine-haxe/spine-haxe/spine/SkeletonData.hx index a02fa8bdf..b3ddf133e 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonData.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonData.hx @@ -196,12 +196,12 @@ class SkeletonData { // --- Constraints. - public function findConstraint>(constraintName:String, type:Class):Null { + public function findConstraint>(constraintName:String, type:Class):T { if (constraintName == null) throw new SpineException("constraintName cannot be null."); if (type == null) throw new SpineException("type cannot be null."); for (constraint in constraints) { - if (Std.is(constraint, type) && constraint.name == constraintName) + if (Std.isOfType(constraint, type) && constraint.name == constraintName) return Std.downcast(constraint, type); } return null; diff --git a/spine-haxe/spine-haxe/spine/SkeletonJson.hx b/spine-haxe/spine-haxe/spine/SkeletonJson.hx index 7791dcfe8..ff6e94d41 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonJson.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonJson.hx @@ -29,13 +29,16 @@ package spine; +import spine.animation.BoneTimeline2; +import spine.animation.SliderMixTimeline; +import spine.animation.SliderTimeline; +import spine.TransformConstraintData; import Reflect; import haxe.Json; import spine.animation.AlphaTimeline; import spine.animation.Animation; import spine.animation.AttachmentTimeline; import spine.animation.CurveTimeline1; -import spine.animation.CurveTimeline2; import spine.animation.CurveTimeline; import spine.animation.DeformTimeline; import spine.animation.DrawOrderTimeline; @@ -52,7 +55,6 @@ import spine.animation.PhysicsConstraintMassTimeline; import spine.animation.PhysicsConstraintMixTimeline; import spine.animation.PhysicsConstraintResetTimeline; import spine.animation.PhysicsConstraintStrengthTimeline; -import spine.animation.PhysicsConstraintTimeline; import spine.animation.PhysicsConstraintWindTimeline; import spine.animation.RGB2Timeline; import spine.animation.RGBA2Timeline; @@ -116,7 +118,6 @@ class SkeletonJson { } // Bones. - var boneData:BoneData; for (boneMap in cast(Reflect.getProperty(root, "bones"), Array)) { var parent:BoneData = null; var parentName:String = Reflect.getProperty(boneMap, "parent"); @@ -125,204 +126,242 @@ class SkeletonJson { if (parent == null) throw new SpineException("Parent bone not found: " + parentName); } - boneData = new BoneData(skeletonData.bones.length, Reflect.getProperty(boneMap, "name"), parent); - boneData.length = getFloat(boneMap, "length") * scale; - boneData.x = getFloat(boneMap, "x") * scale; - boneData.y = getFloat(boneMap, "y") * scale; - boneData.rotation = getFloat(boneMap, "rotation"); - boneData.scaleX = getFloat(boneMap, "scaleX", 1); - boneData.scaleY = getFloat(boneMap, "scaleY", 1); - boneData.shearX = getFloat(boneMap, "shearX"); - boneData.shearY = getFloat(boneMap, "shearY"); - boneData.inherit = Reflect.hasField(boneMap, - "inherit") ? Inherit.fromName(Reflect.getProperty(boneMap, "inherit")) : Inherit.normal; - boneData.skinRequired = Reflect.hasField(boneMap, "skin") ? cast(Reflect.getProperty(boneMap, "skin"), Bool) : false; + var data = new BoneData(skeletonData.bones.length, Reflect.getProperty(boneMap, "name"), parent); + data.length = getFloat(boneMap, "length") * scale; + var setup = data.setup; + setup.x = getFloat(boneMap, "x") * scale; + setup.y = getFloat(boneMap, "y") * scale; + setup.rotation = getFloat(boneMap, "rotation"); + setup.scaleX = getFloat(boneMap, "scaleX", 1); + setup.scaleY = getFloat(boneMap, "scaleY", 1); + setup.shearX = getFloat(boneMap, "shearX"); + setup.shearY = getFloat(boneMap, "shearY"); + setup.inherit = Reflect.hasField(boneMap, "inherit") ? Inherit.fromName(Reflect.getProperty(boneMap, "inherit")) : Inherit.normal; + data.skinRequired = Reflect.hasField(boneMap, "skin") ? cast(Reflect.getProperty(boneMap, "skin"), Bool) : false; var color:String = Reflect.getProperty(boneMap, "color"); - if (color != null) { - boneData.color.setFromString(color); - } + if (color != null) data.color.setFromString(color); - skeletonData.bones.push(boneData); + skeletonData.bones.push(data); } // Slots. for (slotMap in cast(Reflect.getProperty(root, "slots"), Array)) { - var path:String = null; var slotName:String = Reflect.getProperty(slotMap, "name"); - var boneName:String = Reflect.getProperty(slotMap, "bone"); - boneData = skeletonData.findBone(boneName); - if (boneData == null) - throw new SpineException("Slot bone not found: " + boneName); - var slotData:SlotData = new SlotData(skeletonData.slots.length, slotName, boneData); + var boneData = skeletonData.findBone(boneName); + if (boneData == null) throw new SpineException("Slot bone not found: " + boneName); + + var data = new SlotData(skeletonData.slots.length, slotName, boneData); var color:String = Reflect.getProperty(slotMap, "color"); - if (color != null) { - slotData.color.setFromString(color); - } + if (color != null) data.setup.color.setFromString(color); var dark:String = Reflect.getProperty(slotMap, "dark"); - if (dark != null) { - slotData.darkColor = new Color(0, 0, 0); - slotData.darkColor.setFromString(dark); - } + if (dark != null) data.setup.darkColor = new Color(0, 0, 0).setFromString(dark); - slotData.attachmentName = Reflect.getProperty(slotMap, "attachment"); - slotData.blendMode = Reflect.hasField(slotMap, "blend") ? BlendMode.fromName(Reflect.getProperty(slotMap, "blend")) : BlendMode.normal; - slotData.visible = getValue(slotMap, "visible", true); - skeletonData.slots.push(slotData); + data.attachmentName = Reflect.getProperty(slotMap, "attachment"); + data.blendMode = Reflect.hasField(slotMap, "blend") ? BlendMode.fromName(Reflect.getProperty(slotMap, "blend")) : BlendMode.normal; + data.visible = getValue(slotMap, "visible", true); + skeletonData.slots.push(data); } - // IK constraints. - if (Reflect.hasField(root, "ik")) { - for (constraintMap in cast(Reflect.getProperty(root, "ik"), Array)) { - var ikData:IkConstraintData = new IkConstraintData(Reflect.getProperty(constraintMap, "name")); - ikData.order = getInt(constraintMap, "order"); - ikData.skinRequired = Reflect.hasField(constraintMap, "skin") ? cast(Reflect.getProperty(constraintMap, "skin"), Bool) : false; + // Constraints. + if (Reflect.hasField(root, "constraints")) { + for (constraintMap in cast(Reflect.getProperty(root, "constraints"), Array)) { + var name:String = Reflect.getProperty(constraintMap, "name"); + var skinRequired:Bool = Reflect.getProperty(constraintMap, "skinRequired"); + var type:String = Reflect.getProperty(constraintMap, "type"); + switch (type) { + case "ik": + var data = new IkConstraintData(name); + data.skinRequired = skinRequired; - for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { - var bone:BoneData = skeletonData.findBone(boneName); - if (bone == null) - throw new SpineException("IK constraint bone not found: " + boneName); - ikData.bones.push(bone); + for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new SpineException("IK constraint bone not found: " + boneName); + data.bones.push(bone); + } + + data.target = skeletonData.findBone(Reflect.getProperty(constraintMap, "target")); + if (data.target == null) throw new SpineException("Target bone not found: " + Reflect.getProperty(constraintMap, "target")); + + data.uniform = (Reflect.hasField(constraintMap, "uniform") && cast(Reflect.getProperty(constraintMap, "uniform"), Bool)); + var setup = data.setup; + setup.mix = getFloat(constraintMap, "mix", 1); + setup.softness = getFloat(constraintMap, "softness", 0) * scale; + setup.bendDirection = (!Reflect.hasField(constraintMap, "bendPositive") || cast(Reflect.getProperty(constraintMap, "bendPositive"), Bool)) ? 1 : -1; + setup.compress = (Reflect.hasField(constraintMap, "compress") && cast(Reflect.getProperty(constraintMap, "compress"), Bool)); + setup.stretch = (Reflect.hasField(constraintMap, "stretch") && cast(Reflect.getProperty(constraintMap, "stretch"), Bool)); + + skeletonData.constraints.push(data); + case "transform": + var data = new TransformConstraintData(name); + data.skinRequired = skinRequired; + + for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new SpineException("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + + data.source = skeletonData.findBone(Reflect.getProperty(constraintMap, "source")); + if (data.source == null) throw new SpineException("Transform constraint source bone not found: " + Reflect.getProperty(constraintMap, "source")); + + data.localSource = Reflect.hasField(constraintMap, "localSource") ? cast(Reflect.getProperty(constraintMap, "localSource"), Bool) : false; + data.localTarget = Reflect.hasField(constraintMap, "localTarget") ? cast(Reflect.getProperty(constraintMap, "localTarget"), Bool) : false; + data.additive = Reflect.hasField(constraintMap, "additive") ? cast(Reflect.getProperty(constraintMap, "additive"), Bool) : false; + data.clamp = Reflect.hasField(constraintMap, "clamp") ? cast(Reflect.getProperty(constraintMap, "clamp"), Bool) : false; + + var rotate = false, x = false, y = false, scaleX = false, scaleY = false, shearY = false; + var propertiesMap:Dynamic = Reflect.getProperty(constraintMap, "properties"); + for (name in Reflect.fields(propertiesMap)) { + var fromEntry = Reflect.field(propertiesMap, name); + var from = fromProperty(name); + var fromScale = propertyScale(name, scale); + from.offset = getFloat(fromEntry, "offset", 0) * fromScale; + var toMap:Dynamic = Reflect.getProperty(fromEntry, "to"); + for (name in Reflect.fields(toMap)) { + var toEntry = Reflect.field(toMap, name); + var toScale = 1.; + var to:ToProperty; + switch (name) { + case "rotate": { + rotate = true; + to = new ToRotate(); + } + case "x": { + x = true; + to = new ToX(); + toScale = scale; + } + case "y": { + y = true; + to = new ToY(); + toScale = scale; + } + case "scaleX": { + scaleX = true; + to = new ToScaleX(); + } + case "scaleY": { + scaleY = true; + to = new ToScaleY(); + } + case "shearY": { + shearY = true; + to = new ToShearY(); + } + default: throw new SpineException("Invalid transform constraint to property: " + toEntry.name); + } + to.offset = getFloat(toEntry, "offset", 0) * toScale; + to.max = getFloat(toEntry, "max", 1) * toScale; + to.scale = getFloat(toEntry, "scale") * toScale / fromScale; + from.to.push(to); + } + if (from.to.length > 0) data.properties.push(from); + } + + data.offsets[0] = getFloat(constraintMap, "rotation", 0); + data.offsets[1] = getFloat(constraintMap, "x", 0) * scale; + data.offsets[2] = getFloat(constraintMap, "y", 0) * scale; + data.offsets[3] = getFloat(constraintMap, "scaleX", 0); + data.offsets[4] = getFloat(constraintMap, "scaleY", 0); + data.offsets[5] = getFloat(constraintMap, "shearY", 0); + + var setup = data.setup; + if (rotate) setup.mixRotate = getFloat(constraintMap, "mixRotate", 1); + if (x) setup.mixX = getFloat(constraintMap, "mixX", 1); + if (y) setup.mixY = getFloat(constraintMap, "mixY", setup.mixX); + if (scaleX) setup.mixScaleX = getFloat(constraintMap, "mixScaleX", 1); + if (scaleY) setup.mixScaleY = getFloat(constraintMap, "mixScaleY", setup.mixScaleX); + if (shearY) setup.mixShearY = getFloat(constraintMap, "mixShearY", 1); + + skeletonData.constraints.push(data); + case "path": + var data = new PathConstraintData(name); + data.skinRequired = skinRequired; + + for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new SpineException("Path bone not found: " + boneName); + data.bones.push(bone); + } + + var slotName = getString(constraintMap, "slot", ""); + data.slot = skeletonData.findSlot(slotName); + if (data.slot == null) throw new SpineException("Path slot not found: " + slotName); + + data.positionMode = Reflect.hasField(constraintMap, "positionMode") ? PositionMode.fromName(Reflect.getProperty(constraintMap, "positionMode")) : PositionMode.percent; + data.spacingMode = Reflect.hasField(constraintMap, "spacingMode") ? SpacingMode.fromName(Reflect.getProperty(constraintMap, "spacingMode")) : SpacingMode.length; + data.rotateMode = Reflect.hasField(constraintMap, "rotateMode") ? RotateMode.fromName(Reflect.getProperty(constraintMap, "rotateMode")) : RotateMode.tangent; + data.offsetRotation = getFloat(constraintMap, "rotation", 0); + var setup = data.setup; + setup.position = getFloat(constraintMap, "position", 0); + if (data.positionMode == PositionMode.fixed) setup.position *= scale; + setup.spacing = getFloat(constraintMap, "spacing", 0); + if (data.spacingMode == SpacingMode.length || data.spacingMode == SpacingMode.fixed) setup.spacing *= scale; + setup.mixRotate = getFloat(constraintMap, "mixRotate", 1); + setup.mixX = getFloat(constraintMap, "mixX", 1); + setup.mixY = getFloat(constraintMap, "mixY", setup.mixX); + + skeletonData.constraints.push(data); + case "physics": + var data = new PhysicsConstraintData(name); + data.skinRequired = skinRequired; + + var boneName:String = getString(constraintMap, "bone"); + data.bone = skeletonData.findBone(boneName); + if (data.bone == null) throw new SpineException("Physics bone not found: " + boneName); + + data.x = getFloat(constraintMap, "x"); + data.y = getFloat(constraintMap, "y"); + data.rotate = getFloat(constraintMap, "rotate"); + data.scaleX = getFloat(constraintMap, "scaleX"); + data.shearX = getFloat(constraintMap, "shearX"); + data.limit = getFloat(constraintMap, "limit", 5000) * scale; + data.step = 1 / getFloat(constraintMap, "fps", 60); + var setup = data.setup; + setup.inertia = getFloat(constraintMap, "inertia", .5); + setup.strength = getFloat(constraintMap, "strength", 100); + setup.damping = getFloat(constraintMap, "damping", .85); + setup.massInverse = 1 / getFloat(constraintMap, "mass", 1); + setup.wind = getFloat(constraintMap, "wind", 0); + setup.gravity = getFloat(constraintMap, "gravity", 0); + setup.mix = getValue(constraintMap, "mix", 1); + data.inertiaGlobal = Reflect.hasField(constraintMap, "inertiaGlobal") ? cast(Reflect.getProperty(constraintMap, "inertiaGlobal"), Bool) : false; + data.strengthGlobal = Reflect.hasField(constraintMap, "strengthGlobal") ? cast(Reflect.getProperty(constraintMap, "strengthGlobal"), Bool) : false; + data.dampingGlobal = Reflect.hasField(constraintMap, "dampingGlobal") ? cast(Reflect.getProperty(constraintMap, "dampingGlobal"), Bool) : false; + data.dampingGlobal = Reflect.hasField(constraintMap, "dampingGlobal") ? cast(Reflect.getProperty(constraintMap, "dampingGlobal"), Bool) : false; + data.windGlobal = Reflect.hasField(constraintMap, "windGlobal") ? cast(Reflect.getProperty(constraintMap, "windGlobal"), Bool) : false; + data.gravityGlobal = Reflect.hasField(constraintMap, "gravityGlobal") ? cast(Reflect.getProperty(constraintMap, "gravityGlobal"), Bool) : false; + data.mixGlobal = Reflect.hasField(constraintMap, "mixGlobal") ? cast(Reflect.getProperty(constraintMap, "mixGlobal"), Bool) : false; + + skeletonData.constraints.push(data); + case "slider": + var data = new SliderData(name); + data.skinRequired = skinRequired; + data.additive = getBoolean(constraintMap, "additive", false); + data.loop = getBoolean(constraintMap, "loop", false); + data.setup.time = getFloat(constraintMap, "time", 0); + data.setup.mix = getFloat(constraintMap, "mix", 1); + + var boneName = constraintMap.getString("bone", null); + if (boneName != null) { + data.bone = skeletonData.findBone(boneName); + if (data.bone == null) throw new SpineException("Slider bone not found: " + boneName); + var property = getString(constraintMap, "property"); + data.property = fromProperty(property); + data.property.offset = getFloat(constraintMap, "offset", 0) * propertyScale(property, scale); + data.scale = getFloat(constraintMap, "scale"); + data.local = getBoolean(constraintMap, "local", false); + } + + skeletonData.constraints.push(data); } - - ikData.target = skeletonData.findBone(Reflect.getProperty(constraintMap, "target")); - if (ikData.target == null) - throw new SpineException("Target bone not found: " + Reflect.getProperty(constraintMap, "target")); - - ikData.mix = getFloat(constraintMap, "mix", 1); - ikData.softness = getFloat(constraintMap, "softness", 0) * scale; - ikData.bendDirection = (!Reflect.hasField(constraintMap, "bendPositive") - || cast(Reflect.getProperty(constraintMap, "bendPositive"), Bool)) ? 1 : -1; - ikData.compress = (Reflect.hasField(constraintMap, "compress") - && cast(Reflect.getProperty(constraintMap, "compress"), Bool)); - ikData.stretch = (Reflect.hasField(constraintMap, "stretch") && cast(Reflect.getProperty(constraintMap, "stretch"), Bool)); - ikData.uniform = (Reflect.hasField(constraintMap, "uniform") && cast(Reflect.getProperty(constraintMap, "uniform"), Bool)); - - skeletonData.ikConstraints.push(ikData); } } - // Transform constraints. - if (Reflect.hasField(root, "transform")) { - for (constraintMap in cast(Reflect.getProperty(root, "transform"), Array)) { - var transformData:TransformConstraintData = new TransformConstraintData(Reflect.getProperty(constraintMap, "name")); - transformData.order = getInt(constraintMap, "order"); - transformData.skinRequired = Reflect.hasField(constraintMap, "skin") ? cast(Reflect.getProperty(constraintMap, "skin"), Bool) : false; - - for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new SpineException("Transform constraint bone not found: " + boneName); - transformData.bones.push(bone); - } - - transformData.target = skeletonData.findBone(Reflect.getProperty(constraintMap, "target")); - if (transformData.target == null) - throw new SpineException("Target bone not found: " + Reflect.getProperty(constraintMap, "target")); - - transformData.local = Reflect.hasField(constraintMap, "local") ? cast(Reflect.getProperty(constraintMap, "local"), Bool) : false; - transformData.relative = Reflect.hasField(constraintMap, "relative") ? cast(Reflect.getProperty(constraintMap, "relative"), Bool) : false; - - transformData.offsetRotation = getFloat(constraintMap, "rotation"); - transformData.offsetX = getFloat(constraintMap, "x") * scale; - - transformData.offsetY = getFloat(constraintMap, "y") * scale; - - transformData.offsetScaleX = getFloat(constraintMap, "scaleX"); - transformData.offsetScaleY = getFloat(constraintMap, "scaleY"); - transformData.offsetShearY = getFloat(constraintMap, "shearY"); - - transformData.mixRotate = getFloat(constraintMap, "mixRotate", 1); - transformData.mixX = getFloat(constraintMap, "mixX", 1); - transformData.mixY = getFloat(constraintMap, "mixY", transformData.mixX); - transformData.mixScaleX = getFloat(constraintMap, "mixScaleX", 1); - transformData.mixScaleY = getFloat(constraintMap, "mixScaleY", transformData.mixScaleX); - transformData.mixShearY = getFloat(constraintMap, "mixShearY", 1); - - skeletonData.transformConstraints.push(transformData); - } - } - - // Path constraints. - if (Reflect.hasField(root, "path")) { - for (constraintMap in cast(Reflect.getProperty(root, "path"), Array)) { - var pathData:PathConstraintData = new PathConstraintData(Reflect.getProperty(constraintMap, "name")); - pathData.order = getInt(constraintMap, "order"); - pathData.skinRequired = Reflect.hasField(constraintMap, "skin") ? cast(Reflect.getProperty(constraintMap, "skin"), Bool) : false; - - for (boneName in cast(Reflect.getProperty(constraintMap, "bones"), Array)) { - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new SpineException("Path constraint bone not found: " + boneName); - pathData.bones.push(bone); - } - - pathData.target = skeletonData.findSlot(Reflect.getProperty(constraintMap, "target")); - if (pathData.target == null) - throw new SpineException("Path target slot not found: " + Reflect.getProperty(constraintMap, "target")); - - pathData.positionMode = Reflect.hasField(constraintMap, - "positionMode") ? PositionMode.fromName(Reflect.getProperty(constraintMap, "positionMode")) : PositionMode.percent; - pathData.spacingMode = Reflect.hasField(constraintMap, - "spacingMode") ? SpacingMode.fromName(Reflect.getProperty(constraintMap, "spacingMode")) : SpacingMode.length; - pathData.rotateMode = Reflect.hasField(constraintMap, - "rotateMode") ? RotateMode.fromName(Reflect.getProperty(constraintMap, "rotateMode")) : RotateMode.tangent; - pathData.offsetRotation = getFloat(constraintMap, "rotation"); - pathData.position = getFloat(constraintMap, "position"); - if (pathData.positionMode == PositionMode.fixed) - pathData.position *= scale; - pathData.spacing = getFloat(constraintMap, "spacing"); - if (pathData.spacingMode == SpacingMode.length || pathData.spacingMode == SpacingMode.fixed) - pathData.spacing *= scale; - pathData.mixRotate = getFloat(constraintMap, "mixRotate", 1); - pathData.mixX = getFloat(constraintMap, "mixX", 1); - pathData.mixY = getFloat(constraintMap, "mixY", 1); - - skeletonData.pathConstraints.push(pathData); - } - } - - // Physics constraints. - if (Reflect.hasField(root, "physics")) { - for (constraintMap in cast(Reflect.getProperty(root, "physics"), Array)) { - var physicsData:PhysicsConstraintData = new PhysicsConstraintData(Reflect.getProperty(constraintMap, "name")); - physicsData.order = getInt(constraintMap, "order"); - physicsData.skinRequired = Reflect.hasField(constraintMap, "skin") ? cast(Reflect.getProperty(constraintMap, "skin"), Bool) : false; - - var boneName:String = Reflect.getProperty(constraintMap, "bone"); - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new SpineException("Physics constraint bone not found: " + boneName); - physicsData.bone = bone; - - physicsData.x = getFloat(constraintMap, "x"); - physicsData.y = getFloat(constraintMap, "y"); - physicsData.rotate = getFloat(constraintMap, "rotate"); - physicsData.scaleX = getFloat(constraintMap, "scaleX"); - physicsData.shearX = getFloat(constraintMap, "shearX"); - physicsData.limit = getFloat(constraintMap, "limit", 5000) * scale; - physicsData.step = 1 / getFloat(constraintMap, "fps", 60); - physicsData.inertia = getFloat(constraintMap, "inertia", 1); - physicsData.strength = getFloat(constraintMap, "strength", 100); - physicsData.damping = getFloat(constraintMap, "damping", 1); - physicsData.massInverse = 1 / getFloat(constraintMap, "mass", 1); - physicsData.wind = getFloat(constraintMap, "wind"); - physicsData.gravity = getFloat(constraintMap, "gravity"); - physicsData.mix = getValue(constraintMap, "mix", 1); - physicsData.inertiaGlobal = Reflect.hasField(constraintMap, "inertiaGlobal") ? cast(Reflect.getProperty(constraintMap, "inertiaGlobal"), Bool) : false; - physicsData.strengthGlobal = Reflect.hasField(constraintMap, "strengthGlobal") ? cast(Reflect.getProperty(constraintMap, "strengthGlobal"), Bool) : false; - physicsData.dampingGlobal = Reflect.hasField(constraintMap, "dampingGlobal") ? cast(Reflect.getProperty(constraintMap, "dampingGlobal"), Bool) : false; - physicsData.dampingGlobal = Reflect.hasField(constraintMap, "dampingGlobal") ? cast(Reflect.getProperty(constraintMap, "dampingGlobal"), Bool) : false; - physicsData.windGlobal = Reflect.hasField(constraintMap, "windGlobal") ? cast(Reflect.getProperty(constraintMap, "windGlobal"), Bool) : false; - physicsData.gravityGlobal = Reflect.hasField(constraintMap, "gravityGlobal") ? cast(Reflect.getProperty(constraintMap, "gravityGlobal"), Bool) : false; - physicsData.mixGlobal = Reflect.hasField(constraintMap, "mixGlobal") ? cast(Reflect.getProperty(constraintMap, "mixGlobal"), Bool) : false; - - skeletonData.physicsConstraints.push(physicsData); - } - } // Skins. if (Reflect.hasField(root, "skins")) { @@ -340,9 +379,9 @@ class SkeletonJson { } if (Reflect.hasField(skinMap, "ik")) { - var ik:Array = cast(Reflect.getProperty(skinMap, "ik"), Array); + var ik = cast(Reflect.getProperty(skinMap, "ik"), Array); for (ii in 0...ik.length) { - var constraint:ConstraintData = skeletonData.findIkConstraint(ik[ii]); + var constraint = skeletonData.findConstraint(ik[ii], IkConstraintData); if (constraint == null) throw new SpineException("Skin IK constraint not found: " + ik[ii]); skin.constraints.push(constraint); @@ -350,9 +389,9 @@ class SkeletonJson { } if (Reflect.hasField(skinMap, "transform")) { - var transform:Array = cast(Reflect.getProperty(skinMap, "transform"), Array); + var transform = cast(Reflect.getProperty(skinMap, "transform"), Array); for (ii in 0...transform.length) { - var constraint:ConstraintData = skeletonData.findTransformConstraint(transform[ii]); + var constraint = skeletonData.findConstraint(transform[ii], TransformConstraintData); if (constraint == null) throw new SpineException("Skin transform constraint not found: " + transform[ii]); skin.constraints.push(constraint); @@ -360,9 +399,9 @@ class SkeletonJson { } if (Reflect.hasField(skinMap, "path")) { - var path:Array = cast(Reflect.getProperty(skinMap, "path"), Array); + var path = cast(Reflect.getProperty(skinMap, "path"), Array); for (ii in 0...path.length) { - var constraint:ConstraintData = skeletonData.findPathConstraint(path[ii]); + var constraint = skeletonData.findConstraint(path[ii], PathConstraintData); if (constraint == null) throw new SpineException("Skin path constraint not found: " + path[ii]); skin.constraints.push(constraint); @@ -370,15 +409,24 @@ class SkeletonJson { } if (Reflect.hasField(skinMap, "physics")) { - var physics:Array = cast(Reflect.getProperty(skinMap, "physics"), Array); + var physics = cast(Reflect.getProperty(skinMap, "physics"), Array); for (ii in 0...physics.length) { - var constraint:ConstraintData = skeletonData.findPhysicsConstraint(physics[ii]); + var constraint = skeletonData.findConstraint(physics[ii], PhysicsConstraintData); if (constraint == null) throw new SpineException("Skin physics constraint not found: " + physics[ii]); skin.constraints.push(constraint); } } + if (Reflect.hasField(skinMap, "slider")) { + var slider = cast(Reflect.getProperty(skinMap, "slider"), Array); + for (ii in 0...slider.length) { + var constraint = skeletonData.findConstraint(slider[ii], SliderData); + if (constraint == null) throw new SpineException("Skin slider constraint not found: " + slider[ii]); + skin.constraints.push(constraint); + } + } + if (Reflect.hasField(skinMap, "attachments")) { var attachments:Dynamic = Reflect.getProperty(skinMap, "attachments"); for (slotName in Reflect.fields(attachments)) { @@ -437,17 +485,43 @@ class SkeletonJson { for (animationName in Reflect.fields(animations)) { readAnimation(Reflect.field(animations, animationName), animationName, skeletonData); } + + // Slider animations. + if (Reflect.hasField(root, "constraints")) { + for (constraintMap in cast(Reflect.getProperty(root, "constraints"), Array)) { + if (Reflect.getProperty(constraintMap, "type") == "slider") { + var data = skeletonData.findConstraint(getString(constraintMap, "name"), SliderData); + var animationName = getString(constraintMap, "animation", ""); + data.animation = skeletonData.findAnimation(animationName); + if (data.animation == null) throw new SpineException("Slider animation not found: " + animationName); + } + } + } + return skeletonData; } - private function readSequence(map:Dynamic) { - if (map == null) - return null; - var sequence = new Sequence(getInt(map, "count", 0)); - sequence.start = getInt(map, "start", 1); - sequence.digits = getInt(map, "digits", 0); - sequence.setupIndex = getInt(map, "setup", 0); - return sequence; + private function fromProperty (type:String): FromProperty { + var property:FromProperty; + switch (type) { + case "rotate": property = new FromRotate(); + case "x": property = new FromX(); + case "y": property = new FromY(); + case "scaleX": property = new FromScaleX(); + case "scaleY": property = new FromScaleY(); + case "shearY": property = new FromShearY(); + default: throw new SpineException("Invalid from property: " + type); + }; + return property; + } + + private function propertyScale (type:String, scale:Float):Float { + var scaleValue:Float; + switch (type) { + case "x", "y": scaleValue = scale; + default: scaleValue = 1; + }; + return scaleValue; } private function readAttachment(map:Dynamic, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment { @@ -567,6 +641,16 @@ class SkeletonJson { return null; } + private function readSequence(map:Dynamic) { + if (map == null) + return null; + var sequence = new Sequence(getInt(map, "count", 0)); + sequence.start = getInt(map, "start", 1); + sequence.digits = getInt(map, "digits", 0); + sequence.setupIndex = getInt(map, "setup", 0); + return sequence; + } + private function readVertices(map:Dynamic, attachment:VertexAttachment, verticesLength:Int):Void { attachment.worldVerticesLength = verticesLength; var vertices:Array = getFloatArray(map, "vertices"); @@ -623,215 +707,194 @@ class SkeletonJson { slotIndex = skeletonData.findSlot(slotName).index; for (timelineName in Reflect.fields(slotMap)) { timelineMap = Reflect.field(slotMap, timelineName); - if (timelineMap == null) - continue; - if (timelineName == "attachment") { - var attachmentTimeline:AttachmentTimeline = new AttachmentTimeline(timelineMap.length, slotIndex); - for (frame in 0...timelineMap.length) { - keyMap = timelineMap[frame]; - attachmentTimeline.setFrame(frame, getFloat(keyMap, "time"), getString(keyMap, "name", null)); - } - timelines.push(attachmentTimeline); - } else if (timelineName == "rgba") { - var rgbaTimeline:RGBATimeline = new RGBATimeline(timelineMap.length, timelineMap.length << 2, slotIndex); - keyMap = timelineMap[0]; - time = getFloat(keyMap, "time"); - var rgba:Color = Color.fromString(keyMap.color); + if (timelineMap == null) continue; - frame = 0; - bezier = 0; - while (true) { - rgbaTimeline.setFrame(frame, time, rgba.r, rgba.g, rgba.b, rgba.a); - if (timelineMap.length == frame + 1) - break; - - nextMap = timelineMap[frame + 1]; - time2 = getFloat(nextMap, "time"); - var newRgba:Color = Color.fromString(nextMap.color); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, rgbaTimeline, bezier, frame, 0, time, time2, rgba.r, newRgba.r, 1); - bezier = readCurve(curve, rgbaTimeline, bezier, frame, 1, time, time2, rgba.g, newRgba.g, 1); - bezier = readCurve(curve, rgbaTimeline, bezier, frame, 2, time, time2, rgba.b, newRgba.b, 1); - bezier = readCurve(curve, rgbaTimeline, bezier, frame, 3, time, time2, rgba.a, newRgba.a, 1); + switch (timelineName) { + case "attachment": + var attachmentTimeline = new AttachmentTimeline(timelineMap.length, slotIndex); + for (frame in 0...timelineMap.length) { + keyMap = timelineMap[frame]; + attachmentTimeline.setFrame(frame, getFloat(keyMap, "time"), getString(keyMap, "name", null)); } - time = time2; - rgba = newRgba; - keyMap = nextMap; + timelines.push(attachmentTimeline); + case "rgba": + var rgbaTimeline = new RGBATimeline(timelineMap.length, timelineMap.length << 2, slotIndex); + keyMap = timelineMap[0]; + time = getFloat(keyMap, "time"); + var rgba:Color = Color.fromString(keyMap.color); - frame++; - } + frame = 0; + bezier = 0; + while (true) { + rgbaTimeline.setFrame(frame, time, rgba.r, rgba.g, rgba.b, rgba.a); + if (timelineMap.length == frame + 1) + break; - timelines.push(rgbaTimeline); - } else if (timelineName == "rgb") { - var rgbTimeline:RGBTimeline = new RGBTimeline(timelineMap.length, timelineMap.length * 3, slotIndex); - keyMap = timelineMap[0]; - time = getFloat(keyMap, "time"); - var rgb:Color = Color.fromString(keyMap.color); + nextMap = timelineMap[frame + 1]; + time2 = getFloat(nextMap, "time"); + var newRgba:Color = Color.fromString(nextMap.color); + curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, rgbaTimeline, bezier, frame, 0, time, time2, rgba.r, newRgba.r, 1); + bezier = readCurve(curve, rgbaTimeline, bezier, frame, 1, time, time2, rgba.g, newRgba.g, 1); + bezier = readCurve(curve, rgbaTimeline, bezier, frame, 2, time, time2, rgba.b, newRgba.b, 1); + bezier = readCurve(curve, rgbaTimeline, bezier, frame, 3, time, time2, rgba.a, newRgba.a, 1); + } + time = time2; + rgba = newRgba; + keyMap = nextMap; - frame = 0; - bezier = 0; - while (true) { - rgbTimeline.setFrame(frame, time, rgb.r, rgb.g, rgb.b); - nextMap = timelineMap[frame + 1]; - if (nextMap == null) { - rgbTimeline.shrink(bezier); - break; + frame++; } - time2 = getFloat(nextMap, "time"); - var newRgb:Color = Color.fromString(nextMap.color); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, rgbTimeline, bezier, frame, 0, time, time2, rgb.r, newRgb.r, 1); - bezier = readCurve(curve, rgbTimeline, bezier, frame, 1, time, time2, rgb.g, newRgb.g, 1); - bezier = readCurve(curve, rgbTimeline, bezier, frame, 2, time, time2, rgb.b, newRgb.b, 1); - } - time = time2; - rgb = newRgb; - keyMap = nextMap; + timelines.push(rgbaTimeline); + case "rgb": + var rgbTimeline = new RGBTimeline(timelineMap.length, timelineMap.length * 3, slotIndex); + keyMap = timelineMap[0]; + time = getFloat(keyMap, "time"); + var rgb:Color = Color.fromString(keyMap.color); - frame++; - } + frame = 0; + bezier = 0; + while (true) { + rgbTimeline.setFrame(frame, time, rgb.r, rgb.g, rgb.b); + nextMap = timelineMap[frame + 1]; + if (nextMap == null) { + rgbTimeline.shrink(bezier); + break; + } - timelines.push(rgbTimeline); - } else if (timelineName == "alpha") { - timelines.push(readTimeline(timelineMap, new AlphaTimeline(timelineMap.length, timelineMap.length, slotIndex), 0, 1)); - } else if (timelineName == "rgba2") { - var rgba2Timeline:RGBA2Timeline = new RGBA2Timeline(timelineMap.length, timelineMap.length * 7, slotIndex); + time2 = getFloat(nextMap, "time"); + var newRgb:Color = Color.fromString(nextMap.color); + curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, rgbTimeline, bezier, frame, 0, time, time2, rgb.r, newRgb.r, 1); + bezier = readCurve(curve, rgbTimeline, bezier, frame, 1, time, time2, rgb.g, newRgb.g, 1); + bezier = readCurve(curve, rgbTimeline, bezier, frame, 2, time, time2, rgb.b, newRgb.b, 1); + } + time = time2; + rgb = newRgb; + keyMap = nextMap; - keyMap = timelineMap[0]; - time = getFloat(keyMap, "time"); - var lighta:Color = Color.fromString(keyMap.light); - var darka:Color = Color.fromString(keyMap.dark); - - frame = 0; - bezier = 0; - while (true) { - rgba2Timeline.setFrame(frame, time, lighta.r, lighta.g, lighta.b, lighta.a, darka.r, darka.g, darka.b); - nextMap = timelineMap[frame + 1]; - if (nextMap == null) { - rgba2Timeline.shrink(bezier); - break; + frame++; } - time2 = getFloat(nextMap, "time"); - var newLighta:Color = Color.fromString(nextMap.light); - var newDarka:Color = Color.fromString(nextMap.dark); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 0, time, time2, lighta.r, newLighta.r, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 1, time, time2, lighta.g, newLighta.g, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 2, time, time2, lighta.b, newLighta.b, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 3, time, time2, lighta.a, newLighta.a, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 4, time, time2, darka.r, newDarka.r, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 5, time, time2, darka.g, newDarka.g, 1); - bezier = readCurve(curve, rgba2Timeline, bezier, frame, 6, time, time2, darka.b, newDarka.b, 1); - } - time = time2; - lighta = newLighta; - darka = newDarka; - keyMap = nextMap; + timelines.push(rgbTimeline); + case "alpha": readTimeline(timelines, timelineMap, new AlphaTimeline(timelineMap.length, timelineMap.length, slotIndex), 0, 1); + case "rgba2": + var rgba2Timeline = new RGBA2Timeline(timelineMap.length, timelineMap.length * 7, slotIndex); - frame++; - } + keyMap = timelineMap[0]; + time = getFloat(keyMap, "time"); + var lighta:Color = Color.fromString(keyMap.light); + var darka:Color = Color.fromString(keyMap.dark); - timelines.push(rgba2Timeline); - } else if (timelineName == "rgb2") { - var rgb2Timeline:RGB2Timeline = new RGB2Timeline(timelineMap.length, timelineMap.length * 6, slotIndex); + frame = 0; + bezier = 0; + while (true) { + rgba2Timeline.setFrame(frame, time, lighta.r, lighta.g, lighta.b, lighta.a, darka.r, darka.g, darka.b); + nextMap = timelineMap[frame + 1]; + if (nextMap == null) { + rgba2Timeline.shrink(bezier); + break; + } - keyMap = timelineMap[0]; - time = getFloat(keyMap, "time"); - var light:Color = Color.fromString(keyMap.light); - var dark:Color = Color.fromString(keyMap.dark); + time2 = getFloat(nextMap, "time"); + var newLighta:Color = Color.fromString(nextMap.light); + var newDarka:Color = Color.fromString(nextMap.dark); + curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 0, time, time2, lighta.r, newLighta.r, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 1, time, time2, lighta.g, newLighta.g, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 2, time, time2, lighta.b, newLighta.b, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 3, time, time2, lighta.a, newLighta.a, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 4, time, time2, darka.r, newDarka.r, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 5, time, time2, darka.g, newDarka.g, 1); + bezier = readCurve(curve, rgba2Timeline, bezier, frame, 6, time, time2, darka.b, newDarka.b, 1); + } + time = time2; + lighta = newLighta; + darka = newDarka; + keyMap = nextMap; - frame = 0; - bezier = 0; - while (true) { - rgb2Timeline.setFrame(frame, time, light.r, light.g, light.b, dark.r, dark.g, dark.b); - nextMap = timelineMap[frame + 1]; - if (nextMap == null) { - rgb2Timeline.shrink(bezier); - break; + frame++; } - time2 = getFloat(nextMap, "time"); - var newLight:Color = Color.fromString(nextMap.light); - var newDark:Color = Color.fromString(nextMap.dark); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 0, time, time2, light.r, newLight.r, 1); - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 1, time, time2, light.g, newLight.g, 1); - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 2, time, time2, light.b, newLight.b, 1); - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 3, time, time2, dark.r, newDark.r, 1); - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 4, time, time2, dark.g, newDark.g, 1); - bezier = readCurve(curve, rgb2Timeline, bezier, frame, 5, time, time2, dark.b, newDark.b, 1); + timelines.push(rgba2Timeline); + case "rgb2": + var rgb2Timeline = new RGB2Timeline(timelineMap.length, timelineMap.length * 6, slotIndex); + + keyMap = timelineMap[0]; + time = getFloat(keyMap, "time"); + var light:Color = Color.fromString(keyMap.light); + var dark:Color = Color.fromString(keyMap.dark); + + frame = 0; + bezier = 0; + while (true) { + rgb2Timeline.setFrame(frame, time, light.r, light.g, light.b, dark.r, dark.g, dark.b); + nextMap = timelineMap[frame + 1]; + if (nextMap == null) { + rgb2Timeline.shrink(bezier); + break; + } + + time2 = getFloat(nextMap, "time"); + var newLight:Color = Color.fromString(nextMap.light); + var newDark:Color = Color.fromString(nextMap.dark); + curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 0, time, time2, light.r, newLight.r, 1); + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 1, time, time2, light.g, newLight.g, 1); + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 2, time, time2, light.b, newLight.b, 1); + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 3, time, time2, dark.r, newDark.r, 1); + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 4, time, time2, dark.g, newDark.g, 1); + bezier = readCurve(curve, rgb2Timeline, bezier, frame, 5, time, time2, dark.b, newDark.b, 1); + } + time = time2; + light = newLight; + dark = newDark; + keyMap = nextMap; + + frame++; } - time = time2; - light = newLight; - dark = newDark; - keyMap = nextMap; - frame++; - } - - timelines.push(rgb2Timeline); - } else { - throw new SpineException("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); + timelines.push(rgb2Timeline); + default: throw new SpineException("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); } } } // Bone timelines. - var bones:Dynamic = Reflect.getProperty(map, "bones"); + var bones = Reflect.getProperty(map, "bones"); for (boneName in Reflect.fields(bones)) { var boneIndex:Int = skeletonData.findBoneIndex(boneName); - if (boneIndex == -1) - throw new SpineException("Bone not found: " + boneName); + if (boneIndex == -1) throw new SpineException("Bone not found: " + boneName); var boneMap:Dynamic = Reflect.field(bones, boneName); for (timelineName in Reflect.fields(boneMap)) { timelineMap = Reflect.field(boneMap, timelineName); - if (timelineMap.length == 0) - continue; + var frames = timelineMap.length; + if (frames == 0) continue; - if (timelineName == "rotate") { - timelines.push(readTimeline(timelineMap, new RotateTimeline(timelineMap.length, timelineMap.length, boneIndex), 0, 1)); - } else if (timelineName == "translate") { - var translateTimeline:TranslateTimeline = new TranslateTimeline(timelineMap.length, timelineMap.length << 1, boneIndex); - timelines.push(readTimeline2(timelineMap, translateTimeline, "x", "y", 0, scale)); - } else if (timelineName == "translatex") { - var translateXTimeline:TranslateXTimeline = new TranslateXTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, translateXTimeline, 0, scale)); - } else if (timelineName == "translatey") { - var translateYTimeline:TranslateYTimeline = new TranslateYTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, translateYTimeline, 0, scale)); - } else if (timelineName == "scale") { - var scaleTimeline:ScaleTimeline = new ScaleTimeline(timelineMap.length, timelineMap.length << 1, boneIndex); - timelines.push(readTimeline2(timelineMap, scaleTimeline, "x", "y", 1, 1)); - } else if (timelineName == "scalex") { - var scaleXTimeline:ScaleXTimeline = new ScaleXTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, scaleXTimeline, 1, 1)); - } else if (timelineName == "scaley") { - var scaleYTimeline:ScaleYTimeline = new ScaleYTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, scaleYTimeline, 1, 1)); - } else if (timelineName == "shear") { - var shearTimeline:ShearTimeline = new ShearTimeline(timelineMap.length, timelineMap.length << 1, boneIndex); - timelines.push(readTimeline2(timelineMap, shearTimeline, "x", "y", 0, 1)); - } else if (timelineName == "shearx") { - var shearXTimeline:ShearXTimeline = new ShearXTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, shearXTimeline, 0, 1)); - } else if (timelineName == "sheary") { - var shearYTimeline:ShearYTimeline = new ShearYTimeline(timelineMap.length, timelineMap.length, boneIndex); - timelines.push(readTimeline(timelineMap, shearYTimeline, 0, 1)); - } else if (timelineName == "inherit") { - var inheritTimeline:InheritTimeline = new InheritTimeline(timelineMap.length, boneIndex); - for (frame in 0...timelineMap.length) { - var aFrame:Dynamic = timelineMap[frame]; - inheritTimeline.setFrame(frame, getFloat(aFrame, "time"), Inherit.fromName(getValue(aFrame, "inherit", "Normal"))); - } - timelines.push(inheritTimeline); - } else { - throw new SpineException("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); + switch (timelineName) { + case "rotate": readTimeline(timelines, timelineMap, new RotateTimeline(frames, frames, boneIndex), 0, 1); + case "translate": readTimeline2(timelines, timelineMap, new TranslateTimeline(frames, frames << 1, boneIndex), "x", "y", 0, scale); + case "translatex": readTimeline(timelines, timelineMap, new TranslateXTimeline(frames, frames, boneIndex), 0, scale); + case "translatey": readTimeline(timelines, timelineMap, new TranslateYTimeline(frames, frames, boneIndex), 0, scale); + case "scale": readTimeline2(timelines, timelineMap, new ScaleTimeline(frames, frames << 1, boneIndex), "x", "y", 1, 1); + case "scalex": readTimeline(timelines, timelineMap, new ScaleXTimeline(frames, frames, boneIndex), 1, 1); + case "scaley": readTimeline(timelines, timelineMap, new ScaleYTimeline(frames, frames, boneIndex), 1, 1); + case "shear": readTimeline2(timelines, timelineMap, new ShearTimeline(frames, frames << 1, boneIndex), "x", "y", 0, 1); + case "shearx": readTimeline(timelines, timelineMap, new ShearXTimeline(frames, frames, boneIndex), 0, 1); + case "sheary": readTimeline(timelines, timelineMap, new ShearYTimeline(frames, frames, boneIndex), 0, 1); + case "inherit": + var timeline = new InheritTimeline(frames, boneIndex); + for (frame in 0...frames) { + var aFrame:Dynamic = timelineMap[frame]; + timeline.setFrame(frame, getFloat(aFrame, "time"), Inherit.fromName(getValue(aFrame, "inherit", "Normal"))); + } + timelines.push(timeline); + default: throw new SpineException("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); } } } @@ -841,11 +904,12 @@ class SkeletonJson { for (ikConstraintName in Reflect.fields(iks)) { timelineMap = Reflect.field(iks, ikConstraintName); keyMap = timelineMap[0]; - if (keyMap == null) - continue; + if (keyMap == null) continue; - var ikIndex:Int = skeletonData.ikConstraints.indexOf(skeletonData.findIkConstraint(ikConstraintName)); - var ikTimeline:IkConstraintTimeline = new IkConstraintTimeline(timelineMap.length, timelineMap.length << 1, ikIndex); + var constraint = skeletonData.findConstraint(ikConstraintName, IkConstraintData); + if (constraint == null) throw new SpineException("IK constraint not found: " + ikConstraintName); + var timeline = new IkConstraintTimeline(timelineMap.length, timelineMap.length << 1, + skeletonData.constraints.indexOf(constraint)); time = getFloat(keyMap, "time"); var mix:Float = getFloat(keyMap, "mix", 1); @@ -854,14 +918,14 @@ class SkeletonJson { frame = 0; bezier = 0; while (true) { - ikTimeline.setFrame(frame, time, mix, softness, + timeline.setFrame(frame, time, mix, softness, Reflect.hasField(keyMap, "bendPositive") ? (cast(Reflect.getProperty(keyMap, "bendPositive"), Bool) ? 1 : -1) : 1, Reflect.hasField(keyMap, "compress") ? cast(Reflect.getProperty(keyMap, "compress"), Bool) : false, Reflect.hasField(keyMap, "stretch") ? cast(Reflect.getProperty(keyMap, "stretch"), Bool) : false); nextMap = timelineMap[frame + 1]; if (nextMap == null) { - ikTimeline.shrink(bezier); + timeline.shrink(bezier); break; } @@ -871,8 +935,8 @@ class SkeletonJson { curve = keyMap.curve; if (curve != null) { - bezier = readCurve(curve, ikTimeline, bezier, frame, 0, time, time2, mix, mix2, 1); - bezier = readCurve(curve, ikTimeline, bezier, frame, 1, time, time2, softness, softness2, scale); + bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, mix, mix2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, softness, softness2, scale); } time = time2; mix = mix2; @@ -881,56 +945,52 @@ class SkeletonJson { frame++; } - timelines.push(ikTimeline); + timelines.push(timeline); } // Transform constraint timelines. - var mixRotate:Float, mixRotate2:Float; - var mixX:Float, mixX2:Float; - var mixY:Float, mixY2:Float; var transforms:Dynamic = Reflect.getProperty(map, "transform"); for (transformName in Reflect.fields(transforms)) { timelineMap = Reflect.field(transforms, transformName); keyMap = timelineMap[0]; - if (keyMap == null) - continue; - - var transformIndex:Int = skeletonData.transformConstraints.indexOf(skeletonData.findTransformConstraint(transformName)); - var transformTimeline:TransformConstraintTimeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length << 2, transformIndex); - - time = getFloat(keyMap, "time"); - mixRotate = getFloat(keyMap, "mixRotate", 1); - var mixShearY:Float = getFloat(keyMap, "mixShearY", 1); - mixX = getFloat(keyMap, "mixX", 1); - mixY = getFloat(keyMap, "mixY", mixX); - var mixScaleX:Float = getFloat(keyMap, "mixScaleX", 1); + if (keyMap == null) continue; + var constraint = skeletonData.findConstraint(transformName, TransformConstraintData); + if (constraint == null) throw new SpineException("Transform constraint not found: " + transformName); + var timeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length * 6, + skeletonData.constraints.indexOf(constraint)); + var time = getFloat(keyMap, "time"); + var mixRotate = getFloat(keyMap, "mixRotate", 0); + var mixX = getFloat(keyMap, "mixX", 0); + var mixY = getFloat(keyMap, "mixY", mixX); + var mixScaleX:Float = getFloat(keyMap, "mixScaleX", 0); var mixScaleY:Float = getFloat(keyMap, "mixScaleY", mixScaleX); + var mixShearY:Float = getFloat(keyMap, "mixShearY", 0); frame = 0; bezier = 0; while (true) { - transformTimeline.setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY); + timeline.setFrame(frame, time, mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY); nextMap = timelineMap[frame + 1]; if (nextMap == null) { - transformTimeline.shrink(bezier); + timeline.shrink(bezier); break; } - time2 = getFloat(nextMap, "time"); - mixRotate2 = getFloat(nextMap, "mixRotate", 1); + var time2 = getFloat(nextMap, "time"); + var mixRotate2 = getFloat(nextMap, "mixRotate", 1); var mixShearY2:Float = getFloat(nextMap, "mixShearY", 1); - mixX2 = getFloat(nextMap, "mixX", 1); - mixY2 = getFloat(nextMap, "mixY", mixX2); + var mixX2 = getFloat(nextMap, "mixX", 1); + var mixY2 = getFloat(nextMap, "mixY", mixX2); var mixScaleX2:Float = getFloat(nextMap, "mixScaleX", 1); var mixScaleY2:Float = getFloat(nextMap, "mixScaleY", mixScaleX2); - curve = keyMap.curve; + var curve = keyMap.curve; if (curve != null) { - bezier = readCurve(curve, transformTimeline, bezier, frame, 0, time, time2, mixRotate, mixRotate2, 1); - bezier = readCurve(curve, transformTimeline, bezier, frame, 1, time, time2, mixX, mixX2, 1); - bezier = readCurve(curve, transformTimeline, bezier, frame, 2, time, time2, mixY, mixY2, 1); - bezier = readCurve(curve, transformTimeline, bezier, frame, 3, time, time2, mixScaleX, mixScaleX2, 1); - bezier = readCurve(curve, transformTimeline, bezier, frame, 4, time, time2, mixScaleY, mixScaleY2, 1); - bezier = readCurve(curve, transformTimeline, bezier, frame, 5, time, time2, mixShearY, mixShearY2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, mixRotate, mixRotate2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, mixX, mixX2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 2, time, time2, mixY, mixY2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 3, time, time2, mixScaleX, mixScaleX2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 4, time, time2, mixScaleY, mixScaleY2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 5, time, time2, mixShearY, mixShearY2, 1); } time = time2; mixRotate = mixRotate2; @@ -944,67 +1004,66 @@ class SkeletonJson { frame++; } - timelines.push(transformTimeline); + timelines.push(timeline); } // Path constraint timelines. var paths:Dynamic = Reflect.getProperty(map, "path"); for (pathName in Reflect.fields(paths)) { - var index:Int = skeletonData.findPathConstraintIndex(pathName); - if (index == -1) - throw new SpineException("Path constraint not found: " + pathName); - var pathData:PathConstraintData = skeletonData.pathConstraints[index]; + var constraint = skeletonData.findConstraint(pathName, PathConstraintData); + if (constraint == null) throw new SpineException("Path constraint not found: " + pathName); + var index = skeletonData.constraints.indexOf(constraint); var pathMap:Dynamic = Reflect.field(paths, pathName); for (timelineName in Reflect.fields(pathMap)) { timelineMap = Reflect.field(pathMap, timelineName); keyMap = timelineMap[0]; - if (keyMap == null) - continue; + if (keyMap == null) continue; - if (timelineName == "position") { - var positionTimeline:PathConstraintPositionTimeline = new PathConstraintPositionTimeline(timelineMap.length, timelineMap.length, index); - timelines.push(readTimeline(timelineMap, positionTimeline, 0, pathData.positionMode == PositionMode.fixed ? scale : 1)); - } else if (timelineName == "spacing") { - var spacingTimeline:PathConstraintSpacingTimeline = new PathConstraintSpacingTimeline(timelineMap.length, timelineMap.length, index); - timelines.push(readTimeline(timelineMap, spacingTimeline, - 0, pathData.spacingMode == SpacingMode.length || pathData.spacingMode == SpacingMode.fixed ? scale : 1)); - } else if (timelineName == "mix") { - var mixTimeline:PathConstraintMixTimeline = new PathConstraintMixTimeline(timelineMap.length, timelineMap.length * 3, index); - time = getFloat(keyMap, "time"); - mixRotate = getFloat(keyMap, "mixRotate", 1); - mixX = getFloat(keyMap, "mixX", 1); - mixY = getFloat(keyMap, "mixY", mixX); + switch (timelineName) { + case "position": + var timeline = new PathConstraintPositionTimeline(timelineMap.length, timelineMap.length, index); + readTimeline(timelines, timelineMap, timeline, 0, constraint.positionMode == PositionMode.fixed ? scale : 1); + case "spacing": + var timeline = new PathConstraintSpacingTimeline(timelineMap.length, timelineMap.length, index); + readTimeline(timelines, timelineMap, timeline, 0, + constraint.spacingMode == SpacingMode.length || constraint.spacingMode == SpacingMode.fixed ? scale : 1); + case "mix": + var timeline = new PathConstraintMixTimeline(timelineMap.length, timelineMap.length * 3, index); + var time = getFloat(keyMap, "time"); + var mixRotate = getFloat(keyMap, "mixRotate", 1); + var mixX = getFloat(keyMap, "mixX", 1); + var mixY = getFloat(keyMap, "mixY", mixX); - frame = 0; - bezier = 0; - while (true) { - mixTimeline.setFrame(frame, time, mixRotate, mixX, mixY); - nextMap = timelineMap[frame + 1]; - if (nextMap == null) { - mixTimeline.shrink(bezier); - break; + frame = 0; + bezier = 0; + while (true) { + timeline.setFrame(frame, time, mixRotate, mixX, mixY); + var nextMap = timelineMap[frame + 1]; + if (nextMap == null) { + timeline.shrink(bezier); + break; + } + var time2 = getFloat(nextMap, "time"); + var mixRotate2 = getFloat(nextMap, "mixRotate", 1); + var mixX2 = getFloat(nextMap, "mixX", 1); + var mixY2 = getFloat(nextMap, "mixY", mixX2); + var curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, mixRotate, mixRotate2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, mixX, mixX2, 1); + bezier = readCurve(curve, timeline, bezier, frame, 2, time, time2, mixY, mixY2, 1); + } + time = time2; + mixRotate = mixRotate2; + mixX = mixX2; + mixY = mixY2; + keyMap = nextMap; + + frame++; } - time2 = getFloat(nextMap, "time"); - mixRotate2 = getFloat(nextMap, "mixRotate", 1); - mixX2 = getFloat(nextMap, "mixX", 1); - mixY2 = getFloat(nextMap, "mixY", mixX2); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, mixTimeline, bezier, frame, 0, time, time2, mixRotate, mixRotate2, 1); - bezier = readCurve(curve, mixTimeline, bezier, frame, 1, time, time2, mixX, mixX2, 1); - bezier = readCurve(curve, mixTimeline, bezier, frame, 2, time, time2, mixY, mixY2, 1); - } - time = time2; - mixRotate = mixRotate2; - mixX = mixX2; - mixY = mixY2; - keyMap = nextMap; - frame++; - } - - timelines.push(mixTimeline); + timelines.push(timeline); } } } @@ -1012,46 +1071,62 @@ class SkeletonJson { // Physics constraint timelines. var physics:Dynamic = Reflect.getProperty(map, "physics"); for (physicsName in Reflect.fields(physics)) { - var constraintIndex:Int = -1; + var index = -1; if (physicsName.length > 0) { - constraintIndex = skeletonData.findPhysicsConstraintIndex(physicsName); - if (constraintIndex == -1) - throw new SpineException("Physics constraint not found: " + physicsName); + var constraint = skeletonData.findConstraint(physicsName, PhysicsConstraintData); + if (constraint == null) throw new SpineException("Physics constraint not found: " + physicsName); + index = skeletonData.constraints.indexOf(constraint); } var physicsMap:Dynamic = Reflect.field(physics, physicsName); for (timelineName in Reflect.fields(physicsMap)) { timelineMap = Reflect.field(physicsMap, timelineName); keyMap = timelineMap[0]; - if (keyMap == null) - continue; + if (keyMap == null) continue; - var frames:Int = timelineMap.length; - if (timelineName == "reset") { - var timeline:PhysicsConstraintResetTimeline = new PhysicsConstraintResetTimeline(frames, constraintIndex); - for (frame => keyMap in timelineMap) - timeline.setFrame(frame, getFloat(keyMap, "time")); - timelines.push(timeline); - continue; - } + var frames = timelineMap.length; - var timeline:PhysicsConstraintTimeline; - if (timelineName == "inertia") - timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex); - else if (timelineName == "strength") - timeline = new PhysicsConstraintStrengthTimeline(frames, frames, constraintIndex); - else if (timelineName == "damping") - timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex); - else if (timelineName == "mass") - timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex); - else if (timelineName == "wind") - timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex); - else if (timelineName == "gravity") - timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex); - else if (timelineName == "mix") // - timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex); - else + var timeline: CurveTimeline1; + var defaultValue = 0.; + switch (timelineName) { + case "reset": + var resetTimeline = new PhysicsConstraintResetTimeline(frames, index); + for (frame => keyMap in timelineMap) + resetTimeline.setFrame(frame, getFloat(keyMap, "time")); + timelines.push(resetTimeline); continue; - timelines.push(readTimeline(timelineMap, timeline, 0, 1)); + case "inertia": timeline = new PhysicsConstraintInertiaTimeline(frames, frames, index); + case "strength": timeline = new PhysicsConstraintStrengthTimeline(frames, frames, index); + case "damping": timeline = new PhysicsConstraintDampingTimeline(frames, frames, index); + case "mass": timeline = new PhysicsConstraintMassTimeline(frames, frames, index); + case "wind": timeline = new PhysicsConstraintWindTimeline(frames, frames, index); + case "gravity": timeline = new PhysicsConstraintGravityTimeline(frames, frames, index); + case "mix": { + defaultValue = 1; + timeline = new PhysicsConstraintMixTimeline(frames, frames, index); + } + default: continue; + } + readTimeline(timelines, timelineMap, timeline, defaultValue, 1); + } + } + + // Slider timelines. + var sliders:Dynamic = Reflect.getProperty(map, "slider"); + for (sliderName in Reflect.fields(sliders)) { + var constraint = skeletonData.findConstraint(sliderName, SliderData); + if (constraint == null) throw new SpineException("Slider not found: " + sliderName); + var index = skeletonData.constraints.indexOf(constraint); + var timelineMap:Dynamic = Reflect.field(physics, sliderName); + for (timelineName in Reflect.fields(timelineMap)) { + timelineMap = Reflect.field(timelineMap, timelineName); + keyMap = timelineMap[0]; + if (keyMap == null) continue; + + var frames = timelineMap.length; + switch (timelineName) { + case "time": readTimeline(timelines, keyMap, new SliderTimeline(frames, frames, index), 1, 1); + case "mix": readTimeline(timelines, keyMap, new SliderMixTimeline(frames, frames, index), 1, 1); + } } } @@ -1080,79 +1155,80 @@ class SkeletonJson { if (keyMap == null) continue; - if (timelineMapName == "deform") { - var vertexAttachment = cast(attachment, VertexAttachment); - var weighted:Bool = vertexAttachment.bones != null; - var vertices:Array = vertexAttachment.vertices; - var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; + switch (timelineMapName) { + case "deform": + var vertexAttachment = cast(attachment, VertexAttachment); + var weighted:Bool = vertexAttachment.bones != null; + var vertices:Array = vertexAttachment.vertices; + var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; - var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment); - time = getFloat(keyMap, "time"); - frame = 0; - bezier = 0; - while (true) { - var deform:Array; - var verticesValue:Array = Reflect.getProperty(keyMap, "vertices"); - if (verticesValue == null) { - if (weighted) { + var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment); + time = getFloat(keyMap, "time"); + frame = 0; + bezier = 0; + while (true) { + var deform:Array; + var verticesValue:Array = Reflect.getProperty(keyMap, "vertices"); + if (verticesValue == null) { + if (weighted) { + deform = new Array(); + ArrayUtils.resize(deform, deformLength, 0); + } else { + deform = vertices; + } + } else { deform = new Array(); ArrayUtils.resize(deform, deformLength, 0); - } else { - deform = vertices; - } - } else { - deform = new Array(); - ArrayUtils.resize(deform, deformLength, 0); - var start:Int = getInt(keyMap, "offset"); - var temp:Array = getFloatArray(keyMap, "vertices"); - for (i in 0...temp.length) { - deform[start + i] = temp[i]; - } - if (scale != 1) { - for (i in start...start + temp.length) { - deform[i] *= scale; + var start:Int = getInt(keyMap, "offset"); + var temp:Array = getFloatArray(keyMap, "vertices"); + for (i in 0...temp.length) { + deform[start + i] = temp[i]; + } + if (scale != 1) { + for (i in start...start + temp.length) { + deform[i] *= scale; + } + } + if (!weighted) { + for (i in 0...deformLength) { + deform[i] += vertices[i]; + } } } - if (!weighted) { - for (i in 0...deformLength) { - deform[i] += vertices[i]; - } + + deformTimeline.setFrame(frame, time, deform); + nextMap = timelineMap[frame + 1]; + if (nextMap == null) { + deformTimeline.shrink(bezier); + break; } + time2 = getFloat(nextMap, "time"); + curve = keyMap.curve; + if (curve != null) { + bezier = readCurve(curve, deformTimeline, bezier, frame, 0, time, time2, 0, 1, 1); + } + time = time2; + keyMap = nextMap; + + frame++; } - deformTimeline.setFrame(frame, time, deform); - nextMap = timelineMap[frame + 1]; - if (nextMap == null) { - deformTimeline.shrink(bezier); - break; + timelines.push(deformTimeline); + case "sequence": + var timeline = new SequenceTimeline(timelineMap.length, slotIndex, cast(attachment, HasTextureRegion)); + var lastDelay:Float = 0; + var frame:Int = 0; + while (frame < timelineMap.length) { + var delay = getFloat(keyMap, "delay", lastDelay); + var time = getFloat(keyMap, "time", 0); + var mode = SequenceMode.fromName(getString(keyMap, "mode", "hold")); + var index = getInt(keyMap, "index", 0); + timeline.setFrame(frame, time, mode, index, delay); + lastDelay = delay; + keyMap = timelineMap[frame + 1]; + frame++; } - time2 = getFloat(nextMap, "time"); - curve = keyMap.curve; - if (curve != null) { - bezier = readCurve(curve, deformTimeline, bezier, frame, 0, time, time2, 0, 1, 1); - } - time = time2; - keyMap = nextMap; - - frame++; - } - - timelines.push(deformTimeline); - } else if (timelineMapName == "sequence") { - var timeline = new SequenceTimeline(timelineMap.length, slotIndex, cast(attachment, HasTextureRegion)); - var lastDelay:Float = 0; - var frame:Int = 0; - while (frame < timelineMap.length) { - var delay = getFloat(keyMap, "delay", lastDelay); - var time = getFloat(keyMap, "time", 0); - var mode = SequenceMode.fromName(getString(keyMap, "mode", "hold")); - var index = getInt(keyMap, "index", 0); - timeline.setFrame(frame, time, mode, index, delay); - lastDelay = delay; - keyMap = timelineMap[frame + 1]; - frame++; - } - timelines.push(timeline); + timelines.push(timeline); } } } @@ -1224,7 +1300,7 @@ class SkeletonJson { event.floatValue = Reflect.hasField(eventMap, "float") ? getFloat(eventMap, "float") : eventData.floatValue; event.stringValue = Reflect.hasField(eventMap, "string") ? Reflect.getProperty(eventMap, "string") : eventData.stringValue; - if (eventData.audioPath != null) { + if (event.data.audioPath != null) { event.volume = getFloat(eventMap, "volume", 1); event.balance = getFloat(eventMap, "balance"); } @@ -1242,7 +1318,7 @@ class SkeletonJson { skeletonData.animations.push(new Animation(name, timelines, duration)); } - static private function readTimeline(keys:Array, timeline:CurveTimeline1, defaultValue:Float, scale:Float):CurveTimeline1 { + static private function readTimeline(timelines:Array, keys:Array, timeline:CurveTimeline1, defaultValue:Float, scale:Float) { var keyMap:Dynamic = keys[0]; var time:Float = getFloat(keyMap, "time"); var value:Float = getFloat(keyMap, "value", defaultValue) * scale; @@ -1253,7 +1329,8 @@ class SkeletonJson { var nextMap:Dynamic = keys[frame + 1]; if (nextMap == null) { timeline.shrink(bezier); - break; + timelines.push(timeline); + return; } var time2:Float = getFloat(nextMap, "time"); var value2:Float = getFloat(nextMap, "value", defaultValue) * scale; @@ -1267,11 +1344,10 @@ class SkeletonJson { frame++; } - return timeline; } - static private function readTimeline2(keys:Array, timeline:CurveTimeline2, name1:String, name2:String, defaultValue:Float, - scale:Float):CurveTimeline2 { + static private function readTimeline2(timelines:Array, keys:Array, timeline:BoneTimeline2, name1:String, name2:String, defaultValue:Float, + scale:Float) { var keyMap:Dynamic = keys[0]; var time:Float = getFloat(keyMap, "time"); var value1:Float = getFloat(keyMap, name1, defaultValue) * scale; @@ -1283,7 +1359,8 @@ class SkeletonJson { var nextMap:Dynamic = keys[frame + 1]; if (nextMap == null) { timeline.shrink(bezier); - break; + timelines.push(timeline); + return; } var time2:Float = getFloat(nextMap, "time"); var nvalue1:Float = getFloat(nextMap, name1, defaultValue) * scale; @@ -1300,7 +1377,6 @@ class SkeletonJson { frame++; } - return timeline; } static private function readCurve(curve:Dynamic, timeline:CurveTimeline, bezier:Int, frame:Int, value:Int, time1:Float, time2:Float, value1:Float, @@ -1325,18 +1401,30 @@ class SkeletonJson { return defaultValue; } - static private function getString(value:Dynamic, name:String, defaultValue:String):String { + static private function getString(value:Dynamic, name:String, defaultValue:String = ""):String { if (Std.isOfType(Reflect.field(value, name), String)) return cast(Reflect.field(value, name), String); return defaultValue; } - static private function getFloat(value:Dynamic, name:String, defaultValue:Float = 0):Float { + static private function getInt(value:Dynamic, name:String, defaultValue:Int = 0):Int { + if (Std.isOfType(Reflect.field(value, name), Int)) + return cast(Reflect.field(value, name), Int); + return defaultValue; + } + + static private function getFloat(value:Dynamic, name:String, defaultValue:Float = 0.):Float { if (Std.isOfType(Reflect.field(value, name), Float)) return cast(Reflect.field(value, name), Float); return defaultValue; } + static private function getBoolean(value:Dynamic, name:String, defaultValue:Bool = false):Bool { + if (Std.isOfType(Reflect.field(value, name), Bool)) + return cast(Reflect.field(value, name), Bool); + return defaultValue; + } + static private function getFloatArray(map:Dynamic, name:String):Array { var list:Array = cast(Reflect.field(map, name), Array); var values:Array = new Array(); @@ -1347,12 +1435,6 @@ class SkeletonJson { return values; } - static private function getInt(value:Dynamic, name:String, defaultValue:Int = 0):Int { - if (Std.isOfType(Reflect.field(value, name), Int)) - return cast(Reflect.field(value, name), Int); - return defaultValue; - } - static private function getIntArray(map:Dynamic, name:String):Array { var list:Array = cast(Reflect.field(map, name), Array); var values:Array = new Array(); diff --git a/spine-haxe/spine-haxe/spine/Skin.hx b/spine-haxe/spine-haxe/spine/Skin.hx index 1785b725a..48585fc3f 100644 --- a/spine-haxe/spine-haxe/spine/Skin.hx +++ b/spine-haxe/spine-haxe/spine/Skin.hx @@ -45,7 +45,7 @@ class Skin { public final attachments:Array> = new Array>(); public final bones:Array = new Array(); - public final constraints = new Array>>(); + public final constraints = new Array>(); /** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */ public final color:Color = new Color(0.99607843, 0.61960787, 0.30980393, 1); // fe9e4fff diff --git a/spine-haxe/spine-haxe/spine/Slider.hx b/spine-haxe/spine-haxe/spine/Slider.hx index b946408dd..6693b170d 100644 --- a/spine-haxe/spine-haxe/spine/Slider.hx +++ b/spine-haxe/spine-haxe/spine/Slider.hx @@ -29,6 +29,12 @@ package spine; +import spine.animation.ConstraintTimeline; +import spine.animation.PhysicsConstraintTimeline; +import spine.animation.SlotTimeline; +import spine.animation.MixDirection; +import spine.animation.MixBlend; + /** Stores the setup pose for a {@link PhysicsConstraint}. *

* See Physics constraints in the Spine User Guide. */ @@ -39,9 +45,9 @@ class Slider extends Constraint { public function new (data:SliderData, skeleton:Skeleton) { super(data, new SliderPose(), new SliderPose()); - if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); + if (skeleton == null) throw new SpineException("skeleton cannot be null."); - if (data.bone != null) bone = skeleton.bones.items[data.bone.index]; + if (data.bone != null) bone = skeleton.bones[data.bone.index]; } public function copy (skeleton:Skeleton) { @@ -67,7 +73,7 @@ class Slider extends Constraint { var bones = skeleton.bones; var indices = animation.bones; - var i = 0, n = animation.bones.size; + var i = 0, n = animation.bones.length; while (i < n) bones[indices[i++]].applied.modifyLocal(skeleton); @@ -77,7 +83,7 @@ class Slider extends Constraint { function sort (skeleton:Skeleton) { if (bone != null && !data.local) skeleton.sortBone(bone); - skeleton.updateCache.add(this); + skeleton._updateCache.push(this); var bones = skeleton.bones; var indices = data.animation.bones; @@ -97,15 +103,16 @@ class Slider extends Constraint { var i = 0, n = data.animation.timelines.length; while (i < n) { var t = timelines[i++]; - if (std.isOfType(t, SlotTimeline)) + if (Std.isOfType(t, SlotTimeline)) skeleton.constrained(slots[cast(t, SlotTimeline).getSlotIndex()]); - else if (std.isOfType(t, PhysicsConstraintTimeline)) { - if (cast(t, PhysicsConstraintTimeline).constraintIndex == -1) { + else if (Std.isOfType(t, PhysicsConstraintTimeline)) { + var timeline = cast(t, PhysicsConstraintTimeline); + if (timeline.constraintIndex == -1) { for (ii in 0...physicsCount) skeleton.constrained(physics[ii]); } else skeleton.constrained(constraints[timeline.constraintIndex]); - } else if (std.isOfType(t, ConstraintTimeline)) // + } else if (Std.isOfType(t, ConstraintTimeline)) // skeleton.constrained(constraints[cast(t, ConstraintTimeline).getConstraintIndex()]); } } diff --git a/spine-haxe/spine-haxe/spine/SliderData.hx b/spine-haxe/spine-haxe/spine/SliderData.hx index 5627babe9..121522f40 100644 --- a/spine-haxe/spine-haxe/spine/SliderData.hx +++ b/spine-haxe/spine-haxe/spine/SliderData.hx @@ -31,6 +31,9 @@ package spine; +import spine.TransformConstraintData.FromProperty; +import spine.animation.Animation; + /** Stores the setup pose for a PhysicsConstraint. * * See Physics constraints in the Spine User Guide. */ diff --git a/spine-haxe/spine-haxe/spine/SliderPose.hx b/spine-haxe/spine-haxe/spine/SliderPose.hx index 1eda08fc2..1311823a4 100644 --- a/spine-haxe/spine-haxe/spine/SliderPose.hx +++ b/spine-haxe/spine-haxe/spine/SliderPose.hx @@ -34,6 +34,9 @@ class SliderPose implements Pose { public var time = 0.; public var mix = 0.; + public function new () { + } + public function set (pose:SliderPose) { time = pose.time; mix = pose.mix; diff --git a/spine-haxe/spine-haxe/spine/TransformConstraintData.hx b/spine-haxe/spine-haxe/spine/TransformConstraintData.hx index ee3ce6699..09d7df83c 100644 --- a/spine-haxe/spine-haxe/spine/TransformConstraintData.hx +++ b/spine-haxe/spine-haxe/spine/TransformConstraintData.hx @@ -152,6 +152,9 @@ class TransformConstraintData extends ConstraintData = from.timelineMode; @@ -391,7 +391,7 @@ class AnimationState { } else { if (drawOrder && Std.isOfType(timeline, DrawOrderTimeline) && timelineBlend == MixBlend.setup) direction = MixDirection.mixIn; - timeline.apply(skeleton, animationLast, applyTime, events, alpha, timelineBlend, direction); + timeline.apply(skeleton, animationLast, applyTime, events, alpha, timelineBlend, direction, false); } } } diff --git a/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx index 366ccd684..286804530 100644 --- a/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx @@ -116,7 +116,7 @@ class SkeletonSprite extends FlxObject public function getAnimationBounds(animation:Animation, clip:Bool = true): lime.math.Rectangle { var clipper = clip ? SkeletonSprite.clipper : null; - skeleton.setToSetupPose(); + skeleton.setupPose(); var steps = 100, time = 0.; var stepTime = animation.duration != 0 ? animation.duration / steps : 0; @@ -124,7 +124,7 @@ class SkeletonSprite extends FlxObject var bounds = new lime.math.Rectangle(); for (i in 0...steps) { - animation.apply(skeleton, time , time, false, [], 1, MixBlend.setup, MixDirection.mixIn); + animation.apply(skeleton, time , time, false, [], 1, MixBlend.setup, MixDirection.mixIn, false); skeleton.updateWorldTransform(Physics.update); bounds = skeleton.getBounds(clipper); @@ -206,8 +206,10 @@ class SkeletonSprite extends FlxObject } var worldVertices:Array = _tempVertices; - if (Std.isOfType(slot.attachment, RegionAttachment)) { - var region:RegionAttachment = cast(slot.attachment, RegionAttachment); + var pose = slot.pose; + var attachment = pose.attachment; + if (Std.isOfType(attachment, RegionAttachment)) { + var region:RegionAttachment = cast(attachment, RegionAttachment); numVertices = 4; numFloats = clippedVertexSize << 2; if (numFloats > worldVertices.length) { @@ -220,23 +222,23 @@ class SkeletonSprite extends FlxObject triangles = QUAD_INDICES; uvs = region.uvs; attachmentColor = region.color; - } else if (Std.isOfType(slot.attachment, MeshAttachment)) { - var meshAttachment:MeshAttachment = cast(slot.attachment, MeshAttachment); + } else if (Std.isOfType(attachment, MeshAttachment)) { + var meshAttachment:MeshAttachment = cast(attachment, MeshAttachment); numVertices = meshAttachment.worldVerticesLength >> 1; numFloats = numVertices * clippedVertexSize; // 8 for now because I'm excluding clipping if (numFloats > worldVertices.length) { worldVertices.resize(numFloats); } - meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, clippedVertexSize); + meshAttachment.computeWorldVertices(skeleton, slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, clippedVertexSize); mesh = getFlixelMeshFromRendererAttachment(meshAttachment); mesh.graphic = meshAttachment.region.texture; triangles = meshAttachment.triangles; uvs = meshAttachment.uvs; attachmentColor = meshAttachment.color; - } else if (Std.isOfType(slot.attachment, ClippingAttachment)) { - var clip:ClippingAttachment = cast(slot.attachment, ClippingAttachment); - clipper.clipStart(slot, clip); + } else if (Std.isOfType(attachment, ClippingAttachment)) { + var clip:ClippingAttachment = cast(attachment, ClippingAttachment); + clipper.clipStart(skeleton, slot, clip); continue; } else { clipper.clipEnd(slot); @@ -247,12 +249,12 @@ class SkeletonSprite extends FlxObject // cannot use directly mesh.color.setRGBFloat otherwise the setter won't be called and transfor color not set mesh.color = FlxColor.fromRGBFloat( - skeleton.color.r * slot.color.r * attachmentColor.r * color.redFloat, - skeleton.color.g * slot.color.g * attachmentColor.g * color.greenFloat, - skeleton.color.b * slot.color.b * attachmentColor.b * color.blueFloat, + skeleton.color.r * pose.color.r * attachmentColor.r * color.redFloat, + skeleton.color.g * pose.color.g * attachmentColor.g * color.greenFloat, + skeleton.color.b * pose.color.b * attachmentColor.b * color.blueFloat, 1 ); - mesh.alpha = skeleton.color.a * slot.color.a * attachmentColor.a * alpha; + mesh.alpha = skeleton.color.a * pose.color.a * attachmentColor.a * alpha; if (clipper.isClipping()) { clipper.clipTriangles(worldVertices, triangles, triangles.length, uvs); @@ -356,10 +358,11 @@ class SkeletonSprite extends FlxObject public function haxeWorldCoordinatesToBone(point:Array, bone: Bone):Void { this.haxeWorldCoordinatesToSkeleton(point); - if (bone.parent != null) { - bone.parent.worldToLocal(point); + var parentBone = bone.parent; + if (parentBone != null) { + parentBone.applied.worldToLocal(point); } else { - bone.worldToLocal(point); + bone.applied.worldToLocal(point); } } diff --git a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx index c429302e8..cb5a8c660 100644 --- a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx @@ -116,8 +116,10 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { } var worldVertices:Array = _tempVertices; - if (Std.isOfType(slot.attachment, RegionAttachment)) { - var region:RegionAttachment = cast(slot.attachment, RegionAttachment); + var pose = slot.pose; + var attachment = pose.attachment; + if (Std.isOfType(pose, RegionAttachment)) { + var region:RegionAttachment = cast(pose, RegionAttachment); verticesLength = 8; verticesCount = verticesLength >> 1; if (worldVertices.length < verticesLength) @@ -144,13 +146,13 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { indexData = mesh.getIndexData(); attachmentColor = region.color; uvs = region.uvs; - } else if (Std.isOfType(slot.attachment, MeshAttachment)) { - var meshAttachment:MeshAttachment = cast(slot.attachment, MeshAttachment); + } else if (Std.isOfType(pose, MeshAttachment)) { + var meshAttachment:MeshAttachment = cast(pose, MeshAttachment); verticesLength = meshAttachment.worldVerticesLength; verticesCount = verticesLength >> 1; if (worldVertices.length < verticesLength) worldVertices.resize(verticesLength); - meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2); + meshAttachment.computeWorldVertices(skeleton, slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2); mesh = null; if (Std.isOfType(meshAttachment.rendererObject, SkeletonMesh)) { @@ -173,26 +175,26 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { indexData = mesh.getIndexData(); attachmentColor = meshAttachment.color; uvs = meshAttachment.uvs; - } else if (Std.isOfType(slot.attachment, ClippingAttachment)) { - var clip:ClippingAttachment = cast(slot.attachment, ClippingAttachment); - clipper.clipStart(slot, clip); + } else if (Std.isOfType(pose, ClippingAttachment)) { + var clip:ClippingAttachment = cast(pose, ClippingAttachment); + clipper.clipStart(skeleton, slot, clip); continue; } else { clipper.clipEnd(slot); continue; } - a = slot.color.a * attachmentColor.a; + a = pose.color.a * attachmentColor.a; if (a == 0) { clipper.clipEnd(slot); continue; } - rgb = Color.rgb(Std.int(r * slot.color.r * attachmentColor.r), Std.int(g * slot.color.g * attachmentColor.g), - Std.int(b * slot.color.b * attachmentColor.b)); - if (slot.darkColor == null) { + rgb = Color.rgb(Std.int(r * pose.color.r * attachmentColor.r), Std.int(g * pose.color.g * attachmentColor.g), + Std.int(b * pose.color.b * attachmentColor.b)); + if (pose.darkColor == null) { dark = Color.rgb(0, 0, 0); } else { - dark = Color.rgb(Std.int(slot.darkColor.r * 255), Std.int(slot.darkColor.g * 255), Std.int(slot.darkColor.b * 255)); + dark = Color.rgb(Std.int(pose.darkColor.r * 255), Std.int(pose.darkColor.g * 255), Std.int(pose.darkColor.b * 255)); } if (clipper.isClipping()) { @@ -249,12 +251,13 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { var empty:Bool = true; for (i in 0...slots.length) { var slot:Slot = slots[i]; - var attachment:Attachment = slot.attachment; + var pose = slot.pose; + var attachment = pose.attachment; if (attachment == null) continue; var verticesLength:Int; if (Std.isOfType(attachment, RegionAttachment)) { - var region:RegionAttachment = cast(slot.attachment, RegionAttachment); + var region:RegionAttachment = cast(attachment, RegionAttachment); verticesLength = 8; region.computeWorldVertices(slot, worldVertices, 0, 2); } else if (Std.isOfType(attachment, MeshAttachment)) { @@ -262,7 +265,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { verticesLength = mesh.worldVerticesLength; if (worldVertices.length < verticesLength) worldVertices.resize(verticesLength); - mesh.computeWorldVertices(slot, 0, verticesLength, worldVertices, 0, 2); + mesh.computeWorldVertices(skeleton, slot, 0, verticesLength, worldVertices, 0, 2); } else { continue; } @@ -324,7 +327,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { public function getAnimationBounds(animation:Animation, clip:Bool = true): Rectangle { var clipper = clip ? SkeletonSprite.clipper : null; - _skeleton.setToSetupPose(); + _skeleton.setupPose(); var steps = 100, time = 0.; var stepTime = animation.duration != 0 ? animation.duration / steps : 0; @@ -332,7 +335,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { var bound:lime.math.Rectangle; for (i in 0...steps) { - animation.apply(_skeleton, time , time, false, [], 1, MixBlend.setup, MixDirection.mixIn); + animation.apply(_skeleton, time , time, false, [], 1, MixBlend.setup, MixDirection.mixIn, false); _skeleton.updateWorldTransform(Physics.update); bound = _skeleton.getBounds(clipper); @@ -412,10 +415,11 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { public function haxeWorldCoordinatesToBone(point:Array, bone: Bone):Void { this.haxeWorldCoordinatesToSkeleton(point); - if (bone.parent != null) { - bone.parent.worldToLocal(point); + var parentBone = bone.parent; + if (parentBone != null) { + parentBone.applied.worldToLocal(point); } else { - bone.worldToLocal(point); + bone.applied.worldToLocal(point); } }