diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b4f35c3..084616171 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * Added support for clipping. * Added support for rotated regions in texture atlas loaded via StarlingAtlasAttachmentLoader. * Added support for vertex effects. See `RaptorExample.as` + * Added 'getTexture()' method to 'StarlingTextureAtlasAttachmentLoader' ## C * **Breaking changes** @@ -63,6 +64,7 @@ * SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting. * Added support for vertex effects. See `RaptorExample.cpp`. * Added ETC1 alpha support, thanks @halx99! Does not work when two color tint is enabled. + * Added `spAtlasPage_setCustomTextureLoader()` which let's you do texture loading manually. Thanks @jareguo. ### Cocos2d-Objc * Fixed renderer to work with 3.6 changes @@ -145,7 +147,9 @@ * Removed `RegionBatcher` and `SkeletonRegionRenderer`, renamed `SkeletonMeshRenderer` to `SkeletonRenderer` * Added support for two color tint. For it to work, you need to add the `SpineEffect.fx` file to your content project, then load it via `var effect = Content.Load("SpineEffect");`, and set it on the `SkeletonRenderer`. See the example project for code. * Added support for any `Effect` to be used by `SkeletonRenderer` + * Added support for `IVertexEffect` to modify vertices of skeletons on the CPU. `IVertexEffect` instances can be set on the `SkeletonRenderer`. See example project. * Added `SkeletonDebugRenderer` + * Made `MeshBatcher` of SkeletonRenderer accessible via a getter. Allows user to batch their own geometry together with skeleton meshes for maximum batching instead of using XNA SpriteBatcher. ## Java * **Breaking changes** diff --git a/spine-c/spine-c/include/spine/AnimationState.h b/spine-c/spine-c/include/spine/AnimationState.h index fe6ae515a..224581961 100644 --- a/spine-c/spine-c/include/spine/AnimationState.h +++ b/spine-c/spine-c/include/spine/AnimationState.h @@ -84,7 +84,8 @@ struct spTrackEntry { timelineData(0), timelineDipMix(0), timelinesRotation(0), - timelinesRotationCount(0) { + timelinesRotationCount(0), + rendererObject(0), userData(0) { } #endif }; @@ -102,6 +103,7 @@ struct spAnimationState { spTrackEntryArray* mixingTo; void* rendererObject; + void* userData; #ifdef __cplusplus spAnimationState() : @@ -111,7 +113,8 @@ struct spAnimationState { listener(0), timeScale(0), mixingTo(0), - rendererObject(0) { + rendererObject(0), + userData(0) { } #endif }; diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp index 4a7378fb1..150700261 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp @@ -31,6 +31,13 @@ #include #include +namespace spine { + static CustomTextureLoader _customTextureLoader = nullptr; + void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) { + _customTextureLoader = texLoader; + } +} + USING_NS_CC; GLuint wrap (spAtlasWrap wrap) { @@ -60,7 +67,13 @@ GLuint filter (spAtlasFilter filter) { } void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { - Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path); + Texture2D* texture = nullptr; + if (spine::_customTextureLoader) { + texture = spine::_customTextureLoader(path); + } + if (!texture) { + texture = Director::getInstance()->getTextureCache()->addImage(path); + } CCASSERT(texture != nullptr, "Invalid image"); texture->retain(); diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.h b/spine-cocos2dx/src/spine/spine-cocos2dx.h index 81e2d7f12..497d12796 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.h +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.h @@ -38,4 +38,10 @@ #include #include +namespace spine { + typedef cocos2d::Texture2D* (*CustomTextureLoader)(const char* path); + // set custom texture loader for _spAtlasPage_createTexture + void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader); +} + #endif /* SPINE_COCOS2DX_H_ */ diff --git a/spine-csharp/src/SkeletonClipping.cs b/spine-csharp/src/SkeletonClipping.cs index 07d052895..1dcbb0a0e 100644 --- a/spine-csharp/src/SkeletonClipping.cs +++ b/spine-csharp/src/SkeletonClipping.cs @@ -258,7 +258,7 @@ namespace Spine { return clipped; } - static void MakeClockwise (ExposedList polygon) { + public static void MakeClockwise (ExposedList polygon) { float[] vertices = polygon.Items; int verticeslength = polygon.Count; diff --git a/spine-csharp/src/Triangulator.cs b/spine-csharp/src/Triangulator.cs index c4bdb0418..ad9f39ee2 100644 --- a/spine-csharp/src/Triangulator.cs +++ b/spine-csharp/src/Triangulator.cs @@ -31,7 +31,7 @@ using System; namespace Spine { - internal class Triangulator { + public class Triangulator { private readonly ExposedList> convexPolygons = new ExposedList>(); private readonly ExposedList> convexPolygonsIndices = new ExposedList>(); diff --git a/spine-monogame/example/Content/SpineEffect.fx b/spine-monogame/example/Content/SpineEffect.fx index 49d09ec0e..067d967fa 100644 --- a/spine-monogame/example/Content/SpineEffect.fx +++ b/spine-monogame/example/Content/SpineEffect.fx @@ -51,7 +51,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 float alpha = texColor.a * input.Color.a; float4 output; output.a = alpha; - output.rgb = (1.0 - texColor.rgb) * input.Color2.rgb * alpha + texColor.rgb * input.Color.rgb; + output.rgb = ((texColor.a - 1.0) * input.Color2.a + 1.0 - texColor.rgb) * input.Color2.rgb + texColor.rgb * input.Color.rgb; return output; } diff --git a/spine-ue4/Content/Test/Blueprints/Cube_Blueprint.uasset b/spine-ue4/Content/Test/Blueprints/Cube_Blueprint.uasset new file mode 100644 index 000000000..235893e9a Binary files /dev/null and b/spine-ue4/Content/Test/Blueprints/Cube_Blueprint.uasset differ diff --git a/spine-ue4/Content/Test/Blueprints/TouchClick.uasset b/spine-ue4/Content/Test/Blueprints/TouchClick.uasset new file mode 100644 index 000000000..9c478dd09 Binary files /dev/null and b/spine-ue4/Content/Test/Blueprints/TouchClick.uasset differ diff --git a/spine-ue4/Content/Test/Blueprints/TouchPlayer.uasset b/spine-ue4/Content/Test/Blueprints/TouchPlayer.uasset new file mode 100644 index 000000000..bb4d02341 Binary files /dev/null and b/spine-ue4/Content/Test/Blueprints/TouchPlayer.uasset differ diff --git a/spine-ue4/Content/Test/Blueprints/TwoColor_Blueprint.uasset b/spine-ue4/Content/Test/Blueprints/TwoColor_Blueprint.uasset index 597a81011..79d88c4de 100644 Binary files a/spine-ue4/Content/Test/Blueprints/TwoColor_Blueprint.uasset and b/spine-ue4/Content/Test/Blueprints/TwoColor_Blueprint.uasset differ diff --git a/spine-ue4/Content/Test/Test.umap b/spine-ue4/Content/Test/Test.umap index f5fc98e8c..ff900fe8f 100644 Binary files a/spine-ue4/Content/Test/Test.umap and b/spine-ue4/Content/Test/Test.umap differ diff --git a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitAdditiveMaterial.uasset b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitAdditiveMaterial.uasset index c48055e19..7af2b68cd 100644 Binary files a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitAdditiveMaterial.uasset and b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitAdditiveMaterial.uasset differ diff --git a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitMultiplyMaterial.uasset b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitMultiplyMaterial.uasset index 3efcd100b..75a0af765 100644 Binary files a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitMultiplyMaterial.uasset and b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitMultiplyMaterial.uasset differ diff --git a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitNormalMaterial.uasset b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitNormalMaterial.uasset index f43f75893..f68e39f99 100644 Binary files a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitNormalMaterial.uasset and b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitNormalMaterial.uasset differ diff --git a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitScreenMaterial.uasset b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitScreenMaterial.uasset index e1b79ff0f..271a7c885 100644 Binary files a/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitScreenMaterial.uasset and b/spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitScreenMaterial.uasset differ diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp index 8a7f1d2ee..613b2d867 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp @@ -178,7 +178,7 @@ void USpineSkeletonRendererComponent::Flush (int &Idx, TArray &Vertices verts.Add(FRuntimeMeshVertexTripleUV(Vertices[i], FVector(), FVector(), Colors[i], Uvs[i], FVector2D(Colors2[i].X, Colors2[i].Y), FVector2D(Colors2[i].Z, 0))); } - CreateMeshSection(Idx, verts, Indices); + CreateMeshSection(Idx, verts, Indices, true); // CreateMeshSection(Idx, Vertices, Indices, TArray(), Uvs, darkRG, Colors, TArray(), false); Vertices.SetNum(0); diff --git a/spine-xna/example-content/SpineEffect.fx b/spine-xna/example-content/SpineEffect.fx index 565709b37..38d1ef0be 100644 --- a/spine-xna/example-content/SpineEffect.fx +++ b/spine-xna/example-content/SpineEffect.fx @@ -42,7 +42,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 float alpha = texColor.a * input.Color.a; float4 output; output.a = alpha; - output.rgb = (1.0 - texColor.rgb) * input.Color2.rgb * alpha + texColor.rgb * input.Color.rgb; + output.rgb = ((texColor.a - 1.0) * input.Color2.a + 1.0 - texColor.rgb) * input.Color2.rgb + texColor.rgb * input.Color.rgb; return output; } diff --git a/spine-xna/example/src/ExampleGame.cs b/spine-xna/example/src/ExampleGame.cs index aa81a027f..a7b251457 100644 --- a/spine-xna/example/src/ExampleGame.cs +++ b/spine-xna/example/src/ExampleGame.cs @@ -85,10 +85,10 @@ namespace Spine { skeletonDebugRenderer.DrawClipping = true; // String name = "spineboy-ess"; - String name = "goblins-pro"; + // String name = "goblins-pro"; // String name = "raptor-pro"; // String name = "tank-pro"; - // String name = "coin-pro"; + String name = "coin-pro"; String atlasName = name.Replace("-pro", "").Replace("-ess", ""); if (name == "goblins-pro") atlasName = "goblins-mesh"; bool binaryData = false; diff --git a/spine-xna/src/SkeletonRenderer.cs b/spine-xna/src/SkeletonRenderer.cs index 8f105dec1..acf9c6f44 100644 --- a/spine-xna/src/SkeletonRenderer.cs +++ b/spine-xna/src/SkeletonRenderer.cs @@ -45,6 +45,7 @@ namespace Spine { SkeletonClipping clipper = new SkeletonClipping(); GraphicsDevice device; MeshBatcher batcher; + public MeshBatcher Batcher { get { return batcher; } } RasterizerState rasterizerState; float[] vertices = new float[8]; int[] quadTriangles = { 0, 1, 2, 2, 3, 0 }; @@ -163,8 +164,13 @@ namespace Spine { Color darkColor = new Color(); if (slot.HasSecondColor) { - darkColor = new Color(slot.R2, slot.G2, slot.B2); + if (premultipliedAlpha) { + darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a); + } else { + darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a); + } } + darkColor.A = premultipliedAlpha ? (byte)255 : (byte)0; // clip if (clipper.IsClipping()) {