diff --git a/spine-as3/spine-as3-example/lib/spine-as3.swc b/spine-as3/spine-as3-example/lib/spine-as3.swc index 84fc894f9..404d9a6e4 100644 Binary files a/spine-as3/spine-as3-example/lib/spine-as3.swc and b/spine-as3/spine-as3-example/lib/spine-as3.swc differ diff --git a/spine-as3/spine-as3/src/spine/atlas/Atlas.as b/spine-as3/spine-as3/src/spine/atlas/Atlas.as index ee130ac37..3cfee4e56 100644 --- a/spine-as3/spine-as3/src/spine/atlas/Atlas.as +++ b/spine-as3/spine-as3/src/spine/atlas/Atlas.as @@ -29,6 +29,7 @@ *****************************************************************************/ package spine.atlas { + import flash.trace.Trace; import flash.utils.ByteArray; public class Atlas { @@ -97,7 +98,15 @@ package spine.atlas { region.name = line; region.page = page; - region.rotate = reader.readValue() == "true"; + var rotateValue : String = reader.readValue(); + if (rotateValue == "true") { + region.degrees = 90; + } else if (rotateValue == "false") { + region.degrees = 0; + } else { + region.degrees = parseInt(rotateValue); + } + region.rotate = region.degrees == 90; reader.readTuple(tuple); var x : int = parseInt(tuple[0]); diff --git a/spine-as3/spine-as3/src/spine/atlas/AtlasRegion.as b/spine-as3/spine-as3/src/spine/atlas/AtlasRegion.as index 3cae80415..51387919c 100644 --- a/spine-as3/spine-as3/src/spine/atlas/AtlasRegion.as +++ b/spine-as3/spine-as3/src/spine/atlas/AtlasRegion.as @@ -46,6 +46,7 @@ package spine.atlas { public var originalHeight : int; public var index : int; public var rotate : Boolean; + public var degrees : int; public var splits : Vector.; public var pads : Vector.; public var rendererObject : Object; diff --git a/spine-as3/spine-as3/src/spine/attachments/AtlasAttachmentLoader.as b/spine-as3/spine-as3/src/spine/attachments/AtlasAttachmentLoader.as index 86d932624..ed758df9d 100644 --- a/spine-as3/spine-as3/src/spine/attachments/AtlasAttachmentLoader.as +++ b/spine-as3/spine-as3/src/spine/attachments/AtlasAttachmentLoader.as @@ -48,8 +48,8 @@ package spine.attachments { throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); var attachment : RegionAttachment = new RegionAttachment(name); attachment.rendererObject = region; - var scaleX : Number = region.page.width / nextPOT(region.page.width); - var scaleY : Number = region.page.height / nextPOT(region.page.height); + var scaleX : Number = 1; + var scaleY : Number = 1; attachment.setUVs(region.u * scaleX, region.v * scaleY, region.u2 * scaleX, region.v2 * scaleY, region.rotate); attachment.regionOffsetX = region.offsetX; attachment.regionOffsetY = region.offsetY; @@ -66,13 +66,14 @@ package spine.attachments { throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); var attachment : MeshAttachment = new MeshAttachment(name); attachment.rendererObject = region; - var scaleX : Number = region.page.width / nextPOT(region.page.width); - var scaleY : Number = region.page.height / nextPOT(region.page.height); + var scaleX : Number = 1; + var scaleY : Number = 1; attachment.regionU = region.u * scaleX; attachment.regionV = region.v * scaleY; attachment.regionU2 = region.u2 * scaleX; attachment.regionV2 = region.v2 * scaleY; attachment.regionRotate = region.rotate; + attachment.regionDegrees = region.degrees; attachment.regionOffsetX = region.offsetX; attachment.regionOffsetY = region.offsetY; attachment.regionWidth = region.width; diff --git a/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as b/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as index a1c54e30b..67cfbeb54 100644 --- a/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as +++ b/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as @@ -46,6 +46,7 @@ package spine.attachments { public var regionU2 : Number; public var regionV2 : Number; public var regionRotate : Boolean; + public var regionDegrees : int; public var regionOffsetX : Number; // Pixels stripped from the bottom left, unrotated. public var regionOffsetY : Number; public var regionWidth : Number; // Unrotated, stripped size. @@ -62,7 +63,67 @@ package spine.attachments { } public function updateUVs() : void { - var i : int, n : int = regionUVs.length; + var i : int = 0, n : int = regionUVs.length; + var u : Number = regionU, v : Number = regionV; + var width : Number = 0, height : Number = 0; + var textureWidth : Number, textureHeight : Number; + if (!uvs || uvs.length != n) uvs = new Vector.(n, true); + + switch (regionDegrees) { + case 90: { + textureWidth = regionHeight / (regionU2 - regionU); + textureHeight = regionWidth / (regionV2 - regionV); + u -= (regionOriginalHeight - regionOffsetY - regionHeight) / textureWidth; + v -= (regionOriginalWidth - regionOffsetX - regionWidth) / textureHeight; + width = regionOriginalHeight / textureWidth; + height = regionOriginalWidth / textureHeight; + for (i = 0; i < n; i += 2) { + uvs[i] = u + regionUVs[i + 1] * width; + uvs[i + 1] = v + (1 - regionUVs[i]) * height; + } + return; + } + case 180: { + textureWidth = regionWidth / (regionU2 - regionU); + textureHeight = regionHeight / (regionV2 - regionV); + u -= (regionOriginalWidth - regionOffsetX - regionWidth) / textureWidth; + v -= regionOffsetY / textureHeight; + width = regionOriginalWidth / textureWidth; + height = regionOriginalHeight / textureHeight; + for (i = 0; i < n; i += 2) { + uvs[i] = u + (1 - regionUVs[i]) * width; + uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height; + } + return; + } + case 270: { + textureWidth = regionWidth / (regionU2 - regionU); + textureHeight = regionHeight / (regionV2 - regionV); + u -= regionOffsetY / textureWidth; + v -= regionOffsetX / textureHeight; + width = regionOriginalHeight / textureWidth; + height = regionOriginalWidth / textureHeight; + for (i = 0; i < n; i += 2) { + uvs[i] = u + (1 - regionUVs[i + 1]) * width; + uvs[i + 1] = v + regionUVs[i] * height; + } + return; + } + default: { + textureWidth = regionWidth / (regionU2 - regionU); + textureHeight = regionHeight / (regionV2 - regionV); + u -= regionOffsetX / textureWidth; + v -= (regionOriginalHeight - regionOffsetY - regionHeight) / textureHeight; + width = regionOriginalWidth / textureWidth; + height = regionOriginalHeight / textureHeight; + for (i = 0; i < n; i += 2) { + uvs[i] = u + regionUVs[i] * width; + uvs[i + 1] = v + regionUVs[i + 1] * height; + } + } + } + + /*var i : int, n : int = regionUVs.length; var u: Number, v: Number, width: Number, height: Number; var textureWidth: Number, textureHeight: Number; if (!uvs || uvs.length != n) uvs = new Vector.(n, true); @@ -88,7 +149,7 @@ package spine.attachments { uvs[i] = u + regionUVs[i] * width; uvs[int(i + 1)] = v + regionUVs[int(i + 1)] * height; } - } + }*/ } override public function applyDeform(sourceAttachment : VertexAttachment) : Boolean { diff --git a/spine-starling/spine-starling-example/lib/spine-as3.swc b/spine-starling/spine-starling-example/lib/spine-as3.swc index 84fc894f9..62392cd02 100644 Binary files a/spine-starling/spine-starling-example/lib/spine-as3.swc and b/spine-starling/spine-starling-example/lib/spine-as3.swc differ diff --git a/spine-starling/spine-starling/lib/spine-as3.swc b/spine-starling/spine-starling/lib/spine-as3.swc index 84fc894f9..62392cd02 100644 Binary files a/spine-starling/spine-starling/lib/spine-as3.swc and b/spine-starling/spine-starling/lib/spine-as3.swc differ