diff --git a/spine-flutter/example/assets/chibi/chibi-stickers.atlas b/spine-flutter/example/assets/chibi/chibi-stickers.atlas new file mode 100644 index 000000000..106cfcca4 --- /dev/null +++ b/spine-flutter/example/assets/chibi/chibi-stickers.atlas @@ -0,0 +1,409 @@ +chibi-stickers.webp +size:2017,491 +filter:Linear,Linear +scale:0.5 +common/angry-mark +bounds:1801,65,42,41 +common/big-purple-fear +bounds:1640,212,134,71 +offsets:0,0,134,72 +rotate:90 +common/big-tear +bounds:1454,15,33,82 +common/eye-3 +bounds:1611,2,15,26 +rotate:90 +common/eye-closed-happy +bounds:1685,348,25,9 +common/eye-dafault +bounds:1993,51,22,21 +common/eye-equal +bounds:1271,146,25,15 +common/eye-fire +bounds:1673,49,26,28 +common/eye-half-open +bounds:1475,101,26,16 +rotate:90 +common/eye-heart +bounds:1094,2,26,23 +rotate:90 +common/eye-reverse-v +bounds:1945,26,26,16 +common/eye-sideway-v +bounds:945,2,21,23 +rotate:90 +common/eye-slant-close +bounds:321,72,23,16 +common/eye-small-dot +bounds:1120,146,14,14 +offsets:0,1,15,15 +common/eye-sparkle +bounds:1810,4,30,29 +rotate:90 +common/eye-star +bounds:534,235,29,27 +rotate:90 +common/eye-twirl +bounds:970,2,21,23 +rotate:90 +common/eye-u +bounds:733,238,24,17 +rotate:90 +common/eye-x +bounds:1993,74,25,22 +rotate:90 +common/lamp +bounds:1319,2,47,65 +common/mouth-3 +bounds:1581,2,15,28 +rotate:90 +common/mouth-bracket +bounds:1450,2,34,11 +common/mouth-doubt +bounds:1639,2,26,15 +common/mouth-fangs +bounds:549,300,39,14 +rotate:90 +common/mouth-line +bounds:1601,212,36,7 +common/mouth-neutral +bounds:807,2,27,12 +common/mouth-o-tall +bounds:1993,101,22,33 +common/mouth-open-smile +bounds:359,33,36,22 +rotate:90 +common/mouth-rectangle +bounds:875,2,35,21 +common/mouth-reverse-v +bounds:1368,2,27,10 +common/mouth-s +bounds:2003,262,41,11 +rotate:90 +common/mouth-smile-little +bounds:1928,71,33,19 +rotate:90 +common/mouth-toungue-sticking-out +bounds:912,2,31,21 +common/mouth-u +bounds:383,33,36,19 +rotate:90 +common/mouth-v +bounds:563,235,27,14 +rotate:90 +common/mouth-x +bounds:1944,4,21,20 +common/purple-fear-lines +bounds:1807,108,48,28 +common/shadow +bounds:359,2,111,29 +offsets:1,1,113,31 +common/small-drop-line +bounds:1925,22,16,17 +rotate:90 +common/small-purple-fear +bounds:1941,451,54,38 +common/tear +bounds:995,3,20,19 +rotate:90 +erikari/arm +bounds:1383,99,28,90 +rotate:90 +erikari/arm-shoulder-decoration +bounds:1765,2,32,43 +rotate:90 +erikari/back-hair +bounds:565,348,158,141 +erikari/back-hair-long +bounds:2,235,220,254 +erikari/blush +bounds:555,43,29,18 +rotate:90 +erikari/body +bounds:575,2,70,98 +rotate:90 +erikari/bracelet +bounds:1841,2,33,11 +rotate:90 +erikari/collar +bounds:1320,99,61,62 +erikari/ear +bounds:105,2,34,42 +rotate:90 +erikari/eyebrow +bounds:2003,241,19,12 +offsets:0,0,20,12 +rotate:90 +erikari/hair-front +bounds:517,103,130,65 +rotate:90 +erikari/hair-side +bounds:1137,176,43,132 +rotate:90 +erikari/hat-border +bounds:1685,450,254,39 +erikari/hat-top +bounds:346,71,160,60 +rotate:90 +erikari/head-base +bounds:1060,221,143,125 +erikari/leg +bounds:2,8,28,101 +rotate:90 +erikari/leg-decoration +bounds:1412,2,36,13 +erikari/skirt +bounds:224,233,164,101 +erikari/strawberries-decoration +bounds:1271,163,112,56 +harri/arm +bounds:1320,69,28,90 +rotate:90 +harri/back-hair +bounds:725,348,158,141 +harri/back-hair-long +bounds:1412,17,40,80 +harri/beard +bounds:1397,2,10,11 +rotate:90 +harri/blush +bounds:1240,156,29,18 +luke/blush +bounds:1240,156,29,18 +nate/blush +bounds:1240,156,29,18 +spineboy/blush +bounds:1240,156,29,18 +harri/body +bounds:675,2,70,98 +rotate:90 +harri/body-decoration +bounds:287,2,70,67 +harri/ear +bounds:149,2,34,42 +rotate:90 +soeren/ear +bounds:149,2,34,42 +rotate:90 +spineboy/ear +bounds:149,2,34,42 +rotate:90 +harri/eyebrow +bounds:2003,305,22,12 +rotate:90 +harri/hair-front +bounds:1866,358,143,90 +harri/head-base +bounds:1205,221,143,125 +luke/head-base +bounds:1205,221,143,125 +soeren/head-base +bounds:1205,221,143,125 +spineboy/head-base +bounds:1205,221,143,125 +harri/leg +bounds:1017,132,28,101 +rotate:90 +harri/sword +bounds:565,264,185,82 +luke/arm +bounds:1489,71,28,90 +rotate:90 +luke/arm-shoulder-decoration +bounds:1801,36,31,27 +luke/back-hair +bounds:885,348,158,141 +luke/body +bounds:775,16,70,98 +rotate:90 +luke/eyebrow +bounds:836,2,27,12 +nate/eyebrow +bounds:836,2,27,12 +spineboy/eyebrow +bounds:836,2,27,12 +luke/face-cover +bounds:224,336,169,153 +luke/glasses-shadow +bounds:584,181,147,81 +luke/hair-decoration +bounds:408,103,130,107 +rotate:90 +luke/hair-front +bounds:1013,162,122,57 +luke/leg +bounds:1016,30,28,101 +rotate:90 +luke/shield +bounds:1495,131,88,104 +rotate:90 +luke/skirt +bounds:1845,73,81,31 +luke/sword +bounds:1601,139,102,71 +offsets:0,0,104,71 +mario/arm +bounds:1489,41,28,90 +rotate:90 +mario/back-hair +bounds:395,341,168,148 +mario/back-hair-long +bounds:194,2,86,91 +rotate:90 +mario/beard +bounds:1858,136,147,93 +mario/blush +bounds:1854,17,29,18 +mario/body +bounds:1018,60,70,98 +rotate:90 +mario/ear +bounds:1949,100,34,42 +rotate:90 +mario/eyebrow +bounds:287,71,32,17 +mario/hair-front +bounds:874,158,137,66 +mario/head-base +bounds:1350,221,143,125 +mario/leg +bounds:1137,146,28,101 +rotate:90 +misaki/arm +bounds:1489,11,28,90 +rotate:90 +misaki/back-hair +bounds:1045,348,158,141 +misaki/back-hair-long +bounds:2,38,190,195 +misaki/belt +bounds:1016,2,76,26 +misaki/blush +bounds:1925,40,29,18 +rotate:90 +misaki/body +bounds:1701,36,70,98 +rotate:90 +misaki/ear +bounds:1949,64,34,42 +rotate:90 +misaki/eyebrow +bounds:775,2,30,12 +misaki/glasses +bounds:875,72,141,35 +misaki/glasses-side +bounds:1240,146,8,23 +rotate:90 +misaki/hair-front +bounds:733,88,140,59 +misaki/hair-side +bounds:875,109,47,140 +rotate:90 +misaki/head-base +bounds:1495,221,143,125 +misaki/leg +bounds:1601,109,28,101 +rotate:90 +misaki/skirt +bounds:1385,129,108,90 +nate/arm +bounds:1581,49,28,90 +rotate:90 +nate/back-hair +bounds:1205,348,158,141 +nate/beard +bounds:584,111,147,68 +nate/body +bounds:1120,74,70,98 +rotate:90 +nate/ear +bounds:1845,37,34,42 +rotate:90 +nate/glasses +bounds:584,74,141,35 +nate/glasses-side +bounds:555,33,8,16 +rotate:90 +nate/hair-front +bounds:390,235,142,65 +nate/head-base +bounds:1713,232,143,125 +nate/leg +bounds:1704,108,28,101 +rotate:90 +sinisa/arm +bounds:1581,19,28,90 +rotate:90 +sinisa/back-hair +bounds:1365,348,158,141 +sinisa/beard +bounds:875,25,139,45 +sinisa/blush +bounds:1945,44,29,18 +sinisa/body +bounds:1119,2,70,98 +rotate:90 +sinisa/body-decoration +bounds:555,74,27,27 +sinisa/ear +bounds:1889,29,34,42 +sinisa/eyebrow +bounds:1997,451,38,18 +offsets:0,0,38,19 +rotate:90 +sinisa/hair-front +bounds:1713,138,143,92 +sinisa/head-base +bounds:1858,231,143,125 +sinisa/leg +bounds:1495,101,28,101 +rotate:90 +soeren/arm +bounds:1673,6,28,90 +rotate:90 +soeren/back-hair +bounds:194,90,150,141 +soeren/beard +bounds:408,33,145,68 +soeren/blush +bounds:1885,9,29,18 +soeren/body +bounds:1219,2,70,98 +rotate:90 +soeren/eyebrow +bounds:2003,329,27,12 +rotate:90 +soeren/glasses +bounds:395,302,152,37 +soeren/glasses-side +bounds:1486,2,7,20 +rotate:90 +soeren/glove +bounds:1368,14,42,53 +soeren/hair-front +bounds:752,233,159,113 +soeren/leg +bounds:1598,79,28,101 +rotate:90 +spineboy/arm +bounds:1857,106,28,90 +rotate:90 +spineboy/arm-decoration +bounds:534,266,32,29 +rotate:90 +spineboy/arm-shoulder-decoration +bounds:1973,19,23,23 +spineboy/back-hair +bounds:1525,348,158,141 +spineboy/body +bounds:1220,74,70,98 +rotate:90 +spineboy/glasses +bounds:1685,359,179,89 +spineboy/glasses-shadow +bounds:733,149,139,82 +spineboy/hair-front +bounds:913,226,145,120 +spineboy/leg +bounds:472,2,29,101 +rotate:90 diff --git a/spine-flutter/example/assets/chibi/chibi-stickers.skel b/spine-flutter/example/assets/chibi/chibi-stickers.skel new file mode 100644 index 000000000..61779a67b Binary files /dev/null and b/spine-flutter/example/assets/chibi/chibi-stickers.skel differ diff --git a/spine-flutter/example/assets/chibi/chibi-stickers.webp b/spine-flutter/example/assets/chibi/chibi-stickers.webp new file mode 100644 index 000000000..2232efb04 Binary files /dev/null and b/spine-flutter/example/assets/chibi/chibi-stickers.webp differ diff --git a/spine-flutter/example/ios/Runner.xcodeproj/project.pbxproj b/spine-flutter/example/ios/Runner.xcodeproj/project.pbxproj index 8923345ba..034aaeae5 100644 --- a/spine-flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/spine-flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -200,6 +200,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -231,6 +232,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/spine-flutter/example/ios/Runner/Info.plist b/spine-flutter/example/ios/Runner/Info.plist index 2cd8ded28..e2c1c6498 100644 --- a/spine-flutter/example/ios/Runner/Info.plist +++ b/spine-flutter/example/ios/Runner/Info.plist @@ -45,5 +45,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/spine-flutter/example/lib/animated_login.dart b/spine-flutter/example/lib/animated_login.dart new file mode 100644 index 000000000..373e3ea9d --- /dev/null +++ b/spine-flutter/example/lib/animated_login.dart @@ -0,0 +1,30 @@ +import 'package:spine_flutter/spine_flutter.dart'; +import 'package:flutter/material.dart'; + +class AnimatedLogin extends StatelessWidget { + const AnimatedLogin({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + reportLeaks(); + final controller = SpineWidgetController(onInitialized: (controller) { + controller.skeleton.setSkinByName("nate"); + controller.skeleton.setToSetupPose(); + controller.animationState.setAnimationByName(0, "login/look-left-down", true); + }); + + return Scaffold( + appBar: AppBar(title: const Text('Animated login')), + body: Container( + margin: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(3.0), + decoration: BoxDecoration(border: Border.all(color: Colors.blueAccent)), + child: SpineWidget.fromAsset( + "assets/chibi/chibi-stickers.atlas", + "assets/chibi/chibi-stickers.skel", + controller, + boundsProvider: SkinAndAnimationBounds(skins: ["nate"], animation: "login/look-left-down"), + sizedByBounds: true, + ))); + } +} diff --git a/spine-flutter/example/lib/main.dart b/spine-flutter/example/lib/main.dart index f0f65bcf1..87453379e 100644 --- a/spine-flutter/example/lib/main.dart +++ b/spine-flutter/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:spine_flutter/spine_flutter.dart'; import 'package:flutter/material.dart'; +import 'package:spine_flutter_example/animated_login.dart'; import 'package:spine_flutter_example/debug_rendering.dart'; import 'animation_state_events.dart'; @@ -67,6 +68,18 @@ class ExampleSelector extends StatelessWidget { }, ), spacer, + ElevatedButton( + child: const Text('Animated login'), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AnimatedLogin(), + ), + ); + }, + ), + spacer, ElevatedButton( child: const Text('Dress Up'), onPressed: () { diff --git a/spine-flutter/lib/ffi_proxy.dart b/spine-flutter/lib/ffi_proxy.dart index 0925c3838..2c16e09d2 100644 --- a/spine-flutter/lib/ffi_proxy.dart +++ b/spine-flutter/lib/ffi_proxy.dart @@ -1,3 +1,32 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated September 24, 2021. Replaces all prior versions. + * + * Copyright (c) 2013-2021, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + export 'dart:ffi' if (dart.library.html) 'package:web_ffi_fork/web_ffi.dart'; export 'package:ffi/ffi.dart' if (dart.library.html) 'package:web_ffi_fork/src/ffi/utf8.dart'; diff --git a/spine-flutter/lib/init.dart b/spine-flutter/lib/init.dart index 69667bf53..7655d5e44 100644 --- a/spine-flutter/lib/init.dart +++ b/spine-flutter/lib/init.dart @@ -1,3 +1,32 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated September 24, 2021. Replaces all prior versions. + * + * Copyright (c) 2013-2021, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + import 'dart:ffi'; import 'dart:io'; diff --git a/spine-flutter/lib/init_web.dart b/spine-flutter/lib/init_web.dart index 2cfa7d645..34fc91d50 100644 --- a/spine-flutter/lib/init_web.dart +++ b/spine-flutter/lib/init_web.dart @@ -1,3 +1,32 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated September 24, 2021. Replaces all prior versions. + * + * Copyright (c) 2013-2021, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + // ignore_for_file: type_argument_not_matching_bounds import 'package:flutter/services.dart'; import 'package:inject_js/inject_js.dart' as js; diff --git a/spine-flutter/lib/spine_flutter.dart b/spine-flutter/lib/spine_flutter.dart index 0aaa4ee13..6a053a31a 100644 --- a/spine-flutter/lib/spine_flutter.dart +++ b/spine-flutter/lib/spine_flutter.dart @@ -1,3 +1,32 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated September 24, 2021. Replaces all prior versions. + * + * Copyright (c) 2013-2021, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + import 'dart:convert' as convert; import 'dart:io'; import 'dart:typed_data'; diff --git a/spine-flutter/lib/spine_widget.dart b/spine-flutter/lib/spine_widget.dart index 46e827b67..c34d46a6d 100644 --- a/spine-flutter/lib/spine_widget.dart +++ b/spine-flutter/lib/spine_widget.dart @@ -1,3 +1,32 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated September 24, 2021. Replaces all prior versions. + * + * Copyright (c) 2013-2021, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + import 'dart:math'; import 'package:flutter/rendering.dart' as rendering; @@ -212,12 +241,12 @@ class SkinAndAnimationBounds extends BoundsProvider { maxY = max(maxY, minY + bounds.height); } } - customSkin.dispose(); drawable.skeleton.setSkinByName("default"); drawable.animationState.clearTracks(); if (oldSkin != null) drawable.skeleton.setSkin(oldSkin); drawable.skeleton.setToSetupPose(); drawable.update(0); + customSkin.dispose(); return Bounds(minX, minY, maxX - minX, maxY - minY); } } diff --git a/spine-flutter/src/main.cpp b/spine-flutter/src/main.cpp deleted file mode 100644 index 170a9e0b4..000000000 --- a/spine-flutter/src/main.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "spine/spine.h" -#include "spine_flutter.h" - -using namespace spine; - -String blendMode(spine_blend_mode mode) { - switch(mode) { - case SPINE_BLEND_MODE_NORMAL: - return "normal"; - case SPINE_BLEND_MODE_ADDITIVE: - return "additiev"; - case SPINE_BLEND_MODE_MULTIPLY: - return "multiply"; - case SPINE_BLEND_MODE_SCREEN: - return "screen"; - } -} - -int main(int argc, char** argv) { - int atlasLength = 0; - void* atlasData = SpineExtension::getInstance()->_readFile("/Users/badlogic/workspaces/spine-runtimes/spine-flutter/example/assets/dragon.atlas", &atlasLength); - uint8_t* cstringAtlas = SpineExtension::calloc(atlasLength + 1, __FILE__, __LINE__); - memcpy(cstringAtlas, atlasData, atlasLength); - int dataLength = 0; - uint8_t* data = (uint8_t*)SpineExtension::getInstance()->_readFile("/Users/badlogic/workspaces/spine-runtimes/spine-flutter/example/assets/dragon-ess.skel", &dataLength); - - spine_atlas atlas = spine_atlas_load((const utf8*)cstringAtlas); - Vector atlasPages; - for (int i = 0, n = spine_atlas_get_num_image_paths(atlas); i < n; i++) { - atlasPages.add(spine_atlas_get_image_path(atlas, i)); - } - - spine_skeleton_data_result result = spine_skeleton_data_load_binary(atlas, data, dataLength); - spine_skeleton_drawable drawable = spine_skeleton_drawable_create(spine_skeleton_data_result_get_data(result)); - spine_skeleton skeleton = spine_skeleton_drawable_get_skeleton(drawable); - spine_skeleton_update_world_transform(skeleton); - spine_render_command cmd = spine_skeleton_drawable_render(drawable); - - int batchId = 0; - while(cmd) { - int numVertices = spine_render_command_get_num_vertices(cmd); - int numIndices = spine_render_command_get_num_indices(cmd); - float *positions = spine_render_command_get_positions(cmd); - float *uvs = spine_render_command_get_uvs(cmd); - int32_t *colors = spine_render_command_get_colors(cmd); - uint16_t *indices = spine_render_command_get_indices(cmd); - String str; - int atlasPage = spine_render_command_get_atlas_page(cmd); - str.append(atlasPages[atlasPage]); - str.append("\n"); - str.append(blendMode(spine_render_command_get_blend_mode(cmd))); - str.append("\n"); - str.append(numVertices); - str.append("\n"); - str.append(numIndices); - str.append("\n"); - for (int i = 0; i < numVertices * 2; i++) { - str.append(positions[i]); - str.append("\n"); - } - for (int i = 0; i < numVertices * 2; i++) { - str.append(uvs[i]); - str.append("\n"); - } - for (int i = 0; i < numVertices; i++) { - str.append(colors[i]); - str.append("\n"); - } - for (int i = 0; i < numIndices; i++) { - str.append(indices[i]); - str.append("\n"); - } - String outputFile = ""; - outputFile.append("/Users/badlogic/Desktop/dragon-"); - outputFile.append(batchId); - outputFile.append(".mesh"); - FILE *file = fopen(outputFile.buffer(), "w"); - fwrite(str.buffer(), str.length(), 1, file); - fclose(file); - batchId++; - cmd = spine_render_command_get_next(cmd); - } -} \ No newline at end of file