Updated spine-cocos2dx 2 and 3 to Spine v3.

This commit is contained in:
NathanSweet 2016-02-16 23:06:23 +01:00
parent 61deedc76c
commit b25992464b
8 changed files with 49 additions and 27 deletions

View File

@ -20,12 +20,14 @@
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
@ -97,6 +99,9 @@
<ClInclude Include="include\spine\Slot.h" /> <ClInclude Include="include\spine\Slot.h" />
<ClInclude Include="include\spine\SlotData.h" /> <ClInclude Include="include\spine\SlotData.h" />
<ClInclude Include="include\spine\spine.h" /> <ClInclude Include="include\spine\spine.h" />
<ClInclude Include="include\spine\TransformConstraint.h" />
<ClInclude Include="include\spine\TransformConstraintData.h" />
<ClInclude Include="include\spine\WeightedMeshAttachment.h" />
<ClInclude Include="src\spine\Json.h" /> <ClInclude Include="src\spine\Json.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -123,9 +128,11 @@
<ClCompile Include="src\spine\SkeletonData.c" /> <ClCompile Include="src\spine\SkeletonData.c" />
<ClCompile Include="src\spine\SkeletonJson.c" /> <ClCompile Include="src\spine\SkeletonJson.c" />
<ClCompile Include="src\spine\Skin.c" /> <ClCompile Include="src\spine\Skin.c" />
<ClCompile Include="src\spine\SkinnedMeshAttachment.c" />
<ClCompile Include="src\spine\Slot.c" /> <ClCompile Include="src\spine\Slot.c" />
<ClCompile Include="src\spine\SlotData.c" /> <ClCompile Include="src\spine\SlotData.c" />
<ClCompile Include="src\spine\TransformConstraint.c" />
<ClCompile Include="src\spine\TransformConstraintData.c" />
<ClCompile Include="src\spine\WeightedMeshAttachment.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -96,6 +96,15 @@
<ClInclude Include="include\spine\IkConstraintData.h"> <ClInclude Include="include\spine\IkConstraintData.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\spine\TransformConstraint.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\spine\TransformConstraintData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\spine\WeightedMeshAttachment.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\spine\Atlas.c"> <ClCompile Include="src\spine\Atlas.c">
@ -167,14 +176,20 @@
<ClCompile Include="src\spine\MeshAttachment.c"> <ClCompile Include="src\spine\MeshAttachment.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\spine\SkinnedMeshAttachment.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\spine\IkConstraint.c"> <ClCompile Include="src\spine\IkConstraint.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\spine\IkConstraintData.c"> <ClCompile Include="src\spine\IkConstraintData.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\spine\TransformConstraint.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\spine\TransformConstraintData.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\spine\WeightedMeshAttachment.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -88,8 +88,8 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
CONST_CAST(float, self->d) = ld; CONST_CAST(float, self->d) = ld;
CONST_CAST(float, self->worldX) = x; CONST_CAST(float, self->worldX) = x;
CONST_CAST(float, self->worldY) = y; CONST_CAST(float, self->worldY) = y;
CONST_CAST(float, self->worldSignX) = scaleX > 0 ? 1 : -1; CONST_CAST(float, self->worldSignX) = scaleX > 0 ? 1.0f : -1.0f;
CONST_CAST(float, self->worldSignY) = scaleY > 0 ? 1 : -1; CONST_CAST(float, self->worldSignY) = scaleY > 0 ? 1.0f : -1.0f;
return; return;
} }

View File

@ -133,7 +133,7 @@ void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float
float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty; float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty;
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa; float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
float d = c1 * c1 - 4 * c2 * c0; float d = c1 * c1 - 4 * c2 * c0;
float minAngle = 0, minDist = 999999999, minX = 0, minY = 0; float minAngle = 0, minDist = 999999999.0f, minX = 0, minY = 0;
float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0; float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0;
float x = l1 + a, dist = x * x, angle, y; float x = l1 + a, dist = x * x, angle, y;
cy = 0; cy = 0;

View File

@ -184,9 +184,9 @@ void SkeletonRenderer::draw () {
a = attachment->a; a = attachment->a;
break; break;
} }
case SP_ATTACHMENT_SKINNED_MESH: { case SP_ATTACHMENT_WEIGHTED_MESH: {
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment; spWeightedMeshAttachment* attachment = (spWeightedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); spWeightedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
texture = getTexture(attachment); texture = getTexture(attachment);
uvs = attachment->uvs; uvs = attachment->uvs;
verticesCount = attachment->uvsCount; verticesCount = attachment->uvsCount;
@ -250,8 +250,8 @@ void SkeletonRenderer::draw () {
ccDrawColor4B(255, 0, 0, 255); ccDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->bonesCount; i < n; i++) { for (int i = 0, n = skeleton->bonesCount; i < n; i++) {
spBone *bone = skeleton->bones[i]; spBone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX; float x = bone->data->length * bone->a + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY; float y = bone->data->length * bone->c + bone->worldY;
ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y)); ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
} }
// Bone origins. // Bone origins.
@ -273,7 +273,7 @@ CCTexture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject; return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
} }
CCTexture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const { CCTexture2D* SkeletonRenderer::getTexture (spWeightedMeshAttachment* attachment) const {
return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject; return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
} }
@ -292,9 +292,9 @@ CCRect SkeletonRenderer::boundingBox () {
spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(mesh, slot, worldVertices); spMeshAttachment_computeWorldVertices(mesh, slot, worldVertices);
verticesCount = mesh->verticesCount; verticesCount = mesh->verticesCount;
} else if (slot->attachment->type == SP_ATTACHMENT_SKINNED_MESH) { } else if (slot->attachment->type == SP_ATTACHMENT_WEIGHTED_MESH) {
spSkinnedMeshAttachment* mesh = (spSkinnedMeshAttachment*)slot->attachment; spWeightedMeshAttachment* mesh = (spWeightedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices); spWeightedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices);
verticesCount = mesh->uvsCount; verticesCount = mesh->uvsCount;
} else } else
continue; continue;

View File

@ -97,7 +97,7 @@ protected:
virtual cocos2d::CCTexture2D* getTexture (spRegionAttachment* attachment) const; virtual cocos2d::CCTexture2D* getTexture (spRegionAttachment* attachment) const;
virtual cocos2d::CCTexture2D* getTexture (spMeshAttachment* attachment) const; virtual cocos2d::CCTexture2D* getTexture (spMeshAttachment* attachment) const;
virtual cocos2d::CCTexture2D* getTexture (spSkinnedMeshAttachment* attachment) const; virtual cocos2d::CCTexture2D* getTexture (spWeightedMeshAttachment* attachment) const;
private: private:
bool ownsSkeletonData; bool ownsSkeletonData;

View File

@ -198,9 +198,9 @@ void SkeletonRenderer::drawSkeleton (const Mat4 &transform, uint32_t transformFl
a = attachment->a; a = attachment->a;
break; break;
} }
case SP_ATTACHMENT_SKINNED_MESH: { case SP_ATTACHMENT_WEIGHTED_MESH: {
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment; spWeightedMeshAttachment* attachment = (spWeightedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices); spWeightedMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices);
texture = getTexture(attachment); texture = getTexture(attachment);
uvs = attachment->uvs; uvs = attachment->uvs;
verticesCount = attachment->uvsCount; verticesCount = attachment->uvsCount;
@ -271,8 +271,8 @@ void SkeletonRenderer::drawSkeleton (const Mat4 &transform, uint32_t transformFl
DrawPrimitives::setDrawColor4B(255, 0, 0, 255); DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = _skeleton->bonesCount; i < n; i++) { for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
spBone *bone = _skeleton->bones[i]; spBone *bone = _skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX; float x = bone->data->length * bone->a + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY; float y = bone->data->length * bone->c + bone->worldY;
DrawPrimitives::drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y)); DrawPrimitives::drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y));
} }
// Bone origins. // Bone origins.
@ -296,7 +296,7 @@ Texture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject; return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
} }
Texture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const { Texture2D* SkeletonRenderer::getTexture (spWeightedMeshAttachment* attachment) const {
return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject; return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
} }
@ -315,9 +315,9 @@ Rect SkeletonRenderer::getBoundingBox () const {
spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices); spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
verticesCount = mesh->verticesCount; verticesCount = mesh->verticesCount;
} else if (slot->attachment->type == SP_ATTACHMENT_SKINNED_MESH) { } else if (slot->attachment->type == SP_ATTACHMENT_WEIGHTED_MESH) {
spSkinnedMeshAttachment* mesh = (spSkinnedMeshAttachment*)slot->attachment; spWeightedMeshAttachment* mesh = (spWeightedMeshAttachment*)slot->attachment;
spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices); spWeightedMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
verticesCount = mesh->uvsCount; verticesCount = mesh->uvsCount;
} else } else
continue; continue;

View File

@ -115,7 +115,7 @@ protected:
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData); void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual cocos2d::Texture2D* getTexture (spRegionAttachment* attachment) const; virtual cocos2d::Texture2D* getTexture (spRegionAttachment* attachment) const;
virtual cocos2d::Texture2D* getTexture (spMeshAttachment* attachment) const; virtual cocos2d::Texture2D* getTexture (spMeshAttachment* attachment) const;
virtual cocos2d::Texture2D* getTexture (spSkinnedMeshAttachment* attachment) const; virtual cocos2d::Texture2D* getTexture (spWeightedMeshAttachment* attachment) const;
bool _ownsSkeletonData; bool _ownsSkeletonData;
spAtlas* _atlas; spAtlas* _atlas;