This commit is contained in:
owen
2019-06-10 15:53:59 +08:00
parent c8e858a184
commit cc0077e7fe
202 changed files with 44410 additions and 18616 deletions
File diff suppressed because it is too large Load Diff
+112 -51
View File
@@ -83,50 +83,72 @@
<ClCompile Include="..\cocos\editor-support\IOTypedArray.cpp" />
<ClCompile Include="..\cocos\editor-support\RenderInfoMgr.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\AttachmentVertices.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\CreatorAttachmentLoader.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SpineAnimation.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SpineRenderer.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonAnimation.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Animation.c" />
<ClCompile Include="..\cocos\editor-support\spine\AnimationState.c" />
<ClCompile Include="..\cocos\editor-support\spine\AnimationStateData.c" />
<ClCompile Include="..\cocos\editor-support\spine\Array.c" />
<ClCompile Include="..\cocos\editor-support\spine\Atlas.c" />
<ClCompile Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.c" />
<ClCompile Include="..\cocos\editor-support\spine\Attachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\AttachmentLoader.c" />
<ClCompile Include="..\cocos\editor-support\spine\Bone.c" />
<ClCompile Include="..\cocos\editor-support\spine\BoneData.c" />
<ClCompile Include="..\cocos\editor-support\spine\BoundingBoxAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\ClippingAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\Color.c" />
<ClCompile Include="..\cocos\editor-support\spine\Event.c" />
<ClCompile Include="..\cocos\editor-support\spine\EventData.c" />
<ClCompile Include="..\cocos\editor-support\spine\extension.c" />
<ClCompile Include="..\cocos\editor-support\spine\IkConstraint.c" />
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintData.c" />
<ClCompile Include="..\cocos\editor-support\spine\Json.c" />
<ClCompile Include="..\cocos\editor-support\spine\MeshAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\PathAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraint.c" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintData.c" />
<ClCompile Include="..\cocos\editor-support\spine\PointAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\RegionAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\Skeleton.c" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBinary.c" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBounds.c" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonClipping.c" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonData.c" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonJson.c" />
<ClCompile Include="..\cocos\editor-support\spine\Skin.c" />
<ClCompile Include="..\cocos\editor-support\spine\Slot.c" />
<ClCompile Include="..\cocos\editor-support\spine\SlotData.c" />
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraint.c" />
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintData.c" />
<ClCompile Include="..\cocos\editor-support\spine\Triangulator.c" />
<ClCompile Include="..\cocos\editor-support\spine\VertexAttachment.c" />
<ClCompile Include="..\cocos\editor-support\spine\VertexEffect.c" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonRenderer.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.cpp" />
<ClCompile Include="..\cocos\editor-support\spine-creator-support\VertexEffectDelegate.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Animation.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\AnimationState.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\AnimationStateData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Atlas.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Attachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\AttachmentLoader.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\AttachmentTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Bone.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\BoneData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\BoundingBoxAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\ClippingAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\ColorTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Constraint.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\CurveTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\DeformTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\DrawOrderTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Event.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\EventData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\EventTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Extension.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\IkConstraint.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Json.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\LinkedMesh.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\MathUtil.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\MeshAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraint.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintMixTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintPositionTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintSpacingTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\PointAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\RegionAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\RotateTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\RTTI.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\ScaleTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\ShearTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Skeleton.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBinary.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBounds.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonClipping.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SkeletonJson.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Skin.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Slot.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SlotData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\SpineObject.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TextureLoader.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Timeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraint.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintData.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TranslateTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Triangulator.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\TwoColorTimeline.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\Updatable.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\VertexAttachment.cpp" />
<ClCompile Include="..\cocos\editor-support\spine\VertexEffect.cpp" />
<ClCompile Include="..\cocos\editor-support\TypedArrayPool.cpp" />
<ClCompile Include="..\cocos\math\CCGeometry.cpp" />
<ClCompile Include="..\cocos\math\CCVertex.cpp" />
@@ -333,38 +355,64 @@
<ClInclude Include="..\cocos\editor-support\IOTypedArray.h" />
<ClInclude Include="..\cocos\editor-support\RenderInfoMgr.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\AttachmentVertices.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\CreatorAttachmentLoader.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SpineAnimation.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SpineRenderer.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonAnimation.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonRenderer.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.h" />
<ClInclude Include="..\cocos\editor-support\spine-creator-support\VertexEffectDelegate.h" />
<ClInclude Include="..\cocos\editor-support\spine\Attachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\Animation.h" />
<ClInclude Include="..\cocos\editor-support\spine\AnimationState.h" />
<ClInclude Include="..\cocos\editor-support\spine\AnimationStateData.h" />
<ClInclude Include="..\cocos\editor-support\spine\Array.h" />
<ClInclude Include="..\cocos\editor-support\spine\Atlas.h" />
<ClInclude Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.h" />
<ClInclude Include="..\cocos\editor-support\spine\Attachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\AttachmentLoader.h" />
<ClInclude Include="..\cocos\editor-support\spine\AttachmentTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\AttachmentType.h" />
<ClInclude Include="..\cocos\editor-support\spine\BlendMode.h" />
<ClInclude Include="..\cocos\editor-support\spine\Bone.h" />
<ClInclude Include="..\cocos\editor-support\spine\BoneData.h" />
<ClInclude Include="..\cocos\editor-support\spine\BoundingBoxAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\ClippingAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\Color.h" />
<ClInclude Include="..\cocos\editor-support\spine\ColorTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Constraint.h" />
<ClInclude Include="..\cocos\editor-support\spine\ContainerUtil.h" />
<ClInclude Include="..\cocos\editor-support\spine\CurveTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Debug.h" />
<ClInclude Include="..\cocos\editor-support\spine\DeformTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\dll.h" />
<ClInclude Include="..\cocos\editor-support\spine\DrawOrderTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Event.h" />
<ClInclude Include="..\cocos\editor-support\spine\EventData.h" />
<ClInclude Include="..\cocos\editor-support\spine\extension.h" />
<ClInclude Include="..\cocos\editor-support\spine\EventTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Extension.h" />
<ClInclude Include="..\cocos\editor-support\spine\HashMap.h" />
<ClInclude Include="..\cocos\editor-support\spine\HasRendererObject.h" />
<ClInclude Include="..\cocos\editor-support\spine\IkConstraint.h" />
<ClInclude Include="..\cocos\editor-support\spine\IkConstraintData.h" />
<ClInclude Include="..\cocos\editor-support\spine\IkConstraintTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Json.h" />
<ClInclude Include="..\cocos\editor-support\spine\kvec.h" />
<ClInclude Include="..\cocos\editor-support\spine\LinkedMesh.h" />
<ClInclude Include="..\cocos\editor-support\spine\MathUtil.h" />
<ClInclude Include="..\cocos\editor-support\spine\MeshAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\MixBlend.h" />
<ClInclude Include="..\cocos\editor-support\spine\MixDirection.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathConstraint.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintData.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintMixTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintPositionTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintSpacingTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\PointAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\Pool.h" />
<ClInclude Include="..\cocos\editor-support\spine\PositionMode.h" />
<ClInclude Include="..\cocos\editor-support\spine\RegionAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\RotateMode.h" />
<ClInclude Include="..\cocos\editor-support\spine\RotateTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\RTTI.h" />
<ClInclude Include="..\cocos\editor-support\spine\ScaleTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\ShearTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Skeleton.h" />
<ClInclude Include="..\cocos\editor-support\spine\SkeletonBinary.h" />
<ClInclude Include="..\cocos\editor-support\spine\SkeletonBounds.h" />
@@ -374,12 +422,25 @@
<ClInclude Include="..\cocos\editor-support\spine\Skin.h" />
<ClInclude Include="..\cocos\editor-support\spine\Slot.h" />
<ClInclude Include="..\cocos\editor-support\spine\SlotData.h" />
<ClInclude Include="..\cocos\editor-support\spine\SpacingMode.h" />
<ClInclude Include="..\cocos\editor-support\spine\spine.h" />
<ClInclude Include="..\cocos\editor-support\spine\SpineObject.h" />
<ClInclude Include="..\cocos\editor-support\spine\SpineString.h" />
<ClInclude Include="..\cocos\editor-support\spine\TextureLoader.h" />
<ClInclude Include="..\cocos\editor-support\spine\Timeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\TimelineType.h" />
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraint.h" />
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraintData.h" />
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraintTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\TransformMode.h" />
<ClInclude Include="..\cocos\editor-support\spine\TranslateTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Triangulator.h" />
<ClInclude Include="..\cocos\editor-support\spine\TwoColorTimeline.h" />
<ClInclude Include="..\cocos\editor-support\spine\Updatable.h" />
<ClInclude Include="..\cocos\editor-support\spine\Vector.h" />
<ClInclude Include="..\cocos\editor-support\spine\VertexAttachment.h" />
<ClInclude Include="..\cocos\editor-support\spine\VertexEffect.h" />
<ClInclude Include="..\cocos\editor-support\spine\Vertices.h" />
<ClInclude Include="..\cocos\editor-support\TypedArrayPool.h" />
<ClInclude Include="..\cocos\math\CCGeometry.h" />
<ClInclude Include="..\cocos\math\CCMath.h" />
+367 -124
View File
@@ -428,19 +428,19 @@
<ClCompile Include="..\cocos\editor-support\spine-creator-support\AttachmentVertices.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\CreatorAttachmentLoader.cpp">
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonAnimation.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SpineAnimation.cpp">
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonRenderer.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SpineRenderer.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.cpp">
<ClCompile Include="..\cocos\editor-support\spine-creator-support\VertexEffectDelegate.cpp">
<Filter>editor-support\spine-creator-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\dragonbones\animation\Animation.cpp">
@@ -569,121 +569,247 @@
<ClCompile Include="..\cocos\editor-support\IOTypedArray.cpp">
<Filter>editor-support</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PointAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\Attachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\RegionAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\Animation.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Skeleton.c">
<ClCompile Include="..\cocos\editor-support\spine\AnimationState.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBinary.c">
<ClCompile Include="..\cocos\editor-support\spine\AnimationStateData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBounds.c">
<ClCompile Include="..\cocos\editor-support\spine\Atlas.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonClipping.c">
<ClCompile Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonData.c">
<ClCompile Include="..\cocos\editor-support\spine\AttachmentLoader.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonJson.c">
<ClCompile Include="..\cocos\editor-support\spine\AttachmentTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Skin.c">
<ClCompile Include="..\cocos\editor-support\spine\AttachmentType.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Slot.c">
<ClCompile Include="..\cocos\editor-support\spine\BlendMode.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SlotData.c">
<ClCompile Include="..\cocos\editor-support\spine\Bone.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraint.c">
<ClCompile Include="..\cocos\editor-support\spine\BoneData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintData.c">
<ClCompile Include="..\cocos\editor-support\spine\BoundingBoxAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Triangulator.c">
<ClCompile Include="..\cocos\editor-support\spine\ClippingAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\VertexAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\Color.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\VertexEffect.c">
<ClCompile Include="..\cocos\editor-support\spine\ColorTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Animation.c">
<ClCompile Include="..\cocos\editor-support\spine\Constraint.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\AnimationState.c">
<ClCompile Include="..\cocos\editor-support\spine\ContainerUtil.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\AnimationStateData.c">
<ClCompile Include="..\cocos\editor-support\spine\CurveTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Array.c">
<ClCompile Include="..\cocos\editor-support\spine\Debug.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Atlas.c">
<ClCompile Include="..\cocos\editor-support\spine\DeformTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.c">
<ClCompile Include="..\cocos\editor-support\spine\dll.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Attachment.c">
<ClCompile Include="..\cocos\editor-support\spine\DrawOrderTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\AttachmentLoader.c">
<ClCompile Include="..\cocos\editor-support\spine\Event.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Bone.c">
<ClCompile Include="..\cocos\editor-support\spine\EventData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\BoneData.c">
<ClCompile Include="..\cocos\editor-support\spine\EventTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\BoundingBoxAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\Extension.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\ClippingAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\HashMap.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Color.c">
<ClCompile Include="..\cocos\editor-support\spine\HasRendererObject.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Event.c">
<ClCompile Include="..\cocos\editor-support\spine\IkConstraint.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\EventData.c">
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\extension.c">
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\IkConstraint.c">
<ClCompile Include="..\cocos\editor-support\spine\Json.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\IkConstraintData.c">
<ClCompile Include="..\cocos\editor-support\spine\LinkedMesh.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Json.c">
<ClCompile Include="..\cocos\editor-support\spine\MathUtil.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\MeshAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\MeshAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathAttachment.c">
<ClCompile Include="..\cocos\editor-support\spine\MixBlend.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraint.c">
<ClCompile Include="..\cocos\editor-support\spine\MixDirection.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintData.c">
<ClCompile Include="..\cocos\editor-support\spine\PathAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraint.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintMixTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintPositionTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PathConstraintSpacingTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PointAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Pool.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\PositionMode.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\RegionAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\RotateMode.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\RotateTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\RTTI.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\ScaleTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\ShearTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Skeleton.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBinary.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonBounds.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonClipping.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SkeletonJson.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Skin.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Slot.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SlotData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SpacingMode.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\spine.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SpineObject.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\SpineString.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TextureLoader.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Timeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TimelineType.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraint.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintData.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformConstraintTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TransformMode.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TranslateTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Triangulator.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\TwoColorTimeline.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Updatable.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Vector.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\VertexAttachment.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\VertexEffect.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\spine\Vertices.cpp">
<Filter>editor-support\spine</Filter>
</ClCompile>
<ClCompile Include="..\cocos\editor-support\MeshBuffer.cpp">
@@ -1223,19 +1349,19 @@
<ClInclude Include="..\cocos\editor-support\spine-creator-support\AttachmentVertices.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\CreatorAttachmentLoader.h">
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonAnimation.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SpineAnimation.h">
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonRenderer.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\spine-cocos2dx.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SpineRenderer.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine-creator-support\SkeletonDataMgr.h">
<ClInclude Include="..\cocos\editor-support\spine-creator-support\VertexEffectDelegate.h">
<Filter>editor-support\spine-creator-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\dragonbones\animation\Animation.h">
@@ -1397,12 +1523,165 @@
<ClInclude Include="..\cocos\editor-support\MiddlewareMacro.h">
<Filter>editor-support</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Attachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Animation.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AnimationState.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AnimationStateData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Atlas.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AttachmentLoader.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AttachmentTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AttachmentType.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\BlendMode.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Bone.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\BoneData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\BoundingBoxAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ClippingAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Color.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ColorTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Constraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ContainerUtil.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\CurveTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Debug.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\DeformTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\dll.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\DrawOrderTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Event.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\EventData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\EventTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Extension.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\HashMap.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\HasRendererObject.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\IkConstraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\IkConstraintData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\IkConstraintTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Json.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\LinkedMesh.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\MathUtil.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\MeshAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\MixBlend.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\MixDirection.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintMixTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintPositionTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintSpacingTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PointAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Pool.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PositionMode.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\RegionAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\RotateMode.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\RotateTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\RTTI.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ScaleTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ShearTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Skeleton.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
@@ -1430,97 +1709,61 @@
<ClInclude Include="..\cocos\editor-support\spine\SlotData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\SpacingMode.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\spine.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\SpineObject.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\SpineString.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TextureLoader.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Timeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TimelineType.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraintData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TransformConstraintTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TransformMode.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TranslateTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Triangulator.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\TwoColorTimeline.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Updatable.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Vector.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\VertexAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\VertexEffect.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Animation.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AnimationState.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AnimationStateData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Array.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Atlas.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AtlasAttachmentLoader.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Attachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\AttachmentLoader.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Bone.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\BoneData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\BoundingBoxAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\ClippingAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Color.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\dll.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Event.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\EventData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\extension.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\IkConstraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\IkConstraintData.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\Json.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\kvec.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\MeshAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathAttachment.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraint.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\spine\PathConstraintData.h">
<ClInclude Include="..\cocos\editor-support\spine\Vertices.h">
<Filter>editor-support\spine</Filter>
</ClInclude>
<ClInclude Include="..\cocos\editor-support\MeshBuffer.h">
+7 -6
View File
@@ -136,17 +136,18 @@ renderer/renderer/Scene.cpp \
renderer/renderer/Technique.cpp \
renderer/renderer/View.cpp \
renderer/renderer/ForwardRenderer.cpp \
renderer/scene/CustomAssembler.cpp \
renderer/scene/assembler/Assembler.cpp \
renderer/scene/assembler/AssemblerBase.cpp \
renderer/scene/assembler/CustomAssembler.cpp \
renderer/scene/assembler/MaskAssembler.cpp \
renderer/scene/assembler/RenderData.cpp \
renderer/scene/assembler/RenderDataList.cpp \
renderer/scene/assembler/TiledMapAssembler.cpp \
renderer/scene/MeshBuffer.cpp \
renderer/scene/ModelBatcher.cpp \
renderer/scene/NodeProxy.cpp \
renderer/scene/RenderFlow.cpp \
renderer/scene/StencilManager.cpp \
renderer/scene/Assembler.cpp \
renderer/scene/AssemblerBase.cpp \
renderer/scene/MaskAssembler.cpp \
renderer/scene/RenderData.cpp \
renderer/scene/RenderDataList.cpp \
scripting/js-bindings/auto/jsb_gfx_auto.cpp \
scripting/js-bindings/auto/jsb_renderer_auto.cpp \
scripting/js-bindings/manual/jsb_renderer_manual.cpp \
+65 -43
View File
@@ -20,51 +20,73 @@ MiddlewareManager.cpp \
ifeq ($(USE_SPINE),1)
LOCAL_SRC_FILES += \
spine/Animation.c \
spine/AnimationState.c \
spine/AnimationStateData.c \
spine/Array.c \
spine/Atlas.c \
spine/AtlasAttachmentLoader.c \
spine/Attachment.c \
spine/AttachmentLoader.c \
spine/Bone.c \
spine/BoneData.c \
spine/BoundingBoxAttachment.c \
spine/ClippingAttachment.c \
spine/Color.c \
spine/Event.c \
spine/EventData.c \
spine/extension.c \
spine/IkConstraint.c \
spine/IkConstraintData.c \
spine/Json.c \
spine/MeshAttachment.c \
spine/PathAttachment.c \
spine/PathConstraint.c \
spine/PathConstraintData.c \
spine/PointAttachment.c \
spine/RegionAttachment.c \
spine/Skeleton.c \
spine/SkeletonBinary.c \
spine/SkeletonBounds.c \
spine/SkeletonClipping.c \
spine/SkeletonData.c \
spine/SkeletonJson.c \
spine/Skin.c \
spine/Slot.c \
spine/SlotData.c \
spine/TransformConstraint.c \
spine/TransformConstraintData.c \
spine/Triangulator.c \
spine/VertexAttachment.c \
spine/VertexEffect.c \
spine/Animation.cpp \
spine/AnimationState.cpp \
spine/AnimationStateData.cpp \
spine/Atlas.cpp \
spine/AtlasAttachmentLoader.cpp \
spine/Attachment.cpp \
spine/AttachmentLoader.cpp \
spine/AttachmentTimeline.cpp \
spine/Bone.cpp \
spine/BoneData.cpp \
spine/BoundingBoxAttachment.cpp \
spine/ClippingAttachment.cpp \
spine/ColorTimeline.cpp \
spine/Constraint.cpp \
spine/CurveTimeline.cpp \
spine/DeformTimeline.cpp \
spine/DrawOrderTimeline.cpp \
spine/Event.cpp \
spine/EventData.cpp \
spine/EventTimeline.cpp \
spine/Extension.cpp \
spine/IkConstraint.cpp \
spine/IkConstraintData.cpp \
spine/IkConstraintTimeline.cpp \
spine/Json.cpp \
spine/LinkedMesh.cpp \
spine/MathUtil.cpp \
spine/MeshAttachment.cpp \
spine/PathAttachment.cpp \
spine/PathConstraint.cpp \
spine/PathConstraintData.cpp \
spine/PathConstraintMixTimeline.cpp \
spine/PathConstraintPositionTimeline.cpp \
spine/PathConstraintSpacingTimeline.cpp \
spine/PointAttachment.cpp \
spine/RegionAttachment.cpp \
spine/RotateTimeline.cpp \
spine/RTTI.cpp \
spine/ScaleTimeline.cpp \
spine/ShearTimeline.cpp \
spine/Skeleton.cpp \
spine/SkeletonBinary.cpp \
spine/SkeletonBounds.cpp \
spine/SkeletonClipping.cpp \
spine/SkeletonData.cpp \
spine/SkeletonJson.cpp \
spine/Skin.cpp \
spine/Slot.cpp \
spine/SlotData.cpp \
spine/SpineObject.cpp \
spine/TextureLoader.cpp \
spine/Timeline.cpp \
spine/TransformConstraint.cpp \
spine/TransformConstraintData.cpp \
spine/TransformConstraintTimeline.cpp \
spine/TranslateTimeline.cpp \
spine/Triangulator.cpp \
spine/TwoColorTimeline.cpp \
spine/Updatable.cpp \
spine/VertexAttachment.cpp \
spine/VertexEffect.cpp \
spine-creator-support/AttachmentVertices.cpp \
spine-creator-support/CreatorAttachmentLoader.cpp \
spine-creator-support/SpineAnimation.cpp \
spine-creator-support/SpineRenderer.cpp \
spine-creator-support/spine-cocos2dx.cpp \
spine-creator-support/SkeletonAnimation.cpp \
spine-creator-support/SkeletonDataMgr.cpp \
spine-creator-support/SkeletonRenderer.cpp \
spine-creator-support/spine-cocos2dx.cpp \
spine-creator-support/VertexEffectDelegate.cpp \
../scripting/js-bindings/manual/jsb_spine_manual.cpp \
../scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp
endif # USE_SPINE
@@ -28,7 +28,7 @@
#define MAX_VERTEX_BUFFER_SIZE 65535
// fill debug data max capacity
#define MAX_DEBUG_BUFFER_SIZE 40960
#define MAX_DEBUG_BUFFER_SIZE 409600
// type array pool min size
#define MIN_TYPE_ARRAY_SIZE 1024
@@ -86,6 +86,7 @@ void Texture2D::setTexParameters(const TexParams& texParams)
void Texture2D::setNativeTexture(Texture* texture)
{
if (_texture == texture) return;
CC_SAFE_RELEASE(_texture);
_texture = texture;
CC_SAFE_RETAIN(_texture);
@@ -1,31 +1,30 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/AttachmentVertices.h"
@@ -34,8 +33,7 @@ USING_NS_CC;
namespace spine {
AttachmentVertices::AttachmentVertices (middleware::Texture2D* texture, int verticesCount, unsigned short* triangles, int trianglesCount)
{
AttachmentVertices::AttachmentVertices (middleware::Texture2D* texture, int verticesCount, unsigned short* triangles, int trianglesCount) {
_texture = texture;
_triangles = new middleware::Triangles();
@@ -45,8 +43,7 @@ namespace spine {
_triangles->indexCount = trianglesCount;
}
AttachmentVertices::~AttachmentVertices ()
{
AttachmentVertices::~AttachmentVertices () {
delete [] _triangles->verts;
delete _triangles;
}
@@ -1,31 +1,30 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
@@ -37,8 +36,7 @@ namespace spine{
/**
* Store attachment vertex and indice list
*/
class AttachmentVertices
{
class AttachmentVertices {
public:
AttachmentVertices (cocos2d::middleware::Texture2D* texture, int verticesCount, unsigned short* triangles, int trianglesCount);
virtual ~AttachmentVertices ();
@@ -1,121 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/CreatorAttachmentLoader.h"
#include "spine/extension.h"
#include "spine-creator-support/AttachmentVertices.h"
USING_NS_CC;
USING_NS_MW;
using namespace spine;
static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
spAttachment* _CreatorAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
const char* name, const char* path)
{
CreatorAttachmentLoader* self = SUB_CAST(CreatorAttachmentLoader, loader);
return spAttachmentLoader_createAttachment(SUPER(self->atlasAttachmentLoader), skin, type, name, path);
}
void _CreatorAttachmentLoader_configureAttachment (spAttachmentLoader* loader, spAttachment* attachment)
{
attachment->attachmentLoader = loader;
switch (attachment->type)
{
case SP_ATTACHMENT_REGION:
{
spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment);
spAtlasRegion* region = (spAtlasRegion*)regionAttachment->rendererObject;
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->rendererObject, 4, quadTriangles, 6);
V2F_T2F_C4B* vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0; i < 4; ++i, ii += 2)
{
vertices[i].texCoord.u = regionAttachment->uvs[ii];
vertices[i].texCoord.v = regionAttachment->uvs[ii + 1];
}
regionAttachment->rendererObject = attachmentVertices;
break;
}
case SP_ATTACHMENT_MESH:
{
spMeshAttachment* meshAttachment = SUB_CAST(spMeshAttachment, attachment);
spAtlasRegion* region = (spAtlasRegion*)meshAttachment->rendererObject;
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->rendererObject,
meshAttachment->super.worldVerticesLength >> 1, meshAttachment->triangles, meshAttachment->trianglesCount);
V2F_T2F_C4B* vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0, nn = meshAttachment->super.worldVerticesLength; ii < nn; ++i, ii += 2)
{
vertices[i].texCoord.u = meshAttachment->uvs[ii];
vertices[i].texCoord.v = meshAttachment->uvs[ii + 1];
}
meshAttachment->rendererObject = attachmentVertices;
break;
}
default: ;
}
}
void _CreatorAttachmentLoader_disposeAttachment (spAttachmentLoader* loader, spAttachment* attachment)
{
switch (attachment->type)
{
case SP_ATTACHMENT_REGION:
{
spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment);
delete (AttachmentVertices*)regionAttachment->rendererObject;
break;
}
case SP_ATTACHMENT_MESH:
{
spMeshAttachment* meshAttachment = SUB_CAST(spMeshAttachment, attachment);
delete (AttachmentVertices*)meshAttachment->rendererObject;
break;
}
default: ;
}
}
void _CreatorAttachmentLoader_dispose (spAttachmentLoader* loader)
{
CreatorAttachmentLoader* self = SUB_CAST(CreatorAttachmentLoader, loader);
spAttachmentLoader_dispose(SUPER_CAST(spAttachmentLoader, self->atlasAttachmentLoader));
_spAttachmentLoader_deinit(loader);
}
CreatorAttachmentLoader* CreatorAttachmentLoader_create (spAtlas* atlas)
{
CreatorAttachmentLoader* self = NEW(CreatorAttachmentLoader);
_spAttachmentLoader_init(SUPER(self), _CreatorAttachmentLoader_dispose, _CreatorAttachmentLoader_createAttachment,
_CreatorAttachmentLoader_configureAttachment, _CreatorAttachmentLoader_disposeAttachment);
self->atlasAttachmentLoader = spAtlasAttachmentLoader_create(atlas);
return self;
}
@@ -0,0 +1,343 @@
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/SkeletonAnimation.h"
#include "spine-creator-support/spine-cocos2dx.h"
#include "spine/extension.h"
#include <algorithm>
USING_NS_CC;
using std::min;
using std::max;
using std::vector;
namespace spine {
typedef struct _TrackEntryListeners {
StartListener startListener;
InterruptListener interruptListener;
EndListener endListener;
DisposeListener disposeListener;
CompleteListener completeListener;
EventListener eventListener;
} _TrackEntryListeners;
void animationCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
((SkeletonAnimation*)state->getRendererObject())->onAnimationStateEvent(entry, type, event);
}
void trackEntryCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
((SkeletonAnimation*)state->getRendererObject())->onTrackEntryEvent(entry, type, event);
if (type == EventType_Dispose)
if (entry->getRendererObject()) delete (spine::_TrackEntryListeners*)entry->getRendererObject();
}
static _TrackEntryListeners* getListeners (TrackEntry* entry) {
if (!entry->getRendererObject()) {
entry->setRendererObject(new spine::_TrackEntryListeners());
entry->setListener(trackEntryCallback);
}
return (_TrackEntryListeners*)entry->getRendererObject();
}
static float globalTimeScale = 1.0f;
void SkeletonAnimation::setGlobalTimeScale(float timeScale) {
globalTimeScale = timeScale;
}
SkeletonAnimation* SkeletonAnimation::create() {
SkeletonAnimation* skeleton = new SkeletonAnimation();
skeleton->autorelease();
return skeleton;
}
SkeletonAnimation* SkeletonAnimation::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
SkeletonAnimation* node = new SkeletonAnimation();
node->initWithData(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, Atlas* atlas, float scale) {
SkeletonAnimation* node = new SkeletonAnimation();
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale) {
SkeletonAnimation* node = new SkeletonAnimation();
node->initWithJsonFile(skeletonJsonFile, atlasFile, scale);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, Atlas* atlas, float scale) {
SkeletonAnimation* node = new SkeletonAnimation();
node->initWithBinaryFile(skeletonBinaryFile, atlas, scale);
node->autorelease();
return node;
}
SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale) {
SkeletonAnimation* node = new SkeletonAnimation();
node->initWithBinaryFile(skeletonBinaryFile, atlasFile, scale);
node->autorelease();
return node;
}
void SkeletonAnimation::initialize () {
super::initialize();
_ownsAnimationStateData = true;
_state = new (__FILE__, __LINE__) AnimationState(new (__FILE__, __LINE__) AnimationStateData(_skeleton->getData()));
_state->setRendererObject(this);
_state->setListener(animationCallback);
}
SkeletonAnimation::SkeletonAnimation ()
: SkeletonRenderer() {
}
SkeletonAnimation::~SkeletonAnimation () {
_startListener = nullptr;
_interruptListener = nullptr;
_endListener = nullptr;
_disposeListener = nullptr;
_completeListener = nullptr;
_eventListener = nullptr;
if (_state) {
clearTracks();
if (_ownsAnimationStateData) delete _state->getData();
delete _state;
}
}
void SkeletonAnimation::update (float deltaTime) {
if (!_skeleton) return;
if (!_paused) {
deltaTime *= _timeScale * globalTimeScale;
if (_ownsSkeleton) _skeleton->update(deltaTime);
_state->update(deltaTime);
_state->apply(*_skeleton);
_skeleton->updateWorldTransform();
}
super::update(deltaTime);
}
void SkeletonAnimation::setAnimationStateData (AnimationStateData* stateData) {
CCASSERT(stateData, "stateData cannot be null.");
if (_state) {
if (_ownsAnimationStateData) delete _state->getData();
delete _state;
}
_ownsAnimationStateData = false;
_state = new (__FILE__, __LINE__) AnimationState(stateData);
_state->setRendererObject(this);
_state->setListener(animationCallback);
}
void SkeletonAnimation::setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration) {
if (_state) {
_state->getData()->setMix(fromAnimation.c_str(), toAnimation.c_str(), duration);
}
}
TrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const std::string& name, bool loop) {
if (!_skeleton) return 0;
Animation* animation = _skeleton->getData()->findAnimation(name.c_str());
if (!animation) {
log("Spine: Animation not found: %s", name.c_str());
return 0;
}
auto trackEntry = _state->setAnimation(trackIndex, animation, loop);
_state->apply(*_skeleton);
return trackEntry;
}
TrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const std::string& name, bool loop, float delay) {
if (!_skeleton) return 0;
Animation* animation = _skeleton->getData()->findAnimation(name.c_str());
if (!animation) {
log("Spine: Animation not found: %s", name.c_str());
return 0;
}
return _state->addAnimation(trackIndex, animation, loop, delay);
}
TrackEntry* SkeletonAnimation::setEmptyAnimation (int trackIndex, float mixDuration) {
if (_state) {
return _state->setEmptyAnimation(trackIndex, mixDuration);
}
return nullptr;
}
void SkeletonAnimation::setEmptyAnimations (float mixDuration) {
if (_state) {
_state->setEmptyAnimations(mixDuration);
}
}
TrackEntry* SkeletonAnimation::addEmptyAnimation (int trackIndex, float mixDuration, float delay) {
if (_state) {
return _state->addEmptyAnimation(trackIndex, mixDuration, delay);
}
return nullptr;
}
Animation* SkeletonAnimation::findAnimation(const std::string& name) const {
if (_skeleton) {
return _skeleton->getData()->findAnimation(name.c_str());
}
return nullptr;
}
TrackEntry* SkeletonAnimation::getCurrent (int trackIndex) {
if (_state) {
return _state->getCurrent(trackIndex);
}
return nullptr;
}
void SkeletonAnimation::clearTracks () {
if (_state) {
_state->clearTracks();
}
}
void SkeletonAnimation::clearTrack (int trackIndex) {
if (_state) {
_state->clearTrack(trackIndex);
}
}
void SkeletonAnimation::onAnimationStateEvent (TrackEntry* entry, EventType type, Event* event) {
switch (type) {
case EventType_Start:
if (_startListener) _startListener(entry);
break;
case EventType_Interrupt:
if (_interruptListener) _interruptListener(entry);
break;
case EventType_End:
if (_endListener) _endListener(entry);
break;
case EventType_Dispose:
if (_disposeListener) _disposeListener(entry);
break;
case EventType_Complete:
if (_completeListener) _completeListener(entry);
break;
case EventType_Event:
if (_eventListener) _eventListener(entry, event);
break;
}
}
void SkeletonAnimation::onTrackEntryEvent (TrackEntry* entry, EventType type, Event* event) {
if (!entry->getRendererObject()) return;
_TrackEntryListeners* listeners = (_TrackEntryListeners*)entry->getRendererObject();
switch (type) {
case EventType_Start:
if (listeners->startListener) listeners->startListener(entry);
break;
case EventType_Interrupt:
if (listeners->interruptListener) listeners->interruptListener(entry);
break;
case EventType_End:
if (listeners->endListener) listeners->endListener(entry);
break;
case EventType_Dispose:
if (listeners->disposeListener) listeners->disposeListener(entry);
break;
case EventType_Complete:
if (listeners->completeListener) listeners->completeListener(entry);
break;
case EventType_Event:
if (listeners->eventListener) listeners->eventListener(entry, event);
break;
}
}
void SkeletonAnimation::setStartListener (const StartListener& listener) {
_startListener = listener;
}
void SkeletonAnimation::setInterruptListener (const InterruptListener& listener) {
_interruptListener = listener;
}
void SkeletonAnimation::setEndListener (const EndListener& listener) {
_endListener = listener;
}
void SkeletonAnimation::setDisposeListener (const DisposeListener& listener) {
_disposeListener = listener;
}
void SkeletonAnimation::setCompleteListener (const CompleteListener& listener) {
_completeListener = listener;
}
void SkeletonAnimation::setEventListener (const EventListener& listener) {
_eventListener = listener;
}
void SkeletonAnimation::setTrackStartListener (TrackEntry* entry, const StartListener& listener) {
getListeners(entry)->startListener = listener;
}
void SkeletonAnimation::setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener) {
getListeners(entry)->interruptListener = listener;
}
void SkeletonAnimation::setTrackEndListener (TrackEntry* entry, const EndListener& listener) {
getListeners(entry)->endListener = listener;
}
void SkeletonAnimation::setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener) {
getListeners(entry)->disposeListener = listener;
}
void SkeletonAnimation::setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener) {
getListeners(entry)->completeListener = listener;
}
void SkeletonAnimation::setTrackEventListener (TrackEntry* entry, const EventListener& listener) {
getListeners(entry)->eventListener = listener;
}
AnimationState* SkeletonAnimation::getState() const {
return _state;
}
}
@@ -0,0 +1,116 @@
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
#include "spine/spine.h"
#include "spine-creator-support/SkeletonRenderer.h"
namespace spine {
typedef std::function<void(TrackEntry* entry)> StartListener;
typedef std::function<void(TrackEntry* entry)> InterruptListener;
typedef std::function<void(TrackEntry* entry)> EndListener;
typedef std::function<void(TrackEntry* entry)> DisposeListener;
typedef std::function<void(TrackEntry* entry)> CompleteListener;
typedef std::function<void(TrackEntry* entry, Event* event)> EventListener;
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
* played later. */
class SkeletonAnimation: public SkeletonRenderer {
public:
static SkeletonAnimation* create();
static SkeletonAnimation* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, Atlas* atlas, float scale = 1);
static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1);
static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, Atlas* atlas, float scale = 1);
static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale = 1);
static void setGlobalTimeScale(float timeScale);
// Use createWithJsonFile instead
CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithFile (const std::string& skeletonJsonFile, Atlas* atlas, float scale = 1) {
return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlas, scale);
}
// Use createWithJsonFile instead
CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1) {
return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlasFile, scale);
}
virtual void update (float deltaTime) override;
void setAnimationStateData (AnimationStateData* stateData);
void setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration);
TrackEntry* setAnimation (int trackIndex, const std::string& name, bool loop);
TrackEntry* addAnimation (int trackIndex, const std::string& name, bool loop, float delay = 0);
TrackEntry* setEmptyAnimation (int trackIndex, float mixDuration);
void setEmptyAnimations (float mixDuration);
TrackEntry* addEmptyAnimation (int trackIndex, float mixDuration, float delay = 0);
Animation* findAnimation(const std::string& name) const;
TrackEntry* getCurrent (int trackIndex = 0);
void clearTracks ();
void clearTrack (int trackIndex = 0);
void setStartListener (const StartListener& listener);
void setInterruptListener (const InterruptListener& listener);
void setEndListener (const EndListener& listener);
void setDisposeListener (const DisposeListener& listener);
void setCompleteListener (const CompleteListener& listener);
void setEventListener (const EventListener& listener);
void setTrackStartListener (TrackEntry* entry, const StartListener& listener);
void setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener);
void setTrackEndListener (TrackEntry* entry, const EndListener& listener);
void setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener);
void setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener);
void setTrackEventListener (TrackEntry* entry, const EventListener& listener);
virtual void onAnimationStateEvent (TrackEntry* entry, EventType type, Event* event);
virtual void onTrackEntryEvent (TrackEntry* entry, EventType type, Event* event);
AnimationState* getState() const;
CC_CONSTRUCTOR_ACCESS:
SkeletonAnimation ();
virtual ~SkeletonAnimation ();
virtual void initialize () override;
protected:
AnimationState* _state = nullptr;
bool _ownsAnimationStateData = false;
StartListener _startListener = nullptr;
InterruptListener _interruptListener = nullptr;
EndListener _endListener = nullptr;
DisposeListener _disposeListener = nullptr;
CompleteListener _completeListener = nullptr;
EventListener _eventListener = nullptr;
private:
typedef SkeletonRenderer super;
};
}
@@ -1,31 +1,30 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "SkeletonDataMgr.h"
@@ -36,53 +35,45 @@ using namespace spine;
class SkeletonDataInfo;
static std::map<std::string, SkeletonDataInfo*> _dataMap;
class SkeletonDataInfo : public cocos2d::Ref{
class SkeletonDataInfo : public cocos2d::Ref {
public:
SkeletonDataInfo (const std::string& uuid)
{
SkeletonDataInfo (const std::string& uuid) {
_uuid = uuid;
}
~SkeletonDataInfo ()
{
if (data)
{
spSkeletonData_dispose(data);
~SkeletonDataInfo () {
if (data) {
delete data;
data = nullptr;
}
if (atlas)
{
spAtlas_dispose(atlas);
if (atlas) {
delete atlas;
atlas = nullptr;
}
if (attachmentLoader)
{
spAttachmentLoader_dispose(attachmentLoader);
if (attachmentLoader) {
delete attachmentLoader;
attachmentLoader = nullptr;
}
}
spSkeletonData* data = nullptr;
spAtlas* atlas = nullptr;
spAttachmentLoader* attachmentLoader = nullptr;
SkeletonData* data = nullptr;
Atlas* atlas = nullptr;
AttachmentLoader* attachmentLoader = nullptr;
std::string _uuid;
};
SkeletonDataMgr* SkeletonDataMgr::_instance = nullptr;
bool SkeletonDataMgr::hasSkeletonData (const std::string& uuid)
{
bool SkeletonDataMgr::hasSkeletonData (const std::string& uuid) {
auto it = _dataMap.find(uuid);
return it != _dataMap.end();
}
void SkeletonDataMgr::setSkeletonData (const std::string& uuid, spSkeletonData* data, spAtlas* atlas, spAttachmentLoader* attachmentLoader)
{
void SkeletonDataMgr::setSkeletonData (const std::string& uuid, SkeletonData* data, Atlas* atlas, AttachmentLoader* attachmentLoader) {
auto it = _dataMap.find(uuid);
if (it != _dataMap.end())
{
if (it != _dataMap.end()) {
releaseByUUID(uuid);
}
SkeletonDataInfo* info = new SkeletonDataInfo(uuid);
@@ -92,8 +83,7 @@ void SkeletonDataMgr::setSkeletonData (const std::string& uuid, spSkeletonData*
_dataMap[uuid] = info;
}
spSkeletonData* SkeletonDataMgr::retainByUUID (const std::string& uuid)
{
SkeletonData* SkeletonDataMgr::retainByUUID (const std::string& uuid) {
auto dataIt = _dataMap.find(uuid);
if (dataIt == _dataMap.end())
{
@@ -103,17 +93,14 @@ spSkeletonData* SkeletonDataMgr::retainByUUID (const std::string& uuid)
return dataIt->second->data;
}
void SkeletonDataMgr::releaseByUUID (const std::string& uuid)
{
void SkeletonDataMgr::releaseByUUID (const std::string& uuid) {
auto dataIt = _dataMap.find(uuid);
if (dataIt == _dataMap.end())
{
if (dataIt == _dataMap.end()) {
return;
}
SkeletonDataInfo* info = dataIt->second;
// If info reference count is 1, then info will be destroy.
if (info->getReferenceCount() == 1)
{
if (info->getReferenceCount() == 1) {
_dataMap.erase(dataIt);
}
info->release();
@@ -1,26 +1,31 @@
/****************************************************************************
Copyright (c) 2019 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
@@ -37,19 +42,15 @@ namespace spine {
*/
class SkeletonDataMgr {
public:
static SkeletonDataMgr* getInstance ()
{
if (_instance == nullptr)
{
static SkeletonDataMgr* getInstance () {
if (_instance == nullptr) {
_instance = new SkeletonDataMgr();
}
return _instance;
}
static void destroyInstance ()
{
if (_instance)
{
static void destroyInstance () {
if (_instance) {
delete _instance;
_instance = nullptr;
}
@@ -58,8 +59,8 @@ public:
SkeletonDataMgr () {}
virtual ~SkeletonDataMgr () {}
bool hasSkeletonData (const std::string& uuid);
void setSkeletonData (const std::string& uuid, spSkeletonData* data, spAtlas* atlas, spAttachmentLoader* attachmentLoader);
spSkeletonData* retainByUUID (const std::string& uuid);
void setSkeletonData (const std::string& uuid, SkeletonData* data, Atlas* atlas, AttachmentLoader* attachmentLoader);
SkeletonData* retainByUUID (const std::string& uuid);
void releaseByUUID (const std::string& uuid);
private:
static SkeletonDataMgr* _instance;
File diff suppressed because it is too large Load Diff
@@ -1,31 +1,30 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
@@ -37,6 +36,7 @@
#include "scripting/js-bindings/jswrapper/Object.hpp"
#include "IOTypedArray.h"
#include "MiddlewareManager.h"
#include "spine-creator-support/VertexEffectDelegate.h"
#include "renderer/scene/NodeProxy.hpp"
#include "base/CCMap.h"
#include "middleware-adapter.h"
@@ -44,23 +44,22 @@
namespace spine {
class NodeProxy;
class AttachmentVertices;
/** Draws a skeleton.
*/
class SpineRenderer: public cocos2d::middleware::IMiddleware, public cocos2d::Ref
{
class SkeletonRenderer: public cocos2d::middleware::IMiddleware, public cocos2d::Ref {
public:
static SpineRenderer* create ();
static SpineRenderer* createWithSkeleton(spSkeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
static SpineRenderer* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
static SpineRenderer* createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1);
static SpineRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
static SkeletonRenderer* create ();
static SkeletonRenderer* createWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
static SkeletonRenderer* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual void update (float deltaTime);
spSkeleton* getSkeleton() const;
virtual cocos2d::Rect getBoundingBox () const;
Skeleton* getSkeleton() const;
void setTimeScale (float scale);
float getTimeScale () const;
@@ -73,19 +72,19 @@ namespace spine {
void paused (bool value);
/* Returns 0 if the bone was not found. */
spBone* findBone (const std::string& boneName) const;
Bone* findBone (const std::string& boneName) const;
/* Returns 0 if the slot was not found. */
spSlot* findSlot (const std::string& slotName) const;
Slot* findSlot (const std::string& slotName) const;
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
* attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
* attached if the corresponding attachment from the old skin was attached.
* @param skin May be empty string ("") for no skin.*/
bool setSkin (const std::string& skinName);
void setSkin (const std::string& skinName);
/** @param skin May be 0 for no skin.*/
bool setSkin (const char* skinName);
void setSkin (const char* skinName);
/* Returns 0 if the slot or attachment was not found. */
spAttachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
Attachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
/* Returns false if the slot or attachment was not found.
* @param attachmentName May be empty string ("") for no attachment. */
bool setAttachment (const std::string& slotName, const std::string& attachmentName);
@@ -95,6 +94,8 @@ namespace spine {
/* Enables/disables two color tinting for this instance. May break batching */
void setUseTint(bool enabled);
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
void setVertexEffectDelegate(VertexEffectDelegate* effectDelegate);
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
void setSlotsRange(int startSlotIndex, int endSlotIndex);
@@ -102,10 +103,8 @@ namespace spine {
* @return debug data,it's a Float32Array,
* format |debug bones length|[beginX|beginY|toX|toY|...loop...]
*/
se_object_ptr getDebugData() const
{
if (_debugBuffer)
{
se_object_ptr getDebugData() const {
if (_debugBuffer) {
return _debugBuffer->getTypeArray();
}
return nullptr;
@@ -130,6 +129,7 @@ namespace spine {
void setColor (cocos2d::Color4B& color);
void setDebugBonesEnabled (bool enabled);
void setDebugSlotsEnabled (bool enabled);
void setDebugMeshEnabled (bool enabled);
void setOpacityModifyRGB (bool value);
bool isOpacityModifyRGB () const;
@@ -140,42 +140,43 @@ namespace spine {
void onDisable();
CC_CONSTRUCTOR_ACCESS:
SpineRenderer ();
SpineRenderer(spSkeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
SpineRenderer (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
SpineRenderer (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1);
SpineRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
SkeletonRenderer ();
SkeletonRenderer(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
SkeletonRenderer (SkeletonData* skeletonData, bool ownsSkeletonData = false);
SkeletonRenderer (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual ~SpineRenderer ();
virtual ~SkeletonRenderer ();
void initWithUUID(const std::string& uuid);
void initWithSkeleton(spSkeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
void initWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
void initWithJsonFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1);
void initWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
void initWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
void initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
void initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
void initWithBinaryFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1);
void initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual void initialize ();
protected:
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const;
virtual AttachmentVertices* getAttachmentVertices (spMeshAttachment* attachment) const;
bool _ownsSkeletonData = true;
bool _ownsSkeleton = true;
spAtlas* _atlas = nullptr;
spAttachmentLoader* _attachmentLoader = nullptr;
spSkeleton* _skeleton = nullptr;
void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData);
bool _ownsSkeletonData = false;
bool _ownsSkeleton = false;
bool _ownsAtlas = false;
Atlas* _atlas = nullptr;
AttachmentLoader* _attachmentLoader = nullptr;
Skeleton* _skeleton = nullptr;
VertexEffectDelegate* _effectDelegate = nullptr;
float _timeScale = 1;
bool _paused = false;
bool _debugMesh = false;
bool _debugSlots = false;
bool _debugBones = false;
cocos2d::Color4F _nodeColor = cocos2d::Color4F::WHITE;
bool _premultipliedAlpha = false;
spSkeletonClipping* _clipper = nullptr;
SkeletonClipping* _clipper = nullptr;
bool _useTint = false;
std::string _uuid = "";
@@ -1,384 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/SpineAnimation.h"
#include "spine-creator-support/spine-cocos2dx.h"
#include "spine/extension.h"
#include <algorithm>
USING_NS_CC;
using std::min;
using std::max;
using std::vector;
namespace spine {
typedef struct _TrackEntryListeners
{
StartListener startListener;
InterruptListener interruptListener;
EndListener endListener;
DisposeListener disposeListener;
CompleteListener completeListener;
EventListener eventListener;
} _TrackEntryListeners;
void animationCallback (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event)
{
((SpineAnimation*)state->rendererObject)->onAnimationStateEvent(entry, type, event);
}
void trackEntryCallback (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event)
{
((SpineAnimation*)state->rendererObject)->onTrackEntryEvent(entry, type, event);
if (type == SP_ANIMATION_DISPOSE)
if (entry->rendererObject) delete (spine::_TrackEntryListeners*)entry->rendererObject;
}
static _TrackEntryListeners* getListeners (spTrackEntry* entry)
{
if (!entry->rendererObject) {
entry->rendererObject = new spine::_TrackEntryListeners();
entry->listener = trackEntryCallback;
}
return (_TrackEntryListeners*)entry->rendererObject;
}
static float globalTimeScale = 1.0f;
void SpineAnimation::setGlobalTimeScale(float timeScale)
{
globalTimeScale = timeScale;
}
SpineAnimation* SpineAnimation::create()
{
SpineAnimation* skeleton = new SpineAnimation();
skeleton->autorelease();
return skeleton;
}
SpineAnimation* SpineAnimation::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData)
{
SpineAnimation* node = new SpineAnimation();
node->initWithData(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
SpineAnimation* SpineAnimation::createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale)
{
SpineAnimation* node = new SpineAnimation();
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
node->autorelease();
return node;
}
SpineAnimation* SpineAnimation::createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale)
{
SpineAnimation* node = new SpineAnimation();
spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
node->autorelease();
return node;
}
SpineAnimation* SpineAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale)
{
SpineAnimation* node = new SpineAnimation();
node->initWithBinaryFile(skeletonBinaryFile, atlas, scale);
node->autorelease();
return node;
}
SpineAnimation* SpineAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale)
{
SpineAnimation* node = new SpineAnimation();
spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
node->initWithBinaryFile(skeletonBinaryFile, atlas, scale);
node->autorelease();
return node;
}
void SpineAnimation::initialize ()
{
super::initialize();
_ownsAnimationStateData = true;
_state = spAnimationState_create(spAnimationStateData_create(_skeleton->data));
_state->rendererObject = this;
_state->listener = animationCallback;
}
SpineAnimation::SpineAnimation ()
: SpineRenderer()
{
}
SpineAnimation::SpineAnimation (spSkeletonData *skeletonData, bool ownsSkeletonData)
: SpineRenderer(skeletonData, ownsSkeletonData)
{
initialize();
}
SpineAnimation::SpineAnimation (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
: SpineRenderer(skeletonDataFile, atlas, scale)
{
initialize();
}
SpineAnimation::SpineAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
: SpineRenderer(skeletonDataFile, atlasFile, scale)
{
initialize();
}
SpineAnimation::~SpineAnimation ()
{
_startListener = nullptr;
_interruptListener = nullptr;
_endListener = nullptr;
_disposeListener = nullptr;
_completeListener = nullptr;
_eventListener = nullptr;
if (_state)
{
clearTracks();
if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data);
spAnimationState_dispose(_state);
}
}
void SpineAnimation::update (float deltaTime)
{
if (!_paused)
{
deltaTime *= _timeScale * globalTimeScale;
spSkeleton_update(_skeleton, deltaTime);
spAnimationState_update(_state, deltaTime);
spAnimationState_apply(_state, _skeleton);
spSkeleton_updateWorldTransform(_skeleton);
}
super::update(deltaTime);
}
void SpineAnimation::setAnimationStateData (spAnimationStateData* stateData)
{
CCASSERT(stateData, "stateData cannot be null.");
if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data);
spAnimationState_dispose(_state);
_ownsAnimationStateData = false;
_state = spAnimationState_create(stateData);
_state->rendererObject = this;
_state->listener = animationCallback;
}
void SpineAnimation::setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration)
{
spAnimationStateData_setMixByName(_state->data, fromAnimation.c_str(), toAnimation.c_str(), duration);
}
spTrackEntry* SpineAnimation::setAnimation (int trackIndex, const std::string& name, bool loop)
{
spAnimation* animation = spSkeletonData_findAnimation(_skeleton->data, name.c_str());
if (!animation) {
log("Spine: Animation not found: %s", name.c_str());
return 0;
}
return spAnimationState_setAnimation(_state, trackIndex, animation, loop);
}
spTrackEntry* SpineAnimation::addAnimation (int trackIndex, const std::string& name, bool loop, float delay)
{
spAnimation* animation = spSkeletonData_findAnimation(_skeleton->data, name.c_str());
if (!animation)
{
log("Spine: Animation not found: %s", name.c_str());
return 0;
}
return spAnimationState_addAnimation(_state, trackIndex, animation, loop, delay);
}
spTrackEntry* SpineAnimation::setEmptyAnimation (int trackIndex, float mixDuration)
{
return spAnimationState_setEmptyAnimation(_state, trackIndex, mixDuration);
}
void SpineAnimation::setEmptyAnimations (float mixDuration)
{
spAnimationState_setEmptyAnimations(_state, mixDuration);
}
spTrackEntry* SpineAnimation::addEmptyAnimation (int trackIndex, float mixDuration, float delay)
{
return spAnimationState_addEmptyAnimation(_state, trackIndex, mixDuration, delay);
}
spAnimation* SpineAnimation::findAnimation(const std::string& name) const
{
return spSkeletonData_findAnimation(_skeleton->data, name.c_str());
}
spTrackEntry* SpineAnimation::getCurrent (int trackIndex)
{
return spAnimationState_getCurrent(_state, trackIndex);
}
void SpineAnimation::clearTracks ()
{
spAnimationState_clearTracks(_state);
}
void SpineAnimation::clearTrack (int trackIndex)
{
spAnimationState_clearTrack(_state, trackIndex);
}
void SpineAnimation::onAnimationStateEvent (spTrackEntry* entry, spEventType type, spEvent* event)
{
switch (type)
{
case SP_ANIMATION_START:
if (_startListener) _startListener(entry);
break;
case SP_ANIMATION_INTERRUPT:
if (_interruptListener) _interruptListener(entry);
break;
case SP_ANIMATION_END:
if (_endListener) _endListener(entry);
break;
case SP_ANIMATION_DISPOSE:
if (_disposeListener) _disposeListener(entry);
break;
case SP_ANIMATION_COMPLETE:
if (_completeListener) _completeListener(entry);
break;
case SP_ANIMATION_EVENT:
if (_eventListener) _eventListener(entry, event);
break;
}
}
void SpineAnimation::onTrackEntryEvent (spTrackEntry* entry, spEventType type, spEvent* event)
{
if (!entry->rendererObject) return;
_TrackEntryListeners* listeners = (_TrackEntryListeners*)entry->rendererObject;
switch (type)
{
case SP_ANIMATION_START:
if (listeners->startListener) listeners->startListener(entry);
break;
case SP_ANIMATION_INTERRUPT:
if (listeners->interruptListener) listeners->interruptListener(entry);
break;
case SP_ANIMATION_END:
if (listeners->endListener) listeners->endListener(entry);
break;
case SP_ANIMATION_DISPOSE:
if (listeners->disposeListener) listeners->disposeListener(entry);
break;
case SP_ANIMATION_COMPLETE:
if (listeners->completeListener) listeners->completeListener(entry);
break;
case SP_ANIMATION_EVENT:
if (listeners->eventListener) listeners->eventListener(entry, event);
break;
}
}
void SpineAnimation::setStartListener (const StartListener& listener)
{
_startListener = listener;
}
void SpineAnimation::setInterruptListener (const InterruptListener& listener)
{
_interruptListener = listener;
}
void SpineAnimation::setEndListener (const EndListener& listener)
{
_endListener = listener;
}
void SpineAnimation::setDisposeListener (const DisposeListener& listener)
{
_disposeListener = listener;
}
void SpineAnimation::setCompleteListener (const CompleteListener& listener)
{
_completeListener = listener;
}
void SpineAnimation::setEventListener (const EventListener& listener)
{
_eventListener = listener;
}
void SpineAnimation::setTrackStartListener (spTrackEntry* entry, const StartListener& listener)
{
getListeners(entry)->startListener = listener;
}
void SpineAnimation::setTrackInterruptListener (spTrackEntry* entry, const InterruptListener& listener)
{
getListeners(entry)->interruptListener = listener;
}
void SpineAnimation::setTrackEndListener (spTrackEntry* entry, const EndListener& listener)
{
getListeners(entry)->endListener = listener;
}
void SpineAnimation::setTrackDisposeListener (spTrackEntry* entry, const DisposeListener& listener)
{
getListeners(entry)->disposeListener = listener;
}
void SpineAnimation::setTrackCompleteListener (spTrackEntry* entry, const CompleteListener& listener)
{
getListeners(entry)->completeListener = listener;
}
void SpineAnimation::setTrackEventListener (spTrackEntry* entry, const EventListener& listener)
{
getListeners(entry)->eventListener = listener;
}
spAnimationState* SpineAnimation::getState() const
{
return _state;
}
}
@@ -1,123 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
#include "spine/spine.h"
#include "spine-creator-support/SpineRenderer.h"
namespace spine {
typedef std::function<void(spTrackEntry* entry)> StartListener;
typedef std::function<void(spTrackEntry* entry)> InterruptListener;
typedef std::function<void(spTrackEntry* entry)> EndListener;
typedef std::function<void(spTrackEntry* entry)> DisposeListener;
typedef std::function<void(spTrackEntry* entry)> CompleteListener;
typedef std::function<void(spTrackEntry* entry, spEvent* event)> EventListener;
/** Draws an animated skeleton, providing an AnimationState for applying one or
* more animations and queuing animations to be played later.
*/
class SpineAnimation: public SpineRenderer
{
public:
static SpineAnimation* create();
static SpineAnimation* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
static SpineAnimation* createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1);
static SpineAnimation* createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1);
static SpineAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale = 1);
static SpineAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale = 1);
static void setGlobalTimeScale(float timeScale);
// Use createWithJsonFile instead
CC_DEPRECATED_ATTRIBUTE static SpineAnimation* createWithFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1)
{
return SpineAnimation::createWithJsonFile(skeletonJsonFile, atlas, scale);
}
// Use createWithJsonFile instead
CC_DEPRECATED_ATTRIBUTE static SpineAnimation* createWithile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1)
{
return SpineAnimation::createWithJsonFile(skeletonJsonFile, atlasFile, scale);
}
virtual void update (float deltaTime) override;
void setAnimationStateData (spAnimationStateData* stateData);
void setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration);
spTrackEntry* setAnimation (int trackIndex, const std::string& name, bool loop);
spTrackEntry* addAnimation (int trackIndex, const std::string& name, bool loop, float delay = 0);
spTrackEntry* setEmptyAnimation (int trackIndex, float mixDuration);
void setEmptyAnimations (float mixDuration);
spTrackEntry* addEmptyAnimation (int trackIndex, float mixDuration, float delay = 0);
spAnimation* findAnimation(const std::string& name) const;
spTrackEntry* getCurrent (int trackIndex = 0);
void clearTracks ();
void clearTrack (int trackIndex = 0);
void setStartListener (const StartListener& listener);
void setInterruptListener (const InterruptListener& listener);
void setEndListener (const EndListener& listener);
void setDisposeListener (const DisposeListener& listener);
void setCompleteListener (const CompleteListener& listener);
void setEventListener (const EventListener& listener);
void setTrackStartListener (spTrackEntry* entry, const StartListener& listener);
void setTrackInterruptListener (spTrackEntry* entry, const InterruptListener& listener);
void setTrackEndListener (spTrackEntry* entry, const EndListener& listener);
void setTrackDisposeListener (spTrackEntry* entry, const DisposeListener& listener);
void setTrackCompleteListener (spTrackEntry* entry, const CompleteListener& listener);
void setTrackEventListener (spTrackEntry* entry, const EventListener& listener);
virtual void onAnimationStateEvent (spTrackEntry* entry, spEventType type, spEvent* event);
virtual void onTrackEntryEvent (spTrackEntry* entry, spEventType type, spEvent* event);
spAnimationState* getState() const;
CC_CONSTRUCTOR_ACCESS:
SpineAnimation ();
SpineAnimation (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
SpineAnimation (const std::string&skeletonDataFile, spAtlas* atlas, float scale = 1);
SpineAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual ~SpineAnimation ();
virtual void initialize () override;
protected:
spAnimationState* _state = nullptr;
bool _ownsAnimationStateData = false;
StartListener _startListener = nullptr;
InterruptListener _interruptListener = nullptr;
EndListener _endListener = nullptr;
DisposeListener _disposeListener = nullptr;
CompleteListener _completeListener = nullptr;
EventListener _eventListener = nullptr;
private:
typedef SpineRenderer super;
};
}
@@ -1,942 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/SpineRenderer.h"
#include "spine/extension.h"
#include "spine-creator-support/AttachmentVertices.h"
#include "spine-creator-support/CreatorAttachmentLoader.h"
#include <algorithm>
#include "base/CCScheduler.h"
#include "MiddlewareMacro.h"
#include "renderer/renderer/Pass.h"
#include "renderer/renderer/Technique.h"
#include "renderer/scene/assembler/CustomAssembler.hpp"
#include "SkeletonDataMgr.h"
USING_NS_CC;
USING_NS_MW;
using std::min;
using std::max;
using namespace spine;
using namespace cocos2d;
using namespace cocos2d::renderer;
static const std::string techStage = "opaque";
static const std::string textureKey = "texture";
SpineRenderer* SpineRenderer::create ()
{
SpineRenderer* skeleton = new SpineRenderer();
skeleton->autorelease();
return skeleton;
}
SpineRenderer* SpineRenderer::createWithSkeleton(spSkeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData)
{
SpineRenderer* node = new SpineRenderer(skeleton, ownsSkeleton, ownsSkeletonData);
node->autorelease();
return node;
}
SpineRenderer* SpineRenderer::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData)
{
SpineRenderer* node = new SpineRenderer(skeletonData, ownsSkeletonData);
node->autorelease();
return node;
}
SpineRenderer* SpineRenderer::createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
{
SpineRenderer* node = new SpineRenderer(skeletonDataFile, atlas, scale);
node->autorelease();
return node;
}
SpineRenderer* SpineRenderer::createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
{
SpineRenderer* node = new SpineRenderer(skeletonDataFile, atlasFile, scale);
node->autorelease();
return node;
}
void SpineRenderer::initialize ()
{
if (_clipper == nullptr)
{
_clipper = spSkeletonClipping_create();
}
beginSchedule();
}
void SpineRenderer::beginSchedule()
{
MiddlewareManager::getInstance()->addTimer(this);
}
void SpineRenderer::onEnable()
{
beginSchedule();
}
void SpineRenderer::onDisable()
{
stopSchedule();
}
void SpineRenderer::stopSchedule()
{
MiddlewareManager::getInstance()->removeTimer(this);
if (_debugBuffer)
{
_debugBuffer->reset();
_debugBuffer->clear();
}
}
void SpineRenderer::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData)
{
_skeleton = spSkeleton_create(skeletonData);
_ownsSkeletonData = ownsSkeletonData;
}
SpineRenderer::SpineRenderer ()
{
}
SpineRenderer::SpineRenderer(spSkeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData)
{
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData);
}
SpineRenderer::SpineRenderer (spSkeletonData *skeletonData, bool ownsSkeletonData)
{
initWithData(skeletonData, ownsSkeletonData);
}
SpineRenderer::SpineRenderer (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
{
initWithJsonFile(skeletonDataFile, atlas, scale);
}
SpineRenderer::SpineRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
{
initWithJsonFile(skeletonDataFile, atlasFile, scale);
}
SpineRenderer::~SpineRenderer ()
{
if (_ownsSkeletonData) spSkeletonData_dispose(_skeleton->data);
if (_ownsSkeleton) spSkeleton_dispose(_skeleton);
if (_atlas) spAtlas_dispose(_atlas);
if (_attachmentLoader) spAttachmentLoader_dispose(_attachmentLoader);
if (_uuid != "") SkeletonDataMgr::getInstance()->releaseByUUID(_uuid);
if (_clipper) spSkeletonClipping_dispose(_clipper);
if (_debugBuffer)
{
delete _debugBuffer;
_debugBuffer = nullptr;
}
CC_SAFE_RELEASE(_nodeProxy);
CC_SAFE_RELEASE(_effect);
stopSchedule();
}
void SpineRenderer::initWithUUID(const std::string& uuid)
{
_ownsSkeleton = true;
_uuid = uuid;
spSkeletonData* skeletonData = SkeletonDataMgr::getInstance()->retainByUUID(uuid);
CCASSERT(skeletonData, "Skeleton data is is null");
setSkeletonData(skeletonData, false);
initialize();
}
void SpineRenderer::initWithSkeleton(spSkeleton* skeleton, bool ownsSkeleton, bool ownsSkeletonData)
{
_skeleton = skeleton;
_ownsSkeleton = ownsSkeleton;
_ownsSkeletonData = ownsSkeletonData;
initialize();
}
void SpineRenderer::initWithData (spSkeletonData* skeletonData, bool ownsSkeletonData)
{
_ownsSkeleton = true;
setSkeletonData(skeletonData, ownsSkeletonData);
initialize();
}
void SpineRenderer::initWithJsonFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
{
_atlas = atlas;
_attachmentLoader = SUPER(CreatorAttachmentLoader_create(_atlas));
spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
json->scale = scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile.c_str());
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data.");
spSkeletonJson_dispose(json);
_ownsSkeleton = true;
setSkeletonData(skeletonData, true);
initialize();
}
void SpineRenderer::initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
{
_atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
CCASSERT(_atlas, "Error reading atlas file.");
_attachmentLoader = SUPER(CreatorAttachmentLoader_create(_atlas));
spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
json->scale = scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile.c_str());
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);
_ownsSkeleton = true;
setSkeletonData(skeletonData, true);
initialize();
}
void SpineRenderer::initWithBinaryFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
{
_atlas = atlas;
_attachmentLoader = SUPER(CreatorAttachmentLoader_create(_atlas));
spSkeletonBinary* binary = spSkeletonBinary_createWithLoader(_attachmentLoader);
binary->scale = scale;
spSkeletonData* skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonDataFile.c_str());
CCASSERT(skeletonData, binary->error ? binary->error : "Error reading skeleton data file.");
spSkeletonBinary_dispose(binary);
_ownsSkeleton = true;
setSkeletonData(skeletonData, true);
initialize();
}
void SpineRenderer::initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
{
_atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
CCASSERT(_atlas, "Error reading atlas file.");
_attachmentLoader = SUPER(CreatorAttachmentLoader_create(_atlas));
spSkeletonBinary* binary = spSkeletonBinary_createWithLoader(_attachmentLoader);
binary->scale = scale;
spSkeletonData* skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonDataFile.c_str());
CCASSERT(skeletonData, binary->error ? binary->error : "Error reading skeleton data file.");
spSkeletonBinary_dispose(binary);
_ownsSkeleton = true;
setSkeletonData(skeletonData, true);
initialize();
}
void SpineRenderer::update (float deltaTime)
{
// avoid other place call update.
auto mgr = MiddlewareManager::getInstance();
if (!mgr->isUpdating) return;
if (_nodeProxy == nullptr)
{
return;
}
CustomAssembler* assembler = (CustomAssembler*)_nodeProxy->getAssembler("render");
if (assembler == nullptr)
{
return;
}
assembler->reset();
_nodeColor.a = _nodeProxy->getRealOpacity() / (float)255;
// If opacity is 0,then return.
if (_skeleton->color.a == 0)
{
return;
}
Color4F color;
Color4F darkColor;
AttachmentVertices* attachmentVertices = nullptr;
bool inRange = _startSlotIndex != -1 || _endSlotIndex != -1 ? false : true;
auto vertexFormat = _useTint? VF_XYUVCC : VF_XYUVC;
middleware::MeshBuffer* mb = mgr->getMeshBuffer(vertexFormat);
middleware::IOBuffer& vb = mb->getVB();
middleware::IOBuffer& ib = mb->getIB();
// vertex size in floats with one color
int vs1 = sizeof(V2F_T2F_C4B) / sizeof(float);
// verex size in floats with two color
int vs2 = sizeof(V2F_T2F_C4B_C4B) / sizeof(float);
int vbSize = 0;
int ibSize = 0;
BlendFactor curBlendSrc = BlendFactor::ONE;
BlendFactor curBlendDst = BlendFactor::ZERO;
int preBlendMode = -1;
int preTextureIndex = -1;
int curTextureIndex = -1;
int preISegWritePos = -1;
int curISegLen = 0;
int debugSlotsLen = 0;
int materialLen = 0;
spSlot* slot = nullptr;
int isFull = 0;
middleware::Texture2D* texture = nullptr;
if (_debugSlots || _debugBones)
{
// If enable debug draw,then init debug buffer.
if (_debugBuffer == nullptr)
{
_debugBuffer = new IOTypedArray(se::Object::TypedArrayType::FLOAT32, MAX_DEBUG_BUFFER_SIZE);
}
_debugBuffer->reset();
if (_debugSlots)
{
//reserved 4 bytes to save debug slots len
_debugBuffer->writeUint32(0);
}
}
auto flush = [&]()
{
// fill pre segment count field
if (preISegWritePos != -1)
{
assembler->updateIARange(materialLen - 1, preISegWritePos, curISegLen);
}
// prepare to fill new segment field
switch (slot->data->blendMode)
{
case SP_BLEND_MODE_ADDITIVE:
curBlendSrc = _premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA;
curBlendDst = BlendFactor::ONE;
break;
case SP_BLEND_MODE_MULTIPLY:
curBlendSrc = BlendFactor::DST_COLOR;
curBlendDst = BlendFactor::ONE_MINUS_SRC_ALPHA;
break;
case SP_BLEND_MODE_SCREEN:
curBlendSrc = BlendFactor::ONE;
curBlendDst = BlendFactor::ONE_MINUS_SRC_COLOR;
break;
default:
curBlendSrc = _premultipliedAlpha ? BlendFactor::ONE : BlendFactor::SRC_ALPHA;
curBlendDst = BlendFactor::ONE_MINUS_SRC_ALPHA;
}
double curHash = curTextureIndex + (int)curBlendSrc + (int)curBlendDst;
Effect* renderEffect = assembler->getEffect(materialLen);
Technique::Parameter* param = nullptr;
Pass* pass = nullptr;
if (renderEffect)
{
double renderHash = renderEffect->getHash();
if (abs(renderHash - curHash) >= 0.01)
{
param = (Technique::Parameter*)&(renderEffect->getProperty(textureKey));
Technique* tech = renderEffect->getTechnique(techStage);
Vector<Pass*>& passes = (Vector<Pass*>&)tech->getPasses();
pass = *(passes.begin());
}
}
else
{
if (_effect == nullptr)
{
cocos2d::log("SpineRender:update get effect failed");
assembler->reset();
return;
}
auto effect = new cocos2d::renderer::Effect();
effect->autorelease();
effect->copy(*_effect);
Technique* tech = effect->getTechnique(techStage);
Vector<Pass*>& passes = (Vector<Pass*>&)tech->getPasses();
pass = *(passes.begin());
assembler->updateEffect(materialLen, effect);
renderEffect = effect;
param = (Technique::Parameter*)&(renderEffect->getProperty(textureKey));
}
if (param)
{
param->setTexture(texture->getNativeTexture());
}
if (pass)
{
pass->setBlend(BlendOp::ADD, curBlendSrc, curBlendDst,
BlendOp::ADD, curBlendSrc, curBlendDst);
}
renderEffect->updateHash(curHash);
// save new segment count pos field
preISegWritePos = (int)ib.getCurPos() / sizeof(unsigned short);
// save new segment vb and ib
assembler->updateIABuffer(materialLen, mb->getGLVB(), mb->getGLIB());
// reset pre blend mode to current
preBlendMode = (int)slot->data->blendMode;
// reset pre texture index to current
preTextureIndex = curTextureIndex;
// reset index segmentation count
curISegLen = 0;
// material length increased
materialLen++;
};
for (int i = 0, n = _skeleton->slotsCount; i < n; ++i)
{
isFull = 0;
slot = _skeleton->drawOrder[i];
if (_startSlotIndex >= 0 && _startSlotIndex == slot->data->index)
{
inRange = true;
}
if (!inRange) {
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (_endSlotIndex >= 0 && _endSlotIndex == slot->data->index)
{
inRange = false;
}
if (!slot->attachment)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
// Early exit if slot is invisible
if (slot->color.a == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (!slot->attachment)
{
continue;
}
Triangles triangles;
TwoColorTriangles trianglesTwoColor;
switch (slot->attachment->type)
{
case SP_ATTACHMENT_REGION:
{
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
attachmentVertices = getAttachmentVertices(attachment);
// Early exit if attachment is invisible
if (attachment->color.a == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (!_useTint)
{
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)triangles.verts, 0, vs1);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
}
else
{
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++)
{
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
}
color.r = attachment->color.r;
color.g = attachment->color.g;
color.b = attachment->color.b;
color.a = attachment->color.a;
if(_debugSlots)
{
float* vertices = _useTint ? (float*)trianglesTwoColor.verts : (float*)triangles.verts;
int stride = _useTint ? vs2 : vs1;
// Quadrangle has 4 vertex.
for (int ii = 0; ii < 4; ii ++)
{
_debugBuffer->writeFloat32(vertices[0]);
_debugBuffer->writeFloat32(vertices[1]);
vertices += stride;
}
debugSlotsLen+=8;
}
break;
}
case SP_ATTACHMENT_MESH:
{
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
attachmentVertices = getAttachmentVertices(attachment);
// Early exit if attachment is invisible
if (attachment->color.a == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (!_useTint)
{
triangles.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
memcpy(triangles.verts, attachmentVertices->_triangles->verts, vbSize);
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)triangles.verts, 0, vs1);
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, attachmentVertices->_triangles->indices, ibSize);
}
else
{
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++)
{
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)trianglesTwoColor.verts, 0, vs2);
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, attachmentVertices->_triangles->indices, ibSize);
}
color.r = attachment->color.r;
color.g = attachment->color.g;
color.b = attachment->color.b;
color.a = attachment->color.a;
break;
}
case SP_ATTACHMENT_CLIPPING:
{
spClippingAttachment* clip = (spClippingAttachment*)slot->attachment;
spSkeletonClipping_clipStart(_clipper, slot, clip);
continue;
}
default:
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
color.a = _skeleton->color.a * slot->color.a * color.a * _nodeColor.a * 255;
// skip rendering if the color of this attachment is 0
if (color.a == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
float multiplier = _premultipliedAlpha ? color.a : 255;
float red = _nodeColor.r * _skeleton->color.r * color.r * multiplier;
float green = _nodeColor.g * _skeleton->color.g * color.g * multiplier;
float blue = _nodeColor.b * _skeleton->color.b * color.b * multiplier;
color.r = red * slot->color.r;
color.g = green * slot->color.g;
color.b = blue * slot->color.b;
if (slot->darkColor)
{
darkColor.r = red * slot->darkColor->r;
darkColor.g = green * slot->darkColor->g;
darkColor.b = blue * slot->darkColor->b;
}
else
{
darkColor.r = 0;
darkColor.g = 0;
darkColor.b = 0;
}
darkColor.a = _premultipliedAlpha ? 255 : 0;
// One color tint logic
if (!_useTint)
{
// Cliping logic
if (spSkeletonClipping_isClipping(_clipper))
{
spSkeletonClipping_clipTriangles(_clipper, (float*)&triangles.verts[0].vertex, triangles.vertCount * vs1, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoord, vs1);
if (_clipper->clippedTriangles->size == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
triangles.vertCount = _clipper->clippedVertices->size >> 1;
vbSize = triangles.vertCount * sizeof(V2F_T2F_C4B);
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = (V2F_T2F_C4B*)vb.getCurBuffer();
triangles.indexCount = _clipper->clippedTriangles->size;
ibSize = triangles.indexCount * sizeof(unsigned short);
ib.checkSpace(ibSize, true);
triangles.indices = (unsigned short*)ib.getCurBuffer();
memcpy(triangles.indices, _clipper->clippedTriangles->items, sizeof(unsigned short) * _clipper->clippedTriangles->size);
float* verts = _clipper->clippedVertices->items;
float* uvs = _clipper->clippedUVs->items;
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv+=2)
{
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
// No cliping logic
}
else
{
for (int v = 0, vn = triangles.vertCount; v < vn; ++v)
{
V2F_T2F_C4B* vertex = triangles.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
}
}
}
// Two color tint logic
else
{
if (spSkeletonClipping_isClipping(_clipper))
{
spSkeletonClipping_clipTriangles(_clipper, (float*)&trianglesTwoColor.verts[0].vertex, trianglesTwoColor.vertCount * vs2, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoord, vs2);
if (_clipper->clippedTriangles->size == 0)
{
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
trianglesTwoColor.vertCount = _clipper->clippedVertices->size >> 1;
vbSize = trianglesTwoColor.vertCount * sizeof(V2F_T2F_C4B_C4B);
isFull |= vb.checkSpace(vbSize, true);
trianglesTwoColor.verts = (V2F_T2F_C4B_C4B*)vb.getCurBuffer();
trianglesTwoColor.indexCount = _clipper->clippedTriangles->size;
ibSize = trianglesTwoColor.indexCount * sizeof(unsigned short);
trianglesTwoColor.indices = (unsigned short*)ib.getCurBuffer();
memcpy(trianglesTwoColor.indices, _clipper->clippedTriangles->items, sizeof(unsigned short) * _clipper->clippedTriangles->size);
float* verts = _clipper->clippedVertices->items;
float* uvs = _clipper->clippedUVs->items;
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2)
{
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->vertex.x = verts[vv];
vertex->vertex.y = verts[vv + 1];
vertex->texCoord.u = uvs[vv];
vertex->texCoord.v = uvs[vv + 1];
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
else
{
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v)
{
V2F_T2F_C4B_C4B* vertex = trianglesTwoColor.verts + v;
vertex->color.r = (GLubyte)color.r;
vertex->color.g = (GLubyte)color.g;
vertex->color.b = (GLubyte)color.b;
vertex->color.a = (GLubyte)color.a;
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
}
texture = attachmentVertices->_texture;
curTextureIndex = texture->getRealTextureIndex();
// If texture or blendMode change or vertex is more than 65535, will change material.
if (preTextureIndex != curTextureIndex || preBlendMode != (int)slot->data->blendMode || isFull)
{
flush();
}
if (vbSize > 0 && ibSize > 0)
{
auto vertexOffset = vb.getCurPos() / sizeof(middleware::V2F_T2F_C4B);
if (_useTint)
{
vertexOffset = vb.getCurPos() / sizeof(middleware::V2F_T2F_C4B_C4B);
}
if (vertexOffset > 0)
{
unsigned short* ibBuffer = (unsigned short*)ib.getCurBuffer();
for (int ii = 0, nn = ibSize / sizeof(unsigned short); ii < nn; ii++)
{
ibBuffer[ii] += vertexOffset;
}
}
vb.move(vbSize);
ib.move(ibSize);
// Record this turn index segmentation count,it will store in material buffer in the end.
curISegLen += ibSize / sizeof(unsigned short);
}
spSkeletonClipping_clipEnd(_clipper, slot);
}
spSkeletonClipping_clipEnd2(_clipper);
if (_debugSlots)
{
_debugBuffer->writeFloat32(0, debugSlotsLen);
}
if (preISegWritePos != -1)
{
assembler->updateIARange(materialLen - 1, preISegWritePos, curISegLen);
}
if (_debugBones)
{
_debugBuffer->writeFloat32(_skeleton->bonesCount*4);
for (int i = 0, n = _skeleton->bonesCount; i < n; i++)
{
spBone *bone = _skeleton->bones[i];
float x = bone->data->length * bone->a + bone->worldX;
float y = bone->data->length * bone->c + bone->worldY;
_debugBuffer->writeFloat32(bone->worldX);
_debugBuffer->writeFloat32(bone->worldY);
_debugBuffer->writeFloat32(x);
_debugBuffer->writeFloat32(y);
}
}
if ((_debugSlots || _debugBones) && _debugBuffer->isOutRange())
{
_debugBuffer->writeFloat32(0, 0);
_debugBuffer->writeFloat32(sizeof(float), 0);
cocos2d::log("Spine debug data is too large,debug buffer has no space to put in it!!!!!!!!!!");
cocos2d::log("You can adjust MAX_DEBUG_BUFFER_SIZE in MiddlewareMacro");
}
}
AttachmentVertices* SpineRenderer::getAttachmentVertices (spRegionAttachment* attachment) const
{
return (AttachmentVertices*)attachment->rendererObject;
}
AttachmentVertices* SpineRenderer::getAttachmentVertices (spMeshAttachment* attachment) const
{
return (AttachmentVertices*)attachment->rendererObject;
}
void SpineRenderer::updateWorldTransform ()
{
spSkeleton_updateWorldTransform(_skeleton);
}
void SpineRenderer::setToSetupPose ()
{
spSkeleton_setToSetupPose(_skeleton);
}
void SpineRenderer::setBonesToSetupPose ()
{
spSkeleton_setBonesToSetupPose(_skeleton);
}
void SpineRenderer::setSlotsToSetupPose ()
{
spSkeleton_setSlotsToSetupPose(_skeleton);
}
spBone* SpineRenderer::findBone (const std::string& boneName) const
{
return spSkeleton_findBone(_skeleton, boneName.c_str());
}
spSlot* SpineRenderer::findSlot (const std::string& slotName) const
{
return spSkeleton_findSlot(_skeleton, slotName.c_str());
}
bool SpineRenderer::setSkin (const std::string& skinName)
{
return spSkeleton_setSkinByName(_skeleton, skinName.empty() ? 0 : skinName.c_str()) ? true : false;
}
bool SpineRenderer::setSkin (const char* skinName)
{
return spSkeleton_setSkinByName(_skeleton, skinName) ? true : false;
}
spAttachment* SpineRenderer::getAttachment (const std::string& slotName, const std::string& attachmentName) const
{
return spSkeleton_getAttachmentForSlotName(_skeleton, slotName.c_str(), attachmentName.c_str());
}
void SpineRenderer::setUseTint(bool enabled) {
_useTint = enabled;
}
void SpineRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex)
{
this->_startSlotIndex = startSlotIndex;
this->_endSlotIndex = endSlotIndex;
}
bool SpineRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName)
{
return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.empty() ? 0 : attachmentName.c_str()) ? true : false;
}
bool SpineRenderer::setAttachment (const std::string& slotName, const char* attachmentName)
{
return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName) ? true : false;
}
spSkeleton* SpineRenderer::getSkeleton () const
{
return _skeleton;
}
void SpineRenderer::setTimeScale (float scale)
{
_timeScale = scale;
}
float SpineRenderer::getTimeScale () const
{
return _timeScale;
}
void SpineRenderer::paused(bool value)
{
_paused = value;
}
void SpineRenderer::setColor (cocos2d::Color4B& color)
{
_nodeColor.r = color.r / 255.0f;
_nodeColor.g = color.g / 255.0f;
_nodeColor.b = color.b / 255.0f;
_nodeColor.a = color.a / 255.0f;
}
void SpineRenderer::setDebugBonesEnabled (bool enabled)
{
_debugBones = enabled;
}
void SpineRenderer::setDebugSlotsEnabled (bool enabled)
{
_debugSlots = enabled;
}
void SpineRenderer::setOpacityModifyRGB (bool value)
{
_premultipliedAlpha = value;
}
bool SpineRenderer::isOpacityModifyRGB () const
{
return _premultipliedAlpha;
}
@@ -0,0 +1,85 @@
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "VertexEffectDelegate.h"
namespace spine {
VertexEffectDelegate::VertexEffectDelegate () {
}
VertexEffectDelegate::~VertexEffectDelegate () {
clear();
}
void VertexEffectDelegate::clear() {
if (_interpolation) {
delete _interpolation;
_interpolation = nullptr;
}
if (_vertexEffect) {
delete _vertexEffect;
_vertexEffect = nullptr;
}
_effectType = "none";
}
JitterVertexEffect* VertexEffectDelegate::initJitter (float jitterX, float jitterY) {
clear();
_vertexEffect = new JitterVertexEffect(jitterX, jitterY);
_effectType = "jitter";
return (JitterVertexEffect*)_vertexEffect;
}
SwirlVertexEffect* VertexEffectDelegate::initSwirlWithPow(float radius, int power) {
clear();
_interpolation = new PowInterpolation(power);
_vertexEffect = new SwirlVertexEffect(radius, *_interpolation);
_effectType = "swirl";
return (SwirlVertexEffect*)_vertexEffect;
}
SwirlVertexEffect* VertexEffectDelegate::initSwirlWithPowOut(float radius, int power) {
clear();
_interpolation = new PowOutInterpolation(power);
_vertexEffect = new SwirlVertexEffect(radius, *_interpolation);
_effectType = "swirl";
return (SwirlVertexEffect*)_vertexEffect;
}
JitterVertexEffect* VertexEffectDelegate::getJitterVertexEffect () {
JitterVertexEffect* jitter = dynamic_cast<JitterVertexEffect*>(_vertexEffect);
return jitter;
}
SwirlVertexEffect* VertexEffectDelegate::getSwirlVertexEffect () {
SwirlVertexEffect* swirl = dynamic_cast<SwirlVertexEffect*>(_vertexEffect);
return swirl;
}
}
@@ -0,0 +1,59 @@
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
#include "spine/spine.h"
#include "base/CCRef.h"
#include "base/ccTypes.h"
#include <string>
namespace spine {
class VertexEffectDelegate: public cocos2d::Ref {
public:
VertexEffectDelegate ();
~VertexEffectDelegate ();
JitterVertexEffect* initJitter (float jitterX, float jitterY);
SwirlVertexEffect* initSwirlWithPow(float radius, int power);
SwirlVertexEffect* initSwirlWithPowOut(float radius, int power);
VertexEffect* getVertexEffect () {
return _vertexEffect;
}
JitterVertexEffect* getJitterVertexEffect ();
SwirlVertexEffect* getSwirlVertexEffect ();
const std::string& getEffectType() const {
return _effectType;
}
void clear();
private:
VertexEffect* _vertexEffect = nullptr;
Interpolation* _interpolation = nullptr;
std::string _effectType = "none";
};
}
@@ -1,107 +1,154 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "spine-creator-support/spine-cocos2dx.h"
#include "spine/extension.h"
#include "spine-creator-support/AttachmentVertices.h"
#include "middleware-adapter.h"
#include "base/CCData.h"
#include "platform/CCFileUtils.h"
namespace spine {
static CustomTextureLoader _customTextureLoader = nullptr;
void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader)
{
void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) {
_customTextureLoader = texLoader;
}
static SpineObjectDisposeCallback _spineObjectDisposeCallback = 0;
void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback) {
_spineObjectDisposeCallback = callback;
}
}
USING_NS_CC;
USING_NS_MW;
using namespace spine;
GLuint wrap (spAtlasWrap wrap)
{
return wrap == SP_ATLAS_CLAMPTOEDGE ? GL_CLAMP_TO_EDGE : GL_REPEAT;
static void deleteAttachmentVertices (void* vertices) {
delete (AttachmentVertices *) vertices;
}
GLuint filter (spAtlasFilter filter)
{
switch (filter)
{
case SP_ATLAS_UNKNOWN_FILTER:
static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
static void setAttachmentVertices(RegionAttachment* attachment) {
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(), 4, quadTriangles, 6);
V2F_T2F_C4B* vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0; i < 4; ++i, ii += 2) {
vertices[i].texCoord.u = attachment->getUVs()[ii];
vertices[i].texCoord.v = attachment->getUVs()[ii + 1];
}
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
}
static void setAttachmentVertices(MeshAttachment* attachment) {
AtlasRegion* region = (AtlasRegion*)attachment->getRendererObject();
AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->getRendererObject(),
attachment->getWorldVerticesLength() >> 1, attachment->getTriangles().buffer(), attachment->getTriangles().size());
V2F_T2F_C4B* vertices = attachmentVertices->_triangles->verts;
for (size_t i = 0, ii = 0, nn = attachment->getWorldVerticesLength(); ii < nn; ++i, ii += 2) {
vertices[i].texCoord.u = attachment->getUVs()[ii];
vertices[i].texCoord.v = attachment->getUVs()[ii + 1];
}
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
}
Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas* atlas): AtlasAttachmentLoader(atlas) {
}
Cocos2dAtlasAttachmentLoader::~Cocos2dAtlasAttachmentLoader() { }
void Cocos2dAtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
setAttachmentVertices((RegionAttachment*)attachment);
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
setAttachmentVertices((MeshAttachment*)attachment);
}
}
GLuint wrap (TextureWrap wrap) {
return wrap == TextureWrap_ClampToEdge ? GL_CLAMP_TO_EDGE : GL_REPEAT;
}
GLuint filter (TextureFilter filter) {
switch (filter) {
case TextureFilter_Unknown:
break;
case SP_ATLAS_NEAREST:
case TextureFilter_Nearest:
return GL_NEAREST;
case SP_ATLAS_LINEAR:
case TextureFilter_Linear:
return GL_LINEAR;
case SP_ATLAS_MIPMAP:
case TextureFilter_MipMap:
return GL_LINEAR_MIPMAP_LINEAR;
case SP_ATLAS_MIPMAP_NEAREST_NEAREST:
case TextureFilter_MipMapNearestNearest:
return GL_NEAREST_MIPMAP_NEAREST;
case SP_ATLAS_MIPMAP_LINEAR_NEAREST:
case TextureFilter_MipMapLinearNearest:
return GL_LINEAR_MIPMAP_NEAREST;
case SP_ATLAS_MIPMAP_NEAREST_LINEAR:
case TextureFilter_MipMapNearestLinear:
return GL_NEAREST_MIPMAP_LINEAR;
case SP_ATLAS_MIPMAP_LINEAR_LINEAR:
case TextureFilter_MipMapLinearLinear:
return GL_LINEAR_MIPMAP_LINEAR;
}
return GL_LINEAR;
}
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path)
{
Cocos2dTextureLoader::Cocos2dTextureLoader() : TextureLoader() { }
Cocos2dTextureLoader::~Cocos2dTextureLoader() { }
void Cocos2dTextureLoader::load(AtlasPage& page, const spine::String& path) {
Texture2D* texture = nullptr;
if (spine::_customTextureLoader)
{
texture = spine::_customTextureLoader(path);
texture = spine::_customTextureLoader(path.buffer());
}
CCASSERT(texture != nullptr, "Invalid image");
texture->retain();
Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)};
texture->setTexParameters(textureParams);
self->rendererObject = texture;
self->width = texture->getPixelsWide();
self->height = texture->getPixelsHigh();
page.setRendererObject(texture);
page.width = texture->getPixelsWide();
page.height = texture->getPixelsHigh();
}
void _spAtlasPage_disposeTexture (spAtlasPage* self)
{
((Texture2D*)self->rendererObject)->release();
void Cocos2dTextureLoader::unload(void* texture) {
((Texture2D*)texture)->release();
}
char* _spUtil_readFile (const char* path, int* length)
{
Cocos2dExtension::Cocos2dExtension() : DefaultSpineExtension() { }
Cocos2dExtension::~Cocos2dExtension() { }
char *Cocos2dExtension::_readFile(const spine::String &path, int *length) {
*length = 0;
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path));
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path.buffer()));
if (data.isNull()) return 0;
char *ret = (char*)malloc(sizeof(unsigned char) * data.getSize());
@@ -109,3 +156,12 @@ char* _spUtil_readFile (const char* path, int* length)
*length = (int)data.getSize();
return ret;
}
SpineExtension *spine::getDefaultExtension () {
return new Cocos2dExtension();
}
void Cocos2dExtension::_free(void *mem, const char *file, int line) {
_spineObjectDisposeCallback(mem);
DefaultSpineExtension::_free(mem, file, line);
}
@@ -1,43 +1,73 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#pragma once
#include "spine/spine.h"
#include "spine-creator-support/CreatorAttachmentLoader.h"
#include "spine-creator-support/SpineRenderer.h"
#include "spine-creator-support/SpineAnimation.h"
#include "spine-creator-support/SkeletonRenderer.h"
#include "spine-creator-support/SkeletonAnimation.h"
#include "middleware-adapter.h"
namespace spine {
typedef cocos2d::middleware::Texture2D* (*CustomTextureLoader)(const char* path);
// set custom texture loader for _spAtlasPage_createTexture
void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader);
class Cocos2dAtlasAttachmentLoader: public AtlasAttachmentLoader {
public:
Cocos2dAtlasAttachmentLoader(Atlas* atlas);
virtual ~Cocos2dAtlasAttachmentLoader();
virtual void configureAttachment(Attachment* attachment);
};
class Cocos2dTextureLoader: public TextureLoader {
public:
Cocos2dTextureLoader();
virtual ~Cocos2dTextureLoader();
virtual void load(AtlasPage& page, const String& path);
virtual void unload(void* texture);
};
class Cocos2dExtension: public DefaultSpineExtension {
public:
Cocos2dExtension();
virtual ~Cocos2dExtension();
virtual void _free(void *mem, const char *file, int line);
protected:
virtual char *_readFile(const String &path, int *length);
};
typedef void (*SpineObjectDisposeCallback)(void*);
void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,141 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Animation.h>
#include <spine/Timeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/ContainerUtil.h>
using namespace spine;
Animation::Animation(const String &name, Vector<Timeline *> &timelines, float duration) :
_timelines(timelines),
_duration(duration),
_name(name) {
assert(_name.length() > 0);
}
Animation::~Animation() {
ContainerUtil::cleanUpVectorOfPointers(_timelines);
}
void Animation::apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
if (loop && _duration != 0) {
time = MathUtil::fmod(time, _duration);
if (lastTime > 0) {
lastTime = MathUtil::fmod(lastTime, _duration);
}
}
for (size_t i = 0, n = _timelines.size(); i < n; ++i) {
_timelines[i]->apply(skeleton, lastTime, time, pEvents, alpha, blend, direction);
}
}
const String &Animation::getName() {
return _name;
}
Vector<Timeline *> &Animation::getTimelines() {
return _timelines;
}
float Animation::getDuration() {
return _duration;
}
void Animation::setDuration(float inValue) {
_duration = inValue;
}
int Animation::binarySearch(Vector<float> &values, float target, int step) {
int low = 0;
int size = (int)values.size();
int high = size / step - 2;
if (high == 0) {
return step;
}
int current = (int) (static_cast<uint32_t>(high) >> 1);
while (true) {
if (values[(current + 1) * step] <= target) {
low = current + 1;
} else {
high = current;
}
if (low == high) {
return (low + 1) * step;
}
current = (int) (static_cast<uint32_t>(low + high) >> 1);
}
}
int Animation::binarySearch(Vector<float> &values, float target) {
int low = 0;
int size = (int)values.size();
int high = size - 2;
if (high == 0) {
return 1;
}
int current = (int) (static_cast<uint32_t>(high) >> 1);
while (true) {
if (values[(current + 1)] <= target) {
low = current + 1;
} else {
high = current;
}
if (low == high) {
return (low + 1);
}
current = (int) (static_cast<uint32_t>(low + high) >> 1);
}
}
int Animation::linearSearch(Vector<float> &values, float target, int step) {
for (int i = 0, last = (int)values.size() - step; i <= last; i += step) {
if (values[i] > target) {
return i;
}
}
return -1;
}
+119 -588
View File
@@ -1,588 +1,119 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ANIMATION_H_
#define SPINE_ANIMATION_H_
#include <spine/dll.h>
#include <spine/Event.h>
#include <spine/Attachment.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spTimeline spTimeline;
struct spSkeleton;
typedef struct spAnimation {
const char* const name;
float duration;
int timelinesCount;
spTimeline** timelines;
#ifdef __cplusplus
spAnimation() :
name(0),
duration(0),
timelinesCount(0),
timelines(0) {
}
#endif
} spAnimation;
typedef enum {
SP_MIX_POSE_SETUP,
SP_MIX_POSE_CURRENT,
SP_MIX_POSE_CURRENT_LAYERED
} spMixPose;
typedef enum {
SP_MIX_DIRECTION_IN,
SP_MIX_DIRECTION_OUT
} spMixDirection;
SP_API spAnimation* spAnimation_create (const char* name, int timelinesCount);
SP_API void spAnimation_dispose (spAnimation* self);
/** Poses the skeleton at the specified time for this animation.
* @param lastTime The last time the animation was applied.
* @param events Any triggered events are added. May be null.*/
SP_API void spAnimation_apply (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop,
spEvent** events, int* eventsCount, float alpha, spMixPose pose, spMixDirection direction);
#ifdef SPINE_SHORT_NAMES
typedef spAnimation Animation;
#define Animation_create(...) spAnimation_create(__VA_ARGS__)
#define Animation_dispose(...) spAnimation_dispose(__VA_ARGS__)
#define Animation_apply(...) spAnimation_apply(__VA_ARGS__)
#endif
/**/
typedef enum {
SP_TIMELINE_ROTATE,
SP_TIMELINE_TRANSLATE,
SP_TIMELINE_SCALE,
SP_TIMELINE_SHEAR,
SP_TIMELINE_ATTACHMENT,
SP_TIMELINE_COLOR,
SP_TIMELINE_DEFORM,
SP_TIMELINE_EVENT,
SP_TIMELINE_DRAWORDER,
SP_TIMELINE_IKCONSTRAINT,
SP_TIMELINE_TRANSFORMCONSTRAINT,
SP_TIMELINE_PATHCONSTRAINTPOSITION,
SP_TIMELINE_PATHCONSTRAINTSPACING,
SP_TIMELINE_PATHCONSTRAINTMIX,
SP_TIMELINE_TWOCOLOR
} spTimelineType;
struct spTimeline {
const spTimelineType type;
const void* const vtable;
#ifdef __cplusplus
spTimeline() :
type(SP_TIMELINE_SCALE),
vtable(0) {
}
#endif
};
SP_API void spTimeline_dispose (spTimeline* self);
SP_API void spTimeline_apply (const spTimeline* self, struct spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
int* eventsCount, float alpha, spMixPose pose, spMixDirection direction);
SP_API int spTimeline_getPropertyId (const spTimeline* self);
#ifdef SPINE_SHORT_NAMES
typedef spTimeline Timeline;
#define TIMELINE_SCALE SP_TIMELINE_SCALE
#define TIMELINE_ROTATE SP_TIMELINE_ROTATE
#define TIMELINE_TRANSLATE SP_TIMELINE_TRANSLATE
#define TIMELINE_COLOR SP_TIMELINE_COLOR
#define TIMELINE_ATTACHMENT SP_TIMELINE_ATTACHMENT
#define TIMELINE_EVENT SP_TIMELINE_EVENT
#define TIMELINE_DRAWORDER SP_TIMELINE_DRAWORDER
#define Timeline_dispose(...) spTimeline_dispose(__VA_ARGS__)
#define Timeline_apply(...) spTimeline_apply(__VA_ARGS__)
#endif
/**/
typedef struct spCurveTimeline {
spTimeline super;
float* curves; /* type, x, y, ... */
#ifdef __cplusplus
spCurveTimeline() :
super(),
curves(0) {
}
#endif
} spCurveTimeline;
SP_API void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex);
SP_API void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex);
/* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
* the difference between the keyframe's values. */
SP_API void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2);
SP_API float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent);
#ifdef SPINE_SHORT_NAMES
typedef spCurveTimeline CurveTimeline;
#define CurveTimeline_setLinear(...) spCurveTimeline_setLinear(__VA_ARGS__)
#define CurveTimeline_setStepped(...) spCurveTimeline_setStepped(__VA_ARGS__)
#define CurveTimeline_setCurve(...) spCurveTimeline_setCurve(__VA_ARGS__)
#define CurveTimeline_getCurvePercent(...) spCurveTimeline_getCurvePercent(__VA_ARGS__)
#endif
/**/
typedef struct spBaseTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */
int boneIndex;
#ifdef __cplusplus
spBaseTimeline() :
super(),
framesCount(0),
frames(0),
boneIndex(0) {
}
#endif
} spBaseTimeline;
/**/
static const int ROTATE_PREV_TIME = -2, ROTATE_PREV_ROTATION = -1;
static const int ROTATE_ROTATION = 1;
static const int ROTATE_ENTRIES = 2;
typedef struct spBaseTimeline spRotateTimeline;
SP_API spRotateTimeline* spRotateTimeline_create (int framesCount);
SP_API void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle);
#ifdef SPINE_SHORT_NAMES
typedef spRotateTimeline RotateTimeline;
#define RotateTimeline_create(...) spRotateTimeline_create(__VA_ARGS__)
#define RotateTimeline_setFrame(...) spRotateTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int TRANSLATE_ENTRIES = 3;
typedef struct spBaseTimeline spTranslateTimeline;
SP_API spTranslateTimeline* spTranslateTimeline_create (int framesCount);
SP_API void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y);
#ifdef SPINE_SHORT_NAMES
typedef spTranslateTimeline TranslateTimeline;
#define TranslateTimeline_create(...) spTranslateTimeline_create(__VA_ARGS__)
#define TranslateTimeline_setFrame(...) spTranslateTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spBaseTimeline spScaleTimeline;
SP_API spScaleTimeline* spScaleTimeline_create (int framesCount);
SP_API void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y);
#ifdef SPINE_SHORT_NAMES
typedef spScaleTimeline ScaleTimeline;
#define ScaleTimeline_create(...) spScaleTimeline_create(__VA_ARGS__)
#define ScaleTimeline_setFrame(...) spScaleTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spBaseTimeline spShearTimeline;
SP_API spShearTimeline* spShearTimeline_create (int framesCount);
SP_API void spShearTimeline_setFrame (spShearTimeline* self, int frameIndex, float time, float x, float y);
#ifdef SPINE_SHORT_NAMES
typedef spShearTimeline ShearTimeline;
#define ShearTimeline_create(...) spShearTimeline_create(__VA_ARGS__)
#define ShearTimeline_setFrame(...) spShearTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int COLOR_ENTRIES = 5;
typedef struct spColorTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, r, g, b, a, ... */
int slotIndex;
#ifdef __cplusplus
spColorTimeline() :
super(),
framesCount(0),
frames(0),
slotIndex(0) {
}
#endif
} spColorTimeline;
SP_API spColorTimeline* spColorTimeline_create (int framesCount);
SP_API void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a);
#ifdef SPINE_SHORT_NAMES
typedef spColorTimeline ColorTimeline;
#define ColorTimeline_create(...) spColorTimeline_create(__VA_ARGS__)
#define ColorTimeline_setFrame(...) spColorTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int TWOCOLOR_ENTRIES = 8;
typedef struct spTwoColorTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, r, g, b, a, ... */
int slotIndex;
#ifdef __cplusplus
spTwoColorTimeline() :
super(),
framesCount(0),
frames(0),
slotIndex(0) {
}
#endif
} spTwoColorTimeline;
SP_API spTwoColorTimeline* spTwoColorTimeline_create (int framesCount);
SP_API void spTwoColorTimeline_setFrame (spTwoColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a, float r2, float g2, float b2);
#ifdef SPINE_SHORT_NAMES
typedef spTwoColorTimeline TwoColorTimeline;
#define TwoColorTimeline_create(...) spTwoColorTimeline_create(__VA_ARGS__)
#define TwoColorTimeline_setFrame(...) spTwoColorTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spAttachmentTimeline {
spTimeline super;
int const framesCount;
float* const frames; /* time, ... */
int slotIndex;
const char** const attachmentNames;
#ifdef __cplusplus
spAttachmentTimeline() :
super(),
framesCount(0),
frames(0),
slotIndex(0),
attachmentNames(0) {
}
#endif
} spAttachmentTimeline;
SP_API spAttachmentTimeline* spAttachmentTimeline_create (int framesCount);
/* @param attachmentName May be 0. */
SP_API void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName);
#ifdef SPINE_SHORT_NAMES
typedef spAttachmentTimeline AttachmentTimeline;
#define AttachmentTimeline_create(...) spAttachmentTimeline_create(__VA_ARGS__)
#define AttachmentTimeline_setFrame(...) spAttachmentTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spEventTimeline {
spTimeline super;
int const framesCount;
float* const frames; /* time, ... */
spEvent** const events;
#ifdef __cplusplus
spEventTimeline() :
super(),
framesCount(0),
frames(0),
events(0) {
}
#endif
} spEventTimeline;
SP_API spEventTimeline* spEventTimeline_create (int framesCount);
SP_API void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* event);
#ifdef SPINE_SHORT_NAMES
typedef spEventTimeline EventTimeline;
#define EventTimeline_create(...) spEventTimeline_create(__VA_ARGS__)
#define EventTimeline_setFrame(...) spEventTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spDrawOrderTimeline {
spTimeline super;
int const framesCount;
float* const frames; /* time, ... */
const int** const drawOrders;
int const slotsCount;
#ifdef __cplusplus
spDrawOrderTimeline() :
super(),
framesCount(0),
frames(0),
drawOrders(0),
slotsCount(0) {
}
#endif
} spDrawOrderTimeline;
SP_API spDrawOrderTimeline* spDrawOrderTimeline_create (int framesCount, int slotsCount);
SP_API void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder);
#ifdef SPINE_SHORT_NAMES
typedef spDrawOrderTimeline DrawOrderTimeline;
#define DrawOrderTimeline_create(...) spDrawOrderTimeline_create(__VA_ARGS__)
#define DrawOrderTimeline_setFrame(...) spDrawOrderTimeline_setFrame(__VA_ARGS__)
#endif
/**/
typedef struct spDeformTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, ... */
int const frameVerticesCount;
const float** const frameVertices;
int slotIndex;
spAttachment* attachment;
#ifdef __cplusplus
spDeformTimeline() :
super(),
framesCount(0),
frames(0),
frameVerticesCount(0),
frameVertices(0),
slotIndex(0) {
}
#endif
} spDeformTimeline;
SP_API spDeformTimeline* spDeformTimeline_create (int framesCount, int frameVerticesCount);
SP_API void spDeformTimeline_setFrame (spDeformTimeline* self, int frameIndex, float time, float* vertices);
#ifdef SPINE_SHORT_NAMES
typedef spDeformTimeline DeformTimeline;
#define DeformTimeline_create(...) spDeformTimeline_create(__VA_ARGS__)
#define DeformTimeline_setFrame(...) spDeformTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int IKCONSTRAINT_ENTRIES = 3;
typedef struct spIkConstraintTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, mix, bendDirection, ... */
int ikConstraintIndex;
#ifdef __cplusplus
spIkConstraintTimeline() :
super(),
framesCount(0),
frames(0),
ikConstraintIndex(0) {
}
#endif
} spIkConstraintTimeline;
SP_API spIkConstraintTimeline* spIkConstraintTimeline_create (int framesCount);
SP_API void spIkConstraintTimeline_setFrame (spIkConstraintTimeline* self, int frameIndex, float time, float mix, int bendDirection);
#ifdef SPINE_SHORT_NAMES
typedef spIkConstraintTimeline IkConstraintTimeline;
#define IkConstraintTimeline_create(...) spIkConstraintTimeline_create(__VA_ARGS__)
#define IkConstraintTimeline_setFrame(...) spIkConstraintTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int TRANSFORMCONSTRAINT_ENTRIES = 5;
typedef struct spTransformConstraintTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */
int transformConstraintIndex;
#ifdef __cplusplus
spTransformConstraintTimeline() :
super(),
framesCount(0),
frames(0),
transformConstraintIndex(0) {
}
#endif
} spTransformConstraintTimeline;
SP_API spTransformConstraintTimeline* spTransformConstraintTimeline_create (int framesCount);
SP_API void spTransformConstraintTimeline_setFrame (spTransformConstraintTimeline* self, int frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix);
#ifdef SPINE_SHORT_NAMES
typedef spTransformConstraintTimeline TransformConstraintTimeline;
#define TransformConstraintTimeline_create(...) spTransformConstraintTimeline_create(__VA_ARGS__)
#define TransformConstraintTimeline_setFrame(...) spTransformConstraintTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int PATHCONSTRAINTPOSITION_ENTRIES = 2;
typedef struct spPathConstraintPositionTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */
int pathConstraintIndex;
#ifdef __cplusplus
spPathConstraintPositionTimeline() :
super(),
framesCount(0),
frames(0),
pathConstraintIndex(0) {
}
#endif
} spPathConstraintPositionTimeline;
SP_API spPathConstraintPositionTimeline* spPathConstraintPositionTimeline_create (int framesCount);
SP_API void spPathConstraintPositionTimeline_setFrame (spPathConstraintPositionTimeline* self, int frameIndex, float time, float value);
#ifdef SPINE_SHORT_NAMES
typedef spPathConstraintPositionTimeline PathConstraintPositionTimeline;
#define PathConstraintPositionTimeline_create(...) spPathConstraintPositionTimeline_create(__VA_ARGS__)
#define PathConstraintPositionTimeline_setFrame(...) spPathConstraintPositionTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int PATHCONSTRAINTSPACING_ENTRIES = 2;
typedef struct spPathConstraintSpacingTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */
int pathConstraintIndex;
#ifdef __cplusplus
spPathConstraintSpacingTimeline() :
super(),
framesCount(0),
frames(0),
pathConstraintIndex(0) {
}
#endif
} spPathConstraintSpacingTimeline;
SP_API spPathConstraintSpacingTimeline* spPathConstraintSpacingTimeline_create (int framesCount);
SP_API void spPathConstraintSpacingTimeline_setFrame (spPathConstraintSpacingTimeline* self, int frameIndex, float time, float value);
#ifdef SPINE_SHORT_NAMES
typedef spPathConstraintSpacingTimeline PathConstraintSpacingTimeline;
#define PathConstraintSpacingTimeline_create(...) spPathConstraintSpacingTimeline_create(__VA_ARGS__)
#define PathConstraintSpacingTimeline_setFrame(...) spPathConstraintSpacingTimeline_setFrame(__VA_ARGS__)
#endif
/**/
static const int PATHCONSTRAINTMIX_ENTRIES = 3;
typedef struct spPathConstraintMixTimeline {
spCurveTimeline super;
int const framesCount;
float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */
int pathConstraintIndex;
#ifdef __cplusplus
spPathConstraintMixTimeline() :
super(),
framesCount(0),
frames(0),
pathConstraintIndex(0) {
}
#endif
} spPathConstraintMixTimeline;
SP_API spPathConstraintMixTimeline* spPathConstraintMixTimeline_create (int framesCount);
SP_API void spPathConstraintMixTimeline_setFrame (spPathConstraintMixTimeline* self, int frameIndex, float time, float rotateMix, float translateMix);
#ifdef SPINE_SHORT_NAMES
typedef spPathConstraintMixTimeline PathConstraintMixTimeline;
#define PathConstraintMixTimeline_create(...) spPathConstraintMixTimeline_create(__VA_ARGS__)
#define PathConstraintMixTimeline_setFrame(...) spPathConstraintMixTimeline_setFrame(__VA_ARGS__)
#endif
/**/
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ANIMATION_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Animation_h
#define Spine_Animation_h
#include <spine/Vector.h>
#include <spine/MixBlend.h>
#include <spine/MixDirection.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class Timeline;
class Skeleton;
class Event;
class SP_API Animation : public SpineObject {
friend class AnimationState;
friend class TrackEntry;
friend class AnimationStateData;
friend class AttachmentTimeline;
friend class ColorTimeline;
friend class DeformTimeline;
friend class DrawOrderTimeline;
friend class EventTimeline;
friend class IkConstraintTimeline;
friend class PathConstraintMixTimeline;
friend class PathConstraintPositionTimeline;
friend class PathConstraintSpacingTimeline;
friend class RotateTimeline;
friend class ScaleTimeline;
friend class ShearTimeline;
friend class TransformConstraintTimeline;
friend class TranslateTimeline;
friend class TwoColorTimeline;
public:
Animation(const String &name, Vector<Timeline *> &timelines, float duration);
~Animation();
/// Applies all the animation's timelines to the specified skeleton.
/// See also Timeline::apply(Skeleton&, float, float, Vector, float, MixPose, MixDirection)
void apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction);
const String &getName();
Vector<Timeline *> &getTimelines();
float getDuration();
void setDuration(float inValue);
private:
Vector<Timeline *> _timelines;
float _duration;
String _name;
/// @param target After the first and before the last entry.
static int binarySearch(Vector<float> &values, float target, int step);
/// @param target After the first and before the last entry.
static int binarySearch(Vector<float> &values, float target);
static int linearSearch(Vector<float> &values, float target, int step);
};
}
#endif /* Spine_Animation_h */
@@ -1,963 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AnimationState.h>
#include <spine/extension.h>
#include <limits.h>
#define SUBSEQUENT 0
#define FIRST 1
#define DIP 2
#define DIP_MIX 3
_SP_ARRAY_IMPLEMENT_TYPE(spTrackEntryArray, spTrackEntry*)
static spAnimation* SP_EMPTY_ANIMATION = 0;
static TrackEntryDisposeCallback _trackEntryDisposeCallback = 0;
void spAnimationState_disposeStatics () {
if (SP_EMPTY_ANIMATION) spAnimation_dispose(SP_EMPTY_ANIMATION);
SP_EMPTY_ANIMATION = 0;
}
/* Forward declaration of some "private" functions so we can keep
the same function order in C as we have method order in Java */
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry);
void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry);
int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* entry, float delta);
float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* entry, spSkeleton* skeleton, spMixPose currentPose);
void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time, float alpha, spMixPose pose, float* timelinesRotation, int i, int /*boolean*/ firstFrame);
void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry, float animationTime);
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* current, int /*boolean*/ interrupt);
spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index);
spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackIndex, spAnimation* animation, int /*boolean*/ loop, spTrackEntry* last);
void _spAnimationState_disposeNext (spAnimationState* self, spTrackEntry* entry);
void _spAnimationState_animationsChanged (spAnimationState* self);
float* _spAnimationState_resizeTimelinesRotation(spTrackEntry* entry, int newSize);
int* _spAnimationState_resizeTimelinesFirst(spTrackEntry* entry, int newSize);
void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity);
int _spAnimationState_addPropertyID(spAnimationState* self, int id);
spTrackEntry* _spTrackEntry_setTimelineData(spTrackEntry* self, spTrackEntry* to, spTrackEntryArray* mixingToArray, spAnimationState* state);
_spEventQueue* _spEventQueue_create (_spAnimationState* state) {
_spEventQueue *self = CALLOC(_spEventQueue, 1);
self->state = state;
self->objectsCount = 0;
self->objectsCapacity = 16;
self->objects = CALLOC(_spEventQueueItem, self->objectsCapacity);
self->drainDisabled = 0;
return self;
}
void _spEventQueue_free (_spEventQueue* self) {
FREE(self->objects);
FREE(self);
}
void _spEventQueue_ensureCapacity (_spEventQueue* self, int newElements) {
if (self->objectsCount + newElements > self->objectsCapacity) {
_spEventQueueItem* newObjects;
self->objectsCapacity <<= 1;
newObjects = CALLOC(_spEventQueueItem, self->objectsCapacity);
memcpy(newObjects, self->objects, sizeof(_spEventQueueItem) * self->objectsCount);
FREE(self->objects);
self->objects = newObjects;
}
}
void _spEventQueue_addType (_spEventQueue* self, spEventType type) {
_spEventQueue_ensureCapacity(self, 1);
self->objects[self->objectsCount++].type = type;
}
void _spEventQueue_addEntry (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_ensureCapacity(self, 1);
self->objects[self->objectsCount++].entry = entry;
}
void _spEventQueue_addEvent (_spEventQueue* self, spEvent* event) {
_spEventQueue_ensureCapacity(self, 1);
self->objects[self->objectsCount++].event = event;
}
void _spEventQueue_start (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_addType(self, SP_ANIMATION_START);
_spEventQueue_addEntry(self, entry);
self->state->animationsChanged = 1;
}
void _spEventQueue_interrupt (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_addType(self, SP_ANIMATION_INTERRUPT);
_spEventQueue_addEntry(self, entry);
}
void _spEventQueue_end (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_addType(self, SP_ANIMATION_END);
_spEventQueue_addEntry(self, entry);
self->state->animationsChanged = 1;
}
void _spEventQueue_dispose (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_addType(self, SP_ANIMATION_DISPOSE);
_spEventQueue_addEntry(self, entry);
}
void _spEventQueue_complete (_spEventQueue* self, spTrackEntry* entry) {
_spEventQueue_addType(self, SP_ANIMATION_COMPLETE);
_spEventQueue_addEntry(self, entry);
}
void _spEventQueue_event (_spEventQueue* self, spTrackEntry* entry, spEvent* event) {
_spEventQueue_addType(self, SP_ANIMATION_EVENT);
_spEventQueue_addEntry(self, entry);
_spEventQueue_addEvent(self, event);
}
void _spEventQueue_clear (_spEventQueue* self) {
self->objectsCount = 0;
}
void _spEventQueue_drain (_spEventQueue* self) {
int i;
if (self->drainDisabled) return;
self->drainDisabled = 1;
for (i = 0; i < self->objectsCount; i += 2) {
spEventType type = (spEventType)self->objects[i].type;
spTrackEntry* entry = self->objects[i+1].entry;
spEvent* event;
switch (type) {
case SP_ANIMATION_START:
case SP_ANIMATION_INTERRUPT:
case SP_ANIMATION_COMPLETE:
if (entry->listener) entry->listener(SUPER(self->state), type, entry, 0);
if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, 0);
break;
case SP_ANIMATION_END:
if (entry->listener) entry->listener(SUPER(self->state), type, entry, 0);
if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, 0);
/* Fall through. */
case SP_ANIMATION_DISPOSE:
if (entry->listener) entry->listener(SUPER(self->state), SP_ANIMATION_DISPOSE, entry, 0);
if (self->state->super.listener) self->state->super.listener(SUPER(self->state), SP_ANIMATION_DISPOSE, entry, 0);
_spAnimationState_disposeTrackEntry(entry);
break;
case SP_ANIMATION_EVENT:
event = self->objects[i+2].event;
if (entry->listener) entry->listener(SUPER(self->state), type, entry, event);
if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, event);
i++;
break;
}
}
_spEventQueue_clear(self);
self->drainDisabled = 0;
}
/* These two functions are needed in the UE4 runtime, see #1037 */
void _spAnimationState_enableQueue(spAnimationState* self) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
internal->queue->drainDisabled = 0;
}
void _spAnimationState_disableQueue(spAnimationState* self) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
internal->queue->drainDisabled = 1;
}
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) {
if (_trackEntryDisposeCallback)
{
_trackEntryDisposeCallback(entry);
}
spIntArray_dispose(entry->timelineData);
spTrackEntryArray_dispose(entry->timelineDipMix);
FREE(entry->timelinesRotation);
FREE(entry);
}
void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry) {
while (entry) {
spTrackEntry* next = entry->next;
spTrackEntry* from = entry->mixingFrom;
while (from) {
spTrackEntry* nextFrom = from->mixingFrom;
if (entry->listener) entry->listener(state, SP_ANIMATION_DISPOSE, from, 0);
if (state->listener) state->listener(state, SP_ANIMATION_DISPOSE, from, 0);
_spAnimationState_disposeTrackEntry(from);
from = nextFrom;
}
if (entry->listener) entry->listener(state, SP_ANIMATION_DISPOSE, entry, 0);
if (state->listener) state->listener(state, SP_ANIMATION_DISPOSE, entry, 0);
_spAnimationState_disposeTrackEntry(entry);
entry = next;
}
}
void spTrackEntry_setDisposeCallback(TrackEntryDisposeCallback cb)
{
_trackEntryDisposeCallback = cb;
}
spAnimationState* spAnimationState_create (spAnimationStateData* data) {
_spAnimationState* internal;
spAnimationState* self;
if (!SP_EMPTY_ANIMATION) {
SP_EMPTY_ANIMATION = (spAnimation*)1; /* dirty trick so we can recursively call spAnimation_create */
SP_EMPTY_ANIMATION = spAnimation_create("<empty>", 0);
}
internal = NEW(_spAnimationState);
self = SUPER(internal);
CONST_CAST(spAnimationStateData*, self->data) = data;
self->timeScale = 1;
internal->queue = _spEventQueue_create(internal);
internal->events = CALLOC(spEvent*, 128);
internal->propertyIDs = CALLOC(int, 128);
internal->propertyIDsCapacity = 128;
self->mixingTo = spTrackEntryArray_create(16);
return self;
}
void spAnimationState_dispose (spAnimationState* self) {
int i;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
for (i = 0; i < self->tracksCount; i++)
_spAnimationState_disposeTrackEntries(self, self->tracks[i]);
FREE(self->tracks);
_spEventQueue_free(internal->queue);
FREE(internal->events);
FREE(internal->propertyIDs);
spTrackEntryArray_dispose(self->mixingTo);
FREE(internal);
}
void spAnimationState_update (spAnimationState* self, float delta) {
int i, n;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
delta *= self->timeScale;
for (i = 0, n = self->tracksCount; i < n; i++) {
float currentDelta;
spTrackEntry* current = self->tracks[i];
spTrackEntry* next;
if (!current) continue;
current->animationLast = current->nextAnimationLast;
current->trackLast = current->nextTrackLast;
currentDelta = delta * current->timeScale;
if (current->delay > 0) {
current->delay -= currentDelta;
if (current->delay > 0) continue;
currentDelta = -current->delay;
current->delay = 0;
}
next = current->next;
if (next) {
/* When the next entry's delay is passed, change to the next entry, preserving leftover time. */
float nextTime = current->trackLast - next->delay;
if (nextTime >= 0) {
next->delay = 0;
next->trackTime = nextTime + delta * next->timeScale;
current->trackTime += currentDelta;
_spAnimationState_setCurrent(self, i, next, 1);
while (next->mixingFrom) {
next->mixTime += currentDelta;
next = next->mixingFrom;
}
continue;
}
} else {
/* Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. */
if (current->trackLast >= current->trackEnd && current->mixingFrom == 0) {
self->tracks[i] = 0;
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
continue;
}
}
if (current->mixingFrom != 0 && _spAnimationState_updateMixingFrom(self, current, delta)) {
/* End mixing from entries once all have completed. */
spTrackEntry* from = current->mixingFrom;
current->mixingFrom = 0;
while (from != 0) {
_spEventQueue_end(internal->queue, from);
from = from->mixingFrom;
}
}
current->trackTime += currentDelta;
}
_spEventQueue_drain(internal->queue);
}
int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* to, float delta) {
spTrackEntry* from = to->mixingFrom;
int finished;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
if (!from) return -1;
finished = _spAnimationState_updateMixingFrom(self, from, delta);
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
/* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */
if (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) {
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
if (from->totalAlpha == 0 || to->mixDuration == 0) {
to->mixingFrom = from->mixingFrom;
to->interruptAlpha = from->interruptAlpha;
_spEventQueue_end(internal->queue, from);
}
return finished;
}
from->trackTime += delta * from->timeScale;
to->mixTime += delta * to->timeScale;
return 0;
}
int spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
spTrackEntry* current;
int i, ii, n;
float animationLast, animationTime;
int timelineCount;
spTimeline** timelines;
int /*boolean*/ firstFrame;
float* timelinesRotation;
spTimeline* timeline;
int applied = 0;
spMixPose currentPose;
spMixPose pose;
if (internal->animationsChanged) _spAnimationState_animationsChanged(self);
for (i = 0, n = self->tracksCount; i < n; i++) {
float mix;
current = self->tracks[i];
if (!current || current->delay > 0) continue;
applied = -1;
currentPose = i == 0 ? SP_MIX_POSE_CURRENT : SP_MIX_POSE_CURRENT_LAYERED;
/* Apply mixing from entries first. */
mix = current->alpha;
if (current->mixingFrom)
mix *= _spAnimationState_applyMixingFrom(self, current, skeleton, currentPose);
else if (current->trackTime >= current->trackEnd && current->next == 0)
mix = 0;
/* Apply current entry. */
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
timelineCount = current->animation->timelinesCount;
timelines = current->animation->timelines;
if (mix == 1) {
for (ii = 0; ii < timelineCount; ii++)
spTimeline_apply(timelines[ii], skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, 1, SP_MIX_POSE_SETUP, SP_MIX_DIRECTION_IN);
} else {
spIntArray* timelineData = current->timelineData;
firstFrame = current->timelinesRotationCount == 0;
if (firstFrame) _spAnimationState_resizeTimelinesRotation(current, timelineCount << 1);
timelinesRotation = current->timelinesRotation;
for (ii = 0; ii < timelineCount; ii++) {
timeline = timelines[ii];
pose = timelineData->items[ii] >= FIRST ? SP_MIX_POSE_SETUP : currentPose;
if (timeline->type == SP_TIMELINE_ROTATE)
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
else
spTimeline_apply(timeline, skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, mix, pose, SP_MIX_DIRECTION_IN);
}
}
_spAnimationState_queueEvents(self, current, animationTime);
internal->eventsCount = 0;
current->nextAnimationLast = animationTime;
current->nextTrackLast = current->trackTime;
}
_spEventQueue_drain(internal->queue);
return applied;
}
float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* to, spSkeleton* skeleton, spMixPose currentPose) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
float mix;
spEvent** events;
int /*boolean*/ attachments;
int /*boolean*/ drawOrder;
float animationLast;
float animationTime;
int timelineCount;
spTimeline** timelines;
spIntArray* timelineData;
spTrackEntryArray* timelineDipMix;
float alphaDip;
float alphaMix;
float alpha;
int /*boolean*/ firstFrame;
float* timelinesRotation;
spMixPose pose;
int i;
spTrackEntry* dipMix;
spTrackEntry* from = to->mixingFrom;
if (from->mixingFrom) _spAnimationState_applyMixingFrom(self, from, skeleton, currentPose);
if (to->mixDuration == 0) { /* Single frame mix to undo mixingFrom changes. */
mix = 1;
currentPose = SP_MIX_POSE_SETUP;
} else {
mix = to->mixTime / to->mixDuration;
if (mix > 1) mix = 1;
}
events = mix < from->eventThreshold ? internal->events : 0;
attachments = mix < from->attachmentThreshold;
drawOrder = mix < from->drawOrderThreshold;
animationLast = from->animationLast;
animationTime = spTrackEntry_getAnimationTime(from);
timelineCount = from->animation->timelinesCount;
timelines = from->animation->timelines;
timelineData = from->timelineData;
timelineDipMix = from->timelineDipMix;
firstFrame = from->timelinesRotationCount == 0;
if (firstFrame) _spAnimationState_resizeTimelinesRotation(from, timelineCount << 1);
timelinesRotation = from->timelinesRotation;
alphaDip = from->alpha * to->interruptAlpha; alphaMix = alphaDip * (1 - mix);
from->totalAlpha = 0;
for (i = 0; i < timelineCount; i++) {
spTimeline* timeline = timelines[i];
switch (timelineData->items[i]) {
case SUBSEQUENT:
if (!attachments && timeline->type == SP_TIMELINE_ATTACHMENT) continue;
if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue;
pose = currentPose;
alpha = alphaMix;
break;
case FIRST:
pose = SP_MIX_POSE_SETUP;
alpha = alphaMix;
break;
case DIP:
pose = SP_MIX_POSE_SETUP;
alpha = alphaDip;
break;
default:
pose = SP_MIX_POSE_SETUP;
alpha = alphaDip;
dipMix = timelineDipMix->items[i];
alpha *= MAX(0, 1 - dipMix->mixTime / dipMix->mixDuration);
break;
}
from->totalAlpha += alpha;
if (timeline->type == SP_TIMELINE_ROTATE)
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
else {
spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount, alpha, pose, SP_MIX_DIRECTION_OUT);
}
}
if (to->mixDuration > 0) _spAnimationState_queueEvents(self, from, animationTime);
internal->eventsCount = 0;
from->nextAnimationLast = animationTime;
from->nextTrackLast = from->trackTime;
return mix;
}
void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time, float alpha, spMixPose pose, float* timelinesRotation, int i, int /*boolean*/ firstFrame) {
spRotateTimeline *rotateTimeline;
float *frames;
spBone* bone;
float r1, r2;
int frame;
float prevRotation;
float frameTime;
float percent;
float total, diff;
int /*boolean*/ current, dir;
if (firstFrame) timelinesRotation[i] = 0;
if (alpha == 1) {
spTimeline_apply(timeline, skeleton, 0, time, 0, 0, 1, pose, SP_MIX_DIRECTION_IN);
return;
}
rotateTimeline = SUB_CAST(spRotateTimeline, timeline);
frames = rotateTimeline->frames;
bone = skeleton->bones[rotateTimeline->boneIndex];
if (time < frames[0]) {
if (pose == SP_MIX_POSE_SETUP) {
bone->rotation = bone->data->rotation;
}
return; /* Time is before first frame. */
}
if (time >= frames[rotateTimeline->framesCount - ROTATE_ENTRIES]) /* Time is after last frame. */
r2 = bone->data->rotation + frames[rotateTimeline->framesCount + ROTATE_PREV_ROTATION];
else {
/* Interpolate between the previous frame and the current frame. */
frame = _spCurveTimeline_binarySearch(frames, rotateTimeline->framesCount, time, ROTATE_ENTRIES);
prevRotation = frames[frame + ROTATE_PREV_ROTATION];
frameTime = frames[frame];
percent = spCurveTimeline_getCurvePercent(SUPER(rotateTimeline), (frame >> 1) - 1,
1 - (time - frameTime) / (frames[frame + ROTATE_PREV_TIME] - frameTime));
r2 = frames[frame + ROTATE_ROTATION] - prevRotation;
r2 -= (16384 - (int)(16384.499999999996 - r2 / 360)) * 360;
r2 = prevRotation + r2 * percent + bone->data->rotation;
r2 -= (16384 - (int)(16384.499999999996 - r2 / 360)) * 360;
}
/* Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. */
r1 = pose == SP_MIX_POSE_SETUP ? bone->data->rotation : bone->rotation;
diff = r2 - r1;
if (diff == 0) {
total = timelinesRotation[i];
} else {
float lastTotal, lastDiff;
diff -= (16384 - (int)(16384.499999999996 - diff / 360)) * 360;
if (firstFrame) {
lastTotal = 0;
lastDiff = diff;
} else {
lastTotal = timelinesRotation[i]; /* Angle and direction of mix, including loops. */
lastDiff = timelinesRotation[i + 1]; /* Difference between bones. */
}
current = diff > 0;
dir = lastTotal >= 0;
/* Detect cross at 0 (not 180). */
if (SIGNUM(lastDiff) != SIGNUM(diff) && ABS(lastDiff) <= 90) {
/* A cross after a 360 rotation is a loop. */
if (ABS(lastTotal) > 180) lastTotal += 360 * SIGNUM(lastTotal);
dir = current;
}
total = diff + lastTotal - FMOD(lastTotal, 360); /* Store loops as part of lastTotal. */
if (dir != current) total += 360 * SIGNUM(lastTotal);
timelinesRotation[i] = total;
}
timelinesRotation[i + 1] = diff;
r1 += total * alpha;
bone->rotation = r1 - (16384 - (int)(16384.499999999996 - r1 / 360)) * 360;
}
void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry, float animationTime) {
spEvent** events;
spEvent* event;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
int i, n, complete;
float animationStart = entry->animationStart, animationEnd = entry->animationEnd;
float duration = animationEnd - animationStart;
float trackLastWrapped = FMOD(entry->trackLast, duration);
/* Queue events before complete. */
events = internal->events;
for (i = 0, n = internal->eventsCount; i < n; i++) {
event = events[i];
if (event->time < trackLastWrapped) break;
if (event->time > animationEnd) continue; /* Discard events outside animation start/end. */
_spEventQueue_event(internal->queue, entry, event);
}
/* Queue complete if completed a loop iteration or the animation. */
if (entry->loop)
complete = duration == 0 || (trackLastWrapped > FMOD(entry->trackTime, duration));
else
complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
if (complete) _spEventQueue_complete(internal->queue, entry);
/* Queue events after complete. */
for (; i < n; i++) {
event = events[i];
if (event->time < animationStart) continue; /* Discard events outside animation start/end. */
_spEventQueue_event(internal->queue, entry, event);
}
}
void spAnimationState_clearTracks (spAnimationState* self) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
int i, n, oldDrainDisabled;
oldDrainDisabled = internal->queue->drainDisabled;
internal->queue->drainDisabled = 1;
for (i = 0, n = self->tracksCount; i < n; i++)
spAnimationState_clearTrack(self, i);
self->tracksCount = 0;
internal->queue->drainDisabled = oldDrainDisabled;
_spEventQueue_drain(internal->queue);
}
void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
spTrackEntry* current;
spTrackEntry* entry;
spTrackEntry* from;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
if (trackIndex >= self->tracksCount) return;
current = self->tracks[trackIndex];
if (!current) return;
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
entry = current;
while (1) {
from = entry->mixingFrom;
if (!from) break;
_spEventQueue_end(internal->queue, from);
entry->mixingFrom = 0;
entry = from;
}
self->tracks[current->trackIndex] = 0;
_spEventQueue_drain(internal->queue);
}
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* current, int /*boolean*/ interrupt) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
spTrackEntry* from = _spAnimationState_expandToIndex(self, index);
self->tracks[index] = current;
if (from) {
if (interrupt) _spEventQueue_interrupt(internal->queue, from);
current->mixingFrom = from;
current->mixTime = 0;
/* Store the interrupted mix percentage. */
if (from->mixingFrom != 0 && from->mixDuration > 0)
current->interruptAlpha *= MIN(1, from->mixTime / from->mixDuration);
from->timelinesRotationCount = 0;
}
_spEventQueue_start(internal->queue, current);
}
/** Set the current animation. Any queued animations are cleared. */
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/*bool*/loop) {
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
}
spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) {
spTrackEntry* entry;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
int interrupt = 1;
spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex);
if (current) {
if (current->nextTrackLast == -1) {
/* Don't mix from an entry that was never applied. */
self->tracks[trackIndex] = current->mixingFrom;
_spEventQueue_interrupt(internal->queue, current);
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
current = current->mixingFrom;
interrupt = 0;
} else
_spAnimationState_disposeNext(self, current);
}
entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, current);
_spAnimationState_setCurrent(self, trackIndex, entry, interrupt);
_spEventQueue_drain(internal->queue);
return entry;
}
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
* duration. */
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/*bool*/loop, float delay) {
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
}
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
float delay) {
spTrackEntry* entry;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
spTrackEntry* last = _spAnimationState_expandToIndex(self, trackIndex);
if (last) {
while (last->next)
last = last->next;
}
entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, last);
if (!last) {
_spAnimationState_setCurrent(self, trackIndex, entry, 1);
_spEventQueue_drain(internal->queue);
} else {
last->next = entry;
if (delay <= 0) {
float duration = last->animationEnd - last->animationStart;
if (duration != 0) {
if (last->loop) {
delay += duration * (1 + (int) (last->trackTime / duration));
} else {
delay += duration;
}
delay -= spAnimationStateData_getMix(self->data, last->animation, animation);
} else
delay = 0;
}
}
entry->delay = delay;
return entry;
}
spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration) {
spTrackEntry* entry = spAnimationState_setAnimation(self, trackIndex, SP_EMPTY_ANIMATION, 0);
entry->mixDuration = mixDuration;
entry->trackEnd = mixDuration;
return entry;
}
spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay) {
spTrackEntry* entry;
if (delay <= 0) delay -= mixDuration;
entry = spAnimationState_addAnimation(self, trackIndex, SP_EMPTY_ANIMATION, 0, delay);
entry->mixDuration = mixDuration;
entry->trackEnd = mixDuration;
return entry;
}
void spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration) {
int i, n, oldDrainDisabled;
spTrackEntry* current;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
oldDrainDisabled = internal->queue->drainDisabled;
internal->queue->drainDisabled = 1;
for (i = 0, n = self->tracksCount; i < n; i++) {
current = self->tracks[i];
if (current) spAnimationState_setEmptyAnimation(self, current->trackIndex, mixDuration);
}
internal->queue->drainDisabled = oldDrainDisabled;
_spEventQueue_drain(internal->queue);
}
spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) {
spTrackEntry** newTracks;
if (index < self->tracksCount) return self->tracks[index];
newTracks = CALLOC(spTrackEntry*, index + 1);
memcpy(newTracks, self->tracks, self->tracksCount * sizeof(spTrackEntry*));
FREE(self->tracks);
self->tracks = newTracks;
self->tracksCount = index + 1;
return 0;
}
spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackIndex, spAnimation* animation, int /*boolean*/ loop, spTrackEntry* last) {
spTrackEntry* entry = NEW(spTrackEntry);
entry->trackIndex = trackIndex;
entry->animation = animation;
entry->loop = loop;
entry->eventThreshold = 0;
entry->attachmentThreshold = 0;
entry->drawOrderThreshold = 0;
entry->animationStart = 0;
entry->animationEnd = animation->duration;
entry->animationLast = -1;
entry->nextAnimationLast = -1;
entry->delay = 0;
entry->trackTime = 0;
entry->trackLast = -1;
entry->nextTrackLast = -1;
entry->trackEnd = (float)INT_MAX;
entry->timeScale = 1;
entry->alpha = 1;
entry->interruptAlpha = 1;
entry->mixTime = 0;
entry->mixDuration = !last ? 0 : spAnimationStateData_getMix(self->data, last->animation, animation);
entry->timelineData = spIntArray_create(16);
entry->timelineDipMix = spTrackEntryArray_create(16);
return entry;
}
void _spAnimationState_disposeNext (spAnimationState* self, spTrackEntry* entry) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
spTrackEntry* next = entry->next;
while (next) {
_spEventQueue_dispose(internal->queue, next);
next = next->next;
}
entry->next = 0;
}
void _spAnimationState_animationsChanged (spAnimationState* self) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
int i, n;
spTrackEntry* entry;
spTrackEntryArray* mixingTo;
internal->animationsChanged = 0;
internal->propertyIDsCount = 0;
i = 0; n = self->tracksCount;
mixingTo = self->mixingTo;
for (;i < n; i++) {
entry = self->tracks[i];
if (entry != 0) _spTrackEntry_setTimelineData(entry, 0, mixingTo, self);
}
}
float* _spAnimationState_resizeTimelinesRotation(spTrackEntry* entry, int newSize) {
if (entry->timelinesRotationCount != newSize) {
float* newTimelinesRotation = CALLOC(float, newSize);
FREE(entry->timelinesRotation);
entry->timelinesRotation = newTimelinesRotation;
entry->timelinesRotationCount = newSize;
}
return entry->timelinesRotation;
}
void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
if (internal->propertyIDsCapacity < capacity) {
int *newPropertyIDs = CALLOC(int, capacity << 1);
memcpy(newPropertyIDs, internal->propertyIDs, sizeof(int) * internal->propertyIDsCount);
FREE(internal->propertyIDs);
internal->propertyIDs = newPropertyIDs;
internal->propertyIDsCapacity = capacity << 1;
}
}
int _spAnimationState_addPropertyID(spAnimationState* self, int id) {
int i, n;
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
for (i = 0, n = internal->propertyIDsCount; i < n; i++) {
if (internal->propertyIDs[i] == id) return 0;
}
_spAnimationState_ensureCapacityPropertyIDs(self, internal->propertyIDsCount + 1);
internal->propertyIDs[internal->propertyIDsCount] = id;
internal->propertyIDsCount++;
return 1;
}
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) {
if (trackIndex >= self->tracksCount) return 0;
return self->tracks[trackIndex];
}
void spAnimationState_clearListenerNotifications(spAnimationState* self) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
_spEventQueue_clear(internal->queue);
}
float spTrackEntry_getAnimationTime (spTrackEntry* entry) {
if (entry->loop) {
float duration = entry->animationEnd - entry->animationStart;
if (duration == 0) return entry->animationStart;
return FMOD(entry->trackTime, duration) + entry->animationStart;
}
return MIN(entry->trackTime + entry->animationStart, entry->animationEnd);
}
int /*boolean*/ _spTrackEntry_hasTimeline(spTrackEntry* self, int id) {
spTimeline** timelines = self->animation->timelines;
int i, n;
for (i = 0, n = self->animation->timelinesCount; i < n; i++)
if (spTimeline_getPropertyId(timelines[i]) == id) return 1;
return 0;
}
spTrackEntry* _spTrackEntry_setTimelineData(spTrackEntry* self, spTrackEntry* to, spTrackEntryArray* mixingToArray, spAnimationState* state) {
spTrackEntry* lastEntry;
spTrackEntry** mixingTo;
int mixingToLast;
spTimeline** timelines;
int timelinesCount;
int* timelineData;
spTrackEntry** timelineDipMix;
int i, ii;
if (to != 0) spTrackEntryArray_add(mixingToArray, to);
lastEntry = self->mixingFrom != 0 ? _spTrackEntry_setTimelineData(self->mixingFrom, self, mixingToArray, state) : self;
if (to != 0) spTrackEntryArray_pop(mixingToArray);
mixingTo = mixingToArray->items;
mixingToLast = mixingToArray->size - 1;
timelines = self->animation->timelines;
timelinesCount = self->animation->timelinesCount;
timelineData = spIntArray_setSize(self->timelineData, timelinesCount)->items;
spTrackEntryArray_clear(self->timelineDipMix);
timelineDipMix = spTrackEntryArray_setSize(self->timelineDipMix, timelinesCount)->items;
i = 0;
continue_outer:
for (; i < timelinesCount; i++) {
int id = spTimeline_getPropertyId(timelines[i]);
if (!_spAnimationState_addPropertyID(state, id))
timelineData[i] = SUBSEQUENT;
else if (to == 0 || !_spTrackEntry_hasTimeline(to, id))
timelineData[i] = FIRST;
else {
for (ii = mixingToLast; ii >= 0; ii--) {
spTrackEntry* entry = mixingTo[ii];
if (!_spTrackEntry_hasTimeline(entry, id)) {
if (entry->mixDuration > 0) {
timelineData[i] = DIP_MIX;
timelineDipMix[i] = entry;
i++;
goto continue_outer;
}
}
break;
}
timelineData[i] = DIP;
}
}
return lastEntry;
}
File diff suppressed because it is too large Load Diff
+449 -190
View File
@@ -1,191 +1,450 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ANIMATIONSTATE_H_
#define SPINE_ANIMATIONSTATE_H_
#include <spine/dll.h>
#include <spine/Animation.h>
#include <spine/AnimationStateData.h>
#include <spine/Event.h>
#include <spine/Array.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SP_ANIMATION_START, SP_ANIMATION_INTERRUPT, SP_ANIMATION_END, SP_ANIMATION_COMPLETE, SP_ANIMATION_DISPOSE, SP_ANIMATION_EVENT
} spEventType;
typedef struct spAnimationState spAnimationState;
typedef struct spTrackEntry spTrackEntry;
typedef void (*spAnimationStateListener) (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event);
_SP_ARRAY_DECLARE_TYPE(spTrackEntryArray, spTrackEntry*)
struct spTrackEntry {
spAnimation* animation;
spTrackEntry* next;
spTrackEntry* mixingFrom;
spAnimationStateListener listener;
int trackIndex;
int /*boolean*/ loop;
float eventThreshold, attachmentThreshold, drawOrderThreshold;
float animationStart, animationEnd, animationLast, nextAnimationLast;
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
float alpha, mixTime, mixDuration, interruptAlpha, totalAlpha;
spIntArray* timelineData;
spTrackEntryArray* timelineDipMix;
float* timelinesRotation;
int timelinesRotationCount;
void* rendererObject;
void* userData;
#ifdef __cplusplus
spTrackEntry() :
animation(0),
next(0), mixingFrom(0),
listener(0),
trackIndex(0),
loop(0),
eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0),
animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0),
delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0),
alpha(0), mixTime(0), mixDuration(0), interruptAlpha(0), totalAlpha(0),
timelineData(0),
timelineDipMix(0),
timelinesRotation(0),
timelinesRotationCount(0),
rendererObject(0), userData(0) {
}
#endif
};
struct spAnimationState {
spAnimationStateData* const data;
int tracksCount;
spTrackEntry** tracks;
spAnimationStateListener listener;
float timeScale;
spTrackEntryArray* mixingTo;
void* rendererObject;
void* userData;
#ifdef __cplusplus
spAnimationState() :
data(0),
tracksCount(0),
tracks(0),
listener(0),
timeScale(0),
mixingTo(0),
rendererObject(0),
userData(0) {
}
#endif
};
/* @param data May be 0 for no mixing. */
SP_API spAnimationState* spAnimationState_create (spAnimationStateData* data);
SP_API void spAnimationState_dispose (spAnimationState* self);
SP_API void spAnimationState_update (spAnimationState* self, float delta);
SP_API int /**bool**/ spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton);
SP_API void spAnimationState_clearTracks (spAnimationState* self);
SP_API void spAnimationState_clearTrack (spAnimationState* self, int trackIndex);
/** Set the current animation. Any queued animations are cleared. */
SP_API spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/*bool*/loop);
SP_API spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop);
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
* duration. */
SP_API spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
int/*bool*/loop, float delay);
SP_API spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
float delay);
SP_API spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration);
SP_API spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay);
SP_API void spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration);
SP_API spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex);
SP_API void spAnimationState_clearListenerNotifications(spAnimationState* self);
SP_API float spTrackEntry_getAnimationTime (spTrackEntry* entry);
/** Use this to dispose static memory before your app exits to appease your memory leak detector*/
SP_API void spAnimationState_disposeStatics ();
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
typedef void (*TrackEntryDisposeCallback)(spTrackEntry*);
void spTrackEntry_setDisposeCallback(TrackEntryDisposeCallback cb);
#ifdef SPINE_SHORT_NAMES
typedef spEventType EventType;
#define ANIMATION_START SP_ANIMATION_START
#define ANIMATION_INTERRUPT SP_ANIMATION_INTERRUPT
#define ANIMATION_END SP_ANIMATION_END
#define ANIMATION_COMPLETE SP_ANIMATION_COMPLETE
#define ANIMATION_DISPOSE SP_ANIMATION_DISPOSE
#define ANIMATION_EVENT SP_ANIMATION_EVENT
typedef spAnimationStateListener AnimationStateListener;
typedef spTrackEntry TrackEntry;
typedef spAnimationState AnimationState;
#define AnimationState_create(...) spAnimationState_create(__VA_ARGS__)
#define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__)
#define AnimationState_update(...) spAnimationState_update(__VA_ARGS__)
#define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__)
#define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__)
#define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__)
#define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__)
#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__)
#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__)
#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__)
#define AnimationState_setEmptyAnimation(...) spAnimatinState_setEmptyAnimation(__VA_ARGS__)
#define AnimationState_addEmptyAnimation(...) spAnimatinState_addEmptyAnimation(__VA_ARGS__)
#define AnimationState_setEmptyAnimations(...) spAnimatinState_setEmptyAnimations(__VA_ARGS__)
#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__)
#define AnimationState_clearListenerNotifications(...) spAnimatinState_clearListenerNotifications(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ANIMATIONSTATE_H_ */
#ifndef Spine_AnimationState_h
#define Spine_AnimationState_h
#include <spine/Vector.h>
#include <spine/Pool.h>
#include <spine/MixBlend.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
#include <spine/HasRendererObject.h>
namespace spine {
enum EventType {
EventType_Start,
EventType_Interrupt,
EventType_End,
EventType_Complete,
EventType_Dispose,
EventType_Event
};
class AnimationState;
class TrackEntry;
class Animation;
class Event;
class AnimationStateData;
class Skeleton;
class RotateTimeline;
typedef void (*AnimationStateListener) (AnimationState* state, EventType type, TrackEntry* entry, Event* event);
/// State for the playback of an animation
class SP_API TrackEntry : public SpineObject, public HasRendererObject {
friend class EventQueue;
friend class AnimationState;
public:
TrackEntry();
virtual ~TrackEntry();
/// The index of the track where this entry is either current or queued.
int getTrackIndex();
/// The animation to apply for this track entry.
Animation* getAnimation();
///
/// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration.
bool getLoop();
void setLoop(bool inValue);
///
/// If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
/// of being mixed out.
///
/// When mixing between animations that key the same property, if a lower track also keys that property then the value will
/// briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
/// while the second animation mixes from 0% to 100%. Setting holdPrevious to true applies the first animation
/// at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
/// keys the property, only when a higher track also keys the property.
///
/// Snapping will occur if holdPrevious is true and this animation does not key all the same properties as the
/// previous animation.
bool getHoldPrevious();
void setHoldPrevious(bool inValue);
///
/// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing
/// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the
/// track entry will become the current track entry.
float getDelay();
void setDelay(float inValue);
///
/// Current time in seconds this track entry has been the current track entry. The track time determines
/// TrackEntry.AnimationTime. The track time can be set to start the animation at a time other than 0, without affecting looping.
float getTrackTime();
void setTrackTime(float inValue);
///
/// The track time in seconds when this animation will be removed from the track. Defaults to the animation duration for
/// non-looping animations and to int.MaxValue for looping animations. If the track end time is reached and no
/// other animations are queued for playback, and mixing from any previous animations is complete, properties keyed by the animation,
/// are set to the setup pose and the track is cleared.
///
/// It may be desired to use AnimationState.addEmptyAnimation(int, float, float) to mix the properties back to the
/// setup pose over time, rather than have it happen instantly.
///
float getTrackEnd();
void setTrackEnd(float inValue);
///
/// Seconds when this animation starts, both initially and after looping. Defaults to 0.
///
/// When changing the animation start time, it often makes sense to set TrackEntry.AnimationLast to the same value to
/// prevent timeline keys before the start time from triggering.
///
float getAnimationStart();
void setAnimationStart(float inValue);
///
/// Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
/// loop back to TrackEntry.AnimationStart at this time. Defaults to the animation duration.
float getAnimationEnd();
void setAnimationEnd(float inValue);
///
/// The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
/// animation is applied, event timelines will fire all events between the animation last time (exclusive) and animation time
/// (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied.
float getAnimationLast();
void setAnimationLast(float inValue);
///
/// Uses TrackEntry.TrackTime to compute the animation time between TrackEntry.AnimationStart. and
/// TrackEntry.AnimationEnd. When the track time is 0, the animation time is equal to the animation start time.
///
float getAnimationTime();
///
/// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or
/// faster. Defaults to 1.
///
float getTimeScale();
void setTimeScale(float inValue);
///
/// Values less than 1 mix this animation with the last skeleton pose. Defaults to 1, which overwrites the last skeleton pose with
/// this animation.
///
/// Typically track 0 is used to completely pose the skeleton, then alpha can be used on higher tracks. It doesn't make sense
/// to use alpha on track 0 if the skeleton pose is from the last frame render.
///
float getAlpha();
void setAlpha(float inValue);
///
/// When the mix percentage (mix time / mix duration) is less than the event threshold, event timelines for the animation
/// being mixed out will be applied. Defaults to 0, so event timelines are not applied for an animation being mixed out.
float getEventThreshold();
void setEventThreshold(float inValue);
///
/// When the mix percentage (mix time / mix duration) is less than the attachment threshold, attachment timelines for the
/// animation being mixed out will be applied. Defaults to 0, so attachment timelines are not applied for an animation being
/// mixed out.
float getAttachmentThreshold();
void setAttachmentThreshold(float inValue);
///
/// When the mix percentage (mix time / mix duration) is less than the draw order threshold, draw order timelines for the
/// animation being mixed out will be applied. Defaults to 0, so draw order timelines are not applied for an animation being
/// mixed out.
///
float getDrawOrderThreshold();
void setDrawOrderThreshold(float inValue);
///
/// The animation queued to start after this animation, or NULL.
TrackEntry* getNext();
///
/// Returns true if at least one loop has been completed.
bool isComplete();
///
/// Seconds from 0 to the mix duration when mixing from the previous animation to this animation. May be slightly more than
/// TrackEntry.MixDuration when the mix is complete.
float getMixTime();
void setMixTime(float inValue);
///
/// Seconds for mixing from the previous animation to this animation. Defaults to the value provided by
/// AnimationStateData based on the animation before this animation (if any).
///
/// The mix duration can be set manually rather than use the value from AnimationStateData.GetMix.
/// In that case, the mixDuration must be set before AnimationState.update(float) is next called.
///
/// When using AnimationState::addAnimation(int, Animation, bool, float) with a delay
/// less than or equal to 0, note the Delay is set using the mix duration from the AnimationStateData
///
///
///
float getMixDuration();
void setMixDuration(float inValue);
MixBlend getMixBlend();
void setMixBlend(MixBlend blend);
///
/// The track entry for the previous animation when mixing from the previous animation to this animation, or NULL if no
/// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a double linked list with MixingTo.
TrackEntry* getMixingFrom();
///
/// The track entry for the next animation when mixing from this animation, or NULL if no mixing is currently occuring.
/// When mixing from multiple animations, MixingTo makes up a double linked list with MixingFrom.
TrackEntry* getMixingTo();
///
/// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
/// long way around when using alpha and starting animations on other tracks.
///
/// Mixing involves finding a rotation between two others, which has two possible solutions: the short way or the long way around.
/// The two rotations likely change over time, so which direction is the short or long way also changes.
/// If the short way was always chosen, bones would flip to the other side when that direction became the long way.
/// TrackEntry chooses the short way the first time it is applied and remembers that direction.
void resetRotationDirections();
void setListener(AnimationStateListener listener);
private:
Animation* _animation;
TrackEntry* _next;
TrackEntry* _mixingFrom;
TrackEntry* _mixingTo;
int _trackIndex;
bool _loop, _holdPrevious;
float _eventThreshold, _attachmentThreshold, _drawOrderThreshold;
float _animationStart, _animationEnd, _animationLast, _nextAnimationLast;
float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale;
float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha;
MixBlend _mixBlend;
Vector<int> _timelineMode;
Vector<TrackEntry*> _timelineHoldMix;
Vector<float> _timelinesRotation;
AnimationStateListener _listener;
void reset();
};
class SP_API EventQueueEntry : public SpineObject {
friend class EventQueue;
public:
EventType _type;
TrackEntry* _entry;
Event* _event;
EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL);
};
class SP_API EventQueue : public SpineObject {
friend class AnimationState;
private:
Vector<EventQueueEntry> _eventQueueEntries;
AnimationState& _state;
Pool<TrackEntry>& _trackEntryPool;
bool _drainDisabled;
static EventQueue* newEventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
static EventQueueEntry newEventQueueEntry(EventType eventType, TrackEntry* entry, Event* event = NULL);
EventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
~EventQueue();
void start(TrackEntry* entry);
void interrupt(TrackEntry* entry);
void end(TrackEntry* entry);
void dispose(TrackEntry* entry);
void complete(TrackEntry* entry);
void event(TrackEntry* entry, Event* event);
/// Raises all events in the queue and drains the queue.
void drain();
};
class SP_API AnimationState : public SpineObject, public HasRendererObject {
friend class TrackEntry;
friend class EventQueue;
public:
explicit AnimationState(AnimationStateData* data);
~AnimationState();
///
/// Increments the track entry times, setting queued animations as current if needed
/// @param delta delta time
void update(float delta);
///
/// Poses the skeleton using the track entry animations. There are no side effects other than invoking listeners, so the
/// animation state can be applied to multiple skeletons to pose them identically.
bool apply(Skeleton& skeleton);
///
/// Removes all animations from all tracks, leaving skeletons in their previous pose.
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
/// rather than leaving them in their previous pose.
void clearTracks();
///
/// Removes all animations from the tracks, leaving skeletons in their previous pose.
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
/// rather than leaving them in their previous pose.
void clearTrack(size_t trackIndex);
/// Sets an animation by name. setAnimation(int, Animation, bool)
TrackEntry* setAnimation(size_t trackIndex, const String& animationName, bool loop);
/// Sets the current animation for a track, discarding any queued animations.
/// @param loop If true, the animation will repeat.
/// If false, it will not, instead its last frame is applied if played beyond its duration.
/// In either case TrackEntry.TrackEnd determines when the track is cleared.
/// @return
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
/// after AnimationState.Dispose.
TrackEntry* setAnimation(size_t trackIndex, Animation* animation, bool loop);
/// Queues an animation by name.
/// addAnimation(int, Animation, bool, float)
TrackEntry* addAnimation(size_t trackIndex, const String& animationName, bool loop, float delay);
/// Adds an animation to be played delay seconds after the current or last queued animation
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
/// @param delay
/// Seconds to begin this animation after the start of the previous animation. May be &lt;= 0 to use the animation
/// duration of the previous track minus any mix duration plus the negative delay.
///
/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
/// after AnimationState.Dispose
TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay);
///
/// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration.
TrackEntry* setEmptyAnimation(size_t trackIndex, float mixDuration);
///
/// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the
/// specified mix duration.
/// @return
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept after AnimationState.Dispose.
///
/// @param trackIndex Track number.
/// @param mixDuration Mix duration.
/// @param delay Seconds to begin this animation after the start of the previous animation. May be &lt;= 0 to use the animation
/// duration of the previous track minus any mix duration plus the negative delay.
TrackEntry* addEmptyAnimation(size_t trackIndex, float mixDuration, float delay);
///
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.
void setEmptyAnimations(float mixDuration);
/// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing.
TrackEntry* getCurrent(size_t trackIndex);
AnimationStateData* getData();
/// A list of tracks that have animations, which may contain NULLs.
Vector<TrackEntry*> &getTracks();
float getTimeScale();
void setTimeScale(float inValue);
void setListener(AnimationStateListener listener);
void disableQueue();
void enableQueue();
private:
AnimationStateData* _data;
Pool<TrackEntry> _trackEntryPool;
Vector<TrackEntry*> _tracks;
Vector<Event*> _events;
EventQueue* _queue;
Vector<int> _propertyIDs;
bool _animationsChanged;
AnimationStateListener _listener;
float _timeScale;
static Animation* getEmptyAnimation();
static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector<float>& timelinesRotation, size_t i, bool firstFrame);
/// Returns true when all mixing from entries are complete.
bool updateMixingFrom(TrackEntry* to, float delta);
float applyMixingFrom(TrackEntry* to, Skeleton& skeleton, MixBlend currentPose);
void queueEvents(TrackEntry* entry, float animationTime);
/// Sets the active TrackEntry for a given track number.
void setCurrent(size_t index, TrackEntry* current, bool interrupt);
TrackEntry* expandToIndex(size_t index);
/// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values.
/// @param last May be NULL.
TrackEntry* newTrackEntry(size_t trackIndex, Animation* animation, bool loop, TrackEntry* last);
/// Dispose all track entries queued after the given TrackEntry.
void disposeNext(TrackEntry* entry);
void animationsChanged();
void setTimelineModes(TrackEntry* entry);
bool hasTimeline(TrackEntry* entry, int inId);
};
}
#endif /* Spine_AnimationState_h */
@@ -1,151 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AnimationStateData.h>
#include <spine/extension.h>
typedef struct _ToEntry _ToEntry;
struct _ToEntry {
spAnimation* animation;
float duration;
_ToEntry* next;
};
_ToEntry* _ToEntry_create (spAnimation* to, float duration) {
_ToEntry* self = NEW(_ToEntry);
self->animation = to;
self->duration = duration;
return self;
}
void _ToEntry_dispose (_ToEntry* self) {
FREE(self);
}
/**/
typedef struct _FromEntry _FromEntry;
struct _FromEntry {
spAnimation* animation;
_ToEntry* toEntries;
_FromEntry* next;
};
_FromEntry* _FromEntry_create (spAnimation* from) {
_FromEntry* self = NEW(_FromEntry);
self->animation = from;
return self;
}
void _FromEntry_dispose (_FromEntry* self) {
FREE(self);
}
/**/
spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) {
spAnimationStateData* self = NEW(spAnimationStateData);
CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData;
return self;
}
void spAnimationStateData_dispose (spAnimationStateData* self) {
_ToEntry* toEntry;
_ToEntry* nextToEntry;
_FromEntry* nextFromEntry;
_FromEntry* fromEntry = (_FromEntry*)self->entries;
while (fromEntry) {
toEntry = fromEntry->toEntries;
while (toEntry) {
nextToEntry = toEntry->next;
_ToEntry_dispose(toEntry);
toEntry = nextToEntry;
}
nextFromEntry = fromEntry->next;
_FromEntry_dispose(fromEntry);
fromEntry = nextFromEntry;
}
FREE(self);
}
void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) {
spAnimation* to;
spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName);
if (!from) return;
to = spSkeletonData_findAnimation(self->skeletonData, toName);
if (!to) return;
spAnimationStateData_setMix(self, from, to, duration);
}
void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) {
/* Find existing FromEntry. */
_ToEntry* toEntry;
_FromEntry* fromEntry = (_FromEntry*)self->entries;
while (fromEntry) {
if (fromEntry->animation == from) {
/* Find existing ToEntry. */
toEntry = fromEntry->toEntries;
while (toEntry) {
if (toEntry->animation == to) {
toEntry->duration = duration;
return;
}
toEntry = toEntry->next;
}
break; /* Add new ToEntry to the existing FromEntry. */
}
fromEntry = fromEntry->next;
}
if (!fromEntry) {
fromEntry = _FromEntry_create(from);
fromEntry->next = (_FromEntry*)self->entries;
CONST_CAST(_FromEntry*, self->entries) = fromEntry;
}
toEntry = _ToEntry_create(to, duration);
toEntry->next = fromEntry->toEntries;
fromEntry->toEntries = toEntry;
}
float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) {
_FromEntry* fromEntry = (_FromEntry*)self->entries;
while (fromEntry) {
if (fromEntry->animation == from) {
_ToEntry* toEntry = fromEntry->toEntries;
while (toEntry) {
if (toEntry->animation == to) return toEntry->duration;
toEntry = toEntry->next;
}
}
fromEntry = fromEntry->next;
}
return self->defaultMix;
}
@@ -0,0 +1,86 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/AnimationStateData.h>
#include <spine/SkeletonData.h>
#include <spine/Animation.h>
using namespace spine;
AnimationStateData::AnimationStateData(SkeletonData *skeletonData) : _skeletonData(skeletonData), _defaultMix(0) {
}
void AnimationStateData::setMix(const String &fromName, const String &toName, float duration) {
Animation *from = _skeletonData->findAnimation(fromName);
Animation *to = _skeletonData->findAnimation(toName);
setMix(from, to, duration);
}
void AnimationStateData::setMix(Animation *from, Animation *to, float duration) {
assert(from != NULL);
assert(to != NULL);
AnimationPair key(from, to);
_animationToMixTime.put(key, duration);
}
float AnimationStateData::getMix(Animation *from, Animation *to) {
assert(from != NULL);
assert(to != NULL);
AnimationPair key(from, to);
if (_animationToMixTime.containsKey(key)) return _animationToMixTime[key];
return _defaultMix;
}
SkeletonData *AnimationStateData::getSkeletonData() {
return _skeletonData;
}
float AnimationStateData::getDefaultMix() {
return _defaultMix;
}
void AnimationStateData::setDefaultMix(float inValue) {
_defaultMix = inValue;
}
AnimationStateData::AnimationPair::AnimationPair(Animation *a1, Animation *a2) : _a1(a1), _a2(a2) {
}
bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name;
}
@@ -1,77 +1,88 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ANIMATIONSTATEDATA_H_
#define SPINE_ANIMATIONSTATEDATA_H_
#include <spine/dll.h>
#include <spine/Animation.h>
#include <spine/SkeletonData.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spAnimationStateData {
spSkeletonData* const skeletonData;
float defaultMix;
const void* const entries;
#ifdef __cplusplus
spAnimationStateData() :
skeletonData(0),
defaultMix(0),
entries(0) {
}
#endif
} spAnimationStateData;
SP_API spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData);
SP_API void spAnimationStateData_dispose (spAnimationStateData* self);
SP_API void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration);
SP_API void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration);
/* Returns 0 if there is no mixing between the animations. */
SP_API float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to);
#ifdef SPINE_SHORT_NAMES
typedef spAnimationStateData AnimationStateData;
#define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__)
#define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__)
#define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__)
#define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__)
#define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ANIMATIONSTATEDATA_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_AnimationStateData_h
#define Spine_AnimationStateData_h
#include <spine/HashMap.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
#include <assert.h>
namespace spine {
class SkeletonData;
class Animation;
/// Stores mix (crossfade) durations to be applied when AnimationState animations are changed.
class SP_API AnimationStateData : public SpineObject {
friend class AnimationState;
public:
explicit AnimationStateData(SkeletonData* skeletonData);
/// The SkeletonData to look up animations when they are specified by name.
SkeletonData* getSkeletonData();
/// The mix duration to use when no mix duration has been specifically defined between two animations.
float getDefaultMix();
void setDefaultMix(float inValue);
/// Sets a mix duration by animation names.
void setMix(const String& fromName, const String& toName, float duration);
/// Sets a mix duration when changing from the specified animation to the other.
/// See TrackEntry.MixDuration.
void setMix(Animation* from, Animation* to, float duration);
///
/// The mix duration to use when changing from the specified animation to the other,
/// or the DefaultMix if no mix duration has been set.
///
float getMix(Animation* from, Animation* to);
private:
class AnimationPair : public SpineObject {
public:
Animation* _a1;
Animation* _a2;
explicit AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL);
bool operator==(const AnimationPair &other) const;
};
SkeletonData* _skeletonData;
float _defaultMix;
HashMap<AnimationPair, float> _animationToMixTime;
};
}
#endif /* Spine_AnimationStateData_h */
-133
View File
@@ -1,133 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ARRAY_H
#define SPINE_ARRAY_H
#include <spine/dll.h>
#ifdef __cplusplus
extern "C" {
#endif
#define _SP_ARRAY_DECLARE_TYPE(name, itemType) \
typedef struct name { int size; int capacity; itemType* items; } name; \
SP_API name* name##_create(int initialCapacity); \
SP_API void name##_dispose(name* self); \
SP_API void name##_clear(name* self); \
SP_API name* name##_setSize(name* self, int newSize); \
SP_API void name##_ensureCapacity(name* self, int newCapacity); \
SP_API void name##_add(name* self, itemType value); \
SP_API void name##_addAll(name* self, name* other); \
SP_API void name##_addAllValues(name* self, itemType* values, int offset, int count); \
SP_API void name##_removeAt(name* self, int index); \
SP_API int name##_contains(name* self, itemType value); \
SP_API itemType name##_pop(name* self); \
SP_API itemType name##_peek(name* self);
#define _SP_ARRAY_IMPLEMENT_TYPE(name, itemType) \
name* name##_create(int initialCapacity) { \
name* array = CALLOC(name, 1); \
array->size = 0; \
array->capacity = initialCapacity; \
array->items = CALLOC(itemType, initialCapacity); \
return array; \
} \
void name##_dispose(name* self) { \
FREE(self->items); \
FREE(self); \
} \
void name##_clear(name* self) { \
self->size = 0; \
} \
name* name##_setSize(name* self, int newSize) { \
self->size = newSize; \
if (self->capacity < newSize) { \
self->capacity = MAX(8, (int)(self->size * 1.75f)); \
self->items = REALLOC(self->items, itemType, self->capacity); \
} \
return self; \
} \
void name##_ensureCapacity(name* self, int newCapacity) { \
if (self->capacity >= newCapacity) return; \
self->capacity = newCapacity; \
self->items = REALLOC(self->items, itemType, self->capacity); \
} \
void name##_add(name* self, itemType value) { \
if (self->size == self->capacity) { \
self->capacity = MAX(8, (int)(self->size * 1.75f)); \
self->items = REALLOC(self->items, itemType, self->capacity); \
} \
self->items[self->size++] = value; \
} \
void name##_addAll(name* self, name* other) { \
int i = 0; \
for (; i < other->size; i++) { \
name##_add(self, other->items[i]); \
} \
} \
void name##_addAllValues(name* self, itemType* values, int offset, int count) { \
int i = offset, n = offset + count; \
for (; i < n; i++) { \
name##_add(self, values[i]); \
} \
} \
void name##_removeAt(name* self, int index) { \
self->size--; \
memmove(self->items + index, self->items + index + 1, sizeof(itemType) * (self->size - index)); \
} \
int name##_contains(name* self, itemType value) { \
itemType* items = self->items; \
int i, n; \
for (i = 0, n = self->size; i < n; i++) { \
if (items[i] == value) return -1; \
} \
return 0; \
} \
itemType name##_pop(name* self) { \
itemType item = self->items[--self->size]; \
return item; \
} \
itemType name##_peek(name* self) { \
return self->items[self->size - 1]; \
}
_SP_ARRAY_DECLARE_TYPE(spFloatArray, float)
_SP_ARRAY_DECLARE_TYPE(spIntArray, int)
_SP_ARRAY_DECLARE_TYPE(spShortArray, short)
_SP_ARRAY_DECLARE_TYPE(spUnsignedShortArray, unsigned short)
_SP_ARRAY_DECLARE_TYPE(spArrayFloatArray, spFloatArray*)
_SP_ARRAY_DECLARE_TYPE(spArrayShortArray, spShortArray*)
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ARRAY_H */
-359
View File
@@ -1,359 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/Atlas.h>
#include <ctype.h>
#include <spine/extension.h>
spAtlasPage* spAtlasPage_create(spAtlas* atlas, const char* name) {
spAtlasPage* self = NEW(spAtlasPage);
CONST_CAST(spAtlas*, self->atlas) = atlas;
MALLOC_STR(self->name, name);
return self;
}
void spAtlasPage_dispose(spAtlasPage* self) {
_spAtlasPage_disposeTexture(self);
FREE(self->name);
FREE(self);
}
/**/
spAtlasRegion* spAtlasRegion_create() {
return NEW(spAtlasRegion);
}
void spAtlasRegion_dispose(spAtlasRegion* self) {
FREE(self->name);
FREE(self->splits);
FREE(self->pads);
FREE(self);
}
/**/
typedef struct {
const char* begin;
const char* end;
} Str;
static void trim(Str* str) {
while (isspace((unsigned char)*str->begin) && str->begin < str->end)
(str->begin)++;
if (str->begin == str->end) return;
str->end--;
while (((unsigned char)*str->end == '\r') && str->end >= str->begin)
str->end--;
str->end++;
}
/* Tokenize string without modification. Returns 0 on failure. */
static int readLine(const char** begin, const char* end, Str* str) {
if (*begin == end) return 0;
str->begin = *begin;
/* Find next delimiter. */
while (*begin != end && **begin != '\n')
(*begin)++;
str->end = *begin;
trim(str);
if (*begin != end) (*begin)++;
return 1;
}
/* Moves str->begin past the first occurence of c. Returns 0 on failure. */
static int beginPast(Str* str, char c) {
const char* begin = str->begin;
while (1) {
char lastSkippedChar = *begin;
if (begin == str->end) return 0;
begin++;
if (lastSkippedChar == c) break;
}
str->begin = begin;
return 1;
}
/* Returns 0 on failure. */
static int readValue(const char** begin, const char* end, Str* str) {
readLine(begin, end, str);
if (!beginPast(str, ':')) return 0;
trim(str);
return 1;
}
/* Returns the number of tuple values read (1, 2, 4, or 0 for failure). */
static int readTuple(const char** begin, const char* end, Str tuple[]) {
int i;
Str str = { NULL, NULL };
readLine(begin, end, &str);
if (!beginPast(&str, ':')) return 0;
for (i = 0; i < 3; ++i) {
tuple[i].begin = str.begin;
if (!beginPast(&str, ',')) break;
tuple[i].end = str.begin - 2;
trim(&tuple[i]);
}
tuple[i].begin = str.begin;
tuple[i].end = str.end;
trim(&tuple[i]);
return i + 1;
}
static char* mallocString(Str* str) {
int length = (int)(str->end - str->begin);
char* string = MALLOC(char, length + 1);
memcpy(string, str->begin, length);
string[length] = '\0';
return string;
}
static int indexOf(const char** array, int count, Str* str) {
int length = (int)(str->end - str->begin);
int i;
for (i = count - 1; i >= 0; i--)
if (strncmp(array[i], str->begin, length) == 0) return i;
return 0;
}
static int equals(Str* str, const char* other) {
return strncmp(other, str->begin, str->end - str->begin) == 0;
}
static int toInt(Str* str) {
return (int)strtol(str->begin, (char**)&str->end, 10);
}
static spAtlas* abortAtlas(spAtlas* self) {
spAtlas_dispose(self);
return 0;
}
static const char* formatNames[] = { "", "Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888", "RGBA8888" };
static const char* textureFilterNames[] = { "", "Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest",
"MipMapNearestLinear", "MipMapLinearLinear" };
spAtlas* spAtlas_create(const char* begin, int length, const char* dir, void* rendererObject) {
spAtlas* self;
int count;
const char* end = begin + length;
int dirLength = (int)strlen(dir);
int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\';
spAtlasPage *page = 0;
spAtlasPage *lastPage = 0;
spAtlasRegion *lastRegion = 0;
Str str;
Str tuple[4];
self = NEW(spAtlas);
self->rendererObject = rendererObject;
while (readLine(&begin, end, &str)) {
if (str.end - str.begin == 0) {
page = 0;
}
else if (!page) {
char* name = mallocString(&str);
char* path = MALLOC(char, dirLength + needsSlash + strlen(name) + 1);
memcpy(path, dir, dirLength);
if (needsSlash) path[dirLength] = '/';
strcpy(path + dirLength + needsSlash, name);
page = spAtlasPage_create(self, name);
FREE(name);
if (lastPage)
lastPage->next = page;
else
self->pages = page;
lastPage = page;
switch (readTuple(&begin, end, tuple)) {
case 0:
return abortAtlas(self);
case 2: /* size is only optional for an atlas packed with an old TexturePacker. */
page->width = toInt(tuple);
page->height = toInt(tuple + 1);
if (!readTuple(&begin, end, tuple)) return abortAtlas(self);
}
page->format = (spAtlasFormat)indexOf(formatNames, 8, tuple);
if (!readTuple(&begin, end, tuple)) return abortAtlas(self);
page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 8, tuple);
page->magFilter = (spAtlasFilter)indexOf(textureFilterNames, 8, tuple + 1);
if (!readValue(&begin, end, &str)) return abortAtlas(self);
page->uWrap = SP_ATLAS_CLAMPTOEDGE;
page->vWrap = SP_ATLAS_CLAMPTOEDGE;
if (!equals(&str, "none")) {
if (str.end - str.begin == 1) {
if (*str.begin == 'x')
page->uWrap = SP_ATLAS_REPEAT;
else if (*str.begin == 'y')
page->vWrap = SP_ATLAS_REPEAT;
}
else if (equals(&str, "xy")) {
page->uWrap = SP_ATLAS_REPEAT;
page->vWrap = SP_ATLAS_REPEAT;
}
}
_spAtlasPage_createTexture(page, path);
FREE(path);
}
else {
spAtlasRegion *region = spAtlasRegion_create();
if (lastRegion)
lastRegion->next = region;
else
self->regions = region;
lastRegion = region;
region->page = page;
region->name = mallocString(&str);
if (!readValue(&begin, end, &str)) return abortAtlas(self);
region->rotate = equals(&str, "true");
if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self);
region->x = toInt(tuple);
region->y = toInt(tuple + 1);
if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self);
region->width = toInt(tuple);
region->height = toInt(tuple + 1);
region->u = region->x / (float)page->width;
region->v = region->y / (float)page->height;
if (region->rotate) {
region->u2 = (region->x + region->height) / (float)page->width;
region->v2 = (region->y + region->width) / (float)page->height;
}
else {
region->u2 = (region->x + region->width) / (float)page->width;
region->v2 = (region->y + region->height) / (float)page->height;
}
count = readTuple(&begin, end, tuple);
if (!count) return abortAtlas(self);
if (count == 4) { /* split is optional */
region->splits = MALLOC(int, 4);
region->splits[0] = toInt(tuple);
region->splits[1] = toInt(tuple + 1);
region->splits[2] = toInt(tuple + 2);
region->splits[3] = toInt(tuple + 3);
count = readTuple(&begin, end, tuple);
if (!count) return abortAtlas(self);
if (count == 4) { /* pad is optional, but only present with splits */
region->pads = MALLOC(int, 4);
region->pads[0] = toInt(tuple);
region->pads[1] = toInt(tuple + 1);
region->pads[2] = toInt(tuple + 2);
region->pads[3] = toInt(tuple + 3);
if (!readTuple(&begin, end, tuple)) return abortAtlas(self);
}
}
region->originalWidth = toInt(tuple);
region->originalHeight = toInt(tuple + 1);
readTuple(&begin, end, tuple);
region->offsetX = toInt(tuple);
region->offsetY = toInt(tuple + 1);
if (!readValue(&begin, end, &str)) return abortAtlas(self);
region->index = toInt(&str);
}
}
return self;
}
spAtlas* spAtlas_createFromFile(const char* path, void* rendererObject) {
int dirLength;
char *dir;
int length;
const char* data;
spAtlas* atlas = 0;
/* Get directory from atlas path. */
const char* lastForwardSlash = strrchr(path, '/');
const char* lastBackwardSlash = strrchr(path, '\\');
const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash;
if (lastSlash == path) lastSlash++; /* Never drop starting slash. */
dirLength = (int)(lastSlash ? lastSlash - path : 0);
dir = MALLOC(char, dirLength + 1);
memcpy(dir, path, dirLength);
dir[dirLength] = '\0';
data = _spUtil_readFile(path, &length);
if (data) atlas = spAtlas_create(data, length, dir, rendererObject);
FREE(data);
FREE(dir);
return atlas;
}
void spAtlas_dispose(spAtlas* self) {
spAtlasRegion* region, *nextRegion;
spAtlasPage* page = self->pages;
while (page) {
spAtlasPage* nextPage = page->next;
spAtlasPage_dispose(page);
page = nextPage;
}
region = self->regions;
while (region) {
nextRegion = region->next;
spAtlasRegion_dispose(region);
region = nextRegion;
}
FREE(self);
}
spAtlasRegion* spAtlas_findRegion(const spAtlas* self, const char* name) {
spAtlasRegion* region = self->regions;
while (region) {
if (strcmp(region->name, name) == 0) return region;
region = region->next;
}
return 0;
}
+357
View File
@@ -0,0 +1,357 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Atlas.h>
#include <spine/TextureLoader.h>
#include <spine/ContainerUtil.h>
#include <ctype.h>
using namespace spine;
Atlas::Atlas(const String &path, TextureLoader *textureLoader) : _textureLoader(textureLoader) {
int dirLength;
char *dir;
int length;
const char *data;
/* Get directory from atlas path. */
const char *lastForwardSlash = strrchr(path.buffer(), '/');
const char *lastBackwardSlash = strrchr(path.buffer(), '\\');
const char *lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash;
if (lastSlash == path) lastSlash++; /* Never drop starting slash. */
dirLength = (int) (lastSlash ? lastSlash - path.buffer() : 0);
dir = SpineExtension::calloc<char>(dirLength + 1, __FILE__, __LINE__);
memcpy(dir, path.buffer(), dirLength);
dir[dirLength] = '\0';
data = SpineExtension::readFile(path, &length);
if (data) {
load(data, length, dir);
}
SpineExtension::free(data, __FILE__, __LINE__);
SpineExtension::free(dir, __FILE__, __LINE__);
}
Atlas::Atlas(const char *data, int length, const char *dir, TextureLoader *textureLoader) : _textureLoader(
textureLoader) {
load(data, length, dir);
}
Atlas::~Atlas() {
if (_textureLoader) {
for (size_t i = 0, n = _pages.size(); i < n; ++i) {
_textureLoader->unload(_pages[i]->getRendererObject());
}
}
ContainerUtil::cleanUpVectorOfPointers(_pages);
ContainerUtil::cleanUpVectorOfPointers(_regions);
}
void Atlas::flipV() {
for (size_t i = 0, n = _regions.size(); i < n; ++i) {
AtlasRegion *regionP = _regions[i];
AtlasRegion &region = *regionP;
region.v = 1 - region.v;
region.v2 = 1 - region.v2;
}
}
AtlasRegion *Atlas::findRegion(const String &name) {
for (size_t i = 0, n = _regions.size(); i < n; ++i) {
if (_regions[i]->name == name) {
return _regions[i];
}
}
return NULL;
}
Vector<AtlasPage*> &Atlas::getPages() {
return _pages;
}
void Atlas::load(const char *begin, int length, const char *dir) {
static const char *formatNames[] = {"", "Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888",
"RGBA8888"};
static const char *textureFilterNames[] = {"", "Nearest", "Linear", "MipMap", "MipMapNearestNearest",
"MipMapLinearNearest",
"MipMapNearestLinear", "MipMapLinearLinear"};
int count;
const char *end = begin + length;
int dirLength = (int) strlen(dir);
int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\';
AtlasPage *page = NULL;
Str str;
Str tuple[4];
while (readLine(&begin, end, &str)) {
if (str.end - str.begin == 0) {
page = 0;
} else if (!page) {
char *name = mallocString(&str);
char *path = SpineExtension::calloc<char>(dirLength + needsSlash + strlen(name) + 1, __FILE__, __LINE__);
memcpy(path, dir, dirLength);
if (needsSlash) {
path[dirLength] = '/';
}
strcpy(path + dirLength + needsSlash, name);
page = new(__FILE__, __LINE__) AtlasPage(String(name, true));
int tupleVal = readTuple(&begin, end, tuple);
assert(tupleVal == 2);
/* size is only optional for an atlas packed with an old TexturePacker. */
page->width = toInt(tuple);
page->height = toInt(tuple + 1);
readTuple(&begin, end, tuple);
page->format = (Format) indexOf(formatNames, 8, tuple);
readTuple(&begin, end, tuple);
page->minFilter = (TextureFilter) indexOf(textureFilterNames, 8, tuple);
page->magFilter = (TextureFilter) indexOf(textureFilterNames, 8, tuple + 1);
readValue(&begin, end, &str);
page->uWrap = TextureWrap_ClampToEdge;
page->vWrap = TextureWrap_ClampToEdge;
if (!equals(&str, "none")) {
if (str.end - str.begin == 1) {
if (*str.begin == 'x') {
page->uWrap = TextureWrap_Repeat;
} else if (*str.begin == 'y') {
page->vWrap = TextureWrap_Repeat;
}
} else if (equals(&str, "xy")) {
page->uWrap = TextureWrap_Repeat;
page->vWrap = TextureWrap_Repeat;
}
}
if (_textureLoader) _textureLoader->load(*page, String(path));
SpineExtension::free(path, __FILE__, __LINE__);
_pages.add(page);
} else {
AtlasRegion *region = new(__FILE__, __LINE__) AtlasRegion();
region->page = page;
region->name = String(mallocString(&str), true);
readValue(&begin, end, &str);
region->rotate = equals(&str, "true") ? true : false;
readTuple(&begin, end, tuple);
region->x = toInt(tuple);
region->y = toInt(tuple + 1);
readTuple(&begin, end, tuple);
region->width = toInt(tuple);
region->height = toInt(tuple + 1);
region->u = region->x / (float) page->width;
region->v = region->y / (float) page->height;
if (region->rotate) {
region->u2 = (region->x + region->height) / (float) page->width;
region->v2 = (region->y + region->width) / (float) page->height;
} else {
region->u2 = (region->x + region->width) / (float) page->width;
region->v2 = (region->y + region->height) / (float) page->height;
}
count = readTuple(&begin, end, tuple);
assert(count);
if (count == 4) {
/* split is optional */
region->splits.setSize(4, 0);
region->splits[0] = toInt(tuple);
region->splits[1] = toInt(tuple + 1);
region->splits[2] = toInt(tuple + 2);
region->splits[3] = toInt(tuple + 3);
count = readTuple(&begin, end, tuple);
assert(count);
if (count == 4) {
/* pad is optional, but only present with splits */
region->pads.setSize(4, 0);
region->pads[0] = toInt(tuple);
region->pads[1] = toInt(tuple + 1);
region->pads[2] = toInt(tuple + 2);
region->pads[3] = toInt(tuple + 3);
readTuple(&begin, end, tuple);
}
}
region->originalWidth = toInt(tuple);
region->originalHeight = toInt(tuple + 1);
readTuple(&begin, end, tuple);
region->offsetX = (float)toInt(tuple);
region->offsetY = (float)toInt(tuple + 1);
readValue(&begin, end, &str);
region->index = toInt(&str);
_regions.add(region);
}
}
}
void Atlas::trim(Str *str) {
while (isspace((unsigned char) *str->begin) && str->begin < str->end) {
(str->begin)++;
}
if (str->begin == str->end) {
return;
}
str->end--;
while (((unsigned char)*str->end == '\r') && str->end >= str->begin) {
str->end--;
}
str->end++;
}
int Atlas::readLine(const char **begin, const char *end, Str *str) {
if (*begin == end) {
return 0;
}
str->begin = *begin;
/* Find next delimiter. */
while (*begin != end && **begin != '\n') {
(*begin)++;
}
str->end = *begin;
trim(str);
if (*begin != end) {
(*begin)++;
}
return 1;
}
int Atlas::beginPast(Str *str, char c) {
const char *begin = str->begin;
while (true) {
char lastSkippedChar = *begin;
if (begin == str->end) {
return 0;
}
begin++;
if (lastSkippedChar == c) {
break;
}
}
str->begin = begin;
return 1;
}
int Atlas::readValue(const char **begin, const char *end, Str *str) {
readLine(begin, end, str);
if (!beginPast(str, ':')) {
return 0;
}
trim(str);
return 1;
}
int Atlas::readTuple(const char **begin, const char *end, Str tuple[]) {
int i;
Str str = {NULL, NULL};
readLine(begin, end, &str);
if (!beginPast(&str, ':')) {
return 0;
}
for (i = 0; i < 3; ++i) {
tuple[i].begin = str.begin;
if (!beginPast(&str, ',')) {
break;
}
tuple[i].end = str.begin - 2;
trim(&tuple[i]);
}
tuple[i].begin = str.begin;
tuple[i].end = str.end;
trim(&tuple[i]);
return i + 1;
}
char *Atlas::mallocString(Str *str) {
int length = (int) (str->end - str->begin);
char *string = SpineExtension::calloc<char>(length + 1, __FILE__, __LINE__);
memcpy(string, str->begin, length);
string[length] = '\0';
return string;
}
int Atlas::indexOf(const char **array, int count, Str *str) {
int length = (int) (str->end - str->begin);
int i;
for (i = count - 1; i >= 0; i--) {
if (strncmp(array[i], str->begin, length) == 0) {
return i;
}
}
return 0;
}
int Atlas::equals(Str *str, const char *other) {
return strncmp(other, str->begin, str->end - str->begin) == 0;
}
int Atlas::toInt(Str *str) {
return (int) strtol(str->begin, (char **) &str->end, 10);
}
+159 -174
View File
@@ -1,174 +1,159 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ATLAS_H_
#define SPINE_ATLAS_H_
#include <spine/dll.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spAtlas spAtlas;
typedef enum {
SP_ATLAS_UNKNOWN_FORMAT,
SP_ATLAS_ALPHA,
SP_ATLAS_INTENSITY,
SP_ATLAS_LUMINANCE_ALPHA,
SP_ATLAS_RGB565,
SP_ATLAS_RGBA4444,
SP_ATLAS_RGB888,
SP_ATLAS_RGBA8888
} spAtlasFormat;
typedef enum {
SP_ATLAS_UNKNOWN_FILTER,
SP_ATLAS_NEAREST,
SP_ATLAS_LINEAR,
SP_ATLAS_MIPMAP,
SP_ATLAS_MIPMAP_NEAREST_NEAREST,
SP_ATLAS_MIPMAP_LINEAR_NEAREST,
SP_ATLAS_MIPMAP_NEAREST_LINEAR,
SP_ATLAS_MIPMAP_LINEAR_LINEAR
} spAtlasFilter;
typedef enum {
SP_ATLAS_MIRROREDREPEAT,
SP_ATLAS_CLAMPTOEDGE,
SP_ATLAS_REPEAT
} spAtlasWrap;
typedef struct spAtlasPage spAtlasPage;
struct spAtlasPage {
const spAtlas* atlas;
const char* name;
spAtlasFormat format;
spAtlasFilter minFilter, magFilter;
spAtlasWrap uWrap, vWrap;
void* rendererObject;
int width, height;
spAtlasPage* next;
};
SP_API spAtlasPage* spAtlasPage_create (spAtlas* atlas, const char* name);
SP_API void spAtlasPage_dispose (spAtlasPage* self);
#ifdef SPINE_SHORT_NAMES
typedef spAtlasFormat AtlasFormat;
#define ATLAS_UNKNOWN_FORMAT SP_ATLAS_UNKNOWN_FORMAT
#define ATLAS_ALPHA SP_ATLAS_ALPHA
#define ATLAS_INTENSITY SP_ATLAS_INTENSITY
#define ATLAS_LUMINANCE_ALPHA SP_ATLAS_LUMINANCE_ALPHA
#define ATLAS_RGB565 SP_ATLAS_RGB565
#define ATLAS_RGBA4444 SP_ATLAS_RGBA4444
#define ATLAS_RGB888 SP_ATLAS_RGB888
#define ATLAS_RGBA8888 SP_ATLAS_RGBA8888
typedef spAtlasFilter AtlasFilter;
#define ATLAS_UNKNOWN_FILTER SP_ATLAS_UNKNOWN_FILTER
#define ATLAS_NEAREST SP_ATLAS_NEAREST
#define ATLAS_LINEAR SP_ATLAS_LINEAR
#define ATLAS_MIPMAP SP_ATLAS_MIPMAP
#define ATLAS_MIPMAP_NEAREST_NEAREST SP_ATLAS_MIPMAP_NEAREST_NEAREST
#define ATLAS_MIPMAP_LINEAR_NEAREST SP_ATLAS_MIPMAP_LINEAR_NEAREST
#define ATLAS_MIPMAP_NEAREST_LINEAR SP_ATLAS_MIPMAP_NEAREST_LINEAR
#define ATLAS_MIPMAP_LINEAR_LINEAR SP_ATLAS_MIPMAP_LINEAR_LINEAR
typedef spAtlasWrap AtlasWrap;
#define ATLAS_MIRROREDREPEAT SP_ATLAS_MIRROREDREPEAT
#define ATLAS_CLAMPTOEDGE SP_ATLAS_CLAMPTOEDGE
#define ATLAS_REPEAT SP_ATLAS_REPEAT
typedef spAtlasPage AtlasPage;
#define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__)
#define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__)
#endif
/**/
typedef struct spAtlasRegion spAtlasRegion;
struct spAtlasRegion {
const char* name;
int x, y, width, height;
float u, v, u2, v2;
int offsetX, offsetY;
int originalWidth, originalHeight;
int index;
int/*bool*/rotate;
int/*bool*/flip;
int* splits;
int* pads;
spAtlasPage* page;
spAtlasRegion* next;
};
SP_API spAtlasRegion* spAtlasRegion_create ();
SP_API void spAtlasRegion_dispose (spAtlasRegion* self);
#ifdef SPINE_SHORT_NAMES
typedef spAtlasRegion AtlasRegion;
#define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__)
#define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__)
#endif
/**/
struct spAtlas {
spAtlasPage* pages;
spAtlasRegion* regions;
void* rendererObject;
};
/* Image files referenced in the atlas file will be prefixed with dir. */
SP_API spAtlas* spAtlas_create (const char* data, int length, const char* dir, void* rendererObject);
/* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */
SP_API spAtlas* spAtlas_createFromFile (const char* path, void* rendererObject);
SP_API void spAtlas_dispose (spAtlas* atlas);
/* Returns 0 if the region was not found. */
SP_API spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name);
#ifdef SPINE_SHORT_NAMES
typedef spAtlas Atlas;
#define Atlas_create(...) spAtlas_create(__VA_ARGS__)
#define Atlas_createFromFile(...) spAtlas_createFromFile(__VA_ARGS__)
#define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__)
#define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ATLAS_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Atlas_h
#define Spine_Atlas_h
#include <spine/Vector.h>
#include <spine/Extension.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
#include <spine/HasRendererObject.h>
namespace spine {
enum Format {
Format_Alpha,
Format_Intensity,
Format_LuminanceAlpha,
Format_RGB565,
Format_RGBA4444,
Format_RGB888,
Format_RGBA8888
};
enum TextureFilter {
TextureFilter_Unknown,
TextureFilter_Nearest,
TextureFilter_Linear,
TextureFilter_MipMap,
TextureFilter_MipMapNearestNearest,
TextureFilter_MipMapLinearNearest,
TextureFilter_MipMapNearestLinear,
TextureFilter_MipMapLinearLinear
};
enum TextureWrap {
TextureWrap_MirroredRepeat,
TextureWrap_ClampToEdge,
TextureWrap_Repeat
};
class SP_API AtlasPage : public SpineObject, public HasRendererObject {
public:
String name;
Format format;
TextureFilter minFilter;
TextureFilter magFilter;
TextureWrap uWrap;
TextureWrap vWrap;
int width, height;
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
vWrap(TextureWrap_ClampToEdge) {
}
virtual ~AtlasPage() { }
};
class SP_API AtlasRegion : public SpineObject {
public:
AtlasPage *page;
String name;
int x, y, width, height;
float u, v, u2, v2;
float offsetX, offsetY;
int originalWidth, originalHeight;
int index;
bool rotate;
Vector<int> splits;
Vector<int> pads;
};
class TextureLoader;
class SP_API Atlas : public SpineObject {
public:
Atlas(const String &path, TextureLoader *textureLoader);
Atlas(const char *data, int length, const char *dir, TextureLoader *textureLoader);
~Atlas();
void flipV();
/// Returns the first region found with the specified name. This method uses String comparison to find the region, so the result
/// should be cached rather than calling this method multiple times.
/// @return The region, or NULL.
AtlasRegion *findRegion(const String &name);
Vector<AtlasPage*> &getPages();
private:
Vector<AtlasPage *> _pages;
Vector<AtlasRegion *> _regions;
TextureLoader *_textureLoader;
void load(const char *begin, int length, const char *dir);
class Str {
public:
const char *begin;
const char *end;
};
static void trim(Str *str);
/// Tokenize string without modification. Returns 0 on failure
static int readLine(const char **begin, const char *end, Str *str);
/// Moves str->begin past the first occurence of c. Returns 0 on failure
static int beginPast(Str *str, char c);
/// Returns 0 on failure
static int readValue(const char **begin, const char *end, Str *str);
/// Returns the number of tuple values read (1, 2, 4, or 0 for failure)
static int readTuple(const char **begin, const char *end, Str tuple[]);
static char *mallocString(Str *str);
static int indexOf(const char **array, int count, Str *str);
static int equals(Str *str, const char *other);
static int toInt(Str *str);
static Atlas *abortAtlas(Atlas *atlas);
};
}
#endif /* Spine_Atlas_h */
@@ -1,100 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AtlasAttachmentLoader.h>
#include <spine/extension.h>
spAttachment* _spAtlasAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
const char* name, const char* path) {
spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader);
switch (type) {
case SP_ATTACHMENT_REGION: {
spRegionAttachment* attachment;
spAtlasRegion* region = spAtlas_findRegion(self->atlas, path);
if (!region) {
_spAttachmentLoader_setError(loader, "Region not found: ", path);
return 0;
}
attachment = spRegionAttachment_create(name);
attachment->rendererObject = region;
spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate);
attachment->regionOffsetX = region->offsetX;
attachment->regionOffsetY = region->offsetY;
attachment->regionWidth = region->width;
attachment->regionHeight = region->height;
attachment->regionOriginalWidth = region->originalWidth;
attachment->regionOriginalHeight = region->originalHeight;
return SUPER(attachment);
}
case SP_ATTACHMENT_MESH:
case SP_ATTACHMENT_LINKED_MESH: {
spMeshAttachment* attachment;
spAtlasRegion* region = spAtlas_findRegion(self->atlas, path);
if (!region) {
_spAttachmentLoader_setError(loader, "Region not found: ", path);
return 0;
}
attachment = spMeshAttachment_create(name);
attachment->rendererObject = region;
attachment->regionU = region->u;
attachment->regionV = region->v;
attachment->regionU2 = region->u2;
attachment->regionV2 = region->v2;
attachment->regionRotate = region->rotate;
attachment->regionOffsetX = region->offsetX;
attachment->regionOffsetY = region->offsetY;
attachment->regionWidth = region->width;
attachment->regionHeight = region->height;
attachment->regionOriginalWidth = region->originalWidth;
attachment->regionOriginalHeight = region->originalHeight;
return SUPER(SUPER(attachment));
}
case SP_ATTACHMENT_BOUNDING_BOX:
return SUPER(SUPER(spBoundingBoxAttachment_create(name)));
case SP_ATTACHMENT_PATH:
return SUPER(SUPER(spPathAttachment_create(name)));
case SP_ATTACHMENT_POINT:
return SUPER(SUPER(spPointAttachment_create(name)));
case SP_ATTACHMENT_CLIPPING:
return SUPER(SUPER(spClippingAttachment_create(name)));
default:
_spAttachmentLoader_setUnknownTypeError(loader, type);
return 0;
}
UNUSED(skin);
}
spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) {
spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader);
_spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_createAttachment, 0, 0);
self->atlas = atlas;
return self;
}
@@ -0,0 +1,129 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
******************************************************S**********************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/AtlasAttachmentLoader.h>
#include <spine/Skin.h>
#include <spine/RegionAttachment.h>
#include <spine/MeshAttachment.h>
#include <spine/BoundingBoxAttachment.h>
#include <spine/PathAttachment.h>
#include <spine/PointAttachment.h>
#include <spine/ClippingAttachment.h>
#include <spine/Atlas.h>
namespace spine {
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader)
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
}
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path) {
SP_UNUSED(skin);
AtlasRegion *regionP = findRegion(path);
if (!regionP) return NULL;
AtlasRegion &region = *regionP;
RegionAttachment *attachmentP = new(__FILE__, __LINE__) RegionAttachment(name);
RegionAttachment &attachment = *attachmentP;
attachment.setRendererObject(regionP);
attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate);
attachment._regionOffsetX = region.offsetX;
attachment._regionOffsetY = region.offsetY;
attachment._regionWidth = (float)region.width;
attachment._regionHeight = (float)region.height;
attachment._regionOriginalWidth = (float)region.originalWidth;
attachment._regionOriginalHeight = (float)region.originalHeight;
return attachmentP;
}
MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const String &name, const String &path) {
SP_UNUSED(skin);
AtlasRegion *regionP = findRegion(path);
if (!regionP) return NULL;
AtlasRegion &region = *regionP;
MeshAttachment *attachmentP = new(__FILE__, __LINE__) MeshAttachment(name);
MeshAttachment &attachment = *attachmentP;
attachment.setRendererObject(regionP);
attachment._regionU = region.u;
attachment._regionV = region.v;
attachment._regionU2 = region.u2;
attachment._regionV2 = region.v2;
attachment._regionRotate = region.rotate;
attachment._regionOffsetX = region.offsetX;
attachment._regionOffsetY = region.offsetY;
attachment._regionWidth = (float)region.width;
attachment._regionHeight = (float)region.height;
attachment._regionOriginalWidth = (float)region.originalWidth;
attachment._regionOriginalHeight = (float)region.originalHeight;
return attachmentP;
}
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) BoundingBoxAttachment(name);
}
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) PathAttachment(name);
}
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) PointAttachment(name);
}
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) ClippingAttachment(name);
}
void AtlasAttachmentLoader::configureAttachment(Attachment* attachment) {
SP_UNUSED(attachment);
}
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
return _atlas->findRegion(name);
}
}
@@ -1,58 +1,74 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ATLASATTACHMENTLOADER_H_
#define SPINE_ATLASATTACHMENTLOADER_H_
#include <spine/dll.h>
#include <spine/AttachmentLoader.h>
#include <spine/Atlas.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spAtlasAttachmentLoader {
spAttachmentLoader super;
spAtlas* atlas;
} spAtlasAttachmentLoader;
SP_API spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas);
#ifdef SPINE_SHORT_NAMES
typedef spAtlasAttachmentLoader AtlasAttachmentLoader;
#define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ATLASATTACHMENTLOADER_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_AtlasAttachmentLoader_h
#define Spine_AtlasAttachmentLoader_h
#include <spine/AttachmentLoader.h>
#include <spine/Vector.h>
#include <spine/SpineString.h>
namespace spine {
class Atlas;
class AtlasRegion;
///
/// An AttachmentLoader that configures attachments using texture regions from an Atlas.
/// See http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data about Loading Skeleton Data in the Spine Runtimes Guide.
///
class SP_API AtlasAttachmentLoader : public AttachmentLoader {
public:
RTTI_DECL
explicit AtlasAttachmentLoader(Atlas* atlas);
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path);
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path);
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name);
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name);
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name);
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
virtual void configureAttachment(Attachment* attachment);
AtlasRegion* findRegion(const String& name);
private:
Atlas* _atlas;
};
}
#endif /* Spine_AtlasAttachmentLoader_h */
@@ -0,0 +1,52 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Attachment.h>
#include <assert.h>
using namespace spine;
RTTI_IMPL_NOPARENT(Attachment)
Attachment::Attachment(const String &name) : _name(name) {
assert(_name.length() > 0);
}
Attachment::~Attachment() {
}
const String &Attachment::getName() const {
return _name;
}
+54 -83
View File
@@ -1,83 +1,54 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ATTACHMENT_H_
#define SPINE_ATTACHMENT_H_
#include <spine/dll.h>
#ifdef __cplusplus
extern "C" {
#endif
struct spAttachmentLoader;
typedef enum {
SP_ATTACHMENT_REGION,
SP_ATTACHMENT_BOUNDING_BOX,
SP_ATTACHMENT_MESH,
SP_ATTACHMENT_LINKED_MESH,
SP_ATTACHMENT_PATH,
SP_ATTACHMENT_POINT,
SP_ATTACHMENT_CLIPPING
} spAttachmentType;
typedef struct spAttachment {
const char* const name;
const spAttachmentType type;
const void* const vtable;
struct spAttachmentLoader* attachmentLoader;
#ifdef __cplusplus
spAttachment() :
name(0),
type(SP_ATTACHMENT_REGION),
vtable(0) {
}
#endif
} spAttachment;
void spAttachment_dispose (spAttachment* self);
#ifdef SPINE_SHORT_NAMES
typedef spAttachmentType AttachmentType;
#define ATTACHMENT_REGION SP_ATTACHMENT_REGION
#define ATTACHMENT_BOUNDING_BOX SP_ATTACHMENT_BOUNDING_BOX
#define ATTACHMENT_MESH SP_ATTACHMENT_MESH
#define ATTACHMENT_LINKED_MESH SP_ATTACHMENT_LINKED_MESH
typedef spAttachment Attachment;
#define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ATTACHMENT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Attachment_h
#define Spine_Attachment_h
#include <spine/RTTI.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class SP_API Attachment : public SpineObject {
RTTI_DECL
public:
explicit Attachment(const String &name);
virtual ~Attachment();
const String &getName() const;
private:
const String _name;
};
}
#endif /* Spine_Attachment_h */
@@ -1,98 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/AttachmentLoader.h>
#include <stdio.h>
#include <spine/extension.h>
typedef struct _spAttachmentLoaderVtable {
spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name,
const char* path);
void (*configureAttachment) (spAttachmentLoader* self, spAttachment*);
void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*);
void (*dispose) (spAttachmentLoader* self);
} _spAttachmentLoaderVtable;
void _spAttachmentLoader_init (spAttachmentLoader* self,
void (*dispose) (spAttachmentLoader* self),
spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name,
const char* path),
void (*configureAttachment) (spAttachmentLoader* self, spAttachment*),
void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*)
) {
CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable);
VTABLE(spAttachmentLoader, self)->dispose = dispose;
VTABLE(spAttachmentLoader, self)->createAttachment = createAttachment;
VTABLE(spAttachmentLoader, self)->configureAttachment = configureAttachment;
VTABLE(spAttachmentLoader, self)->disposeAttachment = disposeAttachment;
}
void _spAttachmentLoader_deinit (spAttachmentLoader* self) {
FREE(self->vtable);
FREE(self->error1);
FREE(self->error2);
}
void spAttachmentLoader_dispose (spAttachmentLoader* self) {
VTABLE(spAttachmentLoader, self)->dispose(self);
FREE(self);
}
spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name,
const char* path) {
FREE(self->error1);
FREE(self->error2);
self->error1 = 0;
self->error2 = 0;
return VTABLE(spAttachmentLoader, self)->createAttachment(self, skin, type, name, path);
}
void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment) {
if (!VTABLE(spAttachmentLoader, self)->configureAttachment) return;
VTABLE(spAttachmentLoader, self)->configureAttachment(self, attachment);
}
void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment) {
if (!VTABLE(spAttachmentLoader, self)->disposeAttachment) return;
VTABLE(spAttachmentLoader, self)->disposeAttachment(self, attachment);
}
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) {
FREE(self->error1);
FREE(self->error2);
MALLOC_STR(self->error1, error1);
MALLOC_STR(self->error2, error2);
}
void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) {
char buffer[16];
sprintf(buffer, "%d", type);
_spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer);
}
@@ -0,0 +1,53 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/AttachmentLoader.h>
#include <spine/Skin.h>
#include <spine/RegionAttachment.h>
#include <spine/MeshAttachment.h>
#include <spine/BoundingBoxAttachment.h>
#include <spine/PathAttachment.h>
#include <spine/PointAttachment.h>
#include <spine/ClippingAttachment.h>
using namespace spine;
RTTI_IMPL_NOPARENT(AttachmentLoader)
AttachmentLoader::AttachmentLoader() {
}
AttachmentLoader::~AttachmentLoader() {
}
@@ -1,79 +1,76 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_ATTACHMENTLOADER_H_
#define SPINE_ATTACHMENTLOADER_H_
#include <spine/dll.h>
#include <spine/Attachment.h>
#include <spine/Skin.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spAttachmentLoader {
const char* error1;
const char* error2;
const void* const vtable;
#ifdef __cplusplus
spAttachmentLoader () :
error1(0),
error2(0),
vtable(0) {
}
#endif
} spAttachmentLoader;
SP_API void spAttachmentLoader_dispose (spAttachmentLoader* self);
/* Called to create each attachment. Returns 0 to not load an attachment. If 0 is returned and _spAttachmentLoader_setError was
* called, an error occurred. */
SP_API spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name,
const char* path);
/* Called after the attachment has been fully configured. */
SP_API void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment);
/* Called just before the attachment is disposed. This can release allocations made in spAttachmentLoader_configureAttachment. */
SP_API void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment);
#ifdef SPINE_SHORT_NAMES
typedef spAttachmentLoader AttachmentLoader;
#define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__)
#define AttachmentLoader_createAttachment(...) spAttachmentLoader_createAttachment(__VA_ARGS__)
#define AttachmentLoader_configureAttachment(...) spAttachmentLoader_configureAttachment(__VA_ARGS__)
#define AttachmentLoader_disposeAttachment(...) spAttachmentLoader_disposeAttachment(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_ATTACHMENTLOADER_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_AttachmentLoader_h
#define Spine_AttachmentLoader_h
#include <spine/RTTI.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class Skin;
class Attachment;
class RegionAttachment;
class MeshAttachment;
class BoundingBoxAttachment;
class PathAttachment;
class PointAttachment;
class ClippingAttachment;
class SP_API AttachmentLoader : public SpineObject {
public:
RTTI_DECL
AttachmentLoader();
virtual ~AttachmentLoader();
/// @return May be NULL to not load any attachment.
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path) = 0;
/// @return May be NULL to not load any attachment.
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path) = 0;
/// @return May be NULL to not load any attachment.
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name) = 0;
/// @return May be NULL to not load any attachment
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name) = 0;
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
virtual void configureAttachment(Attachment* attachment) = 0;
};
}
#endif /* Spine_AttachmentLoader_h */
@@ -0,0 +1,125 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/AttachmentTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
using namespace spine;
RTTI_IMPL(AttachmentTimeline, Timeline)
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
_frames.ensureCapacity(frameCount);
_attachmentNames.ensureCapacity(frameCount);
_frames.setSize(frameCount, 0);
for (int i = 0; i < frameCount; ++i) {
_attachmentNames.add(String());
}
}
void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(alpha);
assert(_slotIndex < skeleton._slots.size());
String *attachmentName;
Slot *slotP = skeleton._slots[_slotIndex];
Slot &slot = *slotP;
if (direction == MixDirection_Out && blend == MixBlend_Setup) {
attachmentName = &slot._data._attachmentName;
slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName));
return;
}
if (time < _frames[0]) {
// Time is before first frame.
if (blend == MixBlend_Setup || blend == MixBlend_First) {
attachmentName = &slot._data._attachmentName;
slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName));
}
return;
}
size_t frameIndex;
if (time >= _frames[_frames.size() - 1]) {
// Time is after last frame.
frameIndex = _frames.size() - 1;
} else {
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
}
attachmentName = &_attachmentNames[frameIndex];
slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName));
}
int AttachmentTimeline::getPropertyId() {
return ((int) TimelineType_Attachment << 24) + _slotIndex;
}
void AttachmentTimeline::setFrame(int frameIndex, float time, const String &attachmentName) {
_frames[frameIndex] = time;
_attachmentNames[frameIndex] = attachmentName;
}
size_t AttachmentTimeline::getSlotIndex() {
return _slotIndex;
}
void AttachmentTimeline::setSlotIndex(size_t inValue) {
_slotIndex = inValue;
}
const Vector<float> &AttachmentTimeline::getFrames() {
return _frames;
}
const Vector<String> &AttachmentTimeline::getAttachmentNames() {
return _attachmentNames;
}
size_t AttachmentTimeline::getFrameCount() {
return _frames.size();
}
@@ -0,0 +1,74 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_AttachmentTimeline_h
#define Spine_AttachmentTimeline_h
#include <spine/Timeline.h>
#include <spine/SpineObject.h>
#include <spine/Vector.h>
#include <spine/MixBlend.h>
#include <spine/MixDirection.h>
#include <spine/SpineString.h>
namespace spine {
class Skeleton;
class Event;
class SP_API AttachmentTimeline : public Timeline {
friend class SkeletonBinary;
friend class SkeletonJson;
RTTI_DECL
public:
explicit AttachmentTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
virtual int getPropertyId();
/// Sets the time and value of the specified keyframe.
void setFrame(int frameIndex, float time, const String& attachmentName);
size_t getSlotIndex();
void setSlotIndex(size_t inValue);
const Vector<float>& getFrames();
const Vector<String>& getAttachmentNames();
size_t getFrameCount();
private:
size_t _slotIndex;
Vector<float> _frames;
Vector<String> _attachmentNames;
};
}
#endif /* Spine_AttachmentTimeline_h */
@@ -0,0 +1,46 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_AttachmentType_h
#define Spine_AttachmentType_h
namespace spine {
enum AttachmentType {
AttachmentType_Region,
AttachmentType_Boundingbox,
AttachmentType_Mesh,
AttachmentType_Linkedmesh,
AttachmentType_Path,
AttachmentType_Point,
AttachmentType_Clipping
};
}
#endif /* Spine_AttachmentType_h */
@@ -1,44 +1,43 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/Event.h>
#include <spine/extension.h>
spEvent* spEvent_create (float time, spEventData* data) {
spEvent* self = NEW(spEvent);
CONST_CAST(spEventData*, self->data) = data;
CONST_CAST(float, self->time) = time;
return self;
}
void spEvent_dispose (spEvent* self) {
FREE(self->stringValue);
FREE(self);
}
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_BlendMode_h
#define Spine_BlendMode_h
namespace spine {
enum BlendMode {
BlendMode_Normal = 0,
BlendMode_Additive,
BlendMode_Multiply,
BlendMode_Screen
};
}
#endif /* Spine_BlendMode_h */
-304
View File
@@ -1,304 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/Bone.h>
#include <spine/extension.h>
#include <stdio.h>
static int yDown;
void spBone_setYDown (int value) {
yDown = value;
}
int spBone_isYDown () {
return yDown;
}
spBone* spBone_create (spBoneData* data, spSkeleton* skeleton, spBone* parent) {
spBone* self = NEW(spBone);
CONST_CAST(spBoneData*, self->data) = data;
CONST_CAST(spSkeleton*, self->skeleton) = skeleton;
CONST_CAST(spBone*, self->parent) = parent;
CONST_CAST(float, self->a) = 1.0f;
CONST_CAST(float, self->d) = 1.0f;
spBone_setToSetupPose(self);
return self;
}
void spBone_dispose (spBone* self) {
FREE(self->children);
FREE(self);
}
void spBone_updateWorldTransform (spBone* self) {
spBone_updateWorldTransformWith(self, self->x, self->y, self->rotation, self->scaleX, self->scaleY, self->shearX, self->shearY);
}
void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
float cosine, sine;
float pa, pb, pc, pd;
spBone* parent = self->parent;
self->ax = x;
self->ay = y;
self->arotation = rotation;
self->ascaleX = scaleX;
self->ascaleY = scaleY;
self->ashearX = shearX;
self->ashearY = shearY;
self->appliedValid = 1;
if (!parent) { /* Root bone. */
float rotationY = rotation + 90 + shearY;
float la = COS_DEG(rotation + shearX) * scaleX;
float lb = COS_DEG(rotationY) * scaleY;
float lc = SIN_DEG(rotation + shearX) * scaleX;
float ld = SIN_DEG(rotationY) * scaleY;
if (self->skeleton->flipX) {
x = -x;
la = -la;
lb = -lb;
}
if (self->skeleton->flipY != yDown) {
y = -y;
lc = -lc;
ld = -ld;
}
CONST_CAST(float, self->a) = la;
CONST_CAST(float, self->b) = lb;
CONST_CAST(float, self->c) = lc;
CONST_CAST(float, self->d) = ld;
CONST_CAST(float, self->worldX) = x + self->skeleton->x;
CONST_CAST(float, self->worldY) = y + self->skeleton->y;
return;
}
pa = parent->a;
pb = parent->b;
pc = parent->c;
pd = parent->d;
CONST_CAST(float, self->worldX) = pa * x + pb * y + parent->worldX;
CONST_CAST(float, self->worldY) = pc * x + pd * y + parent->worldY;
switch (self->data->transformMode) {
case SP_TRANSFORMMODE_NORMAL: {
float rotationY = rotation + 90 + shearY;
float la = COS_DEG(rotation + shearX) * scaleX;
float lb = COS_DEG(rotationY) * scaleY;
float lc = SIN_DEG(rotation + shearX) * scaleX;
float ld = SIN_DEG(rotationY) * scaleY;
CONST_CAST(float, self->a) = pa * la + pb * lc;
CONST_CAST(float, self->b) = pa * lb + pb * ld;
CONST_CAST(float, self->c) = pc * la + pd * lc;
CONST_CAST(float, self->d) = pc * lb + pd * ld;
return;
}
case SP_TRANSFORMMODE_ONLYTRANSLATION: {
float rotationY = rotation + 90 + shearY;
CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX;
CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY;
CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX;
CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY;
break;
}
case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
float s = pa * pa + pc * pc;
float prx, rx, ry, la, lb, lc, ld;
if (s > 0.0001f) {
s = ABS(pa * pd - pb * pc) / s;
pb = pc * s;
pd = pa * s;
prx = ATAN2(pc, pa) * RAD_DEG;
} else {
pa = 0;
pc = 0;
prx = 90 - ATAN2(pd, pb) * RAD_DEG;
}
rx = rotation + shearX - prx;
ry = rotation + shearY - prx + 90;
la = COS_DEG(rx) * scaleX;
lb = COS_DEG(ry) * scaleY;
lc = SIN_DEG(rx) * scaleX;
ld = SIN_DEG(ry) * scaleY;
CONST_CAST(float, self->a) = pa * la - pb * lc;
CONST_CAST(float, self->b) = pa * lb - pb * ld;
CONST_CAST(float, self->c) = pc * la + pd * lc;
CONST_CAST(float, self->d) = pc * lb + pd * ld;
break;
}
case SP_TRANSFORMMODE_NOSCALE:
case SP_TRANSFORMMODE_NOSCALEORREFLECTION: {
float za, zc, s;
float r, zb, zd, la, lb, lc, ld;
cosine = COS_DEG(rotation); sine = SIN_DEG(rotation);
za = pa * cosine + pb * sine;
zc = pc * cosine + pd * sine;
s = SQRT(za * za + zc * zc);
if (s > 0.00001f) s = 1 / s;
za *= s;
zc *= s;
s = SQRT(za * za + zc * zc);
r = PI / 2 + atan2(zc, za);
zb = COS(r) * s;
zd = SIN(r) * s;
la = COS_DEG(shearX) * scaleX;
lb = COS_DEG(90 + shearY) * scaleY;
lc = SIN_DEG(shearX) * scaleX;
ld = SIN_DEG(90 + shearY) * scaleY;
if (self->data->transformMode != SP_TRANSFORMMODE_NOSCALEORREFLECTION ? pa * pd - pb * pc < 0 : self->skeleton->flipX != self->skeleton->flipY) {
zb = -zb;
zd = -zd;
}
CONST_CAST(float, self->a) = za * la + zb * lc;
CONST_CAST(float, self->b) = za * lb + zb * ld;
CONST_CAST(float, self->c) = zc * la + zd * lc;
CONST_CAST(float, self->d) = zc * lb + zd * ld;
return;
}
}
if (self->skeleton->flipX) {
CONST_CAST(float, self->a) = -self->a;
CONST_CAST(float, self->b) = -self->b;
}
if (self->skeleton->flipY != yDown) {
CONST_CAST(float, self->c) = -self->c;
CONST_CAST(float, self->d) = -self->d;
}
}
void spBone_setToSetupPose (spBone* self) {
self->x = self->data->x;
self->y = self->data->y;
self->rotation = self->data->rotation;
self->scaleX = self->data->scaleX;
self->scaleY = self->data->scaleY;
self->shearX = self->data->shearX;
self->shearY = self->data->shearY;
}
float spBone_getWorldRotationX (spBone* self) {
return ATAN2(self->c, self->a) * RAD_DEG;
}
float spBone_getWorldRotationY (spBone* self) {
return ATAN2(self->d, self->b) * RAD_DEG;
}
float spBone_getWorldScaleX (spBone* self) {
return SQRT(self->a * self->a + self->c * self->c);
}
float spBone_getWorldScaleY (spBone* self) {
return SQRT(self->b * self->b + self->d * self->d);
}
/** Computes the individual applied transform values from the world transform. This can be useful to perform processing using
* the applied transform after the world transform has been modified directly (eg, by a constraint).
* <p>
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
void spBone_updateAppliedTransform (spBone* self) {
spBone* parent = self->parent;
self->appliedValid = 1;
if (!parent) {
self->ax = self->worldX;
self->ay = self->worldY;
self->arotation = ATAN2(self->c, self->a) * RAD_DEG;
self->ascaleX = SQRT(self->a * self->a + self->c * self->c);
self->ascaleY = SQRT(self->b * self->b + self->d * self->d);
self->ashearX = 0;
self->ashearY = ATAN2(self->a * self->b + self->c * self->d, self->a * self->d - self->b * self->c) * RAD_DEG;
} else {
float pa = parent->a, pb = parent->b, pc = parent->c, pd = parent->d;
float pid = 1 / (pa * pd - pb * pc);
float dx = self->worldX - parent->worldX, dy = self->worldY - parent->worldY;
float ia = pid * pd;
float id = pid * pa;
float ib = pid * pb;
float ic = pid * pc;
float ra = ia * self->a - ib * self->c;
float rb = ia * self->b - ib * self->d;
float rc = id * self->c - ic * self->a;
float rd = id * self->d - ic * self->b;
self->ax = (dx * pd * pid - dy * pb * pid);
self->ay = (dy * pa * pid - dx * pc * pid);
self->ashearX = 0;
self->ascaleX = SQRT(ra * ra + rc * rc);
if (self->ascaleX > 0.0001f) {
float det = ra * rd - rb * rc;
self->ascaleY = det / self->ascaleX;
self->ashearY = ATAN2(ra * rb + rc * rd, det) * RAD_DEG;
self->arotation = ATAN2(rc, ra) * RAD_DEG;
} else {
self->ascaleX = 0;
self->ascaleY = SQRT(rb * rb + rd * rd);
self->ashearY = 0;
self->arotation = 90 - ATAN2(rd, rb) * RAD_DEG;
}
}
}
void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY) {
float a = self->a, b = self->b, c = self->c, d = self->d;
float invDet = 1 / (a * d - b * c);
float x = worldX - self->worldX, y = worldY - self->worldY;
*localX = (x * d * invDet - y * b * invDet);
*localY = (y * a * invDet - x * c * invDet);
}
void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY) {
float x = localX, y = localY;
*worldX = x * self->a + y * self->b + self->worldX;
*worldY = x * self->c + y * self->d + self->worldY;
}
float spBone_worldToLocalRotation (spBone* self, float worldRotation) {
float sine, cosine;
sine = SIN_DEG(worldRotation);
cosine = COS_DEG(worldRotation);
return ATAN2(self->a * sine - self->c * cosine, self->d * cosine - self->b * sine) * RAD_DEG;
}
float spBone_localToWorldRotation (spBone* self, float localRotation) {
float sine, cosine;
sine = SIN_DEG(localRotation);
cosine = COS_DEG(localRotation);
return ATAN2(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b) * RAD_DEG;
}
void spBone_rotateWorld (spBone* self, float degrees) {
float a = self->a, b = self->b, c = self->c, d = self->d;
float cosine = COS_DEG(degrees), sine = SIN_DEG(degrees);
CONST_CAST(float, self->a) = cosine * a - sine * c;
CONST_CAST(float, self->b) = cosine * b - sine * d;
CONST_CAST(float, self->c) = sine * a + cosine * c;
CONST_CAST(float, self->d) = sine * b + cosine * d;
CONST_CAST(int, self->appliedValid) = 0;
}
+541
View File
@@ -0,0 +1,541 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Bone.h>
#include <spine/BoneData.h>
#include <spine/Skeleton.h>
using namespace spine;
RTTI_IMPL(Bone, Updatable)
bool Bone::yDown = false;
void Bone::setYDown(bool inValue) {
yDown = inValue;
}
bool Bone::isYDown() {
return yDown;
}
Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
_data(data),
_skeleton(skeleton),
_parent(parent),
_x(0),
_y(0),
_rotation(0),
_scaleX(0),
_scaleY(0),
_shearX(0),
_shearY(0),
_ax(0),
_ay(0),
_arotation(0),
_ascaleX(0),
_ascaleY(0),
_ashearX(0),
_ashearY(0),
_appliedValid(false),
_a(1),
_b(0),
_worldX(0),
_c(0),
_d(1),
_worldY(0),
_sorted(false) {
setToSetupPose();
}
void Bone::update() {
updateWorldTransform(_x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY);
}
void Bone::updateWorldTransform() {
updateWorldTransform(_x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY);
}
void
Bone::updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
float cosine, sine;
float pa, pb, pc, pd;
Bone *parent = _parent;
_ax = x;
_ay = y;
_arotation = rotation;
_ascaleX = scaleX;
_ascaleY = scaleY;
_ashearX = shearX;
_ashearY = shearY;
_appliedValid = true;
if (!parent) { /* Root bone. */
float rotationY = rotation + 90 + shearY;
float sx = _skeleton.getScaleX();
float sy = _skeleton.getScaleY();
_a = MathUtil::cosDeg(rotation + shearX) * scaleX * sx;
_b = MathUtil::cosDeg(rotationY) * scaleY * sy;
_c = MathUtil::sinDeg(rotation + shearX) * scaleX * sx;
_d = MathUtil::sinDeg(rotationY) * scaleY * sy;
_worldX = x * sx + _skeleton.getX();
_worldY = y * sy + _skeleton.getY();
return;
}
pa = parent->_a;
pb = parent->_b;
pc = parent->_c;
pd = parent->_d;
_worldX = pa * x + pb * y + parent->_worldX;
_worldY = pc * x + pd * y + parent->_worldY;
switch (_data.getTransformMode()) {
case TransformMode_Normal: {
float rotationY = rotation + 90 + shearY;
float la = MathUtil::cosDeg(rotation + shearX) * scaleX;
float lb = MathUtil::cosDeg(rotationY) * scaleY;
float lc = MathUtil::sinDeg(rotation + shearX) * scaleX;
float ld = MathUtil::sinDeg(rotationY) * scaleY;
_a = pa * la + pb * lc;
_b = pa * lb + pb * ld;
_c = pc * la + pd * lc;
_d = pc * lb + pd * ld;
return;
}
case TransformMode_OnlyTranslation: {
float rotationY = rotation + 90 + shearY;
_a = MathUtil::cosDeg(rotation + shearX) * scaleX;
_b = MathUtil::cosDeg(rotationY) * scaleY;
_c = MathUtil::sinDeg(rotation + shearX) * scaleX;
_d = MathUtil::sinDeg(rotationY) * scaleY;
break;
}
case TransformMode_NoRotationOrReflection: {
float s = pa * pa + pc * pc;
float prx, rx, ry, la, lb, lc, ld;
if (s > 0.0001f) {
s = MathUtil::abs(pa * pd - pb * pc) / s;
pb = pc * s;
pd = pa * s;
prx = MathUtil::atan2(pc, pa) * MathUtil::Rad_Deg;
} else {
pa = 0;
pc = 0;
prx = 90 - MathUtil::atan2(pd, pb) * MathUtil::Rad_Deg;
}
rx = rotation + shearX - prx;
ry = rotation + shearY - prx + 90;
la = MathUtil::cosDeg(rx) * scaleX;
lb = MathUtil::cosDeg(ry) * scaleY;
lc = MathUtil::sinDeg(rx) * scaleX;
ld = MathUtil::sinDeg(ry) * scaleY;
_a = pa * la - pb * lc;
_b = pa * lb - pb * ld;
_c = pc * la + pd * lc;
_d = pc * lb + pd * ld;
break;
}
case TransformMode_NoScale:
case TransformMode_NoScaleOrReflection: {
float za, zc, s;
float r, zb, zd, la, lb, lc, ld;
cosine = MathUtil::cosDeg(rotation);
sine = MathUtil::sinDeg(rotation);
za = (pa * cosine + pb * sine) / _skeleton.getScaleX();
zc = (pc * cosine + pd * sine) / _skeleton.getScaleY();
s = MathUtil::sqrt(za * za + zc * zc);
if (s > 0.00001f) s = 1 / s;
za *= s;
zc *= s;
s = MathUtil::sqrt(za * za + zc * zc);
if (_data.getTransformMode() == TransformMode_NoScale
&& (pa * pd - pb * pc < 0) != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0))
s = -s;
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
zb = MathUtil::cos(r) * s;
zd = MathUtil::sin(r) * s;
la = MathUtil::cosDeg(shearX) * scaleX;
lb = MathUtil::cosDeg(90 + shearY) * scaleY;
lc = MathUtil::sinDeg(shearX) * scaleX;
ld = MathUtil::sinDeg(90 + shearY) * scaleY;
_a = za * la + zb * lc;
_b = za * lb + zb * ld;
_c = zc * la + zd * lc;
_d = zc * lb + zd * ld;
break;
}
}
_a *= _skeleton.getScaleX();
_b *= _skeleton.getScaleX();
_c *= _skeleton.getScaleY();
_d *= _skeleton.getScaleY();
}
void Bone::setToSetupPose() {
BoneData &data = _data;
_x = data.getX();
_y = data.getY();
_rotation = data.getRotation();
_scaleX = data.getScaleX();
_scaleY = data.getScaleY();
_shearX = data.getShearX();
_shearY = data.getShearY();
}
void Bone::worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY) {
float a = _a;
float b = _b;
float c = _c;
float d = _d;
float invDet = 1 / (a * d - b * c);
float x = worldX - _worldX;
float y = worldY - _worldY;
outLocalX = (x * d * invDet - y * b * invDet);
outLocalY = (y * a * invDet - x * c * invDet);
}
void Bone::localToWorld(float localX, float localY, float &outWorldX, float &outWorldY) {
outWorldX = localX * _a + localY * _b + _worldX;
outWorldY = localX * _c + localY * _d + _worldY;
}
float Bone::worldToLocalRotation(float worldRotation) {
float sin = MathUtil::sinDeg(worldRotation);
float cos = MathUtil::cosDeg(worldRotation);
return MathUtil::atan2(_a * sin - _c * cos, _d * cos - _b * sin) * MathUtil::Rad_Deg + this->_rotation - this->_shearX;
}
float Bone::localToWorldRotation(float localRotation) {
localRotation -= this->_rotation - this->_shearX;
float sin = MathUtil::sinDeg(localRotation);
float cos = MathUtil::cosDeg(localRotation);
return MathUtil::atan2(cos * _c + sin * _d, cos * _a + sin * _b) * MathUtil::Rad_Deg;
}
void Bone::rotateWorld(float degrees) {
float a = _a;
float b = _b;
float c = _c;
float d = _d;
float cos = MathUtil::cosDeg(degrees);
float sin = MathUtil::sinDeg(degrees);
_a = cos * a - sin * c;
_b = cos * b - sin * d;
_c = sin * a + cos * c;
_d = sin * b + cos * d;
_appliedValid = false;
}
float Bone::getWorldToLocalRotationX() {
Bone *parent = _parent;
if (!parent) {
return _arotation;
}
float pa = parent->_a;
float pb = parent->_b;
float pc = parent->_c;
float pd = parent->_d;
float a = _a;
float c = _c;
return MathUtil::atan2(pa * c - pc * a, pd * a - pb * c) * MathUtil::Rad_Deg;
}
float Bone::getWorldToLocalRotationY() {
Bone *parent = _parent;
if (!parent) {
return _arotation;
}
float pa = parent->_a;
float pb = parent->_b;
float pc = parent->_c;
float pd = parent->_d;
float b = _b;
float d = _d;
return MathUtil::atan2(pa * d - pc * b, pd * b - pb * d) * MathUtil::Rad_Deg;
}
BoneData &Bone::getData() {
return _data;
}
Skeleton &Bone::getSkeleton() {
return _skeleton;
}
Bone *Bone::getParent() {
return _parent;
}
Vector<Bone *> &Bone::getChildren() {
return _children;
}
float Bone::getX() {
return _x;
}
void Bone::setX(float inValue) {
_x = inValue;
}
float Bone::getY() {
return _y;
}
void Bone::setY(float inValue) {
_y = inValue;
}
float Bone::getRotation() {
return _rotation;
}
void Bone::setRotation(float inValue) {
_rotation = inValue;
}
float Bone::getScaleX() {
return _scaleX;
}
void Bone::setScaleX(float inValue) {
_scaleX = inValue;
}
float Bone::getScaleY() {
return _scaleY;
}
void Bone::setScaleY(float inValue) {
_scaleY = inValue;
}
float Bone::getShearX() {
return _shearX;
}
void Bone::setShearX(float inValue) {
_shearX = inValue;
}
float Bone::getShearY() {
return _shearY;
}
void Bone::setShearY(float inValue) {
_shearY = inValue;
}
float Bone::getAppliedRotation() {
return _arotation;
}
void Bone::setAppliedRotation(float inValue) {
_arotation = inValue;
}
float Bone::getAX() {
return _ax;
}
void Bone::setAX(float inValue) {
_ax = inValue;
}
float Bone::getAY() {
return _ay;
}
void Bone::setAY(float inValue) {
_ay = inValue;
}
float Bone::getAScaleX() {
return _ascaleX;
}
void Bone::setAScaleX(float inValue) {
_ascaleX = inValue;
}
float Bone::getAScaleY() {
return _ascaleY;
}
void Bone::setAScaleY(float inValue) {
_ascaleY = inValue;
}
float Bone::getAShearX() {
return _ashearX;
}
void Bone::setAShearX(float inValue) {
_ashearX = inValue;
}
float Bone::getAShearY() {
return _ashearY;
}
void Bone::setAShearY(float inValue) {
_ashearY = inValue;
}
float Bone::getA() {
return _a;
}
void Bone::setA(float inValue) {
_a = inValue;
}
float Bone::getB() {
return _b;
}
void Bone::setB(float inValue) {
_b = inValue;
}
float Bone::getC() {
return _c;
}
void Bone::setC(float inValue) {
_c = inValue;
}
float Bone::getD() {
return _d;
}
void Bone::setD(float inValue) {
_d = inValue;
}
float Bone::getWorldX() {
return _worldX;
}
void Bone::setWorldX(float inValue) {
_worldX = inValue;
}
float Bone::getWorldY() {
return _worldY;
}
void Bone::setWorldY(float inValue) {
_worldY = inValue;
}
float Bone::getWorldRotationX() {
return MathUtil::atan2(_c, _a) * MathUtil::MathUtil::Rad_Deg;
}
float Bone::getWorldRotationY() {
return MathUtil::atan2(_d, _b) * MathUtil::Rad_Deg;
}
float Bone::getWorldScaleX() {
return MathUtil::sqrt(_a * _a + _c * _c);
}
float Bone::getWorldScaleY() {
return MathUtil::sqrt(_b * _b + _d * _d);
}
bool Bone::isAppliedValid() {
return _appliedValid;
}
void Bone::setAppliedValid(bool valid) {
_appliedValid = valid;
}
void Bone::updateAppliedTransform() {
Bone *parent = _parent;
_appliedValid = 1;
if (!parent) {
_ax = _worldX;
_ay = _worldY;
_arotation = MathUtil::atan2(_c, _a) * MathUtil::Rad_Deg;
_ascaleX = MathUtil::sqrt(_a * _a + _c * _c);
_ascaleY = MathUtil::sqrt(_b * _b + _d * _d);
_ashearX = 0;
_ashearY = MathUtil::atan2(_a * _b + _c * _d, _a * _d - _b * _c) * MathUtil::Rad_Deg;
} else {
float pa = parent->_a, pb = parent->_b, pc = parent->_c, pd = parent->_d;
float pid = 1 / (pa * pd - pb * pc);
float dx = _worldX - parent->_worldX, dy = _worldY - parent->_worldY;
float ia = pid * pd;
float id = pid * pa;
float ib = pid * pb;
float ic = pid * pc;
float ra = ia * _a - ib * _c;
float rb = ia * _b - ib * _d;
float rc = id * _c - ic * _a;
float rd = id * _d - ic * _b;
_ax = (dx * pd * pid - dy * pb * pid);
_ay = (dy * pa * pid - dx * pc * pid);
_ashearX = 0;
_ascaleX = MathUtil::sqrt(ra * ra + rc * rc);
if (_ascaleX > 0.0001f) {
float det = ra * rd - rb * rc;
_ascaleY = det / _ascaleX;
_ashearY = MathUtil::atan2(ra * rb + rc * rd, det) * MathUtil::Rad_Deg;
_arotation = MathUtil::atan2(rc, ra) * MathUtil::Rad_Deg;
} else {
_ascaleX = 0;
_ascaleY = MathUtil::sqrt(rb * rb + rd * rd);
_ashearY = 0;
_arotation = 90 - MathUtil::atan2(rd, rb) * MathUtil::Rad_Deg;
}
}
}
+249 -127
View File
@@ -1,127 +1,249 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_BONE_H_
#define SPINE_BONE_H_
#include <spine/dll.h>
#include <spine/BoneData.h>
#ifdef __cplusplus
extern "C" {
#endif
struct spSkeleton;
typedef struct spBone spBone;
struct spBone {
spBoneData* const data;
struct spSkeleton* const skeleton;
spBone* const parent;
int childrenCount;
spBone** const children;
float x, y, rotation, scaleX, scaleY, shearX, shearY;
float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY;
int /*bool*/ appliedValid;
float const a, b, worldX;
float const c, d, worldY;
int/*bool*/ sorted;
#ifdef __cplusplus
spBone() :
data(0),
skeleton(0),
parent(0),
childrenCount(0), children(0),
x(0), y(0), rotation(0), scaleX(0), scaleY(0),
ax(0), ay(0), arotation(0), ascaleX(0), ascaleY(0), ashearX(0), ashearY(0),
appliedValid(0),
a(0), b(0), worldX(0),
c(0), d(0), worldY(0),
sorted(0) {
}
#endif
};
SP_API void spBone_setYDown (int/*bool*/yDown);
SP_API int/*bool*/spBone_isYDown ();
/* @param parent May be 0. */
SP_API spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent);
SP_API void spBone_dispose (spBone* self);
SP_API void spBone_setToSetupPose (spBone* self);
SP_API void spBone_updateWorldTransform (spBone* self);
SP_API void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
SP_API float spBone_getWorldRotationX (spBone* self);
SP_API float spBone_getWorldRotationY (spBone* self);
SP_API float spBone_getWorldScaleX (spBone* self);
SP_API float spBone_getWorldScaleY (spBone* self);
SP_API void spBone_updateAppliedTransform (spBone* self);
SP_API void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY);
SP_API void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY);
SP_API float spBone_worldToLocalRotation (spBone* self, float worldRotation);
SP_API float spBone_localToWorldRotation (spBone* self, float localRotation);
SP_API void spBone_rotateWorld (spBone* self, float degrees);
#ifdef SPINE_SHORT_NAMES
typedef spBone Bone;
#define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__)
#define Bone_isYDown() spBone_isYDown()
#define Bone_create(...) spBone_create(__VA_ARGS__)
#define Bone_dispose(...) spBone_dispose(__VA_ARGS__)
#define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__)
#define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__)
#define Bone_updateWorldTransformWith(...) spBone_updateWorldTransformWith(__VA_ARGS__)
#define Bone_getWorldRotationX(...) spBone_getWorldRotationX(__VA_ARGS__)
#define Bone_getWorldRotationY(...) spBone_getWorldRotationY(__VA_ARGS__)
#define Bone_getWorldScaleX(...) spBone_getWorldScaleX(__VA_ARGS__)
#define Bone_getWorldScaleY(...) spBone_getWorldScaleY(__VA_ARGS__)
#define Bone_updateAppliedTransform(...) spBone_updateAppliedTransform(__VA_ARGS__)
#define Bone_worldToLocal(...) spBone_worldToLocal(__VA_ARGS__)
#define Bone_localToWorld(...) spBone_localToWorld(__VA_ARGS__)
#define Bone_worldToLocalRotation(...) spBone_worldToLocalRotation(__VA_ARGS__)
#define Bone_localToWorldRotation(...) spBone_localToWorldRotation(__VA_ARGS__)
#define Bone_rotateWorld(...) spBone_rotateWorld(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_BONE_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Bone_h
#define Spine_Bone_h
#include <spine/Updatable.h>
#include <spine/SpineObject.h>
#include <spine/Vector.h>
namespace spine {
class BoneData;
class Skeleton;
/// Stores a bone's current pose.
///
/// A bone has a local transform which is used to compute its world transform. A bone also has an applied transform, which is a
/// local transform that can be applied to compute the world transform. The local transform and applied transform may differ if a
/// constraint or application code modifies the world transform after it was computed from the local transform.
class SP_API Bone : public Updatable {
friend class AnimationState;
friend class RotateTimeline;
friend class IkConstraint;
friend class TransformConstraint;
friend class VertexAttachment;
friend class PathConstraint;
friend class Skeleton;
friend class RegionAttachment;
friend class PointAttachment;
friend class ScaleTimeline;
friend class ShearTimeline;
friend class TranslateTimeline;
RTTI_DECL
public:
static void setYDown(bool inValue);
static bool isYDown();
/// @param parent May be NULL.
Bone(BoneData &data, Skeleton &skeleton, Bone *parent = NULL);
/// Same as updateWorldTransform. This method exists for Bone to implement Spine::Updatable.
virtual void update();
/// Computes the world transform using the parent bone and this bone's local transform.
void updateWorldTransform();
/// Computes the world transform using the parent bone and the specified local transform.
void updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
void setToSetupPose();
void worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY);
void localToWorld(float localX, float localY, float &outWorldX, float &outWorldY);
float worldToLocalRotation(float worldRotation);
float localToWorldRotation(float localRotation);
///
/// Rotates the world transform the specified amount and sets isAppliedValid to false.
///
/// @param degrees Degrees.
void rotateWorld(float degrees);
float getWorldToLocalRotationX();
float getWorldToLocalRotationY();
BoneData &getData();
Skeleton &getSkeleton();
Bone *getParent();
Vector<Bone *> &getChildren();
/// The local X translation.
float getX();
void setX(float inValue);
/// The local Y translation.
float getY();
void setY(float inValue);
/// The local rotation.
float getRotation();
void setRotation(float inValue);
/// The local scaleX.
float getScaleX();
void setScaleX(float inValue);
/// The local scaleY.
float getScaleY();
void setScaleY(float inValue);
/// The local shearX.
float getShearX();
void setShearX(float inValue);
/// The local shearY.
float getShearY();
void setShearY(float inValue);
/// The rotation, as calculated by any constraints.
float getAppliedRotation();
void setAppliedRotation(float inValue);
/// The applied local x translation.
float getAX();
void setAX(float inValue);
/// The applied local y translation.
float getAY();
void setAY(float inValue);
/// The applied local scaleX.
float getAScaleX();
void setAScaleX(float inValue);
/// The applied local scaleY.
float getAScaleY();
void setAScaleY(float inValue);
/// The applied local shearX.
float getAShearX();
void setAShearX(float inValue);
/// The applied local shearY.
float getAShearY();
void setAShearY(float inValue);
float getA();
void setA(float inValue);
float getB();
void setB(float inValue);
float getC();
void setC(float inValue);
float getD();
void setD(float inValue);
float getWorldX();
void setWorldX(float inValue);
float getWorldY();
void setWorldY(float inValue);
float getWorldRotationX();
float getWorldRotationY();
/// Returns the magnitide (always positive) of the world scale X.
float getWorldScaleX();
/// Returns the magnitide (always positive) of the world scale Y.
float getWorldScaleY();
bool isAppliedValid();
void setAppliedValid(bool valid);
private:
static bool yDown;
BoneData &_data;
Skeleton &_skeleton;
Bone *_parent;
Vector<Bone *> _children;
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
float _ax, _ay, _arotation, _ascaleX, _ascaleY, _ashearX, _ashearY;
bool _appliedValid;
float _a, _b, _worldX;
float _c, _d, _worldY;
bool _sorted;
/// Computes the individual applied transform values from the world transform. This can be useful to perform processing using
/// the applied transform after the world transform has been modified directly (eg, by a constraint)..
///
/// Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
void updateAppliedTransform();
};
}
#endif /* Spine_Bone_h */
@@ -0,0 +1,140 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/BoneData.h>
#include <assert.h>
using namespace spine;
BoneData::BoneData(int index, const String &name, BoneData *parent) :
_index(index),
_name(name),
_parent(parent),
_length(0),
_x(0),
_y(0),
_rotation(0),
_scaleX(1),
_scaleY(1),
_shearX(0),
_shearY(0),
_transformMode(TransformMode_Normal) {
assert(index >= 0);
assert(_name.length() > 0);
}
int BoneData::getIndex() {
return _index;
}
const String &BoneData::getName() {
return _name;
}
BoneData *BoneData::getParent() {
return _parent;
}
float BoneData::getLength() {
return _length;
}
void BoneData::setLength(float inValue) {
_length = inValue;
}
float BoneData::getX() {
return _x;
}
void BoneData::setX(float inValue) {
_x = inValue;
}
float BoneData::getY() {
return _y;
}
void BoneData::setY(float inValue) {
_y = inValue;
}
float BoneData::getRotation() {
return _rotation;
}
void BoneData::setRotation(float inValue) {
_rotation = inValue;
}
float BoneData::getScaleX() {
return _scaleX;
}
void BoneData::setScaleX(float inValue) {
_scaleX = inValue;
}
float BoneData::getScaleY() {
return _scaleY;
}
void BoneData::setScaleY(float inValue) {
_scaleY = inValue;
}
float BoneData::getShearX() {
return _shearX;
}
void BoneData::setShearX(float inValue) {
_shearX = inValue;
}
float BoneData::getShearY() {
return _shearY;
}
void BoneData::setShearY(float inValue) {
_shearY = inValue;
}
TransformMode BoneData::getTransformMode() {
return _transformMode;
}
void BoneData::setTransformMode(TransformMode inValue) {
_transformMode = inValue;
}
+120 -85
View File
@@ -1,85 +1,120 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_BONEDATA_H_
#define SPINE_BONEDATA_H_
#include <spine/dll.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SP_TRANSFORMMODE_NORMAL,
SP_TRANSFORMMODE_ONLYTRANSLATION,
SP_TRANSFORMMODE_NOROTATIONORREFLECTION,
SP_TRANSFORMMODE_NOSCALE,
SP_TRANSFORMMODE_NOSCALEORREFLECTION
} spTransformMode;
typedef struct spBoneData spBoneData;
struct spBoneData {
const int index;
const char* const name;
spBoneData* const parent;
float length;
float x, y, rotation, scaleX, scaleY, shearX, shearY;
spTransformMode transformMode;
#ifdef __cplusplus
spBoneData() :
index(0),
name(0),
parent(0),
length(0),
x(0), y(0),
rotation(0),
scaleX(0), scaleY(0),
shearX(0), shearY(0),
transformMode(SP_TRANSFORMMODE_NORMAL) {
}
#endif
};
SP_API spBoneData* spBoneData_create (int index, const char* name, spBoneData* parent);
SP_API void spBoneData_dispose (spBoneData* self);
#ifdef SPINE_SHORT_NAMES
typedef spBoneData BoneData;
#define BoneData_create(...) spBoneData_create(__VA_ARGS__)
#define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_BONEDATA_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_BoneData_h
#define Spine_BoneData_h
#include <spine/TransformMode.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class SP_API BoneData : public SpineObject {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class AnimationState;
friend class RotateTimeline;
friend class ScaleTimeline;
friend class ShearTimeline;
friend class TranslateTimeline;
public:
BoneData(int index, const String &name, BoneData *parent = NULL);
/// The index of the bone in Skeleton.Bones
int getIndex();
/// The name of the bone, which is unique within the skeleton.
const String &getName();
/// May be NULL.
BoneData *getParent();
float getLength();
void setLength(float inValue);
/// Local X translation.
float getX();
void setX(float inValue);
/// Local Y translation.
float getY();
void setY(float inValue);
/// Local rotation.
float getRotation();
void setRotation(float inValue);
/// Local scaleX.
float getScaleX();
void setScaleX(float inValue);
/// Local scaleY.
float getScaleY();
void setScaleY(float inValue);
/// Local shearX.
float getShearX();
void setShearX(float inValue);
/// Local shearY.
float getShearY();
void setShearY(float inValue);
/// The transform mode for how parent world transforms affect this bone.
TransformMode getTransformMode();
void setTransformMode(TransformMode inValue);
private:
const int _index;
const String _name;
BoneData *_parent;
float _length;
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
TransformMode _transformMode;
};
}
#endif /* Spine_BoneData_h */
@@ -0,0 +1,42 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/BoundingBoxAttachment.h>
using namespace spine;
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment)
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
}
@@ -1,59 +1,46 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_BOUNDINGBOXATTACHMENT_H_
#define SPINE_BOUNDINGBOXATTACHMENT_H_
#include <spine/dll.h>
#include <spine/Attachment.h>
#include <spine/VertexAttachment.h>
#include <spine/Atlas.h>
#include <spine/Slot.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spBoundingBoxAttachment {
spVertexAttachment super;
} spBoundingBoxAttachment;
SP_API spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name);
#ifdef SPINE_SHORT_NAMES
typedef spBoundingBoxAttachment BoundingBoxAttachment;
#define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_BOUNDINGBOXATTACHMENT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_BoundingBoxAttachment_h
#define Spine_BoundingBoxAttachment_h
#include <spine/VertexAttachment.h>
#include <spine/SpineObject.h>
namespace spine {
/// Attachment that has a polygon for bounds checking.
class SP_API BoundingBoxAttachment : public VertexAttachment {
RTTI_DECL
explicit BoundingBoxAttachment(const String& name);
};
}
#endif /* Spine_BoundingBoxAttachment_h */
@@ -0,0 +1,52 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/ClippingAttachment.h>
#include <spine/SlotData.h>
using namespace spine;
RTTI_IMPL(ClippingAttachment, VertexAttachment)
ClippingAttachment::ClippingAttachment(const String &name) : VertexAttachment(name), _endSlot(NULL) {
}
SlotData *ClippingAttachment::getEndSlot() {
return _endSlot;
}
void ClippingAttachment::setEndSlot(SlotData *inValue) {
_endSlot = inValue;
}
@@ -1,61 +1,58 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_CLIPPINGATTACHMENT_H_
#define SPINE_CLIPPINGATTACHMENT_H_
#include <spine/dll.h>
#include <spine/Attachment.h>
#include <spine/VertexAttachment.h>
#include <spine/Atlas.h>
#include <spine/Slot.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spClippingAttachment {
spVertexAttachment super;
spSlotData* endSlot;
} spClippingAttachment;
SP_API void _spClippingAttachment_dispose(spAttachment* self);
SP_API spClippingAttachment* spClippingAttachment_create (const char* name);
#ifdef SPINE_SHORT_NAMES
typedef spClippingAttachment ClippingAttachment;
#define ClippingAttachment_create(...) spClippingAttachment_create(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_CLIPPINGATTACHMENT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_ClippingAttachment_h
#define Spine_ClippingAttachment_h
#include <spine/VertexAttachment.h>
namespace spine {
class SlotData;
class SP_API ClippingAttachment : public VertexAttachment {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class SkeletonClipping;
RTTI_DECL
public:
explicit ClippingAttachment(const String& name);
SlotData* getEndSlot();
void setEndSlot(SlotData* inValue);
private:
SlotData* _endSlot;
};
}
#endif /* Spine_ClippingAttachment_h */
+58 -42
View File
@@ -27,52 +27,68 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_COLOR_H
#define SPINE_COLOR_H
#ifndef SPINE_COLOR_H_
#define SPINE_COLOR_H_
#include <spine/MathUtil.h>
#include <spine/dll.h>
namespace spine {
class SP_API Color : public SpineObject {
public:
Color() : r(0), g(0), b(0), a(0) {
}
#ifdef __cplusplus
extern "C" {
#endif
Color(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {
clamp();
}
inline Color &set(float _r, float _g, float _b, float _a) {
this->r = _r;
this->g = _g;
this->b = _b;
this->a = _a;
clamp();
return *this;
}
inline Color &set(const Color &other) {
r = other.r;
g = other.g;
b = other.b;
a = other.a;
clamp();
return *this;
}
inline Color &add(float _r, float _g, float _b, float _a) {
this->r += _r;
this->g += _g;
this->b += _b;
this->a += _a;
clamp();
return *this;
}
inline Color &add(const Color &other) {
r += other.r;
g += other.g;
b += other.b;
a += other.a;
clamp();
return *this;
}
inline Color &clamp() {
r = MathUtil::clamp(this->r, 0, 1);
g = MathUtil::clamp(this->g, 0, 1);
b = MathUtil::clamp(this->b, 0, 1);
a = MathUtil::clamp(this->a, 0, 1);
return *this;
}
typedef struct spColor {
float r, g, b, a;
#ifdef __cplusplus
spColor() :
r(0), g(0), b(0), a(0) {
}
bool operator==(const spColor& rhs) {
return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
}
#endif
} spColor;
/* @param attachmentName May be 0 for no setup pose attachment. */
SP_API spColor* spColor_create();
SP_API void spColor_dispose(spColor* self);
SP_API void spColor_setFromFloats(spColor* color, float r, float g, float b, float a);
SP_API void spColor_setFromColor(spColor* color, spColor* otherColor);
SP_API void spColor_addFloats(spColor* color, float r, float g, float b, float a);
SP_API void spColor_addColor(spColor* color, spColor* otherColor);
SP_API void spColor_clamp(spColor* color);
#ifdef SPINE_SHORT_NAMES
typedef spColor color;
#define Color_create() spColor_create()
#define Color_dispose(...) spColor_dispose(__VA_ARGS__)
#define Color_setFromFloats(...) spColor_setFromFloats(__VA_ARGS__)
#define Color_setFromColor(...) spColor_setFromColor(__VA_ARGS__)
#define Color_addColor(...) spColor_addColor(__VA_ARGS__)
#define Color_addFloats(...) spColor_addFloats(__VA_ARGS__)
#define Color_clamp(...) spColor_clamp(__VA_ARGS__)
#endif
#ifdef __cplusplus
};
}
#endif
#endif /* SPINE_COLOR_H_ */
#endif //SPINE_COLOR_H
@@ -0,0 +1,144 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/ColorTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
using namespace spine;
RTTI_IMPL(ColorTimeline, CurveTimeline)
const int ColorTimeline::ENTRIES = 5;
const int ColorTimeline::PREV_TIME = -5;
const int ColorTimeline::PREV_R = -4;
const int ColorTimeline::PREV_G = -3;
const int ColorTimeline::PREV_B = -2;
const int ColorTimeline::PREV_A = -1;
const int ColorTimeline::R = 1;
const int ColorTimeline::G = 2;
const int ColorTimeline::B = 3;
const int ColorTimeline::A = 4;
ColorTimeline::ColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
_frames.setSize(frameCount * ENTRIES, 0);
}
void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Slot *slotP = skeleton._slots[_slotIndex];
Slot &slot = *slotP;
if (time < _frames[0]) {
switch (blend) {
case MixBlend_Setup:
slot._color.set(slot._data._color);
return;
case MixBlend_First: {
Color &color = slot._color, setup = slot._data._color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
(setup.a - color.a) * alpha);
}
default: ;
}
return;
}
float r, g, b, a;
if (time >= _frames[_frames.size() - ENTRIES]) {
// Time is after last frame.
size_t i = _frames.size();
r = _frames[i + PREV_R];
g = _frames[i + PREV_G];
b = _frames[i + PREV_B];
a = _frames[i + PREV_A];
} else {
// Interpolate between the previous frame and the current frame.
size_t frame = (size_t)Animation::binarySearch(_frames, time, ENTRIES);
r = _frames[frame + PREV_R];
g = _frames[frame + PREV_G];
b = _frames[frame + PREV_B];
a = _frames[frame + PREV_A];
float frameTime = _frames[frame];
float percent = getCurvePercent(frame / ENTRIES - 1,
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
r += (_frames[frame + R] - r) * percent;
g += (_frames[frame + G] - g) * percent;
b += (_frames[frame + B] - b) * percent;
a += (_frames[frame + A] - a) * percent;
}
if (alpha == 1) {
slot.getColor().set(r, g, b, a);
} else {
Color &color = slot.getColor();
if (blend == MixBlend_Setup) color.set(slot.getData().getColor());
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
}
}
int ColorTimeline::getPropertyId() {
return ((int) TimelineType_Color << 24) + _slotIndex;
}
void ColorTimeline::setFrame(int frameIndex, float time, float r, float g, float b, float a) {
frameIndex *= ENTRIES;
_frames[frameIndex] = time;
_frames[frameIndex + R] = r;
_frames[frameIndex + G] = g;
_frames[frameIndex + B] = b;
_frames[frameIndex + A] = a;
}
int ColorTimeline::getSlotIndex() {
return _slotIndex;
}
void ColorTimeline::setSlotIndex(int inValue) {
_slotIndex = inValue;
}
Vector<float> &ColorTimeline::getFrames() {
return _frames;
}
@@ -28,34 +28,54 @@
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/PointAttachment.h>
#include <spine/extension.h>
#ifndef Spine_ColorTimeline_h
#define Spine_ColorTimeline_h
void _spPointAttachment_dispose (spAttachment* attachment) {
spPathAttachment* self = SUB_CAST(spPathAttachment, attachment);
#include <spine/CurveTimeline.h>
_spVertexAttachment_deinit(SUPER(self));
namespace spine {
class SP_API ColorTimeline : public CurveTimeline {
friend class SkeletonBinary;
FREE(self);
friend class SkeletonJson;
RTTI_DECL
public:
static const int ENTRIES;
explicit ColorTimeline(int frameCount);
virtual void
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
MixDirection direction);
virtual int getPropertyId();
/// Sets the time and value of the specified keyframe.
void setFrame(int frameIndex, float time, float r, float g, float b, float a);
int getSlotIndex();
void setSlotIndex(int inValue);
Vector<float> &getFrames();
protected:
static const int PREV_TIME;
static const int PREV_R;
static const int PREV_G;
static const int PREV_B;
static const int PREV_A;
static const int R;
static const int G;
static const int B;
static const int A;
private:
int _slotIndex;
Vector<float> _frames;
};
}
spPointAttachment* spPointAttachment_create (const char* name) {
spPointAttachment* self = NEW(spPointAttachment);
_spVertexAttachment_init(SUPER(self));
_spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_POINT, _spPointAttachment_dispose);
return self;
}
void spPointAttachment_computeWorldPosition (spPointAttachment* self, spBone* bone, float* x, float* y) {
*x = self->x * bone->a + self->y * bone->b + bone->worldX;
*y = self->x * bone->c + self->y * bone->d + bone->worldY;
}
float spPointAttachment_computeWorldRotation (spPointAttachment* self, spBone* bone) {
float cosine, sine, x, y;
cosine = COS_DEG(self->rotation);
sine = SIN_DEG(self->rotation);
x = cosine * bone->a + sine * bone->b;
y = cosine * bone->c + sine * bone->d;
return ATAN2(y, x) * RAD_DEG;
}
#endif /* Spine_ColorTimeline_h */
@@ -1,44 +1,45 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/EventData.h>
#include <spine/extension.h>
spEventData* spEventData_create (const char* name) {
spEventData* self = NEW(spEventData);
MALLOC_STR(self->name, name);
return self;
}
void spEventData_dispose (spEventData* self) {
FREE(self->stringValue);
FREE(self->name);
FREE(self);
}
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Constraint.h>
using namespace spine;
RTTI_IMPL(Constraint, Updatable)
Constraint::Constraint() {
}
Constraint::~Constraint() {
}
@@ -1,44 +1,53 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/PathConstraintData.h>
#include <spine/extension.h>
spPathConstraintData* spPathConstraintData_create (const char* name) {
spPathConstraintData* self = NEW(spPathConstraintData);
MALLOC_STR(self->name, name);
return self;
}
void spPathConstraintData_dispose (spPathConstraintData* self) {
FREE(self->name);
FREE(self->bones);
FREE(self);
}
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Constraint_h
#define Spine_Constraint_h
#include <spine/Updatable.h>
namespace spine {
/// The interface for all constraints.
class SP_API Constraint : public Updatable {
RTTI_DECL
public:
Constraint();
virtual ~Constraint();
virtual void update() = 0;
/// The ordinal for the order a skeleton's constraints will be applied.
virtual int getOrder() = 0;
};
}
#endif /* Spine_Constraint_h */
@@ -0,0 +1,128 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_ContainerUtil_h
#define Spine_ContainerUtil_h
#include <spine/Extension.h>
#include <spine/Vector.h>
#include <spine/HashMap.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
#include <assert.h>
namespace spine {
class SP_API ContainerUtil : public SpineObject {
public:
/// Finds an item by comparing each item's name.
/// It is more efficient to cache the results of this method than to call it multiple times.
/// @return May be NULL.
template<typename T>
static T* findWithName(Vector<T*>& items, const String& name) {
assert(name.length() > 0);
for (size_t i = 0; i < items.size(); ++i) {
T* item = items[i];
if (item->getName() == name) {
return item;
}
}
return NULL;
}
/// @return -1 if the item was not found.
template<typename T>
static int findIndexWithName(Vector<T*>& items, const String& name) {
assert(name.length() > 0);
for (size_t i = 0, len = items.size(); i < len; ++i) {
T* item = items[i];
if (item->getName() == name) {
return static_cast<int>(i);
}
}
return -1;
}
/// Finds an item by comparing each item's name.
/// It is more efficient to cache the results of this method than to call it multiple times.
/// @return May be NULL.
template<typename T>
static T* findWithDataName(Vector<T*>& items, const String& name) {
assert(name.length() > 0);
for (size_t i = 0; i < items.size(); ++i) {
T* item = items[i];
if (item->getData().getName() == name) {
return item;
}
}
return NULL;
}
/// @return -1 if the item was not found.
template<typename T>
static int findIndexWithDataName(Vector<T*>& items, const String& name) {
assert(name.length() > 0);
for (size_t i = 0, len = items.size(); i < len; ++i) {
T* item = items[i];
if (item->getData().getName() == name) {
return static_cast<int>(i);
}
}
return -1;
}
template<typename T>
static void cleanUpVectorOfPointers(Vector<T*>& items) {
for (int i = (int)items.size() - 1; i >= 0; i--) {
T* item = items[i];
delete item;
items.removeAt(i);
}
}
private:
// ctor, copy ctor, and assignment should be private in a Singleton
ContainerUtil();
ContainerUtil(const ContainerUtil&);
ContainerUtil& operator=(const ContainerUtil&);
};
}
#endif /* Spine_ContainerUtil_h */
@@ -0,0 +1,129 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/CurveTimeline.h>
#include <spine/MathUtil.h>
using namespace spine;
RTTI_IMPL(CurveTimeline, Timeline)
const float CurveTimeline::LINEAR = 0;
const float CurveTimeline::STEPPED = 1;
const float CurveTimeline::BEZIER = 2;
const int CurveTimeline::BEZIER_SIZE = 10 * 2 - 1;
CurveTimeline::CurveTimeline(int frameCount) {
assert(frameCount > 0);
_curves.setSize((frameCount - 1) * BEZIER_SIZE, 0);
}
CurveTimeline::~CurveTimeline() {
}
size_t CurveTimeline::getFrameCount() {
return _curves.size() / BEZIER_SIZE + 1;
}
void CurveTimeline::setLinear(size_t frameIndex) {
_curves[frameIndex * BEZIER_SIZE] = LINEAR;
}
void CurveTimeline::setStepped(size_t frameIndex) {
_curves[frameIndex * BEZIER_SIZE] = STEPPED;
}
void CurveTimeline::setCurve(size_t frameIndex, float cx1, float cy1, float cx2, float cy2) {
float tmpx = (-cx1 * 2 + cx2) * 0.03f, tmpy = (-cy1 * 2 + cy2) * 0.03f;
float dddfx = ((cx1 - cx2) * 3 + 1) * 0.006f, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006f;
float ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
float dfx = cx1 * 0.3f + tmpx + dddfx * 0.16666667f, dfy = cy1 * 0.3f + tmpy + dddfy * 0.16666667f;
size_t i = frameIndex * BEZIER_SIZE;
_curves[i++] = BEZIER;
float x = dfx, y = dfy;
for (size_t n = i + BEZIER_SIZE - 1; i < n; i += 2) {
_curves[i] = x;
_curves[i + 1] = y;
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
x += dfx;
y += dfy;
}
}
float CurveTimeline::getCurvePercent(size_t frameIndex, float percent) {
percent = MathUtil::clamp(percent, 0, 1);
size_t i = frameIndex * BEZIER_SIZE;
float type = _curves[i];
if (type == LINEAR) {
return percent;
}
if (type == STEPPED) {
return 0;
}
i++;
float x = 0;
for (size_t start = i, n = i + BEZIER_SIZE - 1; i < n; i += 2) {
x = _curves[i];
if (x >= percent) {
float prevX, prevY;
if (i == start) {
prevX = 0;
prevY = 0;
} else {
prevX = _curves[i - 2];
prevY = _curves[i - 1];
}
return prevY + (_curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
}
}
float y = _curves[i - 1];
return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
}
float CurveTimeline::getCurveType(size_t frameIndex) {
return _curves[frameIndex * BEZIER_SIZE];
}
@@ -0,0 +1,77 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_CurveTimeline_h
#define Spine_CurveTimeline_h
#include <spine/Timeline.h>
#include <spine/Vector.h>
namespace spine {
/// Base class for frames that use an interpolation bezier curve.
class SP_API CurveTimeline : public Timeline {
RTTI_DECL
public:
explicit CurveTimeline(int frameCount);
virtual ~CurveTimeline();
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction) = 0;
virtual int getPropertyId() = 0;
size_t getFrameCount();
void setLinear(size_t frameIndex);
void setStepped(size_t frameIndex);
/// Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
/// cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
/// the difference between the keyframe's values.
void setCurve(size_t frameIndex, float cx1, float cy1, float cx2, float cy2);
float getCurvePercent(size_t frameIndex, float percent);
float getCurveType(size_t frameIndex);
protected:
static const float LINEAR;
static const float STEPPED;
static const float BEZIER;
static const int BEZIER_SIZE;
private:
Vector<float> _curves; // type, x, y, ...
};
}
#endif /* Spine_CurveTimeline_h */
+117
View File
@@ -0,0 +1,117 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_DEBUG_H
#define SPINE_DEBUG_H
#include <spine/Extension.h>
#include <map>
namespace spine {
class SP_API DebugExtension : public SpineExtension {
struct Allocation {
void *address;
size_t size;
const char *fileName;
int line;
Allocation() : address(NULL), size(0), fileName(NULL), line(0) {
}
Allocation(void *a, size_t s, const char *f, int l) : address(a), size(s), fileName(f), line(l) {
}
};
public:
DebugExtension(SpineExtension* extension): _extension(extension), _allocations(0), _reallocations(0), _frees(0) {
}
void reportLeaks() {
for (std::map<void*, Allocation>::iterator it = _allocated.begin(); it != _allocated.end(); it++) {
printf("\"%s:%i (%zu bytes at %p)\n", it->second.fileName, it->second.line, it->second.size, it->second.address);
}
printf("allocations: %zu, reallocations: %zu, frees: %zu\n", _allocations, _reallocations, _frees);
if (_allocated.empty()) printf("No leaks detected");
}
void clearAllocations() {
_allocated.clear();
}
virtual void *_alloc(size_t size, const char *file, int line) {
void *result = _extension->_alloc(size, file, line);
_allocated[result] = Allocation(result, size, file, line);
_allocations++;
return result;
}
virtual void *_calloc(size_t size, const char *file, int line) {
void *result = _extension->_calloc(size, file, line);
_allocated[result] = Allocation(result, size, file, line);
_allocations++;
return result;
}
virtual void *_realloc(void *ptr, size_t size, const char *file, int line) {
_allocated.erase(ptr);
void *result = _extension->_realloc(ptr, size, file, line);
_reallocations++;
_allocated[result] = Allocation(result, size, file, line);
return result;
}
virtual void _free(void *mem, const char *file, int line) {
if (_allocated.count(mem)) {
_extension->_free(mem, file, line);
_frees++;
_allocated.erase(mem);
return;
}
printf("%s:%i (address %p): Double free or not allocated through SpineExtension\n", file, line, mem);
_extension->_free(mem, file, line);
}
virtual char *_readFile(const String &path, int *length) {
return _extension->_readFile(path, length);
}
private:
SpineExtension* _extension;
std::map<void*, Allocation> _allocated;
size_t _allocations;
size_t _reallocations;
size_t _frees;
};
}
#endif //SPINE_DEBUG_H
@@ -0,0 +1,297 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/DeformTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/VertexAttachment.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
using namespace spine;
RTTI_IMPL(DeformTimeline, CurveTimeline)
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
_frames.ensureCapacity(frameCount);
_frameVertices.ensureCapacity(frameCount);
_frames.setSize(frameCount, 0);
for (int i = 0; i < frameCount; ++i) {
Vector<float> vec;
_frameVertices.add(vec);
}
}
void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Slot *slotP = skeleton._slots[_slotIndex];
Slot &slot = *slotP;
Attachment *slotAttachment = slot.getAttachment();
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti)) {
return;
}
VertexAttachment *attachment = static_cast<VertexAttachment *>(slotAttachment);
if (!attachment->applyDeform(_attachment)) {
return;
}
Vector<float> &verticesArray = slot._attachmentVertices;
if (verticesArray.size() == 0) {
blend = MixBlend_Setup;
}
Vector< Vector<float> > &frameVertices = _frameVertices;
size_t vertexCount = frameVertices[0].size();
Vector<float> &frames = _frames;
if (time < _frames[0]) {
switch (blend) {
case MixBlend_Setup:
verticesArray.clear();
return;
case MixBlend_First: {
if (alpha == 1) {
verticesArray.clear();
return;
}
verticesArray.setSize(vertexCount, 0);
Vector<float> &vertices = verticesArray;
if (attachment->getBones().size() == 0) {
// Unweighted vertex positions.
Vector<float> &setupVertices = attachment->getVertices();
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
} else {
// Weighted deform offsets.
alpha = 1 - alpha;
for (size_t i = 0; i < vertexCount; i++)
vertices[i] *= alpha;
}
}
case MixBlend_Replace:
case MixBlend_Add:
return;
}
}
verticesArray.setSize(vertexCount, 0);
Vector<float> &vertices = verticesArray;
if (time >= frames[frames.size() - 1]) { // Time is after last frame.
Vector<float> &lastVertices = frameVertices[frames.size() - 1];
if (alpha == 1) {
if (blend == MixBlend_Add) {
VertexAttachment *vertexAttachment = static_cast<VertexAttachment*>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += lastVertices[i] - setupVertices[i];
} else {
// Weighted deform offsets, no alpha.
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += lastVertices[i];
}
} else {
// Vertex positions or deform offsets, no alpha.
memcpy(vertices.buffer(), lastVertices.buffer(), vertexCount * sizeof(float));
}
} else {
switch (blend) {
case MixBlend_Setup: {
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, with alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++) {
float setup = setupVertices[i];
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
}
} else {
// Weighted deform offsets, with alpha.
for (size_t i = 0; i < vertexCount; i++)
vertices[i] = lastVertices[i] * alpha;
}
break;
}
case MixBlend_First:
case MixBlend_Replace:
// Vertex positions or deform offsets, with alpha.
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
break;
case MixBlend_Add:
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += (lastVertices[i] - setupVertices[i]) * alpha;
} else {
// Weighted deform offsets, alpha.
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += lastVertices[i] * alpha;
}
}
}
return;
}
// Interpolate between the previous frame and the current frame.
int frame = Animation::binarySearch(frames, time);
Vector<float> &prevVertices = frameVertices[frame - 1];
Vector<float> &nextVertices = frameVertices[frame];
float frameTime = frames[frame];
float percent = getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) {
if (blend == MixBlend_Add) {
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i];
}
} else {
// Weighted deform offsets, no alpha.
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += prev + (nextVertices[i] - prev) * percent;
}
}
} else {
// Vertex positions or deform offsets, no alpha.
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] = prev + (nextVertices[i] - prev) * percent;
}
}
} else {
switch (blend) {
case MixBlend_Setup: {
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, with alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i], setup = setupVertices[i];
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
}
} else {
// Weighted deform offsets, with alpha.
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend_First:
case MixBlend_Replace:
// Vertex positions or deform offsets, with alpha.
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha;
}
break;
case MixBlend_Add:
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, with alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
}
} else {
// Weighted deform offsets, with alpha.
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
}
}
}
}
}
int DeformTimeline::getPropertyId() {
assert(_attachment != NULL);
return ((int) TimelineType_Deform << 24) + _attachment->_id + _slotIndex;
}
void DeformTimeline::setFrame(int frameIndex, float time, Vector<float> &vertices) {
_frames[frameIndex] = time;
_frameVertices[frameIndex].clear();
_frameVertices[frameIndex].addAll(vertices);
}
int DeformTimeline::getSlotIndex() {
return _slotIndex;
}
void DeformTimeline::setSlotIndex(int inValue) {
_slotIndex = inValue;
}
Vector<float> &DeformTimeline::getFrames() {
return _frames;
}
Vector<Vector<float> > &DeformTimeline::getVertices() {
return _frameVertices;
}
VertexAttachment *DeformTimeline::getAttachment() {
return _attachment;
}
void DeformTimeline::setAttachment(VertexAttachment *inValue) {
_attachment = inValue;
}
@@ -0,0 +1,70 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_DeformTimeline_h
#define Spine_DeformTimeline_h
#include <spine/CurveTimeline.h>
namespace spine {
class VertexAttachment;
class SP_API DeformTimeline : public CurveTimeline {
friend class SkeletonBinary;
friend class SkeletonJson;
RTTI_DECL
public:
explicit DeformTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
virtual int getPropertyId();
/// Sets the time and value of the specified keyframe.
void setFrame(int frameIndex, float time, Vector<float>& vertices);
int getSlotIndex();
void setSlotIndex(int inValue);
Vector<float>& getFrames();
Vector< Vector<float> >& getVertices();
VertexAttachment* getAttachment();
void setAttachment(VertexAttachment* inValue);
private:
int _slotIndex;
Vector<float> _frames;
Vector< Vector<float> > _frameVertices;
VertexAttachment* _attachment;
};
}
#endif /* Spine_DeformTimeline_h */
@@ -0,0 +1,130 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/DrawOrderTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
using namespace spine;
RTTI_IMPL(DrawOrderTimeline, Timeline)
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
_frames.ensureCapacity(frameCount);
_drawOrders.ensureCapacity(frameCount);
_frames.setSize(frameCount, 0);
for (int i = 0; i < frameCount; ++i) {
Vector<int> vec;
_drawOrders.add(vec);
}
}
void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(alpha);
Vector<Slot *> &drawOrder = skeleton._drawOrder;
Vector<Slot *> &slots = skeleton._slots;
if (direction == MixDirection_Out && blend == MixBlend_Setup) {
drawOrder.clear();
drawOrder.ensureCapacity(slots.size());
for (size_t i = 0, n = slots.size(); i < n; ++i) {
drawOrder.add(slots[i]);
}
return;
}
if (time < _frames[0]) {
if (blend == MixBlend_Setup || blend == MixBlend_First) {
drawOrder.clear();
drawOrder.ensureCapacity(slots.size());
for (size_t i = 0, n = slots.size(); i < n; ++i) {
drawOrder.add(slots[i]);
}
}
return;
}
size_t frame;
if (time >= _frames[_frames.size() - 1]) {
// Time is after last frame.
frame = _frames.size() - 1;
} else {
frame = (size_t)Animation::binarySearch(_frames, time) - 1;
}
Vector<int> &drawOrderToSetupIndex = _drawOrders[frame];
if (drawOrderToSetupIndex.size() == 0) {
drawOrder.clear();
for (size_t i = 0, n = slots.size(); i < n; ++i) {
drawOrder.add(slots[i]);
}
} else {
for (size_t i = 0, n = drawOrderToSetupIndex.size(); i < n; ++i) {
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
}
}
}
int DrawOrderTimeline::getPropertyId() {
return ((int) TimelineType_DrawOrder << 24);
}
void DrawOrderTimeline::setFrame(size_t frameIndex, float time, Vector<int> &drawOrder) {
_frames[frameIndex] = time;
_drawOrders[frameIndex].clear();
_drawOrders[frameIndex].addAll(drawOrder);
}
Vector<float> &DrawOrderTimeline::getFrames() {
return _frames;
}
Vector<Vector<int> > &DrawOrderTimeline::getDrawOrders() {
return _drawOrders;
}
size_t DrawOrderTimeline::getFrameCount() {
return _frames.size();
}
@@ -0,0 +1,64 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_DrawOrderTimeline_h
#define Spine_DrawOrderTimeline_h
#include <spine/Timeline.h>
namespace spine {
class SP_API DrawOrderTimeline : public Timeline {
friend class SkeletonBinary;
friend class SkeletonJson;
RTTI_DECL
public:
explicit DrawOrderTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
virtual int getPropertyId();
/// Sets the time and value of the specified keyframe.
/// @param drawOrder May be NULL to use bind pose draw order
void setFrame(size_t frameIndex, float time, Vector<int>& drawOrder);
Vector<float>& getFrames();
Vector< Vector<int> >& getDrawOrders();
size_t getFrameCount();
private:
Vector<float> _frames;
Vector< Vector<int> > _drawOrders;
};
}
#endif /* Spine_DrawOrderTimeline_h */
@@ -0,0 +1,96 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Event.h>
#include <spine/EventData.h>
spine::Event::Event(float time, const spine::EventData &data) :
_data(data),
_time(time),
_intValue(0),
_floatValue(0),
_stringValue(),
_volume(1),
_balance(0) {
}
const spine::EventData &spine::Event::getData() {
return _data;
}
float spine::Event::getTime() {
return _time;
}
int spine::Event::getIntValue() {
return _intValue;
}
void spine::Event::setIntValue(int inValue) {
_intValue = inValue;
}
float spine::Event::getFloatValue() {
return _floatValue;
}
void spine::Event::setFloatValue(float inValue) {
_floatValue = inValue;
}
const spine::String &spine::Event::getStringValue() {
return _stringValue;
}
void spine::Event::setStringValue(const spine::String &inValue) {
_stringValue = inValue;
}
float spine::Event::getVolume() {
return _volume;
}
void spine::Event::setVolume(float inValue) {
_volume = inValue;
}
float spine::Event::getBalance() {
return _balance;
}
void spine::Event::setBalance(float inValue) {
_balance = inValue;
}
+87 -72
View File
@@ -1,72 +1,87 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_EVENT_H_
#define SPINE_EVENT_H_
#include <spine/dll.h>
#include <spine/EventData.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spEvent {
spEventData* const data;
float const time;
int intValue;
float floatValue;
const char* stringValue;
#ifdef __cplusplus
spEvent() :
data(0),
time(0),
intValue(0),
floatValue(0),
stringValue(0) {
}
#endif
} spEvent;
SP_API spEvent* spEvent_create (float time, spEventData* data);
SP_API void spEvent_dispose (spEvent* self);
#ifdef SPINE_SHORT_NAMES
typedef spEvent Event;
#define Event_create(...) spEvent_create(__VA_ARGS__)
#define Event_dispose(...) spEvent_dispose(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_EVENT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_Event_h
#define Spine_Event_h
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class EventData;
/// Stores the current pose values for an Event.
class SP_API Event : public SpineObject {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class AnimationState;
public:
Event(float time, const EventData &data);
const EventData &getData();
/// The animation time this event was keyed.
float getTime();
int getIntValue();
void setIntValue(int inValue);
float getFloatValue();
void setFloatValue(float inValue);
const String &getStringValue();
void setStringValue(const String &inValue);
float getVolume();
void setVolume(float inValue);
float getBalance();
void setBalance(float inValue);
private:
const EventData &_data;
const float _time;
int _intValue;
float _floatValue;
String _stringValue;
float _volume;
float _balance;
};
}
#endif /* Spine_Event_h */
@@ -0,0 +1,102 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/EventData.h>
#include <assert.h>
spine::EventData::EventData(const spine::String &name) :
_name(name),
_intValue(0),
_floatValue(0),
_stringValue(),
_audioPath(),
_volume(1),
_balance(0) {
assert(_name.length() > 0);
}
/// The name of the event, which is unique within the skeleton.
const spine::String &spine::EventData::getName() const {
return _name;
}
int spine::EventData::getIntValue() {
return _intValue;
}
void spine::EventData::setIntValue(int inValue) {
_intValue = inValue;
}
float spine::EventData::getFloatValue() {
return _floatValue;
}
void spine::EventData::setFloatValue(float inValue) {
_floatValue = inValue;
}
const spine::String &spine::EventData::getStringValue() {
return _stringValue;
}
void spine::EventData::setStringValue(const spine::String &inValue) {
this->_stringValue = inValue;
}
const spine::String &spine::EventData::getAudioPath() {
return _audioPath;
}
void spine::EventData::setAudioPath(const spine::String &inValue) {
_audioPath = inValue;
}
float spine::EventData::getVolume() {
return _volume;
}
void spine::EventData::setVolume(float inValue) {
_volume = inValue;
}
float spine::EventData::getBalance() {
return _balance;
}
void spine::EventData::setBalance(float inValue) {
_balance = inValue;
}
+87 -69
View File
@@ -1,69 +1,87 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_EVENTDATA_H_
#define SPINE_EVENTDATA_H_
#include <spine/dll.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spEventData {
const char* const name;
int intValue;
float floatValue;
const char* stringValue;
#ifdef __cplusplus
spEventData() :
name(0),
intValue(0),
floatValue(0),
stringValue(0) {
}
#endif
} spEventData;
SP_API spEventData* spEventData_create (const char* name);
SP_API void spEventData_dispose (spEventData* self);
#ifdef SPINE_SHORT_NAMES
typedef spEventData EventData;
#define EventData_create(...) spEventData_create(__VA_ARGS__)
#define EventData_dispose(...) spEventData_dispose(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_EVENTDATA_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_EventData_h
#define Spine_EventData_h
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
/// Stores the setup pose values for an Event.
class SP_API EventData : public SpineObject {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class Event;
public:
explicit EventData(const String &name);
/// The name of the event, which is unique within the skeleton.
const String &getName() const;
int getIntValue();
void setIntValue(int inValue);
float getFloatValue();
void setFloatValue(float inValue);
const String &getStringValue();
void setStringValue(const String &inValue);
const String &getAudioPath();
void setAudioPath(const String &inValue);
float getVolume();
void setVolume(float inValue);
float getBalance();
void setBalance(float inValue);
private:
const String _name;
int _intValue;
float _floatValue;
String _stringValue;
String _audioPath;
float _volume;
float _balance;
};
}
#endif /* Spine_EventData_h */
@@ -0,0 +1,116 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/EventTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
#include <spine/EventData.h>
#include <spine/ContainerUtil.h>
using namespace spine;
RTTI_IMPL(EventTimeline, Timeline)
EventTimeline::EventTimeline(int frameCount) : Timeline() {
_frames.setSize(frameCount, 0);
_events.setSize(frameCount, NULL);
}
EventTimeline::~EventTimeline() {
ContainerUtil::cleanUpVectorOfPointers(_events);
}
void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
if (pEvents == NULL) {
return;
}
Vector<Event *> &events = *pEvents;
size_t frameCount = _frames.size();
if (lastTime > time) {
// Fire events after last time for looped animations.
apply(skeleton, lastTime, std::numeric_limits<float>::max(), pEvents, alpha, blend, direction);
lastTime = -1.0f;
} else if (lastTime >= _frames[frameCount - 1]) {
// Last time is after last frame.
return;
}
if (time < _frames[0]) {
return; // Time is before first frame.
}
int frame;
if (lastTime < _frames[0]) {
frame = 0;
} else {
frame = Animation::binarySearch(_frames, lastTime);
float frameTime = _frames[frame];
while (frame > 0) {
// Fire multiple events with the same frame.
if (_frames[frame - 1] != frameTime) {
break;
}
frame--;
}
}
for (; (size_t)frame < frameCount && time >= _frames[frame]; ++frame) {
events.add(_events[frame]);
}
}
int EventTimeline::getPropertyId() {
return ((int) TimelineType_Event << 24);
}
void EventTimeline::setFrame(size_t frameIndex, Event *event) {
_frames[frameIndex] = event->getTime();
_events[frameIndex] = event;
}
Vector<float> EventTimeline::getFrames() { return _frames; }
Vector<Event *> &EventTimeline::getEvents() { return _events; }
size_t EventTimeline::getFrameCount() { return _frames.size(); }
@@ -1,57 +1,65 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/Attachment.h>
#include <spine/extension.h>
#include <spine/Slot.h>
typedef struct _spAttachmentVtable {
void (*dispose) (spAttachment* self);
} _spAttachmentVtable;
void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/
void (*dispose) (spAttachment* self)) {
CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable);
VTABLE(spAttachment, self) ->dispose = dispose;
MALLOC_STR(self->name, name);
CONST_CAST(spAttachmentType, self->type) = type;
}
void _spAttachment_deinit (spAttachment* self) {
if (self->attachmentLoader) spAttachmentLoader_disposeAttachment(self->attachmentLoader, self);
FREE(self->vtable);
FREE(self->name);
}
void spAttachment_dispose (spAttachment* self) {
VTABLE(spAttachment, self) ->dispose(self);
}
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_EventTimeline_h
#define Spine_EventTimeline_h
#include <spine/Timeline.h>
namespace spine {
class SP_API EventTimeline : public Timeline {
friend class SkeletonBinary;
friend class SkeletonJson;
RTTI_DECL
public:
explicit EventTimeline(int frameCount);
~EventTimeline();
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
virtual int getPropertyId();
/// Sets the time and value of the specified keyframe.
void setFrame(size_t frameIndex, Event* event);
Vector<float> getFrames();
Vector<Event*>& getEvents();
size_t getFrameCount();
private:
Vector<float> _frames;
Vector<Event*> _events;
};
}
#endif /* Spine_EventTimeline_h */
@@ -0,0 +1,128 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/Extension.h>
#include <spine/SpineString.h>
#include <assert.h>
using namespace spine;
SpineExtension *SpineExtension::_instance = NULL;
void SpineExtension::setInstance(SpineExtension *inValue) {
assert(inValue);
_instance = inValue;
}
SpineExtension *SpineExtension::getInstance() {
if (!_instance) _instance = spine::getDefaultExtension();
assert(_instance);
return _instance;
}
SpineExtension::~SpineExtension() {
}
SpineExtension::SpineExtension() {
}
DefaultSpineExtension::~DefaultSpineExtension() {
}
void *DefaultSpineExtension::_alloc(size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0)
return 0;
void *ptr = ::malloc(size);
return ptr;
}
void *DefaultSpineExtension::_calloc(size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0)
return 0;
void *ptr = ::malloc(size);
if (ptr) {
memset(ptr, 0, size);
}
return ptr;
}
void *DefaultSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
void *mem = NULL;
if (size == 0)
return 0;
if (ptr == NULL)
mem = ::malloc(size);
else
mem = ::realloc(ptr, size);
return mem;
}
void DefaultSpineExtension::_free(void *mem, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
::free(mem);
}
char *DefaultSpineExtension::_readFile(const String &path, int *length) {
char *data;
FILE *file = fopen(path.buffer(), "rb");
if (!file) return 0;
fseek(file, 0, SEEK_END);
*length = (int) ftell(file);
fseek(file, 0, SEEK_SET);
data = SpineExtension::alloc<char>(*length, __FILE__, __LINE__);
fread(data, 1, *length, file);
fclose(file);
return data;
}
DefaultSpineExtension::DefaultSpineExtension() : SpineExtension() {
}
@@ -1,48 +1,59 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/ClippingAttachment.h>
#include <spine/extension.h>
void _spClippingAttachment_dispose (spAttachment* attachment) {
spClippingAttachment* self = SUB_CAST(spClippingAttachment, attachment);
_spVertexAttachment_deinit(SUPER(self));
FREE(self);
}
spClippingAttachment* spClippingAttachment_create (const char* name) {
spClippingAttachment* self = NEW(spClippingAttachment);
_spVertexAttachment_init(SUPER(self));
_spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_CLIPPING, _spClippingAttachment_dispose);
self->endSlot = 0;
return self;
}
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_HasRendererObject_h
#define Spine_HasRendererObject_h
namespace spine {
typedef void (*DisposeRendererObject) (void* rendererObject);
class SP_API HasRendererObject {
public:
explicit HasRendererObject() : _rendererObject(NULL), _dispose(NULL) {};
virtual ~HasRendererObject() {
if (_dispose && _rendererObject)
_dispose(_rendererObject);
}
void* getRendererObject() { return _rendererObject; }
void setRendererObject(void* rendererObject, DisposeRendererObject dispose = NULL) {
_rendererObject = rendererObject;
_dispose = dispose;
}
private:
void *_rendererObject;
DisposeRendererObject _dispose;
};
}
#endif
+185
View File
@@ -0,0 +1,185 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_HashMap_h
#define Spine_HashMap_h
#include <spine/Extension.h>
#include <spine/Vector.h>
#include <spine/SpineObject.h>
// Required for new with line number and file name in MSVC
#ifdef _MSC_VER
#pragma warning(disable:4291)
#endif
namespace spine {
template<typename K, typename V>
class SP_API HashMap : public SpineObject {
private:
class Entry;
public:
class SP_API Pair {
public:
explicit Pair(K &k, V &v) : key(k), value(v) {}
K &key;
V &value;
};
class SP_API Entries {
public:
friend class HashMap;
explicit Entries(Entry *entry) : _entry(NULL), _hasChecked(false) {
_start.next = entry;
_entry = &_start;
}
Pair next() {
assert(_entry);
assert(_hasChecked);
_entry = _entry->next;
Pair pair(_entry->_key, _entry->_value);
_hasChecked = false;
return pair;
}
bool hasNext() {
_hasChecked = true;
return _entry->next;
}
private:
bool _hasChecked;
Entry _start;
Entry *_entry;
};
HashMap() :
_head(NULL),
_size(0) {
}
~HashMap() {
for (Entry *entry = _head; entry != NULL;) {
Entry* next = entry->next;
delete entry;
entry = next;
}
}
size_t size() {
return _size;
}
void put(const K &key, const V &value) {
Entry *entry = find(key);
if (entry) {
entry->_key = key;
entry->_value = value;
} else {
entry = new(__FILE__, __LINE__) Entry();
entry->_key = key;
entry->_value = value;
Entry *oldHead = _head;
if (oldHead) {
_head = entry;
oldHead->prev = entry;
entry->next = oldHead;
} else {
_head = entry;
}
_size++;
}
}
bool containsKey(const K &key) {
return find(key) != NULL;
}
bool remove(const K &key) {
Entry *entry = find(key);
if (!entry) return false;
Entry *prev = entry->prev;
Entry *next = entry->next;
if (prev) prev->next = next;
else _head = next;
if (next) next->prev = entry->prev;
delete entry;
_size--;
return true;
}
V operator[](const K &key) {
Entry *entry = find(key);
if (entry) return entry->_value;
else {
assert(false);
return 0;
}
}
Entries getEntries() const {
return Entries(_head);
}
private:
Entry *find(const K &key) {
for (Entry *entry = _head; entry != NULL; entry = entry->next) {
if (entry->_key == key)
return entry;
}
return NULL;
}
class SP_API Entry : public SpineObject {
public:
K _key;
V _value;
Entry *next;
Entry *prev;
Entry() : next(NULL), prev(NULL) {}
};
Entry *_head;
size_t _size;
};
}
#endif /* Spine_HashMap_h */
@@ -1,208 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/IkConstraint.h>
#include <spine/Skeleton.h>
#include <spine/extension.h>
#include <float.h>
spIkConstraint *spIkConstraint_create(spIkConstraintData *data, const spSkeleton *skeleton) {
int i;
spIkConstraint *self = NEW(spIkConstraint);
CONST_CAST(spIkConstraintData*, self->data) = data;
self->bendDirection = data->bendDirection;
self->mix = data->mix;
self->bonesCount = self->data->bonesCount;
self->bones = MALLOC(spBone*, self->bonesCount);
for (i = 0; i < self->bonesCount; ++i)
self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name);
self->target = spSkeleton_findBone(skeleton, self->data->target->name);
return self;
}
void spIkConstraint_dispose(spIkConstraint *self) {
FREE(self->bones);
FREE(self);
}
void spIkConstraint_apply(spIkConstraint *self) {
switch (self->bonesCount) {
case 1:
spIkConstraint_apply1(self->bones[0], self->target->worldX, self->target->worldY, self->mix);
break;
case 2:
spIkConstraint_apply2(self->bones[0], self->bones[1], self->target->worldX, self->target->worldY, self->bendDirection, self->mix);
break;
}
}
void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float alpha) {
spBone* p = bone->parent;
float id, x, y, tx, ty, rotationIK;
if (!bone->appliedValid) spBone_updateAppliedTransform(bone);
id = 1 / (p->a * p->d - p->b * p->c);
x = targetX - p->worldX, y = targetY - p->worldY;
tx = (x * p->d - y * p->b) * id - bone->ax; ty = (y * p->a - x * p->c) * id - bone->ay;
rotationIK = ATAN2(ty, tx) * RAD_DEG - bone->ashearX - bone->arotation;
if (bone->ascaleX < 0) rotationIK += 180;
if (rotationIK > 180) rotationIK -= 360;
else if (rotationIK < -180) rotationIK += 360;
spBone_updateWorldTransformWith(bone, bone->ax, bone->ay, bone->arotation + rotationIK * alpha, bone->ascaleX,
bone->ascaleY, bone->ashearX, bone->ashearY);
}
void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDir, float alpha) {
float px, py, psx, psy;
float cx, cy, csx, cwx, cwy;
int o1, o2, s2, u;
spBone* pp = parent->parent;
float tx, ty, dx, dy, l1, l2, a1, a2, r;
float id, x, y;
if (alpha == 0) {
spBone_updateWorldTransform(child);
return;
}
if (!parent->appliedValid) spBone_updateAppliedTransform(parent);
if (!child->appliedValid) spBone_updateAppliedTransform(child);
px = parent->ax; py = parent->ay; psx = parent->ascaleX; psy = parent->ascaleY; csx = child->ascaleX;
if (psx < 0) {
psx = -psx;
o1 = 180;
s2 = -1;
} else {
o1 = 0;
s2 = 1;
}
if (psy < 0) {
psy = -psy;
s2 = -s2;
}
if (csx < 0) {
csx = -csx;
o2 = 180;
} else
o2 = 0;
r = psx - psy;
cx = child->ax;
u = (r < 0 ? -r : r) <= 0.0001f;
if (!u) {
cy = 0;
cwx = parent->a * cx + parent->worldX;
cwy = parent->c * cx + parent->worldY;
} else {
cy = child->ay;
cwx = parent->a * cx + parent->b * cy + parent->worldX;
cwy = parent->c * cx + parent->d * cy + parent->worldY;
}
id = 1 / (pp->a * pp->d - pp->b * pp->c);
x = targetX - pp->worldX;
y = targetY - pp->worldY;
tx = (x * pp->d - y * pp->b) * id - px;
ty = (y * pp->a - x * pp->c) * id - py;
x = cwx - pp->worldX;
y = cwy - pp->worldY;
dx = (x * pp->d - y * pp->b) * id - px;
dy = (y * pp->a - x * pp->c) * id - py;
l1 = SQRT(dx * dx + dy * dy);
l2 = child->data->length * csx;
if (u) {
float cosine, a, b;
l2 *= psx;
cosine = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2);
if (cosine < -1) cosine = -1;
else if (cosine > 1) cosine = 1;
a2 = ACOS(cosine) * bendDir;
a = l1 + l2 * cosine;
b = l2 * SIN(a2);
a1 = ATAN2(ty * a - tx * b, tx * a + ty * b);
} else {
float a = psx * l2, b = psy * l2;
float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty, ta = ATAN2(ty, tx);
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
float d = c1 * c1 - 4 * c2 * c0;
if (d >= 0) {
float q = SQRT(d), r0, r1;
if (c1 < 0) q = -q;
q = -(c1 + q) / 2;
r0 = q / c2; r1 = c0 / q;
r = ABS(r0) < ABS(r1) ? r0 : r1;
if (r * r <= dd) {
y = SQRT(dd - r * r) * bendDir;
a1 = ta - ATAN2(y, r);
a2 = ATAN2(y / psy, (r - l1) / psx);
goto break_outer;
}
}
{
float minAngle = PI, minX = l1 - a, minDist = minX * minX, minY = 0;
float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
c0 = -a * l1 / (aa - bb);
if (c0 >= -1 && c0 <= 1) {
c0 = ACOS(c0);
x = a * COS(c0) + l1;
y = b * SIN(c0);
d = x * x + y * y;
if (d < minDist) {
minAngle = c0;
minDist = d;
minX = x;
minY = y;
}
if (d > maxDist) {
maxAngle = c0;
maxDist = d;
maxX = x;
maxY = y;
}
}
if (dd <= (minDist + maxDist) / 2) {
a1 = ta - ATAN2(minY * bendDir, minX);
a2 = minAngle * bendDir;
} else {
a1 = ta - ATAN2(maxY * bendDir, maxX);
a2 = maxAngle * bendDir;
}
}
}
break_outer: {
float os = ATAN2(cy, cx) * s2;
a1 = (a1 - os) * RAD_DEG + o1 - parent->arotation;
if (a1 > 180) a1 -= 360;
else if (a1 < -180) a1 += 360;
spBone_updateWorldTransformWith(parent, px, py, parent->rotation + a1 * alpha, parent->ascaleX, parent->ascaleY, 0, 0);
a2 = ((a2 + os) * RAD_DEG - child->ashearX) * s2 + o2 - child->arotation;
if (a2 > 180) a2 -= 360;
else if (a2 < -180) a2 += 360;
spBone_updateWorldTransformWith(child, cx, cy, child->arotation + a2 * alpha, child->ascaleX, child->ascaleY, child->ashearX, child->ashearY);
}
}
@@ -0,0 +1,297 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/IkConstraint.h>
#include <spine/IkConstraintData.h>
#include <spine/Skeleton.h>
#include <spine/Bone.h>
#include <spine/BoneData.h>
using namespace spine;
RTTI_IMPL(IkConstraint, Constraint)
void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress, bool stretch, bool uniform, float alpha) {
Bone *p = bone.getParent();
float id, x, y, tx, ty, rotationIK;
if (!bone._appliedValid) bone.updateAppliedTransform();
id = 1 / (p->_a * p->_d - p->_b * p->_c);
x = targetX - p->_worldX, y = targetY - p->_worldY;
tx = (x * p->_d - y * p->_b) * id - bone._ax;
ty = (y * p->_a - x * p->_c) * id - bone._ay;
rotationIK = MathUtil::atan2(ty, tx) * MathUtil::Rad_Deg - bone._ashearX - bone._arotation;
if (bone._ascaleX < 0) rotationIK += 180;
if (rotationIK > 180) rotationIK -= 360;
else if (rotationIK < -180) rotationIK += 360;
float sx = bone._ascaleX;
float sy = bone._ascaleY;
if (compress || stretch) {
float b = bone._data.getLength() * sx, dd = MathUtil::sqrt(tx * tx + ty * ty);
if (((compress && dd < b) || (stretch && dd > b)) && (b > 0.0001f)) {
float s = (dd / b - 1) * alpha + 1;
sx *= s;
if (uniform) sy *= s;
}
}
bone.updateWorldTransform(bone._ax, bone._ay, bone._arotation + rotationIK * alpha, sx,
sy, bone._ashearX, bone._ashearY);
}
void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, float alpha) {
float px, py, psx, sx, psy;
float cx, cy, csx, cwx, cwy;
int o1, o2, s2, u;
Bone *pp = parent.getParent();
float tx, ty, dx, dy, dd, l1, l2, a1, a2, r;
float id, x, y;
if (alpha == 0) {
child.updateWorldTransform();
return;
}
if (!parent._appliedValid) parent.updateAppliedTransform();
if (!child._appliedValid) child.updateAppliedTransform();
px = parent._ax;
py = parent._ay;
psx = parent._ascaleX;
sx = psx;
psy = parent._ascaleY;
csx = child._ascaleX;
if (psx < 0) {
psx = -psx;
o1 = 180;
s2 = -1;
} else {
o1 = 0;
s2 = 1;
}
if (psy < 0) {
psy = -psy;
s2 = -s2;
}
if (csx < 0) {
csx = -csx;
o2 = 180;
} else
o2 = 0;
r = psx - psy;
cx = child._ax;
u = (r < 0 ? -r : r) <= 0.0001f;
if (!u) {
cy = 0;
cwx = parent._a * cx + parent._worldX;
cwy = parent._c * cx + parent._worldY;
} else {
cy = child._ay;
cwx = parent._a * cx + parent._b * cy + parent._worldX;
cwy = parent._c * cx + parent._d * cy + parent._worldY;
}
id = 1 / (pp->_a * pp->_d - pp->_b * pp->_c);
x = targetX - pp->_worldX;
y = targetY - pp->_worldY;
tx = (x * pp->_d - y * pp->_b) * id - px;
ty = (y * pp->_a - x * pp->_c) * id - py;
dd = tx * tx + ty * ty;
x = cwx - pp->_worldX;
y = cwy - pp->_worldY;
dx = (x * pp->_d - y * pp->_b) * id - px;
dy = (y * pp->_a - x * pp->_c) * id - py;
l1 = MathUtil::sqrt(dx * dx + dy * dy);
l2 = child.getData().getLength() * csx;
if (u) {
float cosine, a, b;
l2 *= psx;
cosine = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
if (cosine < -1) cosine = -1;
else if (cosine > 1) {
cosine = 1;
if (stretch && l1 + l2 > 0.0001f) sx *= (MathUtil::sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
}
a2 = MathUtil::acos(cosine) * bendDir;
a = l1 + l2 * cosine;
b = l2 * MathUtil::sin(a2);
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
} else {
float a = psx * l2, b = psy * l2;
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
float d = c1 * c1 - 4 * c2 * c0;
if (d >= 0) {
float q = MathUtil::sqrt(d), r0, r1;
if (c1 < 0) q = -q;
q = -(c1 + q) / 2;
r0 = q / c2;
r1 = c0 / q;
r = MathUtil::abs(r0) < MathUtil::abs(r1) ? r0 : r1;
if (r * r <= dd) {
y = MathUtil::sqrt(dd - r * r) * bendDir;
a1 = ta - MathUtil::atan2(y, r);
a2 = MathUtil::atan2(y / psy, (r - l1) / psx);
goto break_outer;
}
}
{
float minAngle = MathUtil::Pi, minX = l1 - a, minDist = minX * minX, minY = 0;
float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
c0 = -a * l1 / (aa - bb);
if (c0 >= -1 && c0 <= 1) {
c0 = MathUtil::acos(c0);
x = a * MathUtil::cos(c0) + l1;
y = b * MathUtil::sin(c0);
d = x * x + y * y;
if (d < minDist) {
minAngle = c0;
minDist = d;
minX = x;
minY = y;
}
if (d > maxDist) {
maxAngle = c0;
maxDist = d;
maxX = x;
maxY = y;
}
}
if (dd <= (minDist + maxDist) / 2) {
a1 = ta - MathUtil::atan2(minY * bendDir, minX);
a2 = minAngle * bendDir;
} else {
a1 = ta - MathUtil::atan2(maxY * bendDir, maxX);
a2 = maxAngle * bendDir;
}
}
}
break_outer:
{
float os = MathUtil::atan2(cy, cx) * s2;
a1 = (a1 - os) * MathUtil::Rad_Deg + o1 - parent._arotation;
if (a1 > 180) a1 -= 360;
else if (a1 < -180) a1 += 360;
parent.updateWorldTransform(px, py, parent._rotation + a1 * alpha, sx, parent._ascaleY, 0, 0);
a2 = ((a2 + os) * MathUtil::Rad_Deg - child._ashearX) * s2 + o2 - child._arotation;
if (a2 > 180) a2 -= 360;
else if (a2 < -180) a2 += 360;
child.updateWorldTransform(cx, cy, child._arotation + a2 * alpha, child._ascaleX, child._ascaleY,
child._ashearX, child._ashearY);
}
}
IkConstraint::IkConstraint(IkConstraintData &data, Skeleton &skeleton) : Constraint(),
_data(data),
_bendDirection(data.getBendDirection()),
_compress(data.getCompress()),
_stretch(data.getStretch()),
_mix(data.getMix()),
_target(skeleton.findBone(
data.getTarget()->getName())) {
_bones.ensureCapacity(_data.getBones().size());
for (size_t i = 0; i < _data.getBones().size(); i++) {
BoneData *boneData = _data.getBones()[i];
_bones.add(skeleton.findBone(boneData->getName()));
}
}
/// Applies the constraint to the constrained bones.
void IkConstraint::apply() {
update();
}
void IkConstraint::update() {
switch (_bones.size()) {
case 1: {
Bone *bone0 = _bones[0];
apply(*bone0, _target->getWorldX(), _target->getWorldY(), _compress, _stretch, _data._uniform, _mix);
}
break;
case 2: {
Bone *bone0 = _bones[0];
Bone *bone1 = _bones[1];
apply(*bone0, *bone1, _target->getWorldX(), _target->getWorldY(), _bendDirection, _stretch, _mix);
}
break;
}
}
int IkConstraint::getOrder() {
return _data.getOrder();
}
IkConstraintData &IkConstraint::getData() {
return _data;
}
Vector<Bone *> &IkConstraint::getBones() {
return _bones;
}
Bone *IkConstraint::getTarget() {
return _target;
}
void IkConstraint::setTarget(Bone *inValue) {
_target = inValue;
}
int IkConstraint::getBendDirection() {
return _bendDirection;
}
void IkConstraint::setBendDirection(int inValue) {
_bendDirection = inValue;
}
float IkConstraint::getMix() {
return _mix;
}
void IkConstraint::setMix(float inValue) {
_mix = inValue;
}
bool IkConstraint::getStretch() {
return _stretch;
}
void IkConstraint::setStretch(bool inValue) {
_stretch = inValue;
}
bool IkConstraint::getCompress() {
return _compress;
}
void IkConstraint::setCompress(bool inValue) {
_compress = inValue;
}
+106 -87
View File
@@ -1,87 +1,106 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_IKCONSTRAINT_H_
#define SPINE_IKCONSTRAINT_H_
#include <spine/dll.h>
#include <spine/IkConstraintData.h>
#include <spine/Bone.h>
#ifdef __cplusplus
extern "C" {
#endif
struct spSkeleton;
typedef struct spIkConstraint {
spIkConstraintData* const data;
int bonesCount;
spBone** bones;
spBone* target;
int bendDirection;
float mix;
#ifdef __cplusplus
spIkConstraint() :
data(0),
bonesCount(0),
bones(0),
target(0),
bendDirection(0),
mix(0) {
}
#endif
} spIkConstraint;
SP_API spIkConstraint* spIkConstraint_create (spIkConstraintData* data, const struct spSkeleton* skeleton);
SP_API void spIkConstraint_dispose (spIkConstraint* self);
SP_API void spIkConstraint_apply (spIkConstraint* self);
SP_API void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float alpha);
SP_API void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDirection, float alpha);
#ifdef SPINE_SHORT_NAMES
typedef spIkConstraint IkConstraint;
#define IkConstraint_create(...) spIkConstraint_create(__VA_ARGS__)
#define IkConstraint_dispose(...) spIkConstraint_dispose(__VA_ARGS__)
#define IkConstraint_apply(...) spIkConstraint_apply(__VA_ARGS__)
#define IkConstraint_apply1(...) spIkConstraint_apply1(__VA_ARGS__)
#define IkConstraint_apply2(...) spIkConstraint_apply2(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_IKCONSTRAINT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_IkConstraint_h
#define Spine_IkConstraint_h
#include <spine/Constraint.h>
#include <spine/Vector.h>
namespace spine {
class IkConstraintData;
class Skeleton;
class Bone;
class SP_API IkConstraint : public Constraint {
friend class Skeleton;
friend class IkConstraintTimeline;
RTTI_DECL
public:
/// Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
/// in the world coordinate system.
static void apply(Bone &bone, float targetX, float targetY, bool compress, bool stretch, bool uniform, float alpha);
/// Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as
/// possible. The target is specified in the world coordinate system.
/// @param child A direct descendant of the parent bone.
static void apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, float alpha);
IkConstraint(IkConstraintData &data, Skeleton &skeleton);
/// Applies the constraint to the constrained bones.
void apply();
virtual void update();
virtual int getOrder();
IkConstraintData &getData();
Vector<Bone *> &getBones();
Bone *getTarget();
void setTarget(Bone *inValue);
int getBendDirection();
void setBendDirection(int inValue);
bool getCompress();
void setCompress(bool inValue);
bool getStretch();
void setStretch(bool inValue);
float getMix();
void setMix(float inValue);
private:
IkConstraintData &_data;
Vector<Bone *> _bones;
int _bendDirection;
bool _compress;
bool _stretch;
float _mix;
Bone *_target;
};
}
#endif /* Spine_IkConstraint_h */
@@ -1,46 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/IkConstraintData.h>
#include <spine/extension.h>
spIkConstraintData* spIkConstraintData_create (const char* name) {
spIkConstraintData* self = NEW(spIkConstraintData);
MALLOC_STR(self->name, name);
self->bendDirection = 1;
self->mix = 1;
return self;
}
void spIkConstraintData_dispose (spIkConstraintData* self) {
FREE(self->name);
FREE(self->bones);
FREE(self);
}
@@ -0,0 +1,115 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/IkConstraintData.h>
#include <spine/BoneData.h>
using namespace spine;
IkConstraintData::IkConstraintData(const String &name) :
_name(name),
_order(0),
_target(NULL),
_bendDirection(1),
_compress(false),
_stretch(false),
_uniform(false),
_mix(1) {
}
const String &IkConstraintData::getName() {
return _name;
}
size_t IkConstraintData::getOrder() {
return _order;
}
void IkConstraintData::setOrder(size_t inValue) {
_order = inValue;
}
Vector<BoneData *> &IkConstraintData::getBones() {
return _bones;
}
BoneData *IkConstraintData::getTarget() {
return _target;
}
void IkConstraintData::setTarget(BoneData *inValue) {
_target = inValue;
}
int IkConstraintData::getBendDirection() {
return _bendDirection;
}
void IkConstraintData::setBendDirection(int inValue) {
_bendDirection = inValue;
}
float IkConstraintData::getMix() {
return _mix;
}
void IkConstraintData::setMix(float inValue) {
_mix = inValue;
}
bool IkConstraintData::getStretch() {
return _stretch;
}
void IkConstraintData::setStretch(bool inValue) {
_stretch = inValue;
}
bool IkConstraintData::getCompress() {
return _compress;
}
void IkConstraintData::setCompress(bool inValue) {
_compress = inValue;
}
bool IkConstraintData::getUniform() {
return _uniform;
}
void IkConstraintData::setUniform(bool inValue) {
_uniform = inValue;
}
@@ -1,76 +1,93 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_IKCONSTRAINTDATA_H_
#define SPINE_IKCONSTRAINTDATA_H_
#include <spine/dll.h>
#include <spine/BoneData.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spIkConstraintData {
const char* const name;
int order;
int bonesCount;
spBoneData** bones;
spBoneData* target;
int bendDirection;
float mix;
#ifdef __cplusplus
spIkConstraintData() :
name(0),
bonesCount(0),
bones(0),
target(0),
bendDirection(0),
mix(0) {
}
#endif
} spIkConstraintData;
SP_API spIkConstraintData* spIkConstraintData_create (const char* name);
SP_API void spIkConstraintData_dispose (spIkConstraintData* self);
#ifdef SPINE_SHORT_NAMES
typedef spIkConstraintData IkConstraintData;
#define IkConstraintData_create(...) spIkConstraintData_create(__VA_ARGS__)
#define IkConstraintData_dispose(...) spIkConstraintData_dispose(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_IKCONSTRAINTDATA_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_IkConstraintData_h
#define Spine_IkConstraintData_h
#include <spine/Vector.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class BoneData;
class SP_API IkConstraintData : public SpineObject {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class IkConstraint;
friend class Skeleton;
friend class IkConstraintTimeline;
public:
explicit IkConstraintData(const String& name);
/// The IK constraint's name, which is unique within the skeleton.
const String& getName();
size_t getOrder();
void setOrder(size_t inValue);
/// The bones that are constrained by this IK Constraint.
Vector<BoneData*>& getBones();
/// The bone that is the IK target.
BoneData* getTarget();
void setTarget(BoneData* inValue);
/// Controls the bend direction of the IK bones, either 1 or -1.
int getBendDirection();
void setBendDirection(int inValue);
bool getCompress();
void setCompress(bool inValue);
bool getStretch();
void setStretch(bool inValue);
bool getUniform();
void setUniform(bool inValue);
float getMix();
void setMix(float inValue);
private:
const String _name;
size_t _order;
Vector<BoneData*> _bones;
BoneData* _target;
int _bendDirection;
bool _compress;
bool _stretch;
bool _uniform;
float _mix;
};
}
#endif /* Spine_IkConstraintData_h */
@@ -0,0 +1,157 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/IkConstraintTimeline.h>
#include <spine/Skeleton.h>
#include <spine/Event.h>
#include <spine/Animation.h>
#include <spine/TimelineType.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
#include <spine/IkConstraint.h>
#include <spine/IkConstraintData.h>
using namespace spine;
RTTI_IMPL(IkConstraintTimeline, CurveTimeline)
const int IkConstraintTimeline::ENTRIES = 5;
const int IkConstraintTimeline::PREV_TIME = -5;
const int IkConstraintTimeline::PREV_MIX = -4;
const int IkConstraintTimeline::PREV_BEND_DIRECTION = -3;
const int IkConstraintTimeline::PREV_COMPRESS = -2;
const int IkConstraintTimeline::PREV_STRETCH = -1;
const int IkConstraintTimeline::MIX = 1;
const int IkConstraintTimeline::BEND_DIRECTION = 2;
const int IkConstraintTimeline::COMPRESS = 3;
const int IkConstraintTimeline::STRETCH = 4;
IkConstraintTimeline::IkConstraintTimeline(int frameCount) : CurveTimeline(frameCount), _ikConstraintIndex(0) {
_frames.setSize(frameCount * ENTRIES, 0);
}
void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
IkConstraint *constraintP = skeleton._ikConstraints[_ikConstraintIndex];
IkConstraint &constraint = *constraintP;
if (time < _frames[0]) {
switch (blend) {
case MixBlend_Setup:
constraint._mix = constraint._data._mix;
constraint._bendDirection = constraint._data._bendDirection;
constraint._compress = constraint._data._compress;
constraint._stretch = constraint._data._stretch;
return;
case MixBlend_First:
constraint._mix += (constraint._data._mix - constraint._mix) * alpha;
constraint._bendDirection = constraint._data._bendDirection;
constraint._compress = constraint._data._compress;
constraint._stretch = constraint._data._stretch;
return;
default:
return;
}
}
if (time >= _frames[_frames.size() - ENTRIES]) {
// Time is after last frame.
if (blend == MixBlend_Setup) {
constraint._mix =
constraint._data._mix + (_frames[_frames.size() + PREV_MIX] - constraint._data._mix) * alpha;
if (direction == MixDirection_Out) {
constraint._bendDirection = constraint._data._bendDirection;
constraint._compress = constraint._data._compress;
constraint._stretch = constraint._data._stretch;
} else {
constraint._bendDirection = (int) _frames[_frames.size() + PREV_BEND_DIRECTION];
constraint._compress = _frames[_frames.size() + PREV_COMPRESS] != 0;
constraint._stretch = _frames[_frames.size() + PREV_STRETCH] != 0;
}
} else {
constraint._mix += (_frames[_frames.size() + PREV_MIX] - constraint._mix) * alpha;
if (direction == MixDirection_In) {
constraint._bendDirection = (int) _frames[_frames.size() + PREV_BEND_DIRECTION];
constraint._compress = _frames[_frames.size() + PREV_COMPRESS] != 0;
constraint._stretch = _frames[_frames.size() + PREV_STRETCH] != 0;
}
}
return;
}
// Interpolate between the previous frame and the current frame.
int frame = Animation::binarySearch(_frames, time, ENTRIES);
float mix = _frames[frame + PREV_MIX];
float frameTime = _frames[frame];
float percent = getCurvePercent(frame / ENTRIES - 1,
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
if (blend == MixBlend_Setup) {
constraint._mix =
constraint._data._mix + (mix + (_frames[frame + MIX] - mix) * percent - constraint._data._mix) * alpha;
if (direction == MixDirection_Out) {
constraint._bendDirection = constraint._data._bendDirection;
constraint._compress = constraint._data._compress;
constraint._stretch = constraint._data._stretch;
} else {
constraint._bendDirection = (int) _frames[_frames.size() + PREV_BEND_DIRECTION];
constraint._compress = _frames[frame + PREV_COMPRESS] != 0;
constraint._stretch = _frames[frame + PREV_STRETCH] != 0;
}
} else {
constraint._mix += (mix + (_frames[frame + MIX] - mix) * percent - constraint._mix) * alpha;
if (direction == MixDirection_In) {
constraint._bendDirection = (int) _frames[frame + PREV_BEND_DIRECTION];
constraint._compress = _frames[frame + PREV_COMPRESS] != 0;
constraint._stretch = _frames[frame + PREV_STRETCH] != 0;
}
}
}
int IkConstraintTimeline::getPropertyId() {
return ((int) TimelineType_IkConstraint << 24) + _ikConstraintIndex;
}
void IkConstraintTimeline::setFrame(int frameIndex, float time, float mix, int bendDirection, bool compress, bool stretch) {
frameIndex *= ENTRIES;
_frames[frameIndex] = time;
_frames[frameIndex + MIX] = mix;
_frames[frameIndex + BEND_DIRECTION] = (float)bendDirection;
_frames[frameIndex + COMPRESS] = compress ? 1 : 0;
_frames[frameIndex + STRETCH] = stretch ? 1 : 0;
}
@@ -0,0 +1,72 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_IkConstraintTimeline_h
#define Spine_IkConstraintTimeline_h
#include <spine/CurveTimeline.h>
namespace spine {
class SP_API IkConstraintTimeline : public CurveTimeline {
friend class SkeletonBinary;
friend class SkeletonJson;
RTTI_DECL
public:
static const int ENTRIES;
explicit IkConstraintTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
virtual int getPropertyId();
/// Sets the time, mix and bend direction of the specified keyframe.
void setFrame (int frameIndex, float time, float mix, int bendDirection, bool compress, bool stretch);
private:
static const int PREV_TIME;
static const int PREV_MIX;
static const int PREV_BEND_DIRECTION;
static const int PREV_COMPRESS;
static const int PREV_STRETCH;
static const int MIX;
static const int BEND_DIRECTION;
static const int COMPRESS;
static const int STRETCH;
Vector<float> _frames;
int _ikConstraintIndex;
};
}
#endif /* Spine_IkConstraintTimeline_h */
-462
View File
@@ -1,462 +0,0 @@
/*
Copyright (c) 2009, Dave Gamble
Copyright (c) 2013, Esoteric Software
Permission is hereby granted, dispose of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* Json */
/* JSON parser in C. */
#ifndef _DEFAULT_SOURCE
/* Bring strings.h definitions into string.h, where appropriate */
#define _DEFAULT_SOURCE
#endif
#ifndef _BSD_SOURCE
/* Bring strings.h definitions into string.h, where appropriate */
#define _BSD_SOURCE
#endif
#include "Json.h"
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h> /* strtod (C89), strtof (C99) */
#include <string.h> /* strcasecmp (4.4BSD - compatibility), _stricmp (_WIN32) */
#include <spine/extension.h>
#ifndef SPINE_JSON_DEBUG
/* Define this to do extra NULL and expected-character checking */
#define SPINE_JSON_DEBUG 0
#endif
static const char* ep;
const char* Json_getError (void) {
return ep;
}
static int Json_strcasecmp (const char* s1, const char* s2) {
/* TODO we may be able to elide these NULL checks if we can prove
* the graph and input (only callsite is Json_getItem) should not have NULLs
*/
if (s1 && s2) {
#if defined(_WIN32)
return _stricmp(s1, s2);
#else
return strcasecmp( s1, s2 );
#endif
} else {
if (s1 < s2)
return -1; /* s1 is null, s2 is not */
else if (s1 == s2)
return 0; /* both are null */
else
return 1; /* s2 is nul s1 is not */
}
}
/* Internal constructor. */
static Json *Json_new (void) {
return (Json*)CALLOC(Json, 1);
}
/* Delete a Json structure. */
void Json_dispose (Json *c) {
Json *next;
while (c) {
next = c->next;
if (c->child) Json_dispose(c->child);
if (c->valueString) FREE(c->valueString);
if (c->name) FREE(c->name);
FREE(c);
c = next;
}
}
/* Parse the input text to generate a number, and populate the result into item. */
static const char* parse_number (Json *item, const char* num) {
double result = 0.0;
int negative = 0;
char* ptr = (char*)num;
if (*ptr == '-') {
negative = -1;
++ptr;
}
while (*ptr >= '0' && *ptr <= '9') {
result = result * 10.0 + (*ptr - '0');
++ptr;
}
if (*ptr == '.') {
double fraction = 0.0;
int n = 0;
++ptr;
while (*ptr >= '0' && *ptr <= '9') {
fraction = (fraction * 10.0) + (*ptr - '0');
++ptr;
++n;
}
result += fraction / POW(10.0, n);
}
if (negative) result = -result;
if (*ptr == 'e' || *ptr == 'E') {
double exponent = 0;
int expNegative = 0;
int n = 0;
++ptr;
if (*ptr == '-') {
expNegative = -1;
++ptr;
} else if (*ptr == '+') {
++ptr;
}
while (*ptr >= '0' && *ptr <= '9') {
exponent = (exponent * 10.0) + (*ptr - '0');
++ptr;
++n;
}
if (expNegative)
result = result / POW(10, exponent);
else
result = result * POW(10, exponent);
}
if (ptr != num) {
/* Parse success, number found. */
item->valueFloat = result;
item->valueInt = (int)result;
item->type = Json_Number;
return ptr;
} else {
/* Parse failure, ep is set. */
ep = num;
return 0;
}
}
/* Parse the input text into an unescaped cstring, and populate item. */
static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
static const char* parse_string (Json *item, const char* str) {
const char* ptr = str + 1;
char* ptr2;
char* out;
int len = 0;
unsigned uc, uc2;
if (*str != '\"') { /* TODO: don't need this check when called from parse_value, but do need from parse_object */
ep = str;
return 0;
} /* not a string! */
while (*ptr != '\"' && *ptr && ++len)
if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
out = MALLOC(char, len + 1); /* The length needed for the string, roughly. */
if (!out) return 0;
ptr = str + 1;
ptr2 = out;
while (*ptr != '\"' && *ptr) {
if (*ptr != '\\')
*ptr2++ = *ptr++;
else {
ptr++;
switch (*ptr) {
case 'b':
*ptr2++ = '\b';
break;
case 'f':
*ptr2++ = '\f';
break;
case 'n':
*ptr2++ = '\n';
break;
case 'r':
*ptr2++ = '\r';
break;
case 't':
*ptr2++ = '\t';
break;
case 'u': /* transcode utf16 to utf8. */
sscanf(ptr + 1, "%4x", &uc);
ptr += 4; /* get the unicode char. */
if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) break; /* check for invalid. */
/* TODO provide an option to ignore surrogates, use unicode replacement character? */
if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */
{
if (ptr[1] != '\\' || ptr[2] != 'u') break; /* missing second-half of surrogate. */
sscanf(ptr + 3, "%4x", &uc2);
ptr += 6;
if (uc2 < 0xDC00 || uc2 > 0xDFFF) break; /* invalid second-half of surrogate. */
uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF));
}
len = 4;
if (uc < 0x80)
len = 1;
else if (uc < 0x800)
len = 2;
else if (uc < 0x10000) len = 3;
ptr2 += len;
switch (len) {
case 4:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 3:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 2:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 1:
*--ptr2 = (uc | firstByteMark[len]);
}
ptr2 += len;
break;
default:
*ptr2++ = *ptr;
break;
}
ptr++;
}
}
*ptr2 = 0;
if (*ptr == '\"') ptr++; /* TODO error handling if not \" or \0 ? */
item->valueString = out;
item->type = Json_String;
return ptr;
}
/* Predeclare these prototypes. */
static const char* parse_value (Json *item, const char* value);
static const char* parse_array (Json *item, const char* value);
static const char* parse_object (Json *item, const char* value);
/* Utility to jump whitespace and cr/lf */
static const char* skip (const char* in) {
if (!in) return 0; /* must propagate NULL since it's often called in skip(f(...)) form */
while (*in && (unsigned char)*in <= 32)
in++;
return in;
}
/* Parse an object - create a new root, and populate. */
Json *Json_create (const char* value) {
Json *c;
ep = 0;
if (!value) return 0; /* only place we check for NULL other than skip() */
c = Json_new();
if (!c) return 0; /* memory fail */
value = parse_value(c, skip(value));
if (!value) {
Json_dispose(c);
return 0;
} /* parse failure. ep is set. */
return c;
}
/* Parser core - when encountering text, process appropriately. */
static const char* parse_value (Json *item, const char* value) {
/* Referenced by Json_create(), parse_array(), and parse_object(). */
/* Always called with the result of skip(). */
#if SPINE_JSON_DEBUG /* Checked at entry to graph, Json_create, and after every parse_ call. */
if (!value) return 0; /* Fail on null. */
#endif
switch (*value) {
case 'n': {
if (!strncmp(value + 1, "ull", 3)) {
item->type = Json_NULL;
return value + 4;
}
break;
}
case 'f': {
if (!strncmp(value + 1, "alse", 4)) {
item->type = Json_False;
/* calloc prevents us needing item->type = Json_False or valueInt = 0 here */
return value + 5;
}
break;
}
case 't': {
if (!strncmp(value + 1, "rue", 3)) {
item->type = Json_True;
item->valueInt = 1;
return value + 4;
}
break;
}
case '\"':
return parse_string(item, value);
case '[':
return parse_array(item, value);
case '{':
return parse_object(item, value);
case '-': /* fallthrough */
case '0': /* fallthrough */
case '1': /* fallthrough */
case '2': /* fallthrough */
case '3': /* fallthrough */
case '4': /* fallthrough */
case '5': /* fallthrough */
case '6': /* fallthrough */
case '7': /* fallthrough */
case '8': /* fallthrough */
case '9':
return parse_number(item, value);
default:
break;
}
ep = value;
return 0; /* failure. */
}
/* Build an array from input text. */
static const char* parse_array (Json *item, const char* value) {
Json *child;
#if SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */
if (*value != '[') {
ep = value;
return 0;
} /* not an array! */
#endif
item->type = Json_Array;
value = skip(value + 1);
if (*value == ']') return value + 1; /* empty array. */
item->child = child = Json_new();
if (!item->child) return 0; /* memory fail */
value = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */
if (!value) return 0;
item->size = 1;
while (*value == ',') {
Json *new_item = Json_new();
if (!new_item) return 0; /* memory fail */
child->next = new_item;
#if SPINE_JSON_HAVE_PREV
new_item->prev = child;
#endif
child = new_item;
value = skip(parse_value(child, skip(value + 1)));
if (!value) return 0; /* parse fail */
item->size++;
}
if (*value == ']') return value + 1; /* end of array */
ep = value;
return 0; /* malformed. */
}
/* Build an object from the text. */
static const char* parse_object (Json *item, const char* value) {
Json *child;
#if SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */
if (*value != '{') {
ep = value;
return 0;
} /* not an object! */
#endif
item->type = Json_Object;
value = skip(value + 1);
if (*value == '}') return value + 1; /* empty array. */
item->child = child = Json_new();
if (!item->child) return 0;
value = skip(parse_string(child, skip(value)));
if (!value) return 0;
child->name = child->valueString;
child->valueString = 0;
if (*value != ':') {
ep = value;
return 0;
} /* fail! */
value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */
if (!value) return 0;
item->size = 1;
while (*value == ',') {
Json *new_item = Json_new();
if (!new_item) return 0; /* memory fail */
child->next = new_item;
#if SPINE_JSON_HAVE_PREV
new_item->prev = child;
#endif
child = new_item;
value = skip(parse_string(child, skip(value + 1)));
if (!value) return 0;
child->name = child->valueString;
child->valueString = 0;
if (*value != ':') {
ep = value;
return 0;
} /* fail! */
value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */
if (!value) return 0;
item->size++;
}
if (*value == '}') return value + 1; /* end of array */
ep = value;
return 0; /* malformed. */
}
Json *Json_getItem (Json *object, const char* string) {
Json *c = object->child;
while (c && Json_strcasecmp(c->name, string))
c = c->next;
return c;
}
const char* Json_getString (Json* object, const char* name, const char* defaultValue) {
object = Json_getItem(object, name);
if (object) return object->valueString;
return defaultValue;
}
float Json_getFloat (Json* value, const char* name, float defaultValue) {
value = Json_getItem(value, name);
return value ? value->valueFloat : defaultValue;
}
int Json_getInt (Json* value, const char* name, int defaultValue) {
value = Json_getItem(value, name);
return value ? value->valueInt : defaultValue;
}
+544
View File
@@ -0,0 +1,544 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
/* Json */
/* JSON parser in CPP, shamelessly ripped from json.c in the spine-c runtime */
#ifndef _DEFAULT_SOURCE
/* Bring strings.h definitions into string.h, where appropriate */
#define _DEFAULT_SOURCE
#endif
#ifndef _BSD_SOURCE
/* Bring strings.h definitions into string.h, where appropriate */
#define _BSD_SOURCE
#endif
#include <spine/Json.h>
#include <spine/Extension.h>
#include <spine/SpineString.h>
#include <assert.h>
#include <math.h>
using namespace spine;
const int Json::JSON_FALSE = 0;
const int Json::JSON_TRUE = 1;
const int Json::JSON_NULL = 2;
const int Json::JSON_NUMBER = 3;
const int Json::JSON_STRING = 4;
const int Json::JSON_ARRAY = 5;
const int Json::JSON_OBJECT = 6;
const char *Json::_error = NULL;
Json *Json::getItem(Json *object, const char *string) {
Json *c = object->_child;
while (c && json_strcasecmp(c->_name, string)) {
c = c->_next;
}
return c;
}
const char *Json::getString(Json *object, const char *name, const char *defaultValue) {
object = getItem(object, name);
if (object) {
return object->_valueString;
}
return defaultValue;
}
float Json::getFloat(Json *value, const char *name, float defaultValue) {
value = getItem(value, name);
return value ? value->_valueFloat : defaultValue;
}
int Json::getInt(Json *value, const char *name, int defaultValue) {
value = getItem(value, name);
return value ? value->_valueInt : defaultValue;
}
const char *Json::getError() {
return _error;
}
Json::Json(const char *value) :
_next(NULL),
#if SPINE_JSON_HAVE_PREV
_prev(NULL),
#endif
_child(NULL),
_type(0),
_size(0),
_valueString(NULL),
_valueInt(0),
_valueFloat(0),
_name(NULL) {
if (value) {
value = parseValue(this, skip(value));
assert(value);
}
}
Json::~Json() {
delete _child;
if (_valueString) {
SpineExtension::free(_valueString, __FILE__, __LINE__);
}
if (_name) {
SpineExtension::free(_name, __FILE__, __LINE__);
}
delete _next;
}
const char *Json::skip(const char *inValue) {
if (!inValue) {
/* must propagate NULL since it's often called in skip(f(...)) form */
return NULL;
}
while (*inValue && (unsigned char) *inValue <= 32) {
inValue++;
}
return inValue;
}
const char *Json::parseValue(Json *item, const char *value) {
/* Referenced by constructor, parseArray(), and parseObject(). */
/* Always called with the result of skip(). */
#ifdef SPINE_JSON_DEBUG /* Checked at entry to graph, constructor, and after every parse call. */
if (!value) {
/* Fail on null. */
return NULL;
}
#endif
switch (*value) {
case 'n': {
if (!strncmp(value + 1, "ull", 3)) {
item->_type = JSON_NULL;
return value + 4;
}
break;
}
case 'f': {
if (!strncmp(value + 1, "alse", 4)) {
item->_type = JSON_FALSE;
/* calloc prevents us needing item->_type = JSON_FALSE or valueInt = 0 here */
return value + 5;
}
break;
}
case 't': {
if (!strncmp(value + 1, "rue", 3)) {
item->_type = JSON_TRUE;
item->_valueInt = 1;
return value + 4;
}
break;
}
case '\"':
return parseString(item, value);
case '[':
return parseArray(item, value);
case '{':
return parseObject(item, value);
case '-': /* fallthrough */
case '0': /* fallthrough */
case '1': /* fallthrough */
case '2': /* fallthrough */
case '3': /* fallthrough */
case '4': /* fallthrough */
case '5': /* fallthrough */
case '6': /* fallthrough */
case '7': /* fallthrough */
case '8': /* fallthrough */
case '9':
return parseNumber(item, value);
default:
break;
}
_error = value;
return NULL; /* failure. */
}
static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
const char *Json::parseString(Json *item, const char *str) {
const char *ptr = str + 1;
char *ptr2;
char *out;
int len = 0;
unsigned uc, uc2;
if (*str != '\"') {
/* TODO: don't need this check when called from parseValue, but do need from parseObject */
_error = str;
return 0;
} /* not a string! */
while (*ptr != '\"' && *ptr && ++len) {
if (*ptr++ == '\\') {
ptr++; /* Skip escaped quotes. */
}
}
out = SpineExtension::alloc<char>(len + 1, __FILE__, __LINE__); /* The length needed for the string, roughly. */
if (!out) {
return 0;
}
ptr = str + 1;
ptr2 = out;
while (*ptr != '\"' && *ptr) {
if (*ptr != '\\') {
*ptr2++ = *ptr++;
} else {
ptr++;
switch (*ptr) {
case 'b':
*ptr2++ = '\b';
break;
case 'f':
*ptr2++ = '\f';
break;
case 'n':
*ptr2++ = '\n';
break;
case 'r':
*ptr2++ = '\r';
break;
case 't':
*ptr2++ = '\t';
break;
case 'u': {
/* transcode utf16 to utf8. */
sscanf(ptr + 1, "%4x", &uc);
ptr += 4; /* get the unicode char. */
if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) {
break; /* check for invalid. */
}
/* TODO provide an option to ignore surrogates, use unicode replacement character? */
if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ {
if (ptr[1] != '\\' || ptr[2] != 'u') {
break; /* missing second-half of surrogate. */
}
sscanf(ptr + 3, "%4x", &uc2);
ptr += 6;
if (uc2 < 0xDC00 || uc2 > 0xDFFF) {
break; /* invalid second-half of surrogate. */
}
uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF));
}
len = 4;
if (uc < 0x80) {
len = 1;
} else if (uc < 0x800) {
len = 2;
} else if (uc < 0x10000) {
len = 3;
}
ptr2 += len;
switch (len) {
case 4:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 3:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 2:
*--ptr2 = ((uc | 0x80) & 0xBF);
uc >>= 6;
/* fallthrough */
case 1:
*--ptr2 = (uc | firstByteMark[len]);
}
ptr2 += len;
break;
}
default:
*ptr2++ = *ptr;
break;
}
ptr++;
}
}
*ptr2 = 0;
if (*ptr == '\"') {
ptr++; /* TODO error handling if not \" or \0 ? */
}
item->_valueString = out;
item->_type = JSON_STRING;
return ptr;
}
const char *Json::parseNumber(Json *item, const char *num) {
double result = 0.0;
int negative = 0;
char *ptr = (char *) num;
if (*ptr == '-') {
negative = -1;
++ptr;
}
while (*ptr >= '0' && *ptr <= '9') {
result = result * 10.0 + (*ptr - '0');
++ptr;
}
if (*ptr == '.') {
double fraction = 0.0;
int n = 0;
++ptr;
while (*ptr >= '0' && *ptr <= '9') {
fraction = (fraction * 10.0) + (*ptr - '0');
++ptr;
++n;
}
result += fraction / pow(10.0, n);
}
if (negative) {
result = -result;
}
if (*ptr == 'e' || *ptr == 'E') {
double exponent = 0;
int expNegative = 0;
int n = 0;
++ptr;
if (*ptr == '-') {
expNegative = -1;
++ptr;
} else if (*ptr == '+') {
++ptr;
}
while (*ptr >= '0' && *ptr <= '9') {
exponent = (exponent * 10.0) + (*ptr - '0');
++ptr;
++n;
}
if (expNegative) {
result = result / pow(10, exponent);
} else {
result = result * pow(10, exponent);
}
}
if (ptr != num) {
/* Parse success, number found. */
item->_valueFloat = (float)result;
item->_valueInt = (int)result;
item->_type = JSON_NUMBER;
return ptr;
} else {
/* Parse failure, _error is set. */
_error = num;
return NULL;
}
}
const char *Json::parseArray(Json *item, const char *value) {
Json *child;
#ifdef SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */
if (*value != '[') {
ep = value;
return 0;
} /* not an array! */
#endif
item->_type = JSON_ARRAY;
value = skip(value + 1);
if (*value == ']') {
return value + 1; /* empty array. */
}
item->_child = child = new(__FILE__, __LINE__) Json(NULL);
if (!item->_child) {
return NULL; /* memory fail */
}
value = skip(parseValue(child, skip(value))); /* skip any spacing, get the value. */
if (!value) {
return NULL;
}
item->_size = 1;
while (*value == ',') {
Json *new_item = new(__FILE__, __LINE__) Json(NULL);
if (!new_item) {
return NULL; /* memory fail */
}
child->_next = new_item;
#if SPINE_JSON_HAVE_PREV
new_item->prev = child;
#endif
child = new_item;
value = skip(parseValue(child, skip(value + 1)));
if (!value) {
return NULL; /* parse fail */
}
item->_size++;
}
if (*value == ']') {
return value + 1; /* end of array */
}
_error = value;
return NULL; /* malformed. */
}
/* Build an object from the text. */
const char *Json::parseObject(Json *item, const char *value) {
Json *child;
#ifdef SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */
if (*value != '{') {
ep = value;
return 0;
} /* not an object! */
#endif
item->_type = JSON_OBJECT;
value = skip(value + 1);
if (*value == '}') {
return value + 1; /* empty array. */
}
item->_child = child = new(__FILE__, __LINE__) Json(NULL);
if (!item->_child) {
return NULL;
}
value = skip(parseString(child, skip(value)));
if (!value) {
return NULL;
}
child->_name = child->_valueString;
child->_valueString = 0;
if (*value != ':') {
_error = value;
return NULL;
} /* fail! */
value = skip(parseValue(child, skip(value + 1))); /* skip any spacing, get the value. */
if (!value) {
return NULL;
}
item->_size = 1;
while (*value == ',') {
Json *new_item = new(__FILE__, __LINE__) Json(NULL);
if (!new_item) {
return NULL; /* memory fail */
}
child->_next = new_item;
#if SPINE_JSON_HAVE_PREV
new_item->prev = child;
#endif
child = new_item;
value = skip(parseString(child, skip(value + 1)));
if (!value) {
return NULL;
}
child->_name = child->_valueString;
child->_valueString = 0;
if (*value != ':') {
_error = value;
return NULL;
} /* fail! */
value = skip(parseValue(child, skip(value + 1))); /* skip any spacing, get the value. */
if (!value) {
return NULL;
}
item->_size++;
}
if (*value == '}') {
return value + 1; /* end of array */
}
_error = value;
return NULL; /* malformed. */
}
int Json::json_strcasecmp(const char *s1, const char *s2) {
/* TODO we may be able to elide these NULL checks if we can prove
* the graph and input (only callsite is Json_getItem) should not have NULLs
*/
if (s1 && s2) {
#if defined(_WIN32)
return _stricmp(s1, s2);
#else
return strcasecmp(s1, s2);
#endif
} else {
if (s1 < s2) {
return -1; /* s1 is null, s2 is not */
} else if (s1 == s2) {
return 0; /* both are null */
} else {
return 1; /* s2 is nul s1 is not */
}
}
}
+95 -64
View File
@@ -1,83 +1,114 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, dispose of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/* Esoteric Software: Removed everything except parsing, shorter method names, more get methods, double to float, formatted. */
#ifndef Spine_Json_h
#define Spine_Json_h
#ifndef SPINE_JSON_H_
#define SPINE_JSON_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Json Types: */
#define Json_False 0
#define Json_True 1
#define Json_NULL 2
#define Json_Number 3
#define Json_String 4
#define Json_Array 5
#define Json_Object 6
#include <spine/SpineObject.h>
#ifndef SPINE_JSON_HAVE_PREV
/* Spine doesn't use the "prev" link in the Json sibling lists. */
/* spine doesn't use the "prev" link in the Json sibling lists. */
#define SPINE_JSON_HAVE_PREV 0
#endif
/* The Json structure: */
typedef struct Json {
struct Json* next;
namespace spine {
class SP_API Json : public SpineObject {
friend class SkeletonJson;
public:
/* Json Types: */
static const int JSON_FALSE;
static const int JSON_TRUE;
static const int JSON_NULL;
static const int JSON_NUMBER;
static const int JSON_STRING;
static const int JSON_ARRAY;
static const int JSON_OBJECT;
/* Get item "string" from object. Case insensitive. */
static Json *getItem(Json *object, const char *string);
static const char *getString(Json *object, const char *name, const char *defaultValue);
static float getFloat(Json *object, const char *name, float defaultValue);
static int getInt(Json *object, const char *name, int defaultValue);
/* 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. */
static const char *getError();
/* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */
explicit Json(const char *value);
~Json();
private:
static const char *_error;
Json *_next;
#if SPINE_JSON_HAVE_PREV
struct Json* prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */
Json* _prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */
#endif
struct Json* child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
Json *_child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
int size; /* The number of children. */
int _type; /* The type of the item, as above. */
int _size; /* The number of children. */
const char* valueString; /* The item's string, if type==Json_String */
int valueInt; /* The item's number, if type==Json_Number */
float valueFloat; /* The item's number, if type==Json_Number */
const char *_valueString; /* The item's string, if type==JSON_STRING */
int _valueInt; /* The item's number, if type==JSON_NUMBER */
float _valueFloat; /* The item's number, if type==JSON_NUMBER */
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. */
} Json;
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. */
/* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */
Json* Json_create (const char* value);
/* Utility to jump whitespace and cr/lf */
static const char *skip(const char *inValue);
/* Delete a Json entity and all subentities. */
void Json_dispose (Json* json);
/* Parser core - when encountering text, process appropriately. */
static const char *parseValue(Json *item, const char *value);
/* Get item "string" from object. Case insensitive. */
Json* Json_getItem (Json* json, const char* string);
const char* Json_getString (Json* json, const char* name, const char* defaultValue);
float Json_getFloat (Json* json, const char* name, float defaultValue);
int Json_getInt (Json* json, const char* name, int defaultValue);
/* Parse the input text into an unescaped cstring, and populate item. */
static const char *parseString(Json *item, const char *str);
/* 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. */
const char* Json_getError (void);
/* Parse the input text to generate a number, and populate the result into item. */
static const char *parseNumber(Json *item, const char *num);
#ifdef __cplusplus
/* Build an array from input text. */
static const char *parseArray(Json *item, const char *value);
/* Build an object from the text. */
static const char *parseObject(Json *item, const char *value);
static int json_strcasecmp(const char *s1, const char *s2);
};
}
#endif
#endif /* SPINE_JSON_H_ */
#endif /* Spine_Json_h */
@@ -0,0 +1,46 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/LinkedMesh.h>
#include <spine/MeshAttachment.h>
using namespace spine;
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent) :
_mesh(mesh),
_skin(skin),
_slotIndex(slotIndex),
_parent(parent) {
}
@@ -0,0 +1,56 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_LinkedMesh_h
#define Spine_LinkedMesh_h
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
namespace spine {
class MeshAttachment;
class SP_API LinkedMesh : public SpineObject {
friend class SkeletonBinary;
friend class SkeletonJson;
public:
LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent);
private:
MeshAttachment *_mesh;
String _skin;
size_t _slotIndex;
String _parent;
};
}
#endif /* Spine_LinkedMesh_h */
@@ -0,0 +1,129 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/MathUtil.h>
#include <math.h>
#include <random>
#include <stdlib.h>
// Required for division by 0 in _isNaN on MSVC
#ifdef _MSC_VER
#pragma warning(disable:4723)
#endif
using namespace spine;
const float MathUtil::Pi = 3.1415926535897932385f;
const float MathUtil::Pi_2 = 3.1415926535897932385f * 2;
const float MathUtil::Deg_Rad = (3.1415926535897932385f / 180.0f);
const float MathUtil::Rad_Deg = (180.0f / 3.1415926535897932385f);
float MathUtil::abs(float v) {
return ((v) < 0 ? -(v) : (v));
}
float MathUtil::sign(float v) {
return ((v) < 0 ? -1.0f : (v) > 0 ? 1.0f : 0.0f);
}
float MathUtil::clamp(float x, float min, float max) {
return ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)));
}
float MathUtil::fmod(float a, float b) {
return (float)::fmod(a, b);
}
/// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
/// degrees), largest error of 0.00488 radians (0.2796 degrees).
float MathUtil::atan2(float y, float x) {
return (float)::atan2(y, x);
}
/// Returns the cosine in radians from a lookup table.
float MathUtil::cos(float radians) {
return (float)::cos(radians);
}
/// Returns the sine in radians from a lookup table.
float MathUtil::sin(float radians) {
return (float)::sin(radians);
}
float MathUtil::sqrt(float v) {
return (float)::sqrt(v);
}
float MathUtil::acos(float v) {
return (float)::acos(v);
}
/// Returns the sine in radians from a lookup table.
float MathUtil::sinDeg(float degrees) {
return (float)::sin(degrees * MathUtil::Deg_Rad);
}
/// Returns the cosine in radians from a lookup table.
float MathUtil::cosDeg(float degrees) {
return (float)::cos(degrees * MathUtil::Deg_Rad);
}
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
static bool _isNan(float value, float zero) {
float _nan = (float) 0.0 / zero;
return 0 == memcmp((void *) &value, (void *) &_nan, sizeof(value));
}
bool MathUtil::isNan(float v) {
return _isNan(v, 0);
}
float MathUtil::random() {
return ::rand() / (float)RAND_MAX;
}
float MathUtil::randomTriangular(float min, float max) {
return randomTriangular(min, max, (min + max) * 0.5f);
}
float MathUtil::randomTriangular(float min, float max, float mode) {
float u = random();
float d = max - min;
if (u <= (mode - min) / d) return min + sqrt(u * d * (mode - min));
return max - sqrt((1 - u) * d * (max - mode));
}
float MathUtil::pow(float a, float b) {
return (float)::pow(a, b);
}
@@ -0,0 +1,130 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_MathUtil_h
#define Spine_MathUtil_h
#include <spine/SpineObject.h>
#include <string.h>
namespace spine {
class SP_API MathUtil : public SpineObject {
private:
MathUtil();
public:
static const float Pi;
static const float Pi_2;
static const float Deg_Rad;
static const float Rad_Deg;
template<typename T>
static inline T min(T a, T b) { return a < b ? a : b; }
template<typename T>
static inline T max(T a, T b) { return a > b ? a : b; }
static float sign(float val);
static float clamp(float x, float lower, float upper);
static float abs(float v);
/// Returns the sine in radians from a lookup table.
static float sin(float radians);
/// Returns the cosine in radians from a lookup table.
static float cos(float radians);
/// Returns the sine in radians from a lookup table.
static float sinDeg(float degrees);
/// Returns the cosine in radians from a lookup table.
static float cosDeg(float degrees);
/// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
/// degrees), largest error of 0.00488 radians (0.2796 degrees).
static float atan2(float y, float x);
static float acos(float v);
static float sqrt(float v);
static float fmod(float a, float b);
static bool isNan(float v);
static float random();
static float randomTriangular(float min, float max);
static float randomTriangular(float min, float max, float mode);
static float pow(float a, float b);
};
struct SP_API Interpolation {
virtual float apply(float a) = 0;
virtual float interpolate(float start, float end, float a) {
return start + (end - start) * apply(a);
}
virtual ~Interpolation() {};
};
struct SP_API PowInterpolation: public Interpolation {
PowInterpolation(int power): power(power) {
}
float apply(float a) {
if (a <= 0.5f) return MathUtil::pow(a * 2.0f, (float)power) / 2.0f;
return MathUtil::pow((a - 1.0f) * 2.0f, (float)power) / (power % 2 == 0 ? -2.0f : 2.0f) + 1.0f;
}
int power;
};
struct SP_API PowOutInterpolation: public Interpolation {
PowOutInterpolation(int power): power(power) {
}
float apply(float a) {
return MathUtil::pow(a - 1, (float)power) * (power % 2 == 0 ? -1.0f : 1.0f) + 1.0f;
}
int power;
};
}
#endif /* Spine_MathUtil_h */
@@ -1,100 +0,0 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/MeshAttachment.h>
#include <spine/extension.h>
void _spMeshAttachment_dispose (spAttachment* attachment) {
spMeshAttachment* self = SUB_CAST(spMeshAttachment, attachment);
FREE(self->path);
FREE(self->uvs);
if (!self->parentMesh) {
_spVertexAttachment_deinit(SUPER(self));
FREE(self->regionUVs);
FREE(self->triangles);
FREE(self->edges);
} else
_spAttachment_deinit(attachment);
FREE(self);
}
spMeshAttachment* spMeshAttachment_create (const char* name) {
spMeshAttachment* self = NEW(spMeshAttachment);
_spVertexAttachment_init(SUPER(self));
spColor_setFromFloats(&self->color, 1, 1, 1, 1);
_spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_MESH, _spMeshAttachment_dispose);
return self;
}
void spMeshAttachment_updateUVs (spMeshAttachment* self) {
int i;
float width = self->regionU2 - self->regionU, height = self->regionV2 - self->regionV;
int verticesLength = SUPER(self)->worldVerticesLength;
FREE(self->uvs);
self->uvs = MALLOC(float, verticesLength);
if (self->regionRotate) {
for (i = 0; i < verticesLength; i += 2) {
self->uvs[i] = self->regionU + self->regionUVs[i + 1] * width;
self->uvs[i + 1] = self->regionV + height - self->regionUVs[i] * height;
}
} else {
for (i = 0; i < verticesLength; i += 2) {
self->uvs[i] = self->regionU + self->regionUVs[i] * width;
self->uvs[i + 1] = self->regionV + self->regionUVs[i + 1] * height;
}
}
}
void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) {
CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh;
if (parentMesh) {
self->super.bones = parentMesh->super.bones;
self->super.bonesCount = parentMesh->super.bonesCount;
self->super.vertices = parentMesh->super.vertices;
self->super.verticesCount = parentMesh->super.verticesCount;
self->regionUVs = parentMesh->regionUVs;
self->triangles = parentMesh->triangles;
self->trianglesCount = parentMesh->trianglesCount;
self->hullLength = parentMesh->hullLength;
self->super.worldVerticesLength = parentMesh->super.worldVerticesLength;
self->edges = parentMesh->edges;
self->edgesCount = parentMesh->edgesCount;
self->width = parentMesh->width;
self->height = parentMesh->height;
}
}
@@ -0,0 +1,264 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/MeshAttachment.h>
#include <spine/HasRendererObject.h>
using namespace spine;
RTTI_IMPL(MeshAttachment, VertexAttachment)
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(),
_regionOffsetX(0),
_regionOffsetY(0),
_regionWidth(0),
_regionHeight(0),
_regionOriginalWidth(0),
_regionOriginalHeight(0),
_parentMesh(NULL),
_path(),
_regionU(0),
_regionV(0),
_regionU2(0),
_regionV2(0),
_width(0),
_height(0),
_color(1, 1, 1, 1),
_hullLength(0),
_inheritDeform(false),
_regionRotate(false) {
}
MeshAttachment::~MeshAttachment() {}
void MeshAttachment::updateUVs() {
if (_uvs.size() != _regionUVs.size()) {
_uvs.setSize(_regionUVs.size(), 0);
}
if (_regionRotate) {
float textureHeight = _regionWidth / (_regionV2 - _regionV);
float textureWidth = _regionHeight / (_regionU2 - _regionU);
float u = _regionU - (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureWidth;
float v = _regionV - (_regionOriginalWidth - _regionOffsetX - _regionWidth) / textureHeight;
float width = _regionOriginalHeight / textureWidth;
float height = _regionOriginalWidth / textureHeight;
for (size_t i = 0, n = _uvs.size(); i < n; i += 2) {
_uvs[i] = u + _regionUVs[i + 1] * width;
_uvs[i + 1] = v + height - _regionUVs[i] * height;
}
} else {
float textureWidth = _regionWidth / (_regionU2 - _regionU);
float textureHeight = _regionHeight / (_regionV2 - _regionV);
float u = _regionU - _regionOffsetX / textureWidth;
float v = _regionV - (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureHeight;
float width = _regionOriginalWidth / textureWidth;
float height = _regionOriginalHeight / textureHeight;
for (size_t i = 0, n = _uvs.size(); i < n; i += 2) {
_uvs[i] = u + _regionUVs[i] * width;
_uvs[i + 1] = v + _regionUVs[i + 1] * height;
}
}
}
bool MeshAttachment::applyDeform(VertexAttachment *sourceAttachment) {
return this == sourceAttachment || (_inheritDeform && _parentMesh == sourceAttachment);
}
int MeshAttachment::getHullLength() {
return _hullLength;
}
void MeshAttachment::setHullLength(int inValue) {
_hullLength = inValue;
}
Vector<float> &MeshAttachment::getRegionUVs() {
return _regionUVs;
}
Vector<float> &MeshAttachment::getUVs() {
return _uvs;
}
Vector<unsigned short> &MeshAttachment::getTriangles() {
return _triangles;
}
const String &MeshAttachment::getPath() {
return _path;
}
void MeshAttachment::setPath(const String &inValue) {
_path = inValue;
}
float MeshAttachment::getRegionU() {
return _regionU;
}
void MeshAttachment::setRegionU(float inValue) {
_regionU = inValue;
}
float MeshAttachment::getRegionV() {
return _regionV;
}
void MeshAttachment::setRegionV(float inValue) {
_regionV = inValue;
}
float MeshAttachment::getRegionU2() {
return _regionU2;
}
void MeshAttachment::setRegionU2(float inValue) {
_regionU2 = inValue;
}
float MeshAttachment::getRegionV2() {
return _regionV2;
}
void MeshAttachment::setRegionV2(float inValue) {
_regionV2 = inValue;
}
bool MeshAttachment::getRegionRotate() {
return _regionRotate;
}
void MeshAttachment::setRegionRotate(bool inValue) {
_regionRotate = inValue;
}
float MeshAttachment::getRegionOffsetX() {
return _regionOffsetX;
}
void MeshAttachment::setRegionOffsetX(float inValue) {
_regionOffsetX = inValue;
}
float MeshAttachment::getRegionOffsetY() {
return _regionOffsetY;
}
void MeshAttachment::setRegionOffsetY(float inValue) {
_regionOffsetY = inValue;
}
float MeshAttachment::getRegionWidth() {
return _regionWidth;
}
void MeshAttachment::setRegionWidth(float inValue) {
_regionWidth = inValue;
}
float MeshAttachment::getRegionHeight() {
return _regionHeight;
}
void MeshAttachment::setRegionHeight(float inValue) {
_regionHeight = inValue;
}
float MeshAttachment::getRegionOriginalWidth() {
return _regionOriginalWidth;
}
void MeshAttachment::setRegionOriginalWidth(float inValue) {
_regionOriginalWidth = inValue;
}
float MeshAttachment::getRegionOriginalHeight() {
return _regionOriginalHeight;
}
void MeshAttachment::setRegionOriginalHeight(float inValue) {
_regionOriginalHeight = inValue;
}
bool MeshAttachment::getInheritDeform() {
return _inheritDeform;
}
void MeshAttachment::setInheritDeform(bool inValue) {
_inheritDeform = inValue;
}
MeshAttachment *MeshAttachment::getParentMesh() {
return _parentMesh;
}
void MeshAttachment::setParentMesh(MeshAttachment *inValue) {
_parentMesh = inValue;
if (inValue != NULL) {
_bones.clearAndAddAll(inValue->_bones);
_vertices.clearAndAddAll(inValue->_vertices);
_worldVerticesLength = inValue->_worldVerticesLength;
_regionUVs.clearAndAddAll(inValue->_regionUVs);
_triangles.clearAndAddAll(inValue->_triangles);
_hullLength = inValue->_hullLength;
_edges.clearAndAddAll(inValue->_edges);
_width = inValue->_width;
_height = inValue->_height;
}
}
Vector<unsigned short> &MeshAttachment::getEdges() {
return _edges;
}
float MeshAttachment::getWidth() {
return _width;
}
void MeshAttachment::setWidth(float inValue) {
_width = inValue;
}
float MeshAttachment::getHeight() {
return _height;
}
void MeshAttachment::setHeight(float inValue) {
_height = inValue;
}
spine::Color &MeshAttachment::getColor() {
return _color;
}
@@ -1,91 +1,142 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_MESHATTACHMENT_H_
#define SPINE_MESHATTACHMENT_H_
#include <spine/dll.h>
#include <spine/Attachment.h>
#include <spine/VertexAttachment.h>
#include <spine/Atlas.h>
#include <spine/Slot.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spMeshAttachment spMeshAttachment;
struct spMeshAttachment {
spVertexAttachment super;
void* rendererObject;
int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */
int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */
float regionU, regionV, regionU2, regionV2;
int/*bool*/regionRotate;
const char* path;
float* regionUVs;
float* uvs;
int trianglesCount;
unsigned short* triangles;
spColor color;
int hullLength;
spMeshAttachment* const parentMesh;
int/*bool*/inheritDeform;
/* Nonessential. */
int edgesCount;
int* edges;
float width, height;
};
SP_API spMeshAttachment* spMeshAttachment_create (const char* name);
SP_API void spMeshAttachment_updateUVs (spMeshAttachment* self);
SP_API void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh);
#ifdef SPINE_SHORT_NAMES
typedef spMeshAttachment MeshAttachment;
#define MeshAttachment_create(...) spMeshAttachment_create(__VA_ARGS__)
#define MeshAttachment_updateUVs(...) spMeshAttachment_updateUVs(__VA_ARGS__)
#define MeshAttachment_setParentMesh(...) spMeshAttachment_setParentMesh(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_MESHATTACHMENT_H_ */
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_MeshAttachment_h
#define Spine_MeshAttachment_h
#include <spine/VertexAttachment.h>
#include <spine/Vector.h>
#include <spine/Color.h>
#include <spine/HasRendererObject.h>
namespace spine {
/// Attachment that displays a texture region using a mesh.
class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
friend class SkeletonBinary;
friend class SkeletonJson;
friend class AtlasAttachmentLoader;
RTTI_DECL
public:
explicit MeshAttachment(const String& name);
virtual ~MeshAttachment();
void updateUVs();
virtual bool applyDeform(VertexAttachment* sourceAttachment);
int getHullLength();
void setHullLength(int inValue);
Vector<float>& getRegionUVs();
/// The UV pair for each vertex, normalized within the entire texture. See also MeshAttachment::updateUVs
Vector<float>& getUVs();
Vector<unsigned short>& getTriangles();
Color& getColor();
const String& getPath();
void setPath(const String& inValue);
float getRegionU();
void setRegionU(float inValue);
float getRegionV();
void setRegionV(float inValue);
float getRegionU2();
void setRegionU2(float inValue);
float getRegionV2();
void setRegionV2(float inValue);
bool getRegionRotate();
void setRegionRotate(bool inValue);
float getRegionOffsetX();
void setRegionOffsetX(float inValue);
// Pixels stripped from the bottom left, unrotated.
float getRegionOffsetY();
void setRegionOffsetY(float inValue);
float getRegionWidth();
void setRegionWidth(float inValue);
// Unrotated, stripped size.
float getRegionHeight();
void setRegionHeight(float inValue);
float getRegionOriginalWidth();
void setRegionOriginalWidth(float inValue);
// Unrotated, unstripped size.
float getRegionOriginalHeight();
void setRegionOriginalHeight(float inValue);
bool getInheritDeform();
void setInheritDeform(bool inValue);
MeshAttachment* getParentMesh();
void setParentMesh(MeshAttachment* inValue);
// Nonessential.
Vector<unsigned short>& getEdges();
float getWidth();
void setWidth(float inValue);
float getHeight();
void setHeight(float inValue);
private:
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
MeshAttachment* _parentMesh;
Vector<float> _uvs;
Vector<float> _regionUVs;
Vector<unsigned short> _triangles;
Vector<unsigned short> _edges;
String _path;
float _regionU;
float _regionV;
float _regionU2;
float _regionV2;
float _width;
float _height;
Color _color;
int _hullLength;
bool _inheritDeform;
bool _regionRotate;
};
}
#endif /* Spine_MeshAttachment_h */
@@ -28,12 +28,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/Array.h>
#include <spine/extension.h>
#ifndef Spine_MixPose_h
#define Spine_MixPose_h
_SP_ARRAY_IMPLEMENT_TYPE(spFloatArray, float)
_SP_ARRAY_IMPLEMENT_TYPE(spIntArray, int)
_SP_ARRAY_IMPLEMENT_TYPE(spShortArray, short)
_SP_ARRAY_IMPLEMENT_TYPE(spUnsignedShortArray, unsigned short)
_SP_ARRAY_IMPLEMENT_TYPE(spArrayFloatArray, spFloatArray*)
_SP_ARRAY_IMPLEMENT_TYPE(spArrayShortArray, spShortArray*)
namespace spine {
///
/// Controls how a timeline is mixed with the setup or current pose.
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, Blend, MixDirection)
enum MixBlend {
MixBlend_Setup = 0,
MixBlend_First,
MixBlend_Replace,
MixBlend_Add
};
}
#endif /* Spine_MixPose_h */
@@ -0,0 +1,44 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef Spine_MixDirection_h
#define Spine_MixDirection_h
namespace spine {
///
/// Indicates whether a timeline's alpha is mixing out over time toward 0 (the setup or current pose) or mixing in toward 1 (the timeline's pose).
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, MixPose, MixDirection)
enum MixDirection {
MixDirection_In = 0,
MixDirection_Out
};
}
#endif /* Spine_MixDirection_h */
@@ -0,0 +1,62 @@
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifdef SPINE_UE4
#include "SpinePluginPrivatePCH.h"
#endif
#include <spine/PathAttachment.h>
using namespace spine;
RTTI_IMPL(PathAttachment, VertexAttachment)
PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
}
Vector<float> &PathAttachment::getLengths() {
return _lengths;
}
bool PathAttachment::isClosed() {
return _closed;
}
void PathAttachment::setClosed(bool inValue) {
_closed = inValue;
}
bool PathAttachment::isConstantSpeed() {
return _constantSpeed;
}
void PathAttachment::setConstantSpeed(bool inValue) {
_constantSpeed = inValue;
}

Some files were not shown because too many files have changed in this diff Show More