mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[csharp] Fix UV/Vertex order to favor existing renderers.
This commit is contained in:
parent
cd2c3e6b9d
commit
af2b483ca7
@ -76,29 +76,6 @@ namespace Spine {
|
|||||||
: base(name) {
|
: base(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUVs (float u, float v, float u2, float v2, bool rotate) {
|
|
||||||
float[] uvs = this.uvs;
|
|
||||||
if (rotate) {
|
|
||||||
uvs[ULX] = u;
|
|
||||||
uvs[ULY] = v2;
|
|
||||||
uvs[URX] = u;
|
|
||||||
uvs[URY] = v;
|
|
||||||
uvs[BRX] = u2;
|
|
||||||
uvs[BRY] = v;
|
|
||||||
uvs[BLX] = u2;
|
|
||||||
uvs[BLY] = v2;
|
|
||||||
} else {
|
|
||||||
uvs[BLX] = u;
|
|
||||||
uvs[BLY] = v2;
|
|
||||||
uvs[ULX] = u;
|
|
||||||
uvs[ULY] = v;
|
|
||||||
uvs[URX] = u2;
|
|
||||||
uvs[URY] = v;
|
|
||||||
uvs[BRX] = u2;
|
|
||||||
uvs[BRY] = v2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateOffset () {
|
public void UpdateOffset () {
|
||||||
float width = this.width;
|
float width = this.width;
|
||||||
float height = this.height;
|
float height = this.height;
|
||||||
@ -134,20 +111,29 @@ namespace Spine {
|
|||||||
offset[BRY] = localYCos + localX2Sin;
|
offset[BRY] = localYCos + localX2Sin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Obsolete("Please use the new ComputeWorldVertices that requires offset and stride parameters introduced in 3.6")]
|
public void SetUVs (float u, float v, float u2, float v2, bool rotate) {
|
||||||
// public void ComputeWorldVertices (Bone bone, float[] worldVertices) {
|
float[] uvs = this.uvs;
|
||||||
// float x = bone.worldX, y = bone.worldY;
|
// UV values differ from RegionAttachment.java
|
||||||
// float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
if (rotate) {
|
||||||
// float[] offset = this.offset;
|
uvs[ULX] = u;
|
||||||
// worldVertices[BLX] = offset[BLX] * a + offset[BLY] * b + x;
|
uvs[ULY] = v2;
|
||||||
// worldVertices[BLY] = offset[BLX] * c + offset[BLY] * d + y;
|
uvs[URX] = u;
|
||||||
// worldVertices[ULX] = offset[ULX] * a + offset[ULY] * b + x;
|
uvs[URY] = v;
|
||||||
// worldVertices[ULY] = offset[ULX] * c + offset[ULY] * d + y;
|
uvs[BRX] = u2;
|
||||||
// worldVertices[URX] = offset[URX] * a + offset[URY] * b + x;
|
uvs[BRY] = v;
|
||||||
// worldVertices[URY] = offset[URX] * c + offset[URY] * d + y;
|
uvs[BLX] = u2;
|
||||||
// worldVertices[BRX] = offset[BRX] * a + offset[BRY] * b + x;
|
uvs[BLY] = v2;
|
||||||
// worldVertices[BRY] = offset[BRX] * c + offset[BRY] * d + y;
|
} else {
|
||||||
// }
|
uvs[BLX] = u;
|
||||||
|
uvs[BLY] = v2;
|
||||||
|
uvs[ULX] = u;
|
||||||
|
uvs[ULY] = v;
|
||||||
|
uvs[URX] = u2;
|
||||||
|
uvs[URY] = v;
|
||||||
|
uvs[BRX] = u2;
|
||||||
|
uvs[BRY] = v2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Transforms the attachment's four vertices to world coordinates.</summary>
|
/// <summary>Transforms the attachment's four vertices to world coordinates.</summary>
|
||||||
/// <param name="bone">The parent bone.</param>
|
/// <param name="bone">The parent bone.</param>
|
||||||
@ -160,28 +146,30 @@ namespace Spine {
|
|||||||
float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
||||||
float offsetX, offsetY;
|
float offsetX, offsetY;
|
||||||
|
|
||||||
offsetX = vertexOffset[BRX];
|
// Vertex order is different from RegionAttachment.java
|
||||||
offsetY = vertexOffset[BRY];
|
offsetX = vertexOffset[BLX]; // 0
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // br
|
offsetY = vertexOffset[BLY]; // 1
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
|
||||||
offset += stride;
|
|
||||||
|
|
||||||
offsetX = vertexOffset[BLX];
|
|
||||||
offsetY = vertexOffset[BLY];
|
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // bl
|
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // bl
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
||||||
offset += stride;
|
offset += stride;
|
||||||
|
|
||||||
offsetX = vertexOffset[ULX];
|
offsetX = vertexOffset[ULX]; // 2
|
||||||
offsetY = vertexOffset[ULY];
|
offsetY = vertexOffset[ULY]; // 3
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ul
|
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ul
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
||||||
offset += stride;
|
offset += stride;
|
||||||
|
|
||||||
offsetX = vertexOffset[URX];
|
offsetX = vertexOffset[URX]; // 4
|
||||||
offsetY = vertexOffset[URY];
|
offsetY = vertexOffset[URY]; // 5
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ur
|
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ur
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
||||||
|
offset += stride;
|
||||||
|
|
||||||
|
offsetX = vertexOffset[BRX]; // 6
|
||||||
|
offsetY = vertexOffset[BRY]; // 7
|
||||||
|
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // br
|
||||||
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
||||||
|
//offset += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user