├── .gitignore ├── config.py ├── SCsub ├── register_types.h ├── src └── spine │ ├── EventData.c │ ├── Event.c │ ├── PathConstraintData.c │ ├── IkConstraintData.c │ ├── TransformConstraintData.c │ ├── BoneData.c │ ├── BoundingBoxAttachment.c │ ├── SlotData.c │ ├── Attachment.c │ ├── PathAttachment.c │ ├── extension.c │ ├── Json.h │ ├── Slot.c │ ├── kvec.h │ ├── Skin.c │ ├── AtlasAttachmentLoader.c │ ├── MeshAttachment.c │ ├── VertexAttachment.c │ ├── AttachmentLoader.c │ ├── TransformConstraint.c │ ├── AnimationStateData.c │ ├── RegionAttachment.c │ └── SkeletonData.c ├── include └── spine │ ├── AtlasAttachmentLoader.h │ ├── EventData.h │ ├── Event.h │ ├── spine.h │ ├── BoundingBoxAttachment.h │ ├── IkConstraintData.h │ ├── PathAttachment.h │ ├── VertexAttachment.h │ ├── Attachment.h │ ├── BoneData.h │ ├── TransformConstraint.h │ ├── TransformConstraintData.h │ ├── SkeletonJson.h │ ├── SkeletonBinary.h │ ├── IkConstraint.h │ ├── SlotData.h │ ├── AnimationStateData.h │ ├── Slot.h │ ├── PathConstraintData.h │ ├── AttachmentLoader.h │ ├── Skin.h │ ├── MeshAttachment.h │ ├── RegionAttachment.h │ ├── PathConstraint.h │ ├── SkeletonData.h │ ├── Bone.h │ ├── SkeletonBounds.h │ ├── Atlas.h │ ├── Skeleton.h │ └── AnimationState.h ├── spine_batcher.h └── spine_batcher.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.pyc 4 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def can_build(platform): 4 | return True 5 | 6 | 7 | def configure(env): 8 | #env.Append(CPPFLAGS=['-DNEED_LONG_INT']) 9 | pass 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SCsub: -------------------------------------------------------------------------------- 1 | Import('env') 2 | Import('env_modules') 3 | 4 | env_modules.add_source_files(env.modules_sources,"src/spine/*.c") 5 | env_modules.add_source_files(env.modules_sources,"*.cpp") 6 | 7 | env_modules.Append(CPPFLAGS=[ 8 | "-I", "modules/spine/include", 9 | ]) 10 | 11 | Export('env_modules') 12 | Export('env') 13 | 14 | 15 | -------------------------------------------------------------------------------- /register_types.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* register_types.h */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* http://www.godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ 9 | /* */ 10 | /* Permission is hereby granted, free of charge, to any person obtaining */ 11 | /* a copy of this software and associated documentation files (the */ 12 | /* "Software"), to deal in the Software without restriction, including */ 13 | /* without limitation the rights to use, copy, modify, merge, publish, */ 14 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 15 | /* permit persons to whom the Software is furnished to do so, subject to */ 16 | /* the following conditions: */ 17 | /* */ 18 | /* The above copyright notice and this permission notice shall be */ 19 | /* included in all copies or substantial portions of the Software. */ 20 | /* */ 21 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 22 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 23 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 24 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 25 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 26 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 27 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 28 | /*************************************************************************/ 29 | void register_spine_types(); 30 | void unregister_spine_types(); 31 | -------------------------------------------------------------------------------- /src/spine/EventData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spEventData* spEventData_create (const char* name) { 35 | spEventData* self = NEW(spEventData); 36 | MALLOC_STR(self->name, name); 37 | return self; 38 | } 39 | 40 | void spEventData_dispose (spEventData* self) { 41 | FREE(self->stringValue); 42 | FREE(self->name); 43 | FREE(self); 44 | } 45 | -------------------------------------------------------------------------------- /src/spine/Event.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spEvent* spEvent_create (float time, spEventData* data) { 35 | spEvent* self = NEW(spEvent); 36 | CONST_CAST(spEventData*, self->data) = data; 37 | CONST_CAST(float, self->time) = time; 38 | return self; 39 | } 40 | 41 | void spEvent_dispose (spEvent* self) { 42 | FREE(self->stringValue); 43 | FREE(self); 44 | } 45 | -------------------------------------------------------------------------------- /src/spine/PathConstraintData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spPathConstraintData* spPathConstraintData_create (const char* name) { 35 | spPathConstraintData* self = NEW(spPathConstraintData); 36 | MALLOC_STR(self->name, name); 37 | return self; 38 | } 39 | 40 | void spPathConstraintData_dispose (spPathConstraintData* self) { 41 | FREE(self->name); 42 | FREE(self->bones); 43 | FREE(self); 44 | } 45 | -------------------------------------------------------------------------------- /src/spine/IkConstraintData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spIkConstraintData* spIkConstraintData_create (const char* name) { 35 | spIkConstraintData* self = NEW(spIkConstraintData); 36 | MALLOC_STR(self->name, name); 37 | self->bendDirection = 1; 38 | self->mix = 1; 39 | return self; 40 | } 41 | 42 | void spIkConstraintData_dispose (spIkConstraintData* self) { 43 | FREE(self->name); 44 | FREE(self->bones); 45 | FREE(self); 46 | } 47 | -------------------------------------------------------------------------------- /src/spine/TransformConstraintData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spTransformConstraintData* spTransformConstraintData_create (const char* name) { 35 | spTransformConstraintData* self = NEW(spTransformConstraintData); 36 | MALLOC_STR(self->name, name); 37 | return self; 38 | } 39 | 40 | void spTransformConstraintData_dispose (spTransformConstraintData* self) { 41 | FREE(self->name); 42 | FREE(self->bones); 43 | FREE(self); 44 | } 45 | -------------------------------------------------------------------------------- /src/spine/BoneData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spBoneData* spBoneData_create (int index, const char* name, spBoneData* parent) { 35 | spBoneData* self = NEW(spBoneData); 36 | CONST_CAST(int, self->index) = index; 37 | MALLOC_STR(self->name, name); 38 | CONST_CAST(spBoneData*, self->parent) = parent; 39 | self->scaleX = 1; 40 | self->scaleY = 1; 41 | self->transformMode = SP_TRANSFORMMODE_NORMAL; 42 | return self; 43 | } 44 | 45 | void spBoneData_dispose (spBoneData* self) { 46 | FREE(self->name); 47 | FREE(self); 48 | } 49 | -------------------------------------------------------------------------------- /include/spine/AtlasAttachmentLoader.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ATLASATTACHMENTLOADER_H_ 32 | #define SPINE_ATLASATTACHMENTLOADER_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct spAtlasAttachmentLoader { 42 | spAttachmentLoader super; 43 | spAtlas* atlas; 44 | } spAtlasAttachmentLoader; 45 | 46 | spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas); 47 | 48 | #ifdef SPINE_SHORT_NAMES 49 | typedef spAtlasAttachmentLoader AtlasAttachmentLoader; 50 | #define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__) 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* SPINE_ATLASATTACHMENTLOADER_H_ */ 58 | -------------------------------------------------------------------------------- /src/spine/BoundingBoxAttachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | void _spBoundingBoxAttachment_dispose (spAttachment* attachment) { 35 | spBoundingBoxAttachment* self = SUB_CAST(spBoundingBoxAttachment, attachment); 36 | 37 | _spVertexAttachment_deinit(SUPER(self)); 38 | 39 | FREE(self); 40 | } 41 | 42 | spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) { 43 | spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment); 44 | _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_BOUNDING_BOX, _spBoundingBoxAttachment_dispose); 45 | return self; 46 | } 47 | 48 | void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spSlot* slot, float* worldVertices) { 49 | spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); 50 | } 51 | -------------------------------------------------------------------------------- /src/spine/SlotData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spSlotData* spSlotData_create (const int index, const char* name, spBoneData* boneData) { 35 | spSlotData* self = NEW(spSlotData); 36 | CONST_CAST(int, self->index) = index; 37 | MALLOC_STR(self->name, name); 38 | CONST_CAST(spBoneData*, self->boneData) = boneData; 39 | self->r = 1; 40 | self->g = 1; 41 | self->b = 1; 42 | self->a = 1; 43 | return self; 44 | } 45 | 46 | void spSlotData_dispose (spSlotData* self) { 47 | FREE(self->name); 48 | FREE(self->attachmentName); 49 | FREE(self); 50 | } 51 | 52 | void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName) { 53 | FREE(self->attachmentName); 54 | if (attachmentName) 55 | MALLOC_STR(self->attachmentName, attachmentName); 56 | else 57 | CONST_CAST(char*, self->attachmentName) = 0; 58 | } 59 | -------------------------------------------------------------------------------- /include/spine/EventData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_EVENTDATA_H_ 32 | #define SPINE_EVENTDATA_H_ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct spEventData { 39 | const char* const name; 40 | int intValue; 41 | float floatValue; 42 | const char* stringValue; 43 | 44 | #ifdef __cplusplus 45 | spEventData() : 46 | name(0), 47 | intValue(0), 48 | floatValue(0), 49 | stringValue(0) { 50 | } 51 | #endif 52 | } spEventData; 53 | 54 | spEventData* spEventData_create (const char* name); 55 | void spEventData_dispose (spEventData* self); 56 | 57 | #ifdef SPINE_SHORT_NAMES 58 | typedef spEventData EventData; 59 | #define EventData_create(...) spEventData_create(__VA_ARGS__) 60 | #define EventData_dispose(...) spEventData_dispose(__VA_ARGS__) 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* SPINE_EVENTDATA_H_ */ 68 | -------------------------------------------------------------------------------- /include/spine/Event.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_EVENT_H_ 32 | #define SPINE_EVENT_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | typedef struct spEvent { 41 | spEventData* const data; 42 | float const time; 43 | int intValue; 44 | float floatValue; 45 | const char* stringValue; 46 | 47 | #ifdef __cplusplus 48 | spEvent() : 49 | data(0), 50 | time(0), 51 | intValue(0), 52 | floatValue(0), 53 | stringValue(0) { 54 | } 55 | #endif 56 | } spEvent; 57 | 58 | spEvent* spEvent_create (float time, spEventData* data); 59 | void spEvent_dispose (spEvent* self); 60 | 61 | #ifdef SPINE_SHORT_NAMES 62 | typedef spEvent Event; 63 | #define Event_create(...) spEvent_create(__VA_ARGS__) 64 | #define Event_dispose(...) spEvent_dispose(__VA_ARGS__) 65 | #endif 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* SPINE_EVENT_H_ */ 72 | -------------------------------------------------------------------------------- /include/spine/spine.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SPINE_H_ 32 | #define SPINE_SPINE_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | #endif /* SPINE_SPINE_H_ */ 59 | -------------------------------------------------------------------------------- /src/spine/Attachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | typedef struct _spAttachmentVtable { 36 | void (*dispose) (spAttachment* self); 37 | } _spAttachmentVtable; 38 | 39 | void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ 40 | void (*dispose) (spAttachment* self)) { 41 | 42 | CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable); 43 | VTABLE(spAttachment, self) ->dispose = dispose; 44 | 45 | MALLOC_STR(self->name, name); 46 | CONST_CAST(spAttachmentType, self->type) = type; 47 | } 48 | 49 | void _spAttachment_deinit (spAttachment* self) { 50 | if (self->attachmentLoader) spAttachmentLoader_disposeAttachment(self->attachmentLoader, self); 51 | FREE(self->vtable); 52 | FREE(self->name); 53 | } 54 | 55 | void spAttachment_dispose (spAttachment* self) { 56 | VTABLE(spAttachment, self) ->dispose(self); 57 | } 58 | -------------------------------------------------------------------------------- /src/spine/PathAttachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | void _spPathAttachment_dispose (spAttachment* attachment) { 35 | spPathAttachment* self = SUB_CAST(spPathAttachment, attachment); 36 | 37 | _spVertexAttachment_deinit(SUPER(self)); 38 | 39 | FREE(self->lengths); 40 | FREE(self); 41 | } 42 | 43 | spPathAttachment* spPathAttachment_create (const char* name) { 44 | spPathAttachment* self = NEW(spPathAttachment); 45 | _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_PATH, _spPathAttachment_dispose); 46 | return self; 47 | } 48 | 49 | void spPathAttachment_computeWorldVertices (spPathAttachment* self, spSlot* slot, float* worldVertices) { 50 | spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); 51 | } 52 | 53 | void spPathAttachment_computeWorldVertices1 (spPathAttachment* self, spSlot* slot, int start, int count, float* worldVertices, int offset) { 54 | spVertexAttachment_computeWorldVertices1(SUPER(self), start, count, slot, worldVertices, offset); 55 | } 56 | -------------------------------------------------------------------------------- /include/spine/BoundingBoxAttachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_BOUNDINGBOXATTACHMENT_H_ 32 | #define SPINE_BOUNDINGBOXATTACHMENT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | typedef struct spBoundingBoxAttachment { 44 | spVertexAttachment super; 45 | } spBoundingBoxAttachment; 46 | 47 | spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name); 48 | void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spSlot* slot, float* worldVertices); 49 | 50 | #ifdef SPINE_SHORT_NAMES 51 | typedef spBoundingBoxAttachment BoundingBoxAttachment; 52 | #define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__) 53 | #define BoundingBoxAttachment_computeWorldVertices(...) spBoundingBoxAttachment_computeWorldVertices(__VA_ARGS__) 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* SPINE_BOUNDINGBOXATTACHMENT_H_ */ 61 | -------------------------------------------------------------------------------- /include/spine/IkConstraintData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_IKCONSTRAINTDATA_H_ 32 | #define SPINE_IKCONSTRAINTDATA_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | typedef struct spIkConstraintData { 41 | const char* const name; 42 | int order; 43 | int bonesCount; 44 | spBoneData** bones; 45 | 46 | spBoneData* target; 47 | int bendDirection; 48 | float mix; 49 | 50 | #ifdef __cplusplus 51 | spIkConstraintData() : 52 | name(0), 53 | bonesCount(0), 54 | bones(0), 55 | target(0), 56 | bendDirection(0), 57 | mix(0) { 58 | } 59 | #endif 60 | } spIkConstraintData; 61 | 62 | spIkConstraintData* spIkConstraintData_create (const char* name); 63 | void spIkConstraintData_dispose (spIkConstraintData* self); 64 | 65 | #ifdef SPINE_SHORT_NAMES 66 | typedef spIkConstraintData IkConstraintData; 67 | #define IkConstraintData_create(...) spIkConstraintData_create(__VA_ARGS__) 68 | #define IkConstraintData_dispose(...) spIkConstraintData_dispose(__VA_ARGS__) 69 | #endif 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* SPINE_IKCONSTRAINTDATA_H_ */ 76 | -------------------------------------------------------------------------------- /include/spine/PathAttachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_PATHATTACHMENT_H_ 32 | #define SPINE_PATHATTACHMENT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | typedef struct spPathAttachment { 44 | spVertexAttachment super; 45 | int lengthsLength; 46 | float* lengths; 47 | int/*bool*/ closed, constantSpeed; 48 | } spPathAttachment; 49 | 50 | spPathAttachment* spPathAttachment_create (const char* name); 51 | void spPathAttachment_computeWorldVertices (spPathAttachment* self, spSlot* slot, float* worldVertices); 52 | void spPathAttachment_computeWorldVertices1 (spPathAttachment* self, spSlot* slot, int start, int count, float* worldVertices, int offset); 53 | 54 | #ifdef SPINE_SHORT_NAMES 55 | typedef spPathAttachment PathAttachment; 56 | #define PathAttachment_create(...) spPathAttachment_create(__VA_ARGS__) 57 | #define PathAttachment_computeWorldVertices(...) spPathAttachment_computeWorldVertices(__VA_ARGS__) 58 | #endif 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* SPINE_PATHATTACHMENT_H_ */ 65 | -------------------------------------------------------------------------------- /include/spine/VertexAttachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_VERTEXATTACHMENT_H_ 32 | #define SPINE_VERTEXATTACHMENT_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct spVertexAttachment spVertexAttachment; 42 | struct spVertexAttachment { 43 | spAttachment super; 44 | 45 | int bonesCount; 46 | int* bones; 47 | 48 | int verticesCount; 49 | float* vertices; 50 | 51 | int worldVerticesLength; 52 | }; 53 | 54 | void spVertexAttachment_computeWorldVertices (spVertexAttachment* self, spSlot* slot, float* worldVertices); 55 | void spVertexAttachment_computeWorldVertices1 (spVertexAttachment* self, int start, int count, spSlot* slot, float* worldVertices, int offset); 56 | 57 | #ifdef SPINE_SHORT_NAMES 58 | typedef spVertexAttachment VertexAttachment; 59 | #define VertexAttachment_computeWorldVertices(...) spVertexAttachment_computeWorldVertices(__VA_ARGS__) 60 | #define VertexAttachment_computeWorldVertices1(...) spVertexAttachment_computeWorldVertices1(__VA_ARGS__) 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* SPINE_VERTEXATTACHMENT_H_ */ 68 | -------------------------------------------------------------------------------- /include/spine/Attachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ATTACHMENT_H_ 32 | #define SPINE_ATTACHMENT_H_ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | struct spAttachmentLoader; 39 | 40 | typedef enum { 41 | SP_ATTACHMENT_REGION, 42 | SP_ATTACHMENT_BOUNDING_BOX, 43 | SP_ATTACHMENT_MESH, 44 | SP_ATTACHMENT_LINKED_MESH, 45 | SP_ATTACHMENT_PATH 46 | } spAttachmentType; 47 | 48 | typedef struct spAttachment { 49 | const char* const name; 50 | const spAttachmentType type; 51 | const void* const vtable; 52 | struct spAttachmentLoader* attachmentLoader; 53 | 54 | #ifdef __cplusplus 55 | spAttachment() : 56 | name(0), 57 | type(SP_ATTACHMENT_REGION), 58 | vtable(0) { 59 | } 60 | #endif 61 | } spAttachment; 62 | 63 | void spAttachment_dispose (spAttachment* self); 64 | 65 | #ifdef SPINE_SHORT_NAMES 66 | typedef spAttachmentType AttachmentType; 67 | #define ATTACHMENT_REGION SP_ATTACHMENT_REGION 68 | #define ATTACHMENT_BOUNDING_BOX SP_ATTACHMENT_BOUNDING_BOX 69 | #define ATTACHMENT_MESH SP_ATTACHMENT_MESH 70 | #define ATTACHMENT_LINKED_MESH SP_ATTACHMENT_LINKED_MESH 71 | typedef spAttachment Attachment; 72 | #define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__) 73 | #endif 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* SPINE_ATTACHMENT_H_ */ 80 | -------------------------------------------------------------------------------- /src/spine/extension.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | static void* (*mallocFunc) (size_t size) = malloc; 35 | static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL; 36 | static void (*freeFunc) (void* ptr) = free; 37 | 38 | void* _malloc (size_t size, const char* file, int line) { 39 | if(debugMallocFunc) 40 | return debugMallocFunc(size, file, line); 41 | 42 | return mallocFunc(size); 43 | } 44 | void* _calloc (size_t num, size_t size, const char* file, int line) { 45 | void* ptr = _malloc(num * size, file, line); 46 | if (ptr) memset(ptr, 0, num * size); 47 | return ptr; 48 | } 49 | void _free (void* ptr) { 50 | freeFunc(ptr); 51 | } 52 | 53 | void _setDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) { 54 | debugMallocFunc = malloc; 55 | } 56 | 57 | void _setMalloc (void* (*malloc) (size_t size)) { 58 | mallocFunc = malloc; 59 | } 60 | void _setFree (void (*free) (void* ptr)) { 61 | freeFunc = free; 62 | } 63 | 64 | char* _readFile (const char* path, int* length) { 65 | char *data; 66 | FILE *file = fopen(path, "rb"); 67 | if (!file) return 0; 68 | 69 | fseek(file, 0, SEEK_END); 70 | *length = (int)ftell(file); 71 | fseek(file, 0, SEEK_SET); 72 | 73 | data = MALLOC(char, *length); 74 | fread(data, 1, *length, file); 75 | fclose(file); 76 | 77 | return data; 78 | } 79 | -------------------------------------------------------------------------------- /include/spine/BoneData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_BONEDATA_H_ 32 | #define SPINE_BONEDATA_H_ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef enum { 39 | SP_TRANSFORMMODE_NORMAL, 40 | SP_TRANSFORMMODE_ONLYTRANSLATION, 41 | SP_TRANSFORMMODE_NOROTATIONORREFLECTION, 42 | SP_TRANSFORMMODE_NOSCALE, 43 | SP_TRANSFORMMODE_NOSCALEORREFLECTION 44 | } spTransformMode; 45 | 46 | typedef struct spBoneData spBoneData; 47 | struct spBoneData { 48 | const int index; 49 | const char* const name; 50 | spBoneData* const parent; 51 | float length; 52 | float x, y, rotation, scaleX, scaleY, shearX, shearY; 53 | spTransformMode transformMode; 54 | 55 | #ifdef __cplusplus 56 | spBoneData() : 57 | index(0), 58 | name(0), 59 | parent(0), 60 | length(0), 61 | x(0), y(0), 62 | rotation(0), 63 | scaleX(0), scaleY(0), 64 | shearX(0), shearY(0), 65 | transformMode(SP_TRANSFORMMODE_NORMAL) { 66 | } 67 | #endif 68 | }; 69 | 70 | spBoneData* spBoneData_create (int index, const char* name, spBoneData* parent); 71 | void spBoneData_dispose (spBoneData* self); 72 | 73 | #ifdef SPINE_SHORT_NAMES 74 | typedef spBoneData BoneData; 75 | #define BoneData_create(...) spBoneData_create(__VA_ARGS__) 76 | #define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__) 77 | #endif 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* SPINE_BONEDATA_H_ */ 84 | -------------------------------------------------------------------------------- /include/spine/TransformConstraint.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_TRANSFORMCONSTRAINT_H_ 32 | #define SPINE_TRANSFORMCONSTRAINT_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | struct spSkeleton; 42 | 43 | typedef struct spTransformConstraint { 44 | spTransformConstraintData* const data; 45 | int bonesCount; 46 | spBone** const bones; 47 | spBone* target; 48 | float rotateMix, translateMix, scaleMix, shearMix; 49 | 50 | #ifdef __cplusplus 51 | spTransformConstraint() : 52 | data(0), 53 | bonesCount(0), 54 | bones(0), 55 | target(0), 56 | rotateMix(0), 57 | translateMix(0), 58 | scaleMix(0), 59 | shearMix(0) { 60 | } 61 | #endif 62 | } spTransformConstraint; 63 | 64 | spTransformConstraint* spTransformConstraint_create (spTransformConstraintData* data, const struct spSkeleton* skeleton); 65 | void spTransformConstraint_dispose (spTransformConstraint* self); 66 | 67 | void spTransformConstraint_apply (spTransformConstraint* self); 68 | 69 | #ifdef SPINE_SHORT_NAMES 70 | typedef spTransformConstraint TransformConstraint; 71 | #define TransformConstraint_create(...) spTransformConstraint_create(__VA_ARGS__) 72 | #define TransformConstraint_dispose(...) spTransformConstraint_dispose(__VA_ARGS__) 73 | #define TransformConstraint_apply(...) spTransformConstraint_apply(__VA_ARGS__) 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* SPINE_TRANSFORMCONSTRAINT_H_ */ 81 | -------------------------------------------------------------------------------- /include/spine/TransformConstraintData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_TRANSFORMCONSTRAINTDATA_H_ 32 | #define SPINE_TRANSFORMCONSTRAINTDATA_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | typedef struct spTransformConstraintData { 41 | const char* const name; 42 | int order; 43 | int bonesCount; 44 | spBoneData** const bones; 45 | spBoneData* target; 46 | float rotateMix, translateMix, scaleMix, shearMix; 47 | float offsetRotation, offsetX, offsetY, offsetScaleX, offsetScaleY, offsetShearY; 48 | 49 | #ifdef __cplusplus 50 | spTransformConstraintData() : 51 | name(0), 52 | bonesCount(0), 53 | bones(0), 54 | target(0), 55 | rotateMix(0), 56 | translateMix(0), 57 | scaleMix(0), 58 | shearMix(0), 59 | offsetRotation(0), 60 | offsetX(0), 61 | offsetY(0), 62 | offsetScaleX(0), 63 | offsetScaleY(0), 64 | offsetShearY(0) { 65 | } 66 | #endif 67 | } spTransformConstraintData; 68 | 69 | spTransformConstraintData* spTransformConstraintData_create (const char* name); 70 | void spTransformConstraintData_dispose (spTransformConstraintData* self); 71 | 72 | #ifdef SPINE_SHORT_NAMES 73 | typedef spTransformConstraintData TransformConstraintData; 74 | #define TransformConstraintData_create(...) spTransformConstraintData_create(__VA_ARGS__) 75 | #define TransformConstraintData_dispose(...) spTransformConstraintData_dispose(__VA_ARGS__) 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* SPINE_TRANSFORMCONSTRAINTDATA_H_ */ 83 | -------------------------------------------------------------------------------- /include/spine/SkeletonJson.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKELETONJSON_H_ 32 | #define SPINE_SKELETONJSON_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | struct spAtlasAttachmentLoader; 45 | 46 | typedef struct spSkeletonJson { 47 | float scale; 48 | spAttachmentLoader* attachmentLoader; 49 | const char* const error; 50 | } spSkeletonJson; 51 | 52 | spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader); 53 | spSkeletonJson* spSkeletonJson_create (spAtlas* atlas); 54 | void spSkeletonJson_dispose (spSkeletonJson* self); 55 | 56 | spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json); 57 | spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path); 58 | 59 | #ifdef SPINE_SHORT_NAMES 60 | typedef spSkeletonJson SkeletonJson; 61 | #define SkeletonJson_createWithLoader(...) spSkeletonJson_createWithLoader(__VA_ARGS__) 62 | #define SkeletonJson_create(...) spSkeletonJson_create(__VA_ARGS__) 63 | #define SkeletonJson_dispose(...) spSkeletonJson_dispose(__VA_ARGS__) 64 | #define SkeletonJson_readSkeletonData(...) spSkeletonJson_readSkeletonData(__VA_ARGS__) 65 | #define SkeletonJson_readSkeletonDataFile(...) spSkeletonJson_readSkeletonDataFile(__VA_ARGS__) 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* SPINE_SKELETONJSON_H_ */ 73 | -------------------------------------------------------------------------------- /src/spine/Json.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Dave Gamble 3 | 4 | Permission is hereby granted, dispose of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | /* Esoteric Software: Removed everything except parsing, shorter method names, more get methods, double to float, formatted. */ 24 | 25 | #ifndef SPINE_JSON_H_ 26 | #define SPINE_JSON_H_ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /* Json Types: */ 33 | #define Json_False 0 34 | #define Json_True 1 35 | #define Json_NULL 2 36 | #define Json_Number 3 37 | #define Json_String 4 38 | #define Json_Array 5 39 | #define Json_Object 6 40 | 41 | #ifndef SPINE_JSON_HAVE_PREV 42 | /* Spine doesn't use the "prev" link in the Json sibling lists. */ 43 | #define SPINE_JSON_HAVE_PREV 0 44 | #endif 45 | 46 | /* The Json structure: */ 47 | typedef struct Json { 48 | struct Json* next; 49 | #if SPINE_JSON_HAVE_PREV 50 | struct Json* prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */ 51 | #endif 52 | struct Json* child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ 53 | 54 | int type; /* The type of the item, as above. */ 55 | int size; /* The number of children. */ 56 | 57 | const char* valueString; /* The item's string, if type==Json_String */ 58 | int valueInt; /* The item's number, if type==Json_Number */ 59 | float valueFloat; /* The item's number, if type==Json_Number */ 60 | 61 | const char* name; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ 62 | } Json; 63 | 64 | /* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */ 65 | Json* Json_create (const char* value); 66 | 67 | /* Delete a Json entity and all subentities. */ 68 | void Json_dispose (Json* json); 69 | 70 | /* Get item "string" from object. Case insensitive. */ 71 | Json* Json_getItem (Json* json, const char* string); 72 | const char* Json_getString (Json* json, const char* name, const char* defaultValue); 73 | float Json_getFloat (Json* json, const char* name, float defaultValue); 74 | int Json_getInt (Json* json, const char* name, int defaultValue); 75 | 76 | /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when Json_create() returns 0. 0 when Json_create() succeeds. */ 77 | const char* Json_getError (void); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* SPINE_JSON_H_ */ 84 | -------------------------------------------------------------------------------- /include/spine/SkeletonBinary.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKELETONBINARY_H_ 32 | #define SPINE_SKELETONBINARY_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | struct spAtlasAttachmentLoader; 44 | 45 | typedef struct spSkeletonBinary { 46 | float scale; 47 | spAttachmentLoader* attachmentLoader; 48 | const char* const error; 49 | } spSkeletonBinary; 50 | 51 | spSkeletonBinary* spSkeletonBinary_createWithLoader (spAttachmentLoader* attachmentLoader); 52 | spSkeletonBinary* spSkeletonBinary_create (spAtlas* atlas); 53 | void spSkeletonBinary_dispose (spSkeletonBinary* self); 54 | 55 | spSkeletonData* spSkeletonBinary_readSkeletonData (spSkeletonBinary* self, const unsigned char* binary, const int length); 56 | spSkeletonData* spSkeletonBinary_readSkeletonDataFile (spSkeletonBinary* self, const char* path); 57 | 58 | #ifdef SPINE_SHORT_NAMES 59 | typedef spSkeletonBinary SkeletonBinary; 60 | #define SkeletonBinary_createWithLoader(...) spSkeletonBinary_createWithLoader(__VA_ARGS__) 61 | #define SkeletonBinary_create(...) spSkeletonBinary_create(__VA_ARGS__) 62 | #define SkeletonBinary_dispose(...) spSkeletonBinary_dispose(__VA_ARGS__) 63 | #define SkeletonBinary_readSkeletonData(...) spSkeletonBinary_readSkeletonData(__VA_ARGS__) 64 | #define SkeletonBinary_readSkeletonDataFile(...) spSkeletonBinary_readSkeletonDataFile(__VA_ARGS__) 65 | #endif 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* SPINE_SKELETONBINARY_H_ */ 72 | -------------------------------------------------------------------------------- /include/spine/IkConstraint.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_IKCONSTRAINT_H_ 32 | #define SPINE_IKCONSTRAINT_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | struct spSkeleton; 42 | 43 | typedef struct spIkConstraint { 44 | spIkConstraintData* const data; 45 | 46 | int bonesCount; 47 | spBone** bones; 48 | 49 | spBone* target; 50 | int bendDirection; 51 | float mix; 52 | 53 | #ifdef __cplusplus 54 | spIkConstraint() : 55 | data(0), 56 | bonesCount(0), 57 | bones(0), 58 | target(0), 59 | bendDirection(0), 60 | mix(0) { 61 | } 62 | #endif 63 | } spIkConstraint; 64 | 65 | spIkConstraint* spIkConstraint_create (spIkConstraintData* data, const struct spSkeleton* skeleton); 66 | void spIkConstraint_dispose (spIkConstraint* self); 67 | 68 | void spIkConstraint_apply (spIkConstraint* self); 69 | 70 | void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float alpha); 71 | void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDirection, float alpha); 72 | 73 | #ifdef SPINE_SHORT_NAMES 74 | typedef spIkConstraint IkConstraint; 75 | #define IkConstraint_create(...) spIkConstraint_create(__VA_ARGS__) 76 | #define IkConstraint_dispose(...) spIkConstraint_dispose(__VA_ARGS__) 77 | #define IkConstraint_apply(...) spIkConstraint_apply(__VA_ARGS__) 78 | #define IkConstraint_apply1(...) spIkConstraint_apply1(__VA_ARGS__) 79 | #define IkConstraint_apply2(...) spIkConstraint_apply2(__VA_ARGS__) 80 | #endif 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* SPINE_IKCONSTRAINT_H_ */ 87 | -------------------------------------------------------------------------------- /src/spine/Slot.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | typedef struct { 35 | spSlot super; 36 | float attachmentTime; 37 | } _spSlot; 38 | 39 | spSlot* spSlot_create (spSlotData* data, spBone* bone) { 40 | spSlot* self = SUPER(NEW(_spSlot)); 41 | CONST_CAST(spSlotData*, self->data) = data; 42 | CONST_CAST(spBone*, self->bone) = bone; 43 | spSlot_setToSetupPose(self); 44 | return self; 45 | } 46 | 47 | void spSlot_dispose (spSlot* self) { 48 | FREE(self->attachmentVertices); 49 | FREE(self); 50 | } 51 | 52 | void spSlot_setAttachment (spSlot* self, spAttachment* attachment) { 53 | if (attachment == self->attachment) return; 54 | CONST_CAST(spAttachment*, self->attachment) = attachment; 55 | SUB_CAST(_spSlot, self)->attachmentTime = self->bone->skeleton->time; 56 | self->attachmentVerticesCount = 0; 57 | } 58 | 59 | void spSlot_setAttachmentTime (spSlot* self, float time) { 60 | SUB_CAST(_spSlot, self)->attachmentTime = self->bone->skeleton->time - time; 61 | } 62 | 63 | float spSlot_getAttachmentTime (const spSlot* self) { 64 | return self->bone->skeleton->time - SUB_CAST(_spSlot, self) ->attachmentTime; 65 | } 66 | 67 | void spSlot_setToSetupPose (spSlot* self) { 68 | self->r = self->data->r; 69 | self->g = self->data->g; 70 | self->b = self->data->b; 71 | self->a = self->data->a; 72 | 73 | if (!self->data->attachmentName) 74 | spSlot_setAttachment(self, 0); 75 | else { 76 | spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex( 77 | self->bone->skeleton, self->data->index, self->data->attachmentName); 78 | CONST_CAST(spAttachment*, self->attachment) = 0; 79 | spSlot_setAttachment(self, attachment); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /include/spine/SlotData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SLOTDATA_H_ 32 | #define SPINE_SLOTDATA_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | typedef enum { 41 | SP_BLEND_MODE_NORMAL, SP_BLEND_MODE_ADDITIVE, SP_BLEND_MODE_MULTIPLY, SP_BLEND_MODE_SCREEN 42 | } spBlendMode; 43 | 44 | typedef struct spSlotData { 45 | const int index; 46 | const char* const name; 47 | const spBoneData* const boneData; 48 | const char* attachmentName; 49 | float r, g, b, a; 50 | spBlendMode blendMode; 51 | 52 | #ifdef __cplusplus 53 | spSlotData() : 54 | index(0), 55 | name(0), 56 | boneData(0), 57 | attachmentName(0), 58 | r(0), g(0), b(0), a(0), 59 | blendMode(SP_BLEND_MODE_NORMAL) { 60 | } 61 | #endif 62 | } spSlotData; 63 | 64 | spSlotData* spSlotData_create (const int index, const char* name, spBoneData* boneData); 65 | void spSlotData_dispose (spSlotData* self); 66 | 67 | /* @param attachmentName May be 0 for no setup pose attachment. */ 68 | void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName); 69 | 70 | #ifdef SPINE_SHORT_NAMES 71 | typedef spBlendMode BlendMode; 72 | #define BLEND_MODE_NORMAL SP_BLEND_MODE_NORMAL 73 | #define BLEND_MODE_ADDITIVE SP_BLEND_MODE_ADDITIVE 74 | #define BLEND_MODE_MULTIPLY SP_BLEND_MODE_MULTIPLY 75 | #define BLEND_MODE_SCREEN SP_BLEND_MODE_SCREEN 76 | typedef spSlotData SlotData; 77 | #define SlotData_create(...) spSlotData_create(__VA_ARGS__) 78 | #define SlotData_dispose(...) spSlotData_dispose(__VA_ARGS__) 79 | #define SlotData_setAttachmentName(...) spSlotData_setAttachmentName(__VA_ARGS__) 80 | #endif 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* SPINE_SLOTDATA_H_ */ 87 | -------------------------------------------------------------------------------- /include/spine/AnimationStateData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ANIMATIONSTATEDATA_H_ 32 | #define SPINE_ANIMATIONSTATEDATA_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct spAnimationStateData { 42 | spSkeletonData* const skeletonData; 43 | float defaultMix; 44 | const void* const entries; 45 | 46 | #ifdef __cplusplus 47 | spAnimationStateData() : 48 | skeletonData(0), 49 | defaultMix(0), 50 | entries(0) { 51 | } 52 | #endif 53 | } spAnimationStateData; 54 | 55 | spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData); 56 | void spAnimationStateData_dispose (spAnimationStateData* self); 57 | 58 | void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration); 59 | void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration); 60 | /* Returns 0 if there is no mixing between the animations. */ 61 | float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to); 62 | 63 | #ifdef SPINE_SHORT_NAMES 64 | typedef spAnimationStateData AnimationStateData; 65 | #define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__) 66 | #define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__) 67 | #define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__) 68 | #define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__) 69 | #define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__) 70 | #endif 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* SPINE_ANIMATIONSTATEDATA_H_ */ 77 | -------------------------------------------------------------------------------- /include/spine/Slot.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SLOT_H_ 32 | #define SPINE_SLOT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | typedef struct spSlot { 43 | spSlotData* const data; 44 | spBone* const bone; 45 | float r, g, b, a; 46 | spAttachment* const attachment; 47 | 48 | int attachmentVerticesCapacity; 49 | int attachmentVerticesCount; 50 | float* attachmentVertices; 51 | 52 | #ifdef __cplusplus 53 | spSlot() : 54 | data(0), 55 | bone(0), 56 | r(0), g(0), b(0), a(0), 57 | attachment(0), 58 | attachmentVerticesCapacity(0), 59 | attachmentVerticesCount(0), 60 | attachmentVertices(0) { 61 | } 62 | #endif 63 | } spSlot; 64 | 65 | spSlot* spSlot_create (spSlotData* data, spBone* bone); 66 | void spSlot_dispose (spSlot* self); 67 | 68 | /* @param attachment May be 0 to clear the attachment for the slot. */ 69 | void spSlot_setAttachment (spSlot* self, spAttachment* attachment); 70 | 71 | void spSlot_setAttachmentTime (spSlot* self, float time); 72 | float spSlot_getAttachmentTime (const spSlot* self); 73 | 74 | void spSlot_setToSetupPose (spSlot* self); 75 | 76 | #ifdef SPINE_SHORT_NAMES 77 | typedef spSlot Slot; 78 | #define Slot_create(...) spSlot_create(__VA_ARGS__) 79 | #define Slot_dispose(...) spSlot_dispose(__VA_ARGS__) 80 | #define Slot_setAttachment(...) spSlot_setAttachment(__VA_ARGS__) 81 | #define Slot_setAttachmentTime(...) spSlot_setAttachmentTime(__VA_ARGS__) 82 | #define Slot_getAttachmentTime(...) spSlot_getAttachmentTime(__VA_ARGS__) 83 | #define Slot_setToSetupPose(...) spSlot_setToSetupPose(__VA_ARGS__) 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* SPINE_SLOT_H_ */ 91 | -------------------------------------------------------------------------------- /include/spine/PathConstraintData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_PATHCONSTRAINTDATA_H_ 32 | #define SPINE_PATHCONSTRAINTDATA_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef enum { 42 | SP_POSITION_MODE_FIXED, SP_POSITION_MODE_PERCENT 43 | } spPositionMode; 44 | 45 | typedef enum { 46 | SP_SPACING_MODE_LENGTH, SP_SPACING_MODE_FIXED, SP_SPACING_MODE_PERCENT 47 | } spSpacingMode; 48 | 49 | typedef enum { 50 | SP_ROTATE_MODE_TANGENT, SP_ROTATE_MODE_CHAIN, SP_ROTATE_MODE_CHAIN_SCALE 51 | } spRotateMode; 52 | 53 | typedef struct spPathConstraintData { 54 | const char* const name; 55 | int order; 56 | int bonesCount; 57 | spBoneData** const bones; 58 | spSlotData* target; 59 | spPositionMode positionMode; 60 | spSpacingMode spacingMode; 61 | spRotateMode rotateMode; 62 | float offsetRotation; 63 | float position, spacing, rotateMix, translateMix; 64 | 65 | #ifdef __cplusplus 66 | spPathConstraintData() : 67 | name(0), 68 | bonesCount(0), 69 | bones(0), 70 | target(0), 71 | positionMode(SP_POSITION_MODE_FIXED), 72 | spacingMode(SP_SPACING_MODE_LENGTH), 73 | rotateMode(SP_ROTATE_MODE_TANGENT), 74 | offsetRotation(0), 75 | position(0), 76 | spacing(0), 77 | rotateMix(0), 78 | translateMix(0) { 79 | } 80 | #endif 81 | } spPathConstraintData; 82 | 83 | spPathConstraintData* spPathConstraintData_create (const char* name); 84 | void spPathConstraintData_dispose (spPathConstraintData* self); 85 | 86 | #ifdef SPINE_SHORT_NAMES 87 | typedef spPathConstraintData PathConstraintData; 88 | #define PathConstraintData_create(...) spPathConstraintData_create(__VA_ARGS__) 89 | #define PathConstraintData_dispose(...) spPathConstraintData_dispose(__VA_ARGS__) 90 | #endif 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* SPINE_PATHCONSTRAINTDATA_H_ */ 97 | -------------------------------------------------------------------------------- /include/spine/AttachmentLoader.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ATTACHMENTLOADER_H_ 32 | #define SPINE_ATTACHMENTLOADER_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct spAttachmentLoader { 42 | const char* error1; 43 | const char* error2; 44 | 45 | const void* const vtable; 46 | #ifdef __cplusplus 47 | spAttachmentLoader () : 48 | error1(0), 49 | error2(0), 50 | vtable(0) { 51 | } 52 | #endif 53 | } spAttachmentLoader; 54 | 55 | void spAttachmentLoader_dispose (spAttachmentLoader* self); 56 | 57 | /* Called to create each attachment. Returns 0 to not load an attachment. If 0 is returned and _spAttachmentLoader_setError was 58 | * called, an error occurred. */ 59 | spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, 60 | const char* path); 61 | /* Called after the attachment has been fully configured. */ 62 | void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment); 63 | /* Called just before the attachment is disposed. This can release allocations made in spAttachmentLoader_configureAttachment. */ 64 | void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment); 65 | 66 | #ifdef SPINE_SHORT_NAMES 67 | typedef spAttachmentLoader AttachmentLoader; 68 | #define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__) 69 | #define AttachmentLoader_createAttachment(...) spAttachmentLoader_createAttachment(__VA_ARGS__) 70 | #define AttachmentLoader_configureAttachment(...) spAttachmentLoader_configureAttachment(__VA_ARGS__) 71 | #define AttachmentLoader_disposeAttachment(...) spAttachmentLoader_disposeAttachment(__VA_ARGS__) 72 | #endif 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* SPINE_ATTACHMENTLOADER_H_ */ 79 | -------------------------------------------------------------------------------- /spine_batcher.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* spine_batcher.h */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* http://www.godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ 9 | /* */ 10 | /* Permission is hereby granted, free of charge, to any person obtaining */ 11 | /* a copy of this software and associated documentation files (the */ 12 | /* "Software"), to deal in the Software without restriction, including */ 13 | /* without limitation the rights to use, copy, modify, merge, publish, */ 14 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 15 | /* permit persons to whom the Software is furnished to do so, subject to */ 16 | /* the following conditions: */ 17 | /* */ 18 | /* The above copyright notice and this permission notice shall be */ 19 | /* included in all copies or substantial portions of the Software. */ 20 | /* */ 21 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 22 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 23 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 24 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 25 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 26 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 27 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 28 | /*************************************************************************/ 29 | #ifdef MODULE_SPINE_ENABLED 30 | 31 | #ifndef SPINE_BATCHER_H 32 | #define SPINE_BATCHER_H 33 | 34 | #include "scene/2d/node_2d.h" 35 | 36 | class SpineBatcher { 37 | 38 | Node2D *owner; 39 | 40 | enum { 41 | CMD_DRAW_ELEMENT, 42 | CMD_SET_BLEND_MODE, 43 | }; 44 | 45 | struct Command { 46 | Command() {} 47 | virtual ~Command() {} 48 | 49 | int cmd; 50 | virtual void draw(RID ci) {} 51 | }; 52 | 53 | struct SetBlendMode : Command { 54 | int mode; 55 | 56 | SetBlendMode(int p_mode); 57 | void draw(RID ci); 58 | }; 59 | 60 | struct Elements : Command { 61 | static List free; 62 | Ref texture; 63 | int vertices_count; 64 | int indies_count; 65 | Vector2 *vertices; 66 | Color *colors; 67 | Vector2 *uvs; 68 | int* indies; 69 | 70 | Elements(); 71 | ~Elements(); 72 | void draw(RID ci); 73 | static Command* take(); 74 | static void retrieve(Command* elem); 75 | 76 | }; 77 | 78 | Elements *elements; 79 | 80 | List element_list; 81 | List drawed_list; 82 | 83 | void push_elements(); 84 | 85 | public: 86 | 87 | void reset(); 88 | 89 | void add(Ref p_texture, 90 | const float* p_vertices, const float* p_uvs, int p_vertices_count, 91 | const unsigned short* p_indies, int p_indies_count, 92 | Color *p_color, bool flip_x, bool flip_y); 93 | 94 | void add_set_blender_mode(bool p_mode); 95 | 96 | void flush(); 97 | 98 | SpineBatcher(Node2D *owner); 99 | ~SpineBatcher(); 100 | }; 101 | 102 | #endif // SPINE_BATCHER_H 103 | 104 | #endif // MODULE_SPINE_ENABLED 105 | -------------------------------------------------------------------------------- /src/spine/kvec.h: -------------------------------------------------------------------------------- 1 | /* The MIT License 2 | 3 | Copyright (c) 2008, by Attractive Chaos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | 26 | /* 27 | An example: 28 | 29 | #include "kvec.h" 30 | int main() { 31 | kvec_t(int) array; 32 | kv_init(array); 33 | kv_push(int, array, 10); // append 34 | kv_a(int, array, 20) = 5; // dynamic 35 | kv_A(array, 20) = 4; // static 36 | kv_destroy(array); 37 | return 0; 38 | } 39 | */ 40 | 41 | /* 42 | 2008-09-22 (0.1.0): 43 | 44 | * The initial version. 45 | 46 | 2017-19-18 (0.1.1): 47 | 48 | Spine Special Edition 49 | * Made helper macros for alloc, free and memcpy, which can be overridden. 50 | * Made these helpers point to the Spine C Runtime alloc and free functions by default 51 | * Reimplemented kv_resize to use alloc and free instead of realloc 52 | * Changed kv_push to use kv_resize instead of realloc 53 | * Removed kv_pushp and kv_a macros because the weren't used 54 | * Removed stdlib include 55 | */ 56 | 57 | #ifndef AC_KVEC_H 58 | #define AC_KVEC_H 59 | 60 | #ifndef _kv_free 61 | #define _kv_free(type, p) (FREE(p)) 62 | #endif 63 | 64 | #ifndef _kv_alloc 65 | #define _kv_alloc(type, s) ((type*)(MALLOC(type, (s)))) 66 | #endif 67 | 68 | #ifndef _kv_copy 69 | #define _kv_copy(type, d, s, n) memcpy((d), (s), sizeof(type) * (n)) 70 | #endif 71 | 72 | #define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) 73 | 74 | #define kvec_t(type) struct { size_t n, m; type *a; } 75 | #define kv_init(v) ((v).n = (v).m = 0, (v).a = 0) 76 | #define kv_destroy(v) _kv_free(type, (v).a) 77 | #define kv_A(v, i) ((v).a[(i)]) 78 | #define kv_array(v) ((v).a) 79 | #define kv_pop(v) ((v).a[--(v).n]) 80 | #define kv_size(v) ((v).n) 81 | #define kv_max(v) ((v).m) 82 | 83 | #define kv_resize(type, v, s) do { \ 84 | type* b = _kv_alloc(type, (s)); \ 85 | if (((s) > 0) && ((v).m > 0)) \ 86 | _kv_copy(type, b, (v).a, ((s) < (v).m)? (s) : (v).m); \ 87 | _kv_free(type, (v).a); \ 88 | (v).a = b; (v).m = (s); \ 89 | } while (0) 90 | 91 | #define kv_trim(type, v) kv_resize(type, (v), kv_size(v)) 92 | 93 | #define kv_copy(type, v1, v0) do { \ 94 | if ((v1).m < (v0).n) kv_resize(type, v1, (v0).n); \ 95 | (v1).n = (v0).n; \ 96 | _kv_copy(type, (v1).a, (v0).a, (v0).n); \ 97 | } while (0) \ 98 | 99 | #define kv_push(type, v, x) do { \ 100 | if ((v).n == (v).m) \ 101 | kv_resize(type, (v), ((v).m? (v).m<<1 : 2)); \ 102 | (v).a[(v).n++] = (x); \ 103 | } while (0) 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /include/spine/Skin.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKIN_H_ 32 | #define SPINE_SKIN_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | struct spSkeleton; 41 | 42 | typedef struct spSkin { 43 | const char* const name; 44 | 45 | #ifdef __cplusplus 46 | spSkin() : 47 | name(0) { 48 | } 49 | #endif 50 | } spSkin; 51 | 52 | /* Private structs, needed by Skeleton */ 53 | typedef struct _Entry _Entry; 54 | struct _Entry { 55 | int slotIndex; 56 | const char* name; 57 | spAttachment* attachment; 58 | _Entry* next; 59 | }; 60 | 61 | typedef struct { 62 | spSkin super; 63 | _Entry* entries; 64 | } _spSkin; 65 | 66 | spSkin* spSkin_create (const char* name); 67 | void spSkin_dispose (spSkin* self); 68 | 69 | /* The Skin owns the attachment. */ 70 | void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment); 71 | /* Returns 0 if the attachment was not found. */ 72 | spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name); 73 | 74 | /* Returns 0 if the slot or attachment was not found. */ 75 | const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex); 76 | 77 | /** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ 78 | void spSkin_attachAll (const spSkin* self, struct spSkeleton* skeleton, const spSkin* oldspSkin); 79 | 80 | #ifdef SPINE_SHORT_NAMES 81 | typedef spSkin Skin; 82 | #define Skin_create(...) spSkin_create(__VA_ARGS__) 83 | #define Skin_dispose(...) spSkin_dispose(__VA_ARGS__) 84 | #define Skin_addAttachment(...) spSkin_addAttachment(__VA_ARGS__) 85 | #define Skin_getAttachment(...) spSkin_getAttachment(__VA_ARGS__) 86 | #define Skin_getAttachmentName(...) spSkin_getAttachmentName(__VA_ARGS__) 87 | #define Skin_attachAll(...) spSkin_attachAll(__VA_ARGS__) 88 | #endif 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* SPINE_SKIN_H_ */ 95 | -------------------------------------------------------------------------------- /include/spine/MeshAttachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_MESHATTACHMENT_H_ 32 | #define SPINE_MESHATTACHMENT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | typedef struct spMeshAttachment spMeshAttachment; 44 | struct spMeshAttachment { 45 | spVertexAttachment super; 46 | 47 | void* rendererObject; 48 | int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */ 49 | int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */ 50 | int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */ 51 | float regionU, regionV, regionU2, regionV2; 52 | int/*bool*/regionRotate; 53 | 54 | const char* path; 55 | 56 | float* regionUVs; 57 | float* uvs; 58 | 59 | int trianglesCount; 60 | unsigned short* triangles; 61 | 62 | float r, g, b, a; 63 | 64 | int hullLength; 65 | 66 | spMeshAttachment* const parentMesh; 67 | int/*bool*/inheritDeform; 68 | 69 | /* Nonessential. */ 70 | int edgesCount; 71 | int* edges; 72 | float width, height; 73 | }; 74 | 75 | spMeshAttachment* spMeshAttachment_create (const char* name); 76 | void spMeshAttachment_updateUVs (spMeshAttachment* self); 77 | void spMeshAttachment_computeWorldVertices (spMeshAttachment* self, spSlot* slot, float* worldVertices); 78 | void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh); 79 | 80 | #ifdef SPINE_SHORT_NAMES 81 | typedef spMeshAttachment MeshAttachment; 82 | #define MeshAttachment_create(...) spMeshAttachment_create(__VA_ARGS__) 83 | #define MeshAttachment_updateUVs(...) spMeshAttachment_updateUVs(__VA_ARGS__) 84 | #define MeshAttachment_computeWorldVertices(...) spMeshAttachment_computeWorldVertices(__VA_ARGS__) 85 | #define MeshAttachment_setParentMesh(...) spMeshAttachment_setParentMesh(__VA_ARGS__) 86 | #endif 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* SPINE_MESHATTACHMENT_H_ */ 93 | -------------------------------------------------------------------------------- /include/spine/RegionAttachment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_REGIONATTACHMENT_H_ 32 | #define SPINE_REGIONATTACHMENT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | typedef enum { 43 | SP_VERTEX_X1 = 0, SP_VERTEX_Y1, SP_VERTEX_X2, SP_VERTEX_Y2, SP_VERTEX_X3, SP_VERTEX_Y3, SP_VERTEX_X4, SP_VERTEX_Y4 44 | } spVertexIndex; 45 | 46 | typedef struct spRegionAttachment { 47 | spAttachment super; 48 | const char* path; 49 | float x, y, scaleX, scaleY, rotation, width, height; 50 | float r, g, b, a; 51 | 52 | void* rendererObject; 53 | int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */ 54 | int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */ 55 | int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */ 56 | 57 | float offset[8]; 58 | float uvs[8]; 59 | } spRegionAttachment; 60 | 61 | spRegionAttachment* spRegionAttachment_create (const char* name); 62 | void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); 63 | void spRegionAttachment_updateOffset (spRegionAttachment* self); 64 | void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, spBone* bone, float* vertices); 65 | 66 | #ifdef SPINE_SHORT_NAMES 67 | typedef spVertexIndex VertexIndex; 68 | #define VERTEX_X1 SP_VERTEX_X1 69 | #define VERTEX_Y1 SP_VERTEX_Y1 70 | #define VERTEX_X2 SP_VERTEX_X2 71 | #define VERTEX_Y2 SP_VERTEX_Y2 72 | #define VERTEX_X3 SP_VERTEX_X3 73 | #define VERTEX_Y3 SP_VERTEX_Y3 74 | #define VERTEX_X4 SP_VERTEX_X4 75 | #define VERTEX_Y4 SP_VERTEX_Y4 76 | typedef spRegionAttachment RegionAttachment; 77 | #define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__) 78 | #define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__) 79 | #define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__) 80 | #define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__) 81 | #endif 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* SPINE_REGIONATTACHMENT_H_ */ 88 | -------------------------------------------------------------------------------- /include/spine/PathConstraint.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_PATHCONSTRAINT_H_ 32 | #define SPINE_PATHCONSTRAINT_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include "PathAttachment.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | struct spSkeleton; 44 | 45 | typedef struct spPathConstraint { 46 | spPathConstraintData* const data; 47 | int bonesCount; 48 | spBone** const bones; 49 | spSlot* target; 50 | float position, spacing, rotateMix, translateMix; 51 | 52 | int spacesCount; 53 | float* spaces; 54 | 55 | int positionsCount; 56 | float* positions; 57 | 58 | int worldCount; 59 | float* world; 60 | 61 | int curvesCount; 62 | float* curves; 63 | 64 | int lengthsCount; 65 | float* lengths; 66 | 67 | float segments[10]; 68 | 69 | #ifdef __cplusplus 70 | spPathConstraint() : 71 | data(0), 72 | bonesCount(0), 73 | bones(0), 74 | target(0), 75 | position(0), 76 | spacing(0), 77 | rotateMix(0), 78 | translateMix(0), 79 | spacesCount(0), 80 | spaces(0), 81 | positionsCount(0), 82 | positions(0), 83 | worldCount(0), 84 | world(0), 85 | curvesCount(0), 86 | curves(0), 87 | lengthsCount(0), 88 | lengths(0) { 89 | } 90 | #endif 91 | } spPathConstraint; 92 | 93 | #define SP_PATHCONSTRAINT_ 94 | 95 | spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const struct spSkeleton* skeleton); 96 | void spPathConstraint_dispose (spPathConstraint* self); 97 | 98 | void spPathConstraint_apply (spPathConstraint* self); 99 | float* spPathConstraint_computeWorldPositions(spPathConstraint* self, spPathAttachment* path, int spacesCount, int/*bool*/ tangents, int/*bool*/percentPosition, int/**/percentSpacing); 100 | 101 | #ifdef SPINE_SHORT_NAMES 102 | typedef spPathConstraint PathConstraint; 103 | #define PathConstraint_create(...) spPathConstraint_create(__VA_ARGS__) 104 | #define PathConstraint_dispose(...) spPathConstraint_dispose(__VA_ARGS__) 105 | #define PathConstraint_apply(...) spPathConstraint_apply(__VA_ARGS__) 106 | #endif 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* SPINE_PATHCONSTRAINT_H_ */ 113 | -------------------------------------------------------------------------------- /src/spine/Skin.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | _Entry* _Entry_create (int slotIndex, const char* name, spAttachment* attachment) { 35 | _Entry* self = NEW(_Entry); 36 | self->slotIndex = slotIndex; 37 | MALLOC_STR(self->name, name); 38 | self->attachment = attachment; 39 | return self; 40 | } 41 | 42 | void _Entry_dispose (_Entry* self) { 43 | spAttachment_dispose(self->attachment); 44 | FREE(self->name); 45 | FREE(self); 46 | } 47 | 48 | /**/ 49 | 50 | spSkin* spSkin_create (const char* name) { 51 | spSkin* self = SUPER(NEW(_spSkin)); 52 | MALLOC_STR(self->name, name); 53 | return self; 54 | } 55 | 56 | void spSkin_dispose (spSkin* self) { 57 | _Entry* entry = SUB_CAST(_spSkin, self)->entries; 58 | while (entry) { 59 | _Entry* nextEntry = entry->next; 60 | _Entry_dispose(entry); 61 | entry = nextEntry; 62 | } 63 | 64 | FREE(self->name); 65 | FREE(self); 66 | } 67 | 68 | void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment) { 69 | _Entry* newEntry = _Entry_create(slotIndex, name, attachment); 70 | newEntry->next = SUB_CAST(_spSkin, self)->entries; 71 | SUB_CAST(_spSkin, self)->entries = newEntry; 72 | } 73 | 74 | spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) { 75 | const _Entry* entry = SUB_CAST(_spSkin, self)->entries; 76 | while (entry) { 77 | if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment; 78 | entry = entry->next; 79 | } 80 | return 0; 81 | } 82 | 83 | const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex) { 84 | const _Entry* entry = SUB_CAST(_spSkin, self)->entries; 85 | int i = 0; 86 | while (entry) { 87 | if (entry->slotIndex == slotIndex) { 88 | if (i == attachmentIndex) return entry->name; 89 | i++; 90 | } 91 | entry = entry->next; 92 | } 93 | return 0; 94 | } 95 | 96 | void spSkin_attachAll (const spSkin* self, spSkeleton* skeleton, const spSkin* oldSkin) { 97 | const _Entry *entry = SUB_CAST(_spSkin, oldSkin)->entries; 98 | while (entry) { 99 | spSlot *slot = skeleton->slots[entry->slotIndex]; 100 | if (slot->attachment == entry->attachment) { 101 | spAttachment *attachment = spSkin_getAttachment(self, entry->slotIndex, entry->name); 102 | if (attachment) spSlot_setAttachment(slot, attachment); 103 | } 104 | entry = entry->next; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/spine/AtlasAttachmentLoader.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | spAttachment* _spAtlasAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, 35 | const char* name, const char* path) { 36 | spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); 37 | switch (type) { 38 | case SP_ATTACHMENT_REGION: { 39 | spRegionAttachment* attachment; 40 | spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); 41 | if (!region) { 42 | _spAttachmentLoader_setError(loader, "Region not found: ", path); 43 | return 0; 44 | } 45 | attachment = spRegionAttachment_create(name); 46 | attachment->rendererObject = region; 47 | spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); 48 | attachment->regionOffsetX = region->offsetX; 49 | attachment->regionOffsetY = region->offsetY; 50 | attachment->regionWidth = region->width; 51 | attachment->regionHeight = region->height; 52 | attachment->regionOriginalWidth = region->originalWidth; 53 | attachment->regionOriginalHeight = region->originalHeight; 54 | return SUPER(attachment); 55 | } 56 | case SP_ATTACHMENT_MESH: 57 | case SP_ATTACHMENT_LINKED_MESH: { 58 | spMeshAttachment* attachment; 59 | spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); 60 | if (!region) { 61 | _spAttachmentLoader_setError(loader, "Region not found: ", path); 62 | return 0; 63 | } 64 | attachment = spMeshAttachment_create(name); 65 | attachment->rendererObject = region; 66 | attachment->regionU = region->u; 67 | attachment->regionV = region->v; 68 | attachment->regionU2 = region->u2; 69 | attachment->regionV2 = region->v2; 70 | attachment->regionRotate = region->rotate; 71 | attachment->regionOffsetX = region->offsetX; 72 | attachment->regionOffsetY = region->offsetY; 73 | attachment->regionWidth = region->width; 74 | attachment->regionHeight = region->height; 75 | attachment->regionOriginalWidth = region->originalWidth; 76 | attachment->regionOriginalHeight = region->originalHeight; 77 | return SUPER(SUPER(attachment)); 78 | } 79 | case SP_ATTACHMENT_BOUNDING_BOX: 80 | return SUPER(SUPER(spBoundingBoxAttachment_create(name))); 81 | case SP_ATTACHMENT_PATH: 82 | return SUPER(SUPER(spPathAttachment_create(name))); 83 | default: 84 | _spAttachmentLoader_setUnknownTypeError(loader, type); 85 | return 0; 86 | } 87 | 88 | UNUSED(skin); 89 | } 90 | 91 | spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) { 92 | spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader); 93 | _spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_createAttachment, 0, 0); 94 | self->atlas = atlas; 95 | return self; 96 | } 97 | -------------------------------------------------------------------------------- /src/spine/MeshAttachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | void _spMeshAttachment_dispose (spAttachment* attachment) { 35 | spMeshAttachment* self = SUB_CAST(spMeshAttachment, attachment); 36 | FREE(self->path); 37 | FREE(self->uvs); 38 | if (!self->parentMesh) { 39 | _spVertexAttachment_deinit(SUPER(self)); 40 | FREE(self->regionUVs); 41 | FREE(self->triangles); 42 | FREE(self->edges); 43 | } else 44 | _spAttachment_deinit(attachment); 45 | FREE(self); 46 | } 47 | 48 | spMeshAttachment* spMeshAttachment_create (const char* name) { 49 | spMeshAttachment* self = NEW(spMeshAttachment); 50 | self->r = 1; 51 | self->g = 1; 52 | self->b = 1; 53 | self->a = 1; 54 | _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_MESH, _spMeshAttachment_dispose); 55 | return self; 56 | } 57 | 58 | void spMeshAttachment_updateUVs (spMeshAttachment* self) { 59 | int i; 60 | float width = self->regionU2 - self->regionU, height = self->regionV2 - self->regionV; 61 | int verticesLength = SUPER(self)->worldVerticesLength; 62 | FREE(self->uvs); 63 | self->uvs = MALLOC(float, verticesLength); 64 | if (self->regionRotate) { 65 | for (i = 0; i < verticesLength; i += 2) { 66 | self->uvs[i] = self->regionU + self->regionUVs[i + 1] * width; 67 | self->uvs[i + 1] = self->regionV + height - self->regionUVs[i] * height; 68 | } 69 | } else { 70 | for (i = 0; i < verticesLength; i += 2) { 71 | self->uvs[i] = self->regionU + self->regionUVs[i] * width; 72 | self->uvs[i + 1] = self->regionV + self->regionUVs[i + 1] * height; 73 | } 74 | } 75 | } 76 | 77 | void spMeshAttachment_computeWorldVertices (spMeshAttachment* self, spSlot* slot, float* worldVertices) { 78 | spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); 79 | } 80 | 81 | void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) { 82 | CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh; 83 | if (parentMesh) { 84 | 85 | self->super.bones = parentMesh->super.bones; 86 | self->super.bonesCount = parentMesh->super.bonesCount; 87 | 88 | self->super.vertices = parentMesh->super.vertices; 89 | self->super.verticesCount = parentMesh->super.verticesCount; 90 | 91 | self->regionUVs = parentMesh->regionUVs; 92 | 93 | self->triangles = parentMesh->triangles; 94 | self->trianglesCount = parentMesh->trianglesCount; 95 | 96 | self->hullLength = parentMesh->hullLength; 97 | 98 | self->super.worldVerticesLength = parentMesh->super.worldVerticesLength; 99 | 100 | self->edges = parentMesh->edges; 101 | self->edgesCount = parentMesh->edgesCount; 102 | 103 | self->width = parentMesh->width; 104 | self->height = parentMesh->height; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/spine/VertexAttachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | void _spVertexAttachment_deinit (spVertexAttachment* attachment) { 35 | _spAttachment_deinit(SUPER(attachment)); 36 | FREE(attachment->bones); 37 | FREE(attachment->vertices); 38 | } 39 | 40 | void spVertexAttachment_computeWorldVertices (spVertexAttachment* self, spSlot* slot, float* worldVertices) { 41 | spVertexAttachment_computeWorldVertices1(self, 0, self->worldVerticesLength, slot, worldVertices, 0); 42 | } 43 | 44 | void spVertexAttachment_computeWorldVertices1 (spVertexAttachment* self, int start, int count, spSlot* slot, float* worldVertices, int offset) { 45 | spSkeleton* skeleton; 46 | int deformLength; 47 | float* deform; 48 | float* vertices; 49 | int* bones; 50 | 51 | count += offset; 52 | skeleton = slot->bone->skeleton; 53 | deformLength = slot->attachmentVerticesCount; 54 | deform = slot->attachmentVertices; 55 | vertices = self->vertices; 56 | bones = self->bones; 57 | if (!bones) { 58 | spBone* bone; 59 | int v, w; 60 | float x, y; 61 | if (deformLength > 0) vertices = deform; 62 | bone = slot->bone; 63 | x = bone->worldX; 64 | y = bone->worldY; 65 | for (v = start, w = offset; w < count; v += 2, w += 2) { 66 | float vx = vertices[v], vy = vertices[v + 1]; 67 | worldVertices[w] = vx * bone->a + vy * bone->b + x; 68 | worldVertices[w + 1] = vx * bone->c + vy * bone->d + y; 69 | } 70 | } else { 71 | int v = 0, skip = 0, i; 72 | spBone** skeletonBones; 73 | for (i = 0; i < start; i += 2) { 74 | int n = bones[v]; 75 | v += n + 1; 76 | skip += n; 77 | } 78 | skeletonBones = skeleton->bones; 79 | if (deformLength == 0) { 80 | int w, b; 81 | for (w = offset, b = skip * 3; w < count; w += 2) { 82 | float wx = 0, wy = 0; 83 | int n = bones[v++]; 84 | n += v; 85 | for (; v < n; v++, b += 3) { 86 | spBone* bone = skeletonBones[bones[v]]; 87 | float vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; 88 | wx += (vx * bone->a + vy * bone->b + bone->worldX) * weight; 89 | wy += (vx * bone->c + vy * bone->d + bone->worldY) * weight; 90 | } 91 | worldVertices[w] = wx; 92 | worldVertices[w + 1] = wy; 93 | } 94 | } else { 95 | int w, b, f; 96 | for (w = offset, b = skip * 3, f = skip << 1; w < count; w += 2) { 97 | float wx = 0, wy = 0; 98 | int n = bones[v++]; 99 | n += v; 100 | for (; v < n; v++, b += 3, f += 2) { 101 | spBone* bone = skeletonBones[bones[v]]; 102 | float vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; 103 | wx += (vx * bone->a + vy * bone->b + bone->worldX) * weight; 104 | wy += (vx * bone->c + vy * bone->d + bone->worldY) * weight; 105 | } 106 | worldVertices[w] = wx; 107 | worldVertices[w + 1] = wy; 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/spine/AttachmentLoader.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | typedef struct _spAttachmentLoaderVtable { 36 | spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, 37 | const char* path); 38 | void (*configureAttachment) (spAttachmentLoader* self, spAttachment*); 39 | void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*); 40 | void (*dispose) (spAttachmentLoader* self); 41 | } _spAttachmentLoaderVtable; 42 | 43 | void _spAttachmentLoader_init (spAttachmentLoader* self, 44 | void (*dispose) (spAttachmentLoader* self), 45 | spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, 46 | const char* path), 47 | void (*configureAttachment) (spAttachmentLoader* self, spAttachment*), 48 | void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*) 49 | ) { 50 | CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable); 51 | VTABLE(spAttachmentLoader, self)->dispose = dispose; 52 | VTABLE(spAttachmentLoader, self)->createAttachment = createAttachment; 53 | VTABLE(spAttachmentLoader, self)->configureAttachment = configureAttachment; 54 | VTABLE(spAttachmentLoader, self)->disposeAttachment = disposeAttachment; 55 | } 56 | 57 | void _spAttachmentLoader_deinit (spAttachmentLoader* self) { 58 | FREE(self->vtable); 59 | FREE(self->error1); 60 | FREE(self->error2); 61 | } 62 | 63 | void spAttachmentLoader_dispose (spAttachmentLoader* self) { 64 | VTABLE(spAttachmentLoader, self)->dispose(self); 65 | FREE(self); 66 | } 67 | 68 | spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, 69 | const char* path) { 70 | FREE(self->error1); 71 | FREE(self->error2); 72 | self->error1 = 0; 73 | self->error2 = 0; 74 | return VTABLE(spAttachmentLoader, self)->createAttachment(self, skin, type, name, path); 75 | } 76 | 77 | void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment) { 78 | if (!VTABLE(spAttachmentLoader, self)->configureAttachment) return; 79 | VTABLE(spAttachmentLoader, self)->configureAttachment(self, attachment); 80 | } 81 | 82 | void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment) { 83 | if (!VTABLE(spAttachmentLoader, self)->disposeAttachment) return; 84 | VTABLE(spAttachmentLoader, self)->disposeAttachment(self, attachment); 85 | } 86 | 87 | void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) { 88 | FREE(self->error1); 89 | FREE(self->error2); 90 | MALLOC_STR(self->error1, error1); 91 | MALLOC_STR(self->error2, error2); 92 | } 93 | 94 | void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) { 95 | char buffer[16]; 96 | sprintf(buffer, "%d", type); 97 | _spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer); 98 | } 99 | -------------------------------------------------------------------------------- /include/spine/SkeletonData.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKELETONDATA_H_ 32 | #define SPINE_SKELETONDATA_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | typedef struct spSkeletonData { 48 | const char* version; 49 | const char* hash; 50 | float width, height; 51 | 52 | int bonesCount; 53 | spBoneData** bones; 54 | 55 | int slotsCount; 56 | spSlotData** slots; 57 | 58 | int skinsCount; 59 | spSkin** skins; 60 | spSkin* defaultSkin; 61 | 62 | int eventsCount; 63 | spEventData** events; 64 | 65 | int animationsCount; 66 | spAnimation** animations; 67 | 68 | int ikConstraintsCount; 69 | spIkConstraintData** ikConstraints; 70 | 71 | int transformConstraintsCount; 72 | spTransformConstraintData** transformConstraints; 73 | 74 | int pathConstraintsCount; 75 | spPathConstraintData** pathConstraints; 76 | } spSkeletonData; 77 | 78 | spSkeletonData* spSkeletonData_create (); 79 | void spSkeletonData_dispose (spSkeletonData* self); 80 | 81 | spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName); 82 | int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName); 83 | 84 | spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName); 85 | int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName); 86 | 87 | spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName); 88 | 89 | spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName); 90 | 91 | spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName); 92 | 93 | spIkConstraintData* spSkeletonData_findIkConstraint (const spSkeletonData* self, const char* constraintName); 94 | 95 | spTransformConstraintData* spSkeletonData_findTransformConstraint (const spSkeletonData* self, const char* constraintName); 96 | 97 | spPathConstraintData* spSkeletonData_findPathConstraint (const spSkeletonData* self, const char* constraintName); 98 | 99 | #ifdef SPINE_SHORT_NAMES 100 | typedef spSkeletonData SkeletonData; 101 | #define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__) 102 | #define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__) 103 | #define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__) 104 | #define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__) 105 | #define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__) 106 | #define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__) 107 | #define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__) 108 | #define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__) 109 | #define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__) 110 | #endif 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* SPINE_SKELETONDATA_H_ */ 117 | -------------------------------------------------------------------------------- /include/spine/Bone.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_BONE_H_ 32 | #define SPINE_BONE_H_ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | struct spSkeleton; 41 | 42 | typedef struct spBone spBone; 43 | struct spBone { 44 | spBoneData* const data; 45 | struct spSkeleton* const skeleton; 46 | spBone* const parent; 47 | int childrenCount; 48 | spBone** const children; 49 | float x, y, rotation, scaleX, scaleY, shearX, shearY; 50 | float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY; 51 | int /*bool*/ appliedValid; 52 | 53 | float const a, b, worldX; 54 | float const c, d, worldY; 55 | 56 | int/*bool*/ sorted; 57 | 58 | #ifdef __cplusplus 59 | spBone() : 60 | data(0), 61 | skeleton(0), 62 | parent(0), 63 | childrenCount(0), children(0), 64 | x(0), y(0), rotation(0), scaleX(0), scaleY(0), 65 | ax(0), ay(0), arotation(0), ascaleX(0), ascaleY(0), ashearX(0), ashearY(0), 66 | appliedValid(0), 67 | 68 | a(0), b(0), worldX(0), 69 | c(0), d(0), worldY(0), 70 | 71 | sorted(0) { 72 | } 73 | #endif 74 | }; 75 | 76 | void spBone_setYDown (int/*bool*/yDown); 77 | int/*bool*/spBone_isYDown (); 78 | 79 | /* @param parent May be 0. */ 80 | spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent); 81 | void spBone_dispose (spBone* self); 82 | 83 | void spBone_setToSetupPose (spBone* self); 84 | 85 | void spBone_updateWorldTransform (spBone* self); 86 | void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY); 87 | 88 | float spBone_getWorldRotationX (spBone* self); 89 | float spBone_getWorldRotationY (spBone* self); 90 | float spBone_getWorldScaleX (spBone* self); 91 | float spBone_getWorldScaleY (spBone* self); 92 | 93 | float spBone_worldToLocalRotationX (spBone* self); 94 | float spBone_worldToLocalRotationY (spBone* self); 95 | void spBone_rotateWorld (spBone* self, float degrees); 96 | void spBone_updateAppliedTransform (spBone* self); 97 | 98 | void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY); 99 | void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY); 100 | 101 | #ifdef SPINE_SHORT_NAMES 102 | typedef spBone Bone; 103 | #define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__) 104 | #define Bone_isYDown() spBone_isYDown() 105 | #define Bone_create(...) spBone_create(__VA_ARGS__) 106 | #define Bone_dispose(...) spBone_dispose(__VA_ARGS__) 107 | #define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__) 108 | #define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__) 109 | #define Bone_updateWorldTransformWith(...) spBone_updateWorldTransformWith(__VA_ARGS__) 110 | #define Bone_getWorldRotationX(...) spBone_getWorldRotationX(__VA_ARGS__) 111 | #define Bone_getWorldRotationY(...) spBone_getWorldRotationY(__VA_ARGS__) 112 | #define Bone_getWorldScaleX(...) spBone_getWorldScaleX(__VA_ARGS__) 113 | #define Bone_getWorldScaleY(...) spBone_getWorldScaleY(__VA_ARGS__) 114 | #define Bone_worldToLocalRotationX(...) spBone_worldToLocalRotationX(__VA_ARGS__) 115 | #define Bone_worldToLocalRotationY(...) spBone_worldToLocalRotationY(__VA_ARGS__) 116 | #define Bone_rotateWorld(...) spBone_rotateWorld(__VA_ARGS__) 117 | #define Bone_updateAppliedTransform(...) spBone_updateAppliedTransform(__VA_ARGS__) 118 | #define Bone_worldToLocal(...) spBone_worldToLocal(__VA_ARGS__) 119 | #define Bone_localToWorld(...) spBone_localToWorld(__VA_ARGS__) 120 | #endif 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif /* SPINE_BONE_H_ */ 127 | -------------------------------------------------------------------------------- /src/spine/TransformConstraint.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | spTransformConstraint* spTransformConstraint_create (spTransformConstraintData* data, const spSkeleton* skeleton) { 36 | int i; 37 | spTransformConstraint* self = NEW(spTransformConstraint); 38 | CONST_CAST(spTransformConstraintData*, self->data) = data; 39 | self->rotateMix = data->rotateMix; 40 | self->translateMix = data->translateMix; 41 | self->scaleMix = data->scaleMix; 42 | self->shearMix = data->shearMix; 43 | self->bonesCount = data->bonesCount; 44 | CONST_CAST(spBone**, self->bones) = MALLOC(spBone*, self->bonesCount); 45 | for (i = 0; i < self->bonesCount; ++i) 46 | self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); 47 | self->target = spSkeleton_findBone(skeleton, self->data->target->name); 48 | return self; 49 | } 50 | 51 | void spTransformConstraint_dispose (spTransformConstraint* self) { 52 | FREE(self->bones); 53 | FREE(self); 54 | } 55 | 56 | void spTransformConstraint_apply (spTransformConstraint* self) { 57 | float rotateMix = self->rotateMix, translateMix = self->translateMix, scaleMix = self->scaleMix, shearMix = self->shearMix; 58 | spBone* target = self->target; 59 | float ta = target->a, tb = target->b, tc = target->c, td = target->d; 60 | float degRadReflect = ta * td - tb * tc > 0 ? DEG_RAD : -DEG_RAD; 61 | float offsetRotation = self->data->offsetRotation * degRadReflect, offsetShearY = self->data->offsetShearY * degRadReflect; 62 | int /*bool*/ modified; 63 | int i; 64 | for (i = 0; i < self->bonesCount; ++i) { 65 | spBone* bone = self->bones[i]; 66 | modified = 0; 67 | 68 | if (rotateMix != 0) { 69 | float a = bone->a, b = bone->b, c = bone->c, d = bone->d; 70 | float r = ATAN2(tc, ta) - ATAN2(c, a) + offsetRotation; 71 | float cosine, sine; 72 | if (r > PI) r -= PI2; 73 | else if (r < -PI) r += PI2; 74 | r *= rotateMix; 75 | cosine = COS(r); 76 | sine = SIN(r); 77 | CONST_CAST(float, bone->a) = cosine * a - sine * c; 78 | CONST_CAST(float, bone->b) = cosine * b - sine * d; 79 | CONST_CAST(float, bone->c) = sine * a + cosine * c; 80 | CONST_CAST(float, bone->d) = sine * b + cosine * d; 81 | modified = 1; 82 | } 83 | 84 | if (translateMix != 0) { 85 | float x, y; 86 | spBone_localToWorld(target, self->data->offsetX, self->data->offsetY, &x, &y); 87 | CONST_CAST(float, bone->worldX) += (x - bone->worldX) * translateMix; 88 | CONST_CAST(float, bone->worldY) += (y - bone->worldY) * translateMix; 89 | modified = 1; 90 | } 91 | 92 | if (scaleMix > 0) { 93 | float s = SQRT(bone->a * bone->a + bone->c * bone->c); 94 | float ts = SQRT(ta * ta + tc * tc); 95 | if (s > 0.00001f) s = (s + (ts - s + self->data->offsetScaleX) * scaleMix) / s; 96 | CONST_CAST(float, bone->a) *= s; 97 | CONST_CAST(float, bone->c) *= s; 98 | s = SQRT(bone->b * bone->b + bone->d * bone->d); 99 | ts = SQRT(tb * tb + td * td); 100 | if (s > 0.00001f) s = (s + (ts - s + self->data->offsetScaleY) * scaleMix) / s; 101 | CONST_CAST(float, bone->b) *= s; 102 | CONST_CAST(float, bone->d) *= s; 103 | modified = 1; 104 | } 105 | 106 | if (shearMix > 0) { 107 | float b = bone->b, d = bone->d; 108 | float by = ATAN2(d, b); 109 | float r = ATAN2(td, tb) - ATAN2(tc, ta) - (by - ATAN2(bone->c, bone->a)); 110 | float s = SQRT(b * b + d * d); 111 | if (r > PI) r -= PI2; 112 | else if (r < -PI) r += PI2; 113 | r = by + (r + offsetShearY) * shearMix; 114 | CONST_CAST(float, bone->b) = COS(r) * s; 115 | CONST_CAST(float, bone->d) = SIN(r) * s; 116 | modified = 1; 117 | } 118 | 119 | if (modified) CONST_CAST(int, bone->appliedValid) = 0; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/spine/AnimationStateData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | typedef struct _ToEntry _ToEntry; 35 | struct _ToEntry { 36 | spAnimation* animation; 37 | float duration; 38 | _ToEntry* next; 39 | }; 40 | 41 | _ToEntry* _ToEntry_create (spAnimation* to, float duration) { 42 | _ToEntry* self = NEW(_ToEntry); 43 | self->animation = to; 44 | self->duration = duration; 45 | return self; 46 | } 47 | 48 | void _ToEntry_dispose (_ToEntry* self) { 49 | FREE(self); 50 | } 51 | 52 | /**/ 53 | 54 | typedef struct _FromEntry _FromEntry; 55 | struct _FromEntry { 56 | spAnimation* animation; 57 | _ToEntry* toEntries; 58 | _FromEntry* next; 59 | }; 60 | 61 | _FromEntry* _FromEntry_create (spAnimation* from) { 62 | _FromEntry* self = NEW(_FromEntry); 63 | self->animation = from; 64 | return self; 65 | } 66 | 67 | void _FromEntry_dispose (_FromEntry* self) { 68 | FREE(self); 69 | } 70 | 71 | /**/ 72 | 73 | spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) { 74 | spAnimationStateData* self = NEW(spAnimationStateData); 75 | CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData; 76 | return self; 77 | } 78 | 79 | void spAnimationStateData_dispose (spAnimationStateData* self) { 80 | _ToEntry* toEntry; 81 | _ToEntry* nextToEntry; 82 | _FromEntry* nextFromEntry; 83 | 84 | _FromEntry* fromEntry = (_FromEntry*)self->entries; 85 | while (fromEntry) { 86 | toEntry = fromEntry->toEntries; 87 | while (toEntry) { 88 | nextToEntry = toEntry->next; 89 | _ToEntry_dispose(toEntry); 90 | toEntry = nextToEntry; 91 | } 92 | nextFromEntry = fromEntry->next; 93 | _FromEntry_dispose(fromEntry); 94 | fromEntry = nextFromEntry; 95 | } 96 | 97 | FREE(self); 98 | } 99 | 100 | void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) { 101 | spAnimation* to; 102 | spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName); 103 | if (!from) return; 104 | to = spSkeletonData_findAnimation(self->skeletonData, toName); 105 | if (!to) return; 106 | spAnimationStateData_setMix(self, from, to, duration); 107 | } 108 | 109 | void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) { 110 | /* Find existing FromEntry. */ 111 | _ToEntry* toEntry; 112 | _FromEntry* fromEntry = (_FromEntry*)self->entries; 113 | while (fromEntry) { 114 | if (fromEntry->animation == from) { 115 | /* Find existing ToEntry. */ 116 | toEntry = fromEntry->toEntries; 117 | while (toEntry) { 118 | if (toEntry->animation == to) { 119 | toEntry->duration = duration; 120 | return; 121 | } 122 | toEntry = toEntry->next; 123 | } 124 | break; /* Add new ToEntry to the existing FromEntry. */ 125 | } 126 | fromEntry = fromEntry->next; 127 | } 128 | if (!fromEntry) { 129 | fromEntry = _FromEntry_create(from); 130 | fromEntry->next = (_FromEntry*)self->entries; 131 | CONST_CAST(_FromEntry*, self->entries) = fromEntry; 132 | } 133 | toEntry = _ToEntry_create(to, duration); 134 | toEntry->next = fromEntry->toEntries; 135 | fromEntry->toEntries = toEntry; 136 | } 137 | 138 | float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) { 139 | _FromEntry* fromEntry = (_FromEntry*)self->entries; 140 | while (fromEntry) { 141 | if (fromEntry->animation == from) { 142 | _ToEntry* toEntry = fromEntry->toEntries; 143 | while (toEntry) { 144 | if (toEntry->animation == to) return toEntry->duration; 145 | toEntry = toEntry->next; 146 | } 147 | } 148 | fromEntry = fromEntry->next; 149 | } 150 | return self->defaultMix; 151 | } 152 | -------------------------------------------------------------------------------- /src/spine/RegionAttachment.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | void _spRegionAttachment_dispose (spAttachment* attachment) { 35 | spRegionAttachment* self = SUB_CAST(spRegionAttachment, attachment); 36 | _spAttachment_deinit(attachment); 37 | FREE(self->path); 38 | FREE(self); 39 | } 40 | 41 | spRegionAttachment* spRegionAttachment_create (const char* name) { 42 | spRegionAttachment* self = NEW(spRegionAttachment); 43 | self->scaleX = 1; 44 | self->scaleY = 1; 45 | self->r = 1; 46 | self->g = 1; 47 | self->b = 1; 48 | self->a = 1; 49 | _spAttachment_init(SUPER(self), name, SP_ATTACHMENT_REGION, _spRegionAttachment_dispose); 50 | return self; 51 | } 52 | 53 | void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) { 54 | if (rotate) { 55 | self->uvs[SP_VERTEX_X2] = u; 56 | self->uvs[SP_VERTEX_Y2] = v2; 57 | self->uvs[SP_VERTEX_X3] = u; 58 | self->uvs[SP_VERTEX_Y3] = v; 59 | self->uvs[SP_VERTEX_X4] = u2; 60 | self->uvs[SP_VERTEX_Y4] = v; 61 | self->uvs[SP_VERTEX_X1] = u2; 62 | self->uvs[SP_VERTEX_Y1] = v2; 63 | } else { 64 | self->uvs[SP_VERTEX_X1] = u; 65 | self->uvs[SP_VERTEX_Y1] = v2; 66 | self->uvs[SP_VERTEX_X2] = u; 67 | self->uvs[SP_VERTEX_Y2] = v; 68 | self->uvs[SP_VERTEX_X3] = u2; 69 | self->uvs[SP_VERTEX_Y3] = v; 70 | self->uvs[SP_VERTEX_X4] = u2; 71 | self->uvs[SP_VERTEX_Y4] = v2; 72 | } 73 | } 74 | 75 | void spRegionAttachment_updateOffset (spRegionAttachment* self) { 76 | float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX; 77 | float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY; 78 | float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX; 79 | float localY = -self->height / 2 * self->scaleY + self->regionOffsetY * regionScaleY; 80 | float localX2 = localX + self->regionWidth * regionScaleX; 81 | float localY2 = localY + self->regionHeight * regionScaleY; 82 | float radians = self->rotation * DEG_RAD; 83 | float cosine = COS(radians), sine = SIN(radians); 84 | float localXCos = localX * cosine + self->x; 85 | float localXSin = localX * sine; 86 | float localYCos = localY * cosine + self->y; 87 | float localYSin = localY * sine; 88 | float localX2Cos = localX2 * cosine + self->x; 89 | float localX2Sin = localX2 * sine; 90 | float localY2Cos = localY2 * cosine + self->y; 91 | float localY2Sin = localY2 * sine; 92 | self->offset[SP_VERTEX_X1] = localXCos - localYSin; 93 | self->offset[SP_VERTEX_Y1] = localYCos + localXSin; 94 | self->offset[SP_VERTEX_X2] = localXCos - localY2Sin; 95 | self->offset[SP_VERTEX_Y2] = localY2Cos + localXSin; 96 | self->offset[SP_VERTEX_X3] = localX2Cos - localY2Sin; 97 | self->offset[SP_VERTEX_Y3] = localY2Cos + localX2Sin; 98 | self->offset[SP_VERTEX_X4] = localX2Cos - localYSin; 99 | self->offset[SP_VERTEX_Y4] = localYCos + localX2Sin; 100 | } 101 | 102 | void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, spBone* bone, float* vertices) { 103 | const float* offset = self->offset; 104 | float x = bone->worldX, y = bone->worldY; 105 | vertices[SP_VERTEX_X1] = offset[SP_VERTEX_X1] * bone->a + offset[SP_VERTEX_Y1] * bone->b + x; 106 | vertices[SP_VERTEX_Y1] = offset[SP_VERTEX_X1] * bone->c + offset[SP_VERTEX_Y1] * bone->d + y; 107 | vertices[SP_VERTEX_X2] = offset[SP_VERTEX_X2] * bone->a + offset[SP_VERTEX_Y2] * bone->b + x; 108 | vertices[SP_VERTEX_Y2] = offset[SP_VERTEX_X2] * bone->c + offset[SP_VERTEX_Y2] * bone->d + y; 109 | vertices[SP_VERTEX_X3] = offset[SP_VERTEX_X3] * bone->a + offset[SP_VERTEX_Y3] * bone->b + x; 110 | vertices[SP_VERTEX_Y3] = offset[SP_VERTEX_X3] * bone->c + offset[SP_VERTEX_Y3] * bone->d + y; 111 | vertices[SP_VERTEX_X4] = offset[SP_VERTEX_X4] * bone->a + offset[SP_VERTEX_Y4] * bone->b + x; 112 | vertices[SP_VERTEX_Y4] = offset[SP_VERTEX_X4] * bone->c + offset[SP_VERTEX_Y4] * bone->d + y; 113 | } 114 | -------------------------------------------------------------------------------- /include/spine/SkeletonBounds.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKELETONBOUNDS_H_ 32 | #define SPINE_SKELETONBOUNDS_H_ 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct spPolygon { 42 | float* const vertices; 43 | int count; 44 | int capacity; 45 | } spPolygon; 46 | 47 | spPolygon* spPolygon_create (int capacity); 48 | void spPolygon_dispose (spPolygon* self); 49 | 50 | int/*bool*/spPolygon_containsPoint (spPolygon* polygon, float x, float y); 51 | int/*bool*/spPolygon_intersectsSegment (spPolygon* polygon, float x1, float y1, float x2, float y2); 52 | 53 | #ifdef SPINE_SHORT_NAMES 54 | typedef spPolygon Polygon; 55 | #define Polygon_create(...) spPolygon_create(__VA_ARGS__) 56 | #define Polygon_dispose(...) spPolygon_dispose(__VA_ARGS__) 57 | #define Polygon_containsPoint(...) spPolygon_containsPoint(__VA_ARGS__) 58 | #define Polygon_intersectsSegment(...) spPolygon_intersectsSegment(__VA_ARGS__) 59 | #endif 60 | 61 | /**/ 62 | 63 | typedef struct spSkeletonBounds { 64 | int count; 65 | spBoundingBoxAttachment** boundingBoxes; 66 | spPolygon** polygons; 67 | 68 | float minX, minY, maxX, maxY; 69 | } spSkeletonBounds; 70 | 71 | spSkeletonBounds* spSkeletonBounds_create (); 72 | void spSkeletonBounds_dispose (spSkeletonBounds* self); 73 | void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb); 74 | 75 | /** Returns true if the axis aligned bounding box contains the point. */ 76 | int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y); 77 | 78 | /** Returns true if the axis aligned bounding box intersects the line segment. */ 79 | int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); 80 | 81 | /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ 82 | int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds); 83 | 84 | /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more 85 | * efficient to only call this method if spSkeletonBounds_aabbContainsPoint returns true. */ 86 | spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y); 87 | 88 | /** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually 89 | * more efficient to only call this method if spSkeletonBounds_aabbIntersectsSegment returns true. */ 90 | spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); 91 | 92 | /** Returns the polygon for the specified bounding box, or null. */ 93 | spPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox); 94 | 95 | #ifdef SPINE_SHORT_NAMES 96 | typedef spSkeletonBounds SkeletonBounds; 97 | #define SkeletonBounds_create(...) spSkeletonBounds_create(__VA_ARGS__) 98 | #define SkeletonBounds_dispose(...) spSkeletonBounds_dispose(__VA_ARGS__) 99 | #define SkeletonBounds_update(...) spSkeletonBounds_update(__VA_ARGS__) 100 | #define SkeletonBounds_aabbContainsPoint(...) spSkeletonBounds_aabbContainsPoint(__VA_ARGS__) 101 | #define SkeletonBounds_aabbIntersectsSegment(...) spSkeletonBounds_aabbIntersectsSegment(__VA_ARGS__) 102 | #define SkeletonBounds_aabbIntersectsSkeleton(...) spSkeletonBounds_aabbIntersectsSkeleton(__VA_ARGS__) 103 | #define SkeletonBounds_containsPoint(...) spSkeletonBounds_containsPoint(__VA_ARGS__) 104 | #define SkeletonBounds_intersectsSegment(...) spSkeletonBounds_intersectsSegment(__VA_ARGS__) 105 | #define SkeletonBounds_getPolygon(...) spSkeletonBounds_getPolygon(__VA_ARGS__) 106 | #endif 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* SPINE_SKELETONBOUNDS_H_ */ 113 | -------------------------------------------------------------------------------- /src/spine/SkeletonData.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | spSkeletonData* spSkeletonData_create () { 36 | return NEW(spSkeletonData); 37 | } 38 | 39 | void spSkeletonData_dispose (spSkeletonData* self) { 40 | int i; 41 | for (i = 0; i < self->bonesCount; ++i) 42 | spBoneData_dispose(self->bones[i]); 43 | FREE(self->bones); 44 | 45 | for (i = 0; i < self->slotsCount; ++i) 46 | spSlotData_dispose(self->slots[i]); 47 | FREE(self->slots); 48 | 49 | for (i = 0; i < self->skinsCount; ++i) 50 | spSkin_dispose(self->skins[i]); 51 | FREE(self->skins); 52 | 53 | for (i = 0; i < self->eventsCount; ++i) 54 | spEventData_dispose(self->events[i]); 55 | FREE(self->events); 56 | 57 | for (i = 0; i < self->animationsCount; ++i) 58 | spAnimation_dispose(self->animations[i]); 59 | FREE(self->animations); 60 | 61 | for (i = 0; i < self->ikConstraintsCount; ++i) 62 | spIkConstraintData_dispose(self->ikConstraints[i]); 63 | FREE(self->ikConstraints); 64 | 65 | for (i = 0; i < self->transformConstraintsCount; ++i) 66 | spTransformConstraintData_dispose(self->transformConstraints[i]); 67 | FREE(self->transformConstraints); 68 | 69 | for (i = 0; i < self->pathConstraintsCount; i++) 70 | spPathConstraintData_dispose(self->pathConstraints[i]); 71 | FREE(self->pathConstraints); 72 | 73 | FREE(self->hash); 74 | FREE(self->version); 75 | 76 | FREE(self); 77 | } 78 | 79 | spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName) { 80 | int i; 81 | for (i = 0; i < self->bonesCount; ++i) 82 | if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i]; 83 | return 0; 84 | } 85 | 86 | int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName) { 87 | int i; 88 | for (i = 0; i < self->bonesCount; ++i) 89 | if (strcmp(self->bones[i]->name, boneName) == 0) return i; 90 | return -1; 91 | } 92 | 93 | spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName) { 94 | int i; 95 | for (i = 0; i < self->slotsCount; ++i) 96 | if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i]; 97 | return 0; 98 | } 99 | 100 | int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName) { 101 | int i; 102 | for (i = 0; i < self->slotsCount; ++i) 103 | if (strcmp(self->slots[i]->name, slotName) == 0) return i; 104 | return -1; 105 | } 106 | 107 | spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName) { 108 | int i; 109 | for (i = 0; i < self->skinsCount; ++i) 110 | if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i]; 111 | return 0; 112 | } 113 | 114 | spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName) { 115 | int i; 116 | for (i = 0; i < self->eventsCount; ++i) 117 | if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i]; 118 | return 0; 119 | } 120 | 121 | spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName) { 122 | int i; 123 | for (i = 0; i < self->animationsCount; ++i) 124 | if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i]; 125 | return 0; 126 | } 127 | 128 | spIkConstraintData* spSkeletonData_findIkConstraint (const spSkeletonData* self, const char* constraintName) { 129 | int i; 130 | for (i = 0; i < self->ikConstraintsCount; ++i) 131 | if (strcmp(self->ikConstraints[i]->name, constraintName) == 0) return self->ikConstraints[i]; 132 | return 0; 133 | } 134 | 135 | spTransformConstraintData* spSkeletonData_findTransformConstraint (const spSkeletonData* self, const char* constraintName) { 136 | int i; 137 | for (i = 0; i < self->transformConstraintsCount; ++i) 138 | if (strcmp(self->transformConstraints[i]->name, constraintName) == 0) return self->transformConstraints[i]; 139 | return 0; 140 | } 141 | 142 | spPathConstraintData* spSkeletonData_findPathConstraint (const spSkeletonData* self, const char* constraintName) { 143 | int i; 144 | for (i = 0; i < self->pathConstraintsCount; ++i) 145 | if (strcmp(self->pathConstraints[i]->name, constraintName) == 0) return self->pathConstraints[i]; 146 | return 0; 147 | } 148 | -------------------------------------------------------------------------------- /include/spine/Atlas.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ATLAS_H_ 32 | #define SPINE_ATLAS_H_ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct spAtlas spAtlas; 39 | 40 | typedef enum { 41 | SP_ATLAS_UNKNOWN_FORMAT, 42 | SP_ATLAS_ALPHA, 43 | SP_ATLAS_INTENSITY, 44 | SP_ATLAS_LUMINANCE_ALPHA, 45 | SP_ATLAS_RGB565, 46 | SP_ATLAS_RGBA4444, 47 | SP_ATLAS_RGB888, 48 | SP_ATLAS_RGBA8888 49 | } spAtlasFormat; 50 | 51 | typedef enum { 52 | SP_ATLAS_UNKNOWN_FILTER, 53 | SP_ATLAS_NEAREST, 54 | SP_ATLAS_LINEAR, 55 | SP_ATLAS_MIPMAP, 56 | SP_ATLAS_MIPMAP_NEAREST_NEAREST, 57 | SP_ATLAS_MIPMAP_LINEAR_NEAREST, 58 | SP_ATLAS_MIPMAP_NEAREST_LINEAR, 59 | SP_ATLAS_MIPMAP_LINEAR_LINEAR 60 | } spAtlasFilter; 61 | 62 | typedef enum { 63 | SP_ATLAS_MIRROREDREPEAT, 64 | SP_ATLAS_CLAMPTOEDGE, 65 | SP_ATLAS_REPEAT 66 | } spAtlasWrap; 67 | 68 | typedef struct spAtlasPage spAtlasPage; 69 | struct spAtlasPage { 70 | const spAtlas* atlas; 71 | const char* name; 72 | spAtlasFormat format; 73 | spAtlasFilter minFilter, magFilter; 74 | spAtlasWrap uWrap, vWrap; 75 | 76 | void* rendererObject; 77 | int width, height; 78 | 79 | spAtlasPage* next; 80 | }; 81 | 82 | spAtlasPage* spAtlasPage_create (spAtlas* atlas, const char* name); 83 | void spAtlasPage_dispose (spAtlasPage* self); 84 | 85 | #ifdef SPINE_SHORT_NAMES 86 | typedef spAtlasFormat AtlasFormat; 87 | #define ATLAS_UNKNOWN_FORMAT SP_ATLAS_UNKNOWN_FORMAT 88 | #define ATLAS_ALPHA SP_ATLAS_ALPHA 89 | #define ATLAS_INTENSITY SP_ATLAS_INTENSITY 90 | #define ATLAS_LUMINANCE_ALPHA SP_ATLAS_LUMINANCE_ALPHA 91 | #define ATLAS_RGB565 SP_ATLAS_RGB565 92 | #define ATLAS_RGBA4444 SP_ATLAS_RGBA4444 93 | #define ATLAS_RGB888 SP_ATLAS_RGB888 94 | #define ATLAS_RGBA8888 SP_ATLAS_RGBA8888 95 | typedef spAtlasFilter AtlasFilter; 96 | #define ATLAS_UNKNOWN_FILTER SP_ATLAS_UNKNOWN_FILTER 97 | #define ATLAS_NEAREST SP_ATLAS_NEAREST 98 | #define ATLAS_LINEAR SP_ATLAS_LINEAR 99 | #define ATLAS_MIPMAP SP_ATLAS_MIPMAP 100 | #define ATLAS_MIPMAP_NEAREST_NEAREST SP_ATLAS_MIPMAP_NEAREST_NEAREST 101 | #define ATLAS_MIPMAP_LINEAR_NEAREST SP_ATLAS_MIPMAP_LINEAR_NEAREST 102 | #define ATLAS_MIPMAP_NEAREST_LINEAR SP_ATLAS_MIPMAP_NEAREST_LINEAR 103 | #define ATLAS_MIPMAP_LINEAR_LINEAR SP_ATLAS_MIPMAP_LINEAR_LINEAR 104 | typedef spAtlasWrap AtlasWrap; 105 | #define ATLAS_MIRROREDREPEAT SP_ATLAS_MIRROREDREPEAT 106 | #define ATLAS_CLAMPTOEDGE SP_ATLAS_CLAMPTOEDGE 107 | #define ATLAS_REPEAT SP_ATLAS_REPEAT 108 | typedef spAtlasPage AtlasPage; 109 | #define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__) 110 | #define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__) 111 | #endif 112 | 113 | /**/ 114 | 115 | typedef struct spAtlasRegion spAtlasRegion; 116 | struct spAtlasRegion { 117 | const char* name; 118 | int x, y, width, height; 119 | float u, v, u2, v2; 120 | int offsetX, offsetY; 121 | int originalWidth, originalHeight; 122 | int index; 123 | int/*bool*/rotate; 124 | int/*bool*/flip; 125 | int* splits; 126 | int* pads; 127 | 128 | spAtlasPage* page; 129 | 130 | spAtlasRegion* next; 131 | }; 132 | 133 | spAtlasRegion* spAtlasRegion_create (); 134 | void spAtlasRegion_dispose (spAtlasRegion* self); 135 | 136 | #ifdef SPINE_SHORT_NAMES 137 | typedef spAtlasRegion AtlasRegion; 138 | #define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__) 139 | #define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__) 140 | #endif 141 | 142 | /**/ 143 | 144 | struct spAtlas { 145 | spAtlasPage* pages; 146 | spAtlasRegion* regions; 147 | 148 | void* rendererObject; 149 | }; 150 | 151 | /* Image files referenced in the atlas file will be prefixed with dir. */ 152 | spAtlas* spAtlas_create (const char* data, int length, const char* dir, void* rendererObject); 153 | /* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */ 154 | spAtlas* spAtlas_createFromFile (const char* path, void* rendererObject); 155 | void spAtlas_dispose (spAtlas* atlas); 156 | 157 | /* Returns 0 if the region was not found. */ 158 | spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name); 159 | 160 | #ifdef SPINE_SHORT_NAMES 161 | typedef spAtlas Atlas; 162 | #define Atlas_create(...) spAtlas_create(__VA_ARGS__) 163 | #define Atlas_createFromFile(...) spAtlas_createFromFile(__VA_ARGS__) 164 | #define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__) 165 | #define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__) 166 | #endif 167 | 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | #endif /* SPINE_ATLAS_H_ */ 173 | -------------------------------------------------------------------------------- /spine_batcher.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* spine_batcher.cpp */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* http://www.godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ 9 | /* */ 10 | /* Permission is hereby granted, free of charge, to any person obtaining */ 11 | /* a copy of this software and associated documentation files (the */ 12 | /* "Software"), to deal in the Software without restriction, including */ 13 | /* without limitation the rights to use, copy, modify, merge, publish, */ 14 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 15 | /* permit persons to whom the Software is furnished to do so, subject to */ 16 | /* the following conditions: */ 17 | /* */ 18 | /* The above copyright notice and this permission notice shall be */ 19 | /* included in all copies or substantial portions of the Software. */ 20 | /* */ 21 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 22 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 23 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 24 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 25 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 26 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 27 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 28 | /*************************************************************************/ 29 | #ifdef MODULE_SPINE_ENABLED 30 | #include "spine_batcher.h" 31 | 32 | #define BATCH_CAPACITY 1024 33 | #define BATCH_ELEMENTS_POOL 64 34 | 35 | 36 | 37 | List SpineBatcher::Elements::free; 38 | 39 | SpineBatcher::SetBlendMode::SetBlendMode(int p_mode) { 40 | 41 | cmd = CMD_SET_BLEND_MODE; 42 | mode = p_mode; 43 | } 44 | 45 | void SpineBatcher::SetBlendMode::draw(RID ci) { 46 | 47 | VisualServer::get_singleton()->canvas_item_add_set_blend_mode(ci, VS::MaterialBlendMode(mode)); 48 | } 49 | 50 | SpineBatcher::Elements::Elements() { 51 | 52 | cmd = CMD_DRAW_ELEMENT; 53 | vertices = memnew_arr(Vector2, BATCH_CAPACITY); 54 | colors = memnew_arr(Color, BATCH_CAPACITY); 55 | uvs = memnew_arr(Vector2, BATCH_CAPACITY); 56 | indies = memnew_arr(int, BATCH_CAPACITY * 3); 57 | vertices_count = 0; 58 | indies_count = 0; 59 | }; 60 | 61 | SpineBatcher::Elements::~Elements() { 62 | 63 | memdelete_arr(vertices); 64 | memdelete_arr(colors); 65 | memdelete_arr(uvs); 66 | memdelete_arr(indies); 67 | } 68 | 69 | 70 | 71 | void SpineBatcher::Elements::draw(RID ci) { 72 | 73 | VisualServer::get_singleton()->canvas_item_add_triangle_array_ptr(ci, 74 | indies_count / 3, 75 | indies, 76 | vertices, 77 | colors, 78 | uvs, 79 | texture->get_rid() 80 | ); 81 | } 82 | 83 | SpineBatcher::Command* SpineBatcher::Elements::take(){ 84 | if (free.size() == 0){ 85 | print_line("preallocate " + itos(BATCH_ELEMENTS_POOL) + " SpineBatcher::Elements"); 86 | for (int i=0; i(elem); 97 | if (e){ 98 | e->vertices_count = 0; 99 | e->indies_count = 0; 100 | e->texture.unref(); 101 | free.push_back(e); 102 | } else { 103 | memdelete(elem); 104 | } 105 | } 106 | 107 | void SpineBatcher::add(Ref p_texture, 108 | const float* p_vertices, const float* p_uvs, int p_vertices_count, 109 | const unsigned short* p_indies, int p_indies_count, 110 | Color *p_color, bool flip_x, bool flip_y) { 111 | 112 | //print_line("add vertices" + itos(p_vertices_count) + ":" + itos(elements->vertices_count) + " " + 113 | // itos(p_indies_count) + ":" + itos(elements->indies_count)); 114 | 115 | if ( p_texture.is_null() ) return; 116 | if ( (p_vertices_count >> 1) >= BATCH_CAPACITY || p_indies_count >= BATCH_CAPACITY * 3) return; 117 | 118 | //print_line("adding"); 119 | if (p_texture != elements->texture 120 | || elements->vertices_count + (p_vertices_count >> 1) >= BATCH_CAPACITY 121 | || elements->indies_count + p_indies_count >= BATCH_CAPACITY * 3) { 122 | 123 | //print_line("add oversized, push_elements"); 124 | push_elements(); 125 | elements->texture = p_texture; 126 | } 127 | 128 | for (int i = 0; i < p_indies_count; ++i, ++elements->indies_count) 129 | elements->indies[elements->indies_count] = p_indies[i] + elements->vertices_count; 130 | //print_line("add indicess added"); 131 | for (int i = 0; i+1 < p_vertices_count; i += 2, ++elements->vertices_count) { 132 | 133 | elements->vertices[elements->vertices_count].x = flip_x ? -p_vertices[i] : p_vertices[i]; 134 | elements->vertices[elements->vertices_count].y = flip_y ? p_vertices[i + 1] : -p_vertices[i + 1]; 135 | elements->colors[elements->vertices_count] = *p_color; 136 | elements->uvs[elements->vertices_count].x = p_uvs[i]; 137 | elements->uvs[elements->vertices_count].y = p_uvs[i + 1]; 138 | } 139 | } 140 | 141 | void SpineBatcher::add_set_blender_mode(bool p_mode) { 142 | 143 | push_elements(); 144 | element_list.push_back(memnew(SetBlendMode(p_mode))); 145 | } 146 | 147 | void SpineBatcher::flush() { 148 | 149 | RID ci = owner->get_canvas_item(); 150 | push_elements(); 151 | 152 | for (List::Element *E = element_list.front(); E; E = E->next()) { 153 | 154 | Command *e = E->get(); 155 | e->draw(ci); 156 | drawed_list.push_back(e); 157 | } 158 | element_list.clear(); 159 | } 160 | 161 | void SpineBatcher::push_elements() { 162 | 163 | if (elements->vertices_count <= 0 || elements->indies_count <= 0) 164 | return; 165 | 166 | element_list.push_back(elements); 167 | elements = reinterpret_cast(Elements::take()); 168 | } 169 | 170 | void SpineBatcher::reset() { 171 | 172 | for (List::Element *E = drawed_list.front(); E; E = E->next()) { 173 | 174 | Command *e = E->get(); 175 | Elements::retrieve(e); 176 | } 177 | drawed_list.clear(); 178 | } 179 | 180 | SpineBatcher::SpineBatcher(Node2D *owner) : owner(owner) { 181 | 182 | elements = reinterpret_cast(Elements::take()); 183 | } 184 | 185 | SpineBatcher::~SpineBatcher() { 186 | 187 | for (List::Element *E = element_list.front(); E; E = E->next()) { 188 | 189 | Command *e = E->get(); 190 | Elements::retrieve(e); 191 | } 192 | element_list.clear(); 193 | 194 | for (List::Element *E = drawed_list.front(); E; E = E->next()) { 195 | 196 | Command *e = E->get(); 197 | Elements::retrieve(e); 198 | } 199 | drawed_list.clear(); 200 | 201 | Elements::retrieve(elements); 202 | } 203 | 204 | #endif // MODULE_SPINE_ENABLED 205 | 206 | -------------------------------------------------------------------------------- /include/spine/Skeleton.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_SKELETON_H_ 32 | #define SPINE_SKELETON_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | typedef struct spSkeleton { 46 | spSkeletonData* const data; 47 | 48 | int bonesCount; 49 | spBone** bones; 50 | spBone* const root; 51 | 52 | int slotsCount; 53 | spSlot** slots; 54 | spSlot** drawOrder; 55 | 56 | int ikConstraintsCount; 57 | spIkConstraint** ikConstraints; 58 | 59 | int transformConstraintsCount; 60 | spTransformConstraint** transformConstraints; 61 | 62 | int pathConstraintsCount; 63 | spPathConstraint** pathConstraints; 64 | 65 | spSkin* const skin; 66 | float r, g, b, a; 67 | float time; 68 | int/*bool*/flipX, flipY; 69 | float x, y; 70 | 71 | #ifdef __cplusplus 72 | spSkeleton() : 73 | data(0), 74 | bonesCount(0), 75 | bones(0), 76 | root(0), 77 | slotsCount(0), 78 | slots(0), 79 | drawOrder(0), 80 | 81 | ikConstraintsCount(0), 82 | ikConstraints(0), 83 | 84 | transformConstraintsCount(0), 85 | transformConstraints(0), 86 | 87 | skin(0), 88 | r(0), g(0), b(0), a(0), 89 | time(0), 90 | flipX(0), 91 | flipY(0), 92 | x(0), y(0) { 93 | } 94 | #endif 95 | } spSkeleton; 96 | 97 | spSkeleton* spSkeleton_create (spSkeletonData* data); 98 | void spSkeleton_dispose (spSkeleton* self); 99 | 100 | /* Caches information about bones and constraints. Must be called if bones or constraints, or weighted path attachments 101 | * are added or removed. */ 102 | void spSkeleton_updateCache (spSkeleton* self); 103 | void spSkeleton_updateWorldTransform (const spSkeleton* self); 104 | 105 | /* Sets the bones, constraints, and slots to their setup pose values. */ 106 | void spSkeleton_setToSetupPose (const spSkeleton* self); 107 | /* Sets the bones and constraints to their setup pose values. */ 108 | void spSkeleton_setBonesToSetupPose (const spSkeleton* self); 109 | void spSkeleton_setSlotsToSetupPose (const spSkeleton* self); 110 | 111 | /* Returns 0 if the bone was not found. */ 112 | spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName); 113 | /* Returns -1 if the bone was not found. */ 114 | int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName); 115 | 116 | /* Returns 0 if the slot was not found. */ 117 | spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName); 118 | /* Returns -1 if the slot was not found. */ 119 | int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName); 120 | 121 | /* Sets the skin used to look up attachments before looking in the SkeletonData defaultSkin. Attachments from the new skin are 122 | * attached if the corresponding attachment from the old skin was attached. If there was no old skin, each slot's setup mode 123 | * attachment is attached from the new skin. 124 | * @param skin May be 0.*/ 125 | void spSkeleton_setSkin (spSkeleton* self, spSkin* skin); 126 | /* Returns 0 if the skin was not found. See spSkeleton_setSkin. 127 | * @param skinName May be 0. */ 128 | int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName); 129 | 130 | /* Returns 0 if the slot or attachment was not found. */ 131 | spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName); 132 | /* Returns 0 if the slot or attachment was not found. */ 133 | spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName); 134 | /* Returns 0 if the slot or attachment was not found. 135 | * @param attachmentName May be 0. */ 136 | int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName); 137 | 138 | /* Returns 0 if the IK constraint was not found. */ 139 | spIkConstraint* spSkeleton_findIkConstraint (const spSkeleton* self, const char* constraintName); 140 | 141 | /* Returns 0 if the transform constraint was not found. */ 142 | spTransformConstraint* spSkeleton_findTransformConstraint (const spSkeleton* self, const char* constraintName); 143 | 144 | /* Returns 0 if the path constraint was not found. */ 145 | spPathConstraint* spSkeleton_findPathConstraint (const spSkeleton* self, const char* constraintName); 146 | 147 | void spSkeleton_update (spSkeleton* self, float deltaTime); 148 | 149 | #ifdef SPINE_SHORT_NAMES 150 | typedef spSkeleton Skeleton; 151 | #define Skeleton_create(...) spSkeleton_create(__VA_ARGS__) 152 | #define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__) 153 | #define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__) 154 | #define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__) 155 | #define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__) 156 | #define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__) 157 | #define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__) 158 | #define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__) 159 | #define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__) 160 | #define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__) 161 | #define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__) 162 | #define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__) 163 | #define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__) 164 | #define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__) 165 | #define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__) 166 | #define Skeleton_update(...) spSkeleton_update(__VA_ARGS__) 167 | #endif 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | #endif /* SPINE_SKELETON_H_*/ 174 | -------------------------------------------------------------------------------- /include/spine/AnimationState.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Spine Runtimes Software License v2.5 3 | * 4 | * Copyright (c) 2013-2016, Esoteric Software 5 | * All rights reserved. 6 | * 7 | * You are granted a perpetual, non-exclusive, non-sublicensable, and 8 | * non-transferable license to use, install, execute, and perform the Spine 9 | * Runtimes software and derivative works solely for personal or internal 10 | * use. Without the written permission of Esoteric Software (see Section 2 of 11 | * the Spine Software License Agreement), you may not (a) modify, translate, 12 | * adapt, or develop new applications using the Spine Runtimes or otherwise 13 | * create derivative works or improvements of the Spine Runtimes or (b) remove, 14 | * delete, alter, or obscure any trademarks or any copyright, trademark, patent, 15 | * or other intellectual property or proprietary rights notices on or in the 16 | * Software, including any copy thereof. Redistributions in binary or source 17 | * form must include this license and terms. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF 25 | * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | *****************************************************************************/ 30 | 31 | #ifndef SPINE_ANIMATIONSTATE_H_ 32 | #define SPINE_ANIMATIONSTATE_H_ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | typedef enum { 43 | SP_ANIMATION_START, SP_ANIMATION_INTERRUPT, SP_ANIMATION_END, SP_ANIMATION_COMPLETE, SP_ANIMATION_DISPOSE, SP_ANIMATION_EVENT 44 | } spEventType; 45 | 46 | typedef struct spAnimationState spAnimationState; 47 | typedef struct spTrackEntry spTrackEntry; 48 | 49 | typedef void (*spAnimationStateListener) (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event); 50 | 51 | struct spTrackEntry { 52 | spAnimation* animation; 53 | spTrackEntry* next; 54 | spTrackEntry* mixingFrom; 55 | spAnimationStateListener listener; 56 | int trackIndex; 57 | int /*boolean*/ loop; 58 | float eventThreshold, attachmentThreshold, drawOrderThreshold; 59 | float animationStart, animationEnd, animationLast, nextAnimationLast; 60 | float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale; 61 | float alpha, mixTime, mixDuration, mixAlpha; 62 | int* /*boolean*/ timelinesFirst; 63 | int timelinesFirstCount; 64 | float* timelinesRotation; 65 | int timelinesRotationCount; 66 | void* rendererObject; 67 | void* userData; 68 | 69 | #ifdef __cplusplus 70 | spTrackEntry() : 71 | animation(0), 72 | next(0), mixingFrom(0), 73 | listener(0), 74 | trackIndex(0), 75 | loop(0), 76 | eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0), 77 | animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0), 78 | delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0), 79 | alpha(0), mixTime(0), mixDuration(0), mixAlpha(0), 80 | timelinesFirst(0), 81 | timelinesFirstCount(0), 82 | timelinesRotation(0), 83 | timelinesRotationCount(0) { 84 | } 85 | #endif 86 | }; 87 | 88 | struct spAnimationState { 89 | spAnimationStateData* const data; 90 | 91 | int tracksCount; 92 | spTrackEntry** tracks; 93 | 94 | spAnimationStateListener listener; 95 | 96 | float timeScale; 97 | 98 | void* rendererObject; 99 | 100 | #ifdef __cplusplus 101 | spAnimationState() : 102 | data(0), 103 | tracksCount(0), 104 | tracks(0), 105 | listener(0), 106 | timeScale(0) { 107 | } 108 | #endif 109 | }; 110 | 111 | /* @param data May be 0 for no mixing. */ 112 | spAnimationState* spAnimationState_create (spAnimationStateData* data); 113 | void spAnimationState_dispose (spAnimationState* self); 114 | 115 | void spAnimationState_update (spAnimationState* self, float delta); 116 | void spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton); 117 | 118 | void spAnimationState_clearTracks (spAnimationState* self); 119 | void spAnimationState_clearTrack (spAnimationState* self, int trackIndex); 120 | 121 | /** Set the current animation. Any queued animations are cleared. */ 122 | spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, 123 | int/*bool*/loop); 124 | spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop); 125 | 126 | /** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix 127 | * duration. */ 128 | spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, 129 | int/*bool*/loop, float delay); 130 | spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, 131 | float delay); 132 | spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration); 133 | spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay); 134 | void spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration); 135 | 136 | spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex); 137 | 138 | void spAnimationState_clearListenerNotifications(spAnimationState* self); 139 | 140 | float spTrackEntry_getAnimationTime (spTrackEntry* entry); 141 | 142 | /** Use this to dispose static memory before your app exits to appease your memory leak detector*/ 143 | void spAnimationState_disposeStatics (); 144 | 145 | #ifdef SPINE_SHORT_NAMES 146 | typedef spEventType EventType; 147 | #define ANIMATION_START SP_ANIMATION_START 148 | #define ANIMATION_INTERRUPT SP_ANIMATION_INTERRUPT 149 | #define ANIMATION_END SP_ANIMATION_END 150 | #define ANIMATION_COMPLETE SP_ANIMATION_COMPLETE 151 | #define ANIMATION_DISPOSE SP_ANIMATION_DISPOSE 152 | #define ANIMATION_EVENT SP_ANIMATION_EVENT 153 | typedef spAnimationStateListener AnimationStateListener; 154 | typedef spTrackEntry TrackEntry; 155 | typedef spAnimationState AnimationState; 156 | #define AnimationState_create(...) spAnimationState_create(__VA_ARGS__) 157 | #define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__) 158 | #define AnimationState_update(...) spAnimationState_update(__VA_ARGS__) 159 | #define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__) 160 | #define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__) 161 | #define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__) 162 | #define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__) 163 | #define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__) 164 | #define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__) 165 | #define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__) 166 | #define AnimationState_setEmptyAnimation(...) spAnimatinState_setEmptyAnimation(__VA_ARGS__) 167 | #define AnimationState_addEmptyAnimation(...) spAnimatinState_addEmptyAnimation(__VA_ARGS__) 168 | #define AnimationState_setEmptyAnimations(...) spAnimatinState_setEmptyAnimations(__VA_ARGS__) 169 | #define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__) 170 | #define AnimationState_clearListenerNotifications(...) spAnimatinState_clearListenerNotifications(__VA_ARGS__) 171 | #endif 172 | 173 | #ifdef __cplusplus 174 | } 175 | #endif 176 | 177 | #endif /* SPINE_ANIMATIONSTATE_H_ */ 178 | --------------------------------------------------------------------------------