Browse Source

Merge remote-tracking branch 'origin/3.6' into 3.6

NathanSweet 8 years ago
parent
commit
5f03186b36

+ 4 - 0
CHANGELOG.md

@@ -25,6 +25,7 @@
  * Added support for clipping.
  * Added support for clipping.
  * Added support for rotated regions in texture atlas loaded via StarlingAtlasAttachmentLoader.
  * Added support for rotated regions in texture atlas loaded via StarlingAtlasAttachmentLoader.
  * Added support for vertex effects. See `RaptorExample.as`
  * Added support for vertex effects. See `RaptorExample.as`
+ * Added 'getTexture()' method to 'StarlingTextureAtlasAttachmentLoader'
 
 
 ## C
 ## C
  * **Breaking changes**
  * **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.
  * 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 support for vertex effects. See `RaptorExample.cpp`.
  * Added ETC1 alpha support, thanks @halx99! Does not work when two color tint is enabled.
  * 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
 ### Cocos2d-Objc
  * Fixed renderer to work with 3.6 changes
  * Fixed renderer to work with 3.6 changes
@@ -145,7 +147,9 @@
  * Removed `RegionBatcher` and `SkeletonRegionRenderer`, renamed `SkeletonMeshRenderer` to `SkeletonRenderer`
  * 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<Effect>("SpineEffect");`, and set it on the `SkeletonRenderer`. See the example project for code.
  * 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<Effect>("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 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`
  * 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
 ## Java
  * **Breaking changes**
  * **Breaking changes**

+ 5 - 2
spine-c/spine-c/include/spine/AnimationState.h

@@ -84,7 +84,8 @@ struct spTrackEntry {
 		timelineData(0),
 		timelineData(0),
 		timelineDipMix(0),
 		timelineDipMix(0),
 		timelinesRotation(0),
 		timelinesRotation(0),
-		timelinesRotationCount(0) {
+		timelinesRotationCount(0),
+		rendererObject(0), userData(0) {
 	}
 	}
 #endif
 #endif
 };
 };
@@ -102,6 +103,7 @@ struct spAnimationState {
 	spTrackEntryArray* mixingTo;
 	spTrackEntryArray* mixingTo;
 
 
 	void* rendererObject;
 	void* rendererObject;
+	void* userData;
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 	spAnimationState() :
 	spAnimationState() :
@@ -111,7 +113,8 @@ struct spAnimationState {
 		listener(0),
 		listener(0),
 		timeScale(0),
 		timeScale(0),
 		mixingTo(0),
 		mixingTo(0),
-		rendererObject(0) {
+		rendererObject(0),
+		userData(0) {
 	}
 	}
 #endif
 #endif
 };
 };

+ 14 - 1
spine-cocos2dx/src/spine/spine-cocos2dx.cpp

@@ -31,6 +31,13 @@
 #include <spine/spine-cocos2dx.h>
 #include <spine/spine-cocos2dx.h>
 #include <spine/extension.h>
 #include <spine/extension.h>
 
 
+namespace spine {
+	static CustomTextureLoader _customTextureLoader = nullptr;
+	void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) {
+		_customTextureLoader = texLoader;
+	}
+}
+
 USING_NS_CC;
 USING_NS_CC;
 
 
 GLuint wrap (spAtlasWrap wrap) {
 GLuint wrap (spAtlasWrap wrap) {
@@ -60,7 +67,13 @@ GLuint filter (spAtlasFilter filter) {
 }
 }
 
 
 void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
 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");
 	CCASSERT(texture != nullptr, "Invalid image");
 	texture->retain();
 	texture->retain();
 
 

+ 6 - 0
spine-cocos2dx/src/spine/spine-cocos2dx.h

@@ -38,4 +38,10 @@
 #include <spine/SkeletonAnimation.h>
 #include <spine/SkeletonAnimation.h>
 #include <spine/SkeletonBatch.h>
 #include <spine/SkeletonBatch.h>
 
 
+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_ */
 #endif /* SPINE_COCOS2DX_H_ */

+ 1 - 1
spine-csharp/src/SkeletonClipping.cs

@@ -258,7 +258,7 @@ namespace Spine {
 			return clipped;
 			return clipped;
 		}
 		}
 
 
-		static void MakeClockwise (ExposedList<float> polygon) {
+		public static void MakeClockwise (ExposedList<float> polygon) {
 			float[] vertices = polygon.Items;
 			float[] vertices = polygon.Items;
 			int verticeslength = polygon.Count;
 			int verticeslength = polygon.Count;
 
 

+ 1 - 1
spine-csharp/src/Triangulator.cs

@@ -31,7 +31,7 @@
 using System;
 using System;
 
 
 namespace Spine {
 namespace Spine {
-	internal class Triangulator {
+	public class Triangulator {
 		private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
 		private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
 		private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
 		private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
 
 

+ 1 - 1
spine-monogame/example/Content/SpineEffect.fx

@@ -51,7 +51,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
 	float alpha = texColor.a * input.Color.a;
 	float alpha = texColor.a * input.Color.a;
 	float4 output;
 	float4 output;
 	output.a = alpha;
 	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;
 	return output;
 }
 }

BIN
spine-ue4/Content/Test/Blueprints/Cube_Blueprint.uasset


BIN
spine-ue4/Content/Test/Blueprints/TouchClick.uasset


BIN
spine-ue4/Content/Test/Blueprints/TouchPlayer.uasset


BIN
spine-ue4/Content/Test/Blueprints/TwoColor_Blueprint.uasset


BIN
spine-ue4/Content/Test/Test.umap


BIN
spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitAdditiveMaterial.uasset


BIN
spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitMultiplyMaterial.uasset


BIN
spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitNormalMaterial.uasset


BIN
spine-ue4/Plugins/SpinePlugin/Content/SpineUnlitScreenMaterial.uasset


+ 1 - 1
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp

@@ -178,7 +178,7 @@ void USpineSkeletonRendererComponent::Flush (int &Idx, TArray<FVector> &Vertices
 		verts.Add(FRuntimeMeshVertexTripleUV(Vertices[i], FVector(), FVector(), Colors[i], Uvs[i], FVector2D(Colors2[i].X, Colors2[i].Y), FVector2D(Colors2[i].Z, 0)));
 		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<FVector>(), Uvs, darkRG, Colors, TArray<FRuntimeMeshTangent>(), false);
 	// CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, darkRG, Colors, TArray<FRuntimeMeshTangent>(), false);
 	Vertices.SetNum(0);
 	Vertices.SetNum(0);

+ 1 - 1
spine-xna/example-content/SpineEffect.fx

@@ -42,7 +42,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
 	float alpha = texColor.a * input.Color.a;
 	float alpha = texColor.a * input.Color.a;
 	float4 output;
 	float4 output;
 	output.a = alpha;
 	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;
 	return output;
 }
 }

+ 2 - 2
spine-xna/example/src/ExampleGame.cs

@@ -85,10 +85,10 @@ namespace Spine {
 			skeletonDebugRenderer.DrawClipping = true;
 			skeletonDebugRenderer.DrawClipping = true;
 
 
 			// String name = "spineboy-ess";
 			// String name = "spineboy-ess";
-			String name = "goblins-pro";
+			// String name = "goblins-pro";
 			// String name = "raptor-pro";
 			// String name = "raptor-pro";
 			// String name = "tank-pro";
 			// String name = "tank-pro";
-			// String name = "coin-pro";
+			String name = "coin-pro";
 			String atlasName = name.Replace("-pro", "").Replace("-ess", "");
 			String atlasName = name.Replace("-pro", "").Replace("-ess", "");
 			if (name == "goblins-pro") atlasName = "goblins-mesh";
 			if (name == "goblins-pro") atlasName = "goblins-mesh";
 			bool binaryData = false;
 			bool binaryData = false;

+ 7 - 1
spine-xna/src/SkeletonRenderer.cs

@@ -45,6 +45,7 @@ namespace Spine {
 		SkeletonClipping clipper = new SkeletonClipping();	
 		SkeletonClipping clipper = new SkeletonClipping();	
 		GraphicsDevice device;
 		GraphicsDevice device;
 		MeshBatcher batcher;
 		MeshBatcher batcher;
+		public MeshBatcher Batcher { get { return batcher; } }
 		RasterizerState rasterizerState;
 		RasterizerState rasterizerState;
 		float[] vertices = new float[8];
 		float[] vertices = new float[8];
 		int[] quadTriangles = { 0, 1, 2, 2, 3, 0 };
 		int[] quadTriangles = { 0, 1, 2, 2, 3, 0 };
@@ -163,8 +164,13 @@ namespace Spine {
 
 
 				Color darkColor = new Color();
 				Color darkColor = new Color();
 				if (slot.HasSecondColor) {
 				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
 				// clip
 				if (clipper.IsClipping()) {
 				if (clipper.IsClipping()) {