[xna] More clipping debugging

This commit is contained in:
badlogic 2017-07-21 16:12:34 +02:00
parent 4b93db20fd
commit d950da644f
3 changed files with 10 additions and 8 deletions

View File

@ -56,7 +56,8 @@ public class SkeletonClipping {
float[] vertices = clippingPolygon.setSize(n); float[] vertices = clippingPolygon.setSize(n);
clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
makeClockwise(clippingPolygon); makeClockwise(clippingPolygon);
clippingPolygons = triangulator.decompose(clippingPolygon, triangulator.triangulate(clippingPolygon)); ShortArray triangles = triangulator.triangulate(clippingPolygon);
clippingPolygons = triangulator.decompose(clippingPolygon, triangles);
for (FloatArray polygon : clippingPolygons) { for (FloatArray polygon : clippingPolygons) {
makeClockwise(polygon); makeClockwise(polygon);
polygon.add(polygon.items[0]); polygon.add(polygon.items[0]);

View File

@ -148,15 +148,15 @@ namespace Spine {
else if (name == "skeleton") { else if (name == "skeleton") {
skeleton.SetSkin("Pig_Normal"); skeleton.SetSkin("Pig_Normal");
skeleton.FlipY = true; skeleton.FlipY = true;
skeleton.Y -= 200; // skeleton.Y -= 200;
state.SetAnimation(0, "BattleIdle", true); // state.SetAnimation(0, "BattleIdle", true);
} }
else { else {
state.SetAnimation(0, "walk", true); state.SetAnimation(0, "walk", true);
} }
skeleton.X += 400; // skeleton.X += 400;
skeleton.Y += GraphicsDevice.Viewport.Height; // skeleton.Y += GraphicsDevice.Viewport.Height;
skeleton.UpdateWorldTransform(); skeleton.UpdateWorldTransform();
headSlot = skeleton.FindSlot("head"); headSlot = skeleton.FindSlot("head");

View File

@ -208,11 +208,12 @@ namespace Spine {
} }
if (DrawClippingDecomposed) { if (DrawClippingDecomposed) {
if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(clippingPolygon); SkeletonClipping.MakeClockwise(clippingPolygon);
var clippingPolygons = triangulator.Decompose(clippingPolygon, triangulator.Triangulate(clippingPolygon)); var triangles = triangulator.Triangulate(clippingPolygon);
var clippingPolygons = triangulator.Decompose(clippingPolygon, triangles);
renderer.SetColor(clipDecomposedColor); renderer.SetColor(clipDecomposedColor);
foreach (var polygon in clippingPolygons) { foreach (var polygon in clippingPolygons) {
if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(polygon); SkeletonClipping.MakeClockwise(polygon);
polygon.Add(polygon.Items[0]); polygon.Add(polygon.Items[0]);
polygon.Add(polygon.Items[1]); polygon.Add(polygon.Items[1]);
renderer.Polygon(polygon.Items, 0, polygon.Count >> 1); renderer.Polygon(polygon.Items, 0, polygon.Count >> 1);