Added spiral test.

This commit is contained in:
Nathan Sweet 2017-04-01 08:48:40 +09:00
parent cf9103d1f5
commit 7829b39e00
2 changed files with 55 additions and 22 deletions

View File

@ -52,8 +52,8 @@ public class ClippingTest extends ApplicationAdapter {
TextureAtlas atlas;
Skeleton skeleton;
AnimationState state;
WindowedMean mean = new WindowedMean(30);
WindowedMean mean = new WindowedMean(30);
public void create () {
camera = new OrthographicCamera();
@ -74,8 +74,8 @@ public class ClippingTest extends ApplicationAdapter {
skeleton.setPosition(250, 20);
AnimationStateData stateData = new AnimationStateData(skeletonData);
// stateData.setMix("run", "jump", 0.2f);
// stateData.setMix("jump", "run", 0.2f);
// stateData.setMix("run", "jump", 0.2f);
// stateData.setMix("jump", "run", 0.2f);
state = new AnimationState(stateData);
state.setTimeScale(0.5f);
@ -86,25 +86,43 @@ public class ClippingTest extends ApplicationAdapter {
// Create a clipping attachment, slot data, and slot.
ClippingAttachment clip = new ClippingAttachment("clip");
// Spiral.
clip.setVertices(new float[] {430.90802f, 278.212f, 72.164f, 361.816f, 31.143997f, 128.804f, 191.896f, 61.0f, 291.312f,
175.73201f, 143.956f, 207.408f, 161.4f, 145.628f, 227.456f, 160.61601f, 224.392f, 126.535995f, 188.264f, 113.144f,
147.13199f, 108.87601f, 77.035995f, 158.212f, 86.15199f, 220.676f, 102.77199f, 240.716f, 174.74399f, 243.20801f,
250.572f, 216.74802f, 324.772f, 200.33202f, 309.388f, 124.968f, 258.168f, 60.503998f, 199.696f, 42.872f, 116.951996f,
6.7400017f, 11.332001f, 72.48f, -6.708008f, 143.136f, 1.0679932f, 239.92801f, 26.5f, 355.6f, -47.380005f, 377.52798f,
-40.608f, 303.1f, -53.584015f, 77.316f, 5.4600067f, 8.728001f, 113.343994f, -56.04f, 192.42801f, -45.112f, 274.564f,
-38.784f, 322.592f, -10.604f, 371.98f, 21.920002f, 405.16f, 60.896004f, 428.68f, 104.852005f, 406.996f, 188.976f,
364.58398f, 220.14401f, 309.3f, 238.788f, 263.232f, 244.75201f, 219.468f, 271.58002f, 210.824f, 294.176f, 250.664f,
295.2f, 295.972f, 276.02f, 357.46f, 269.172f, 420.008f, 242.37201f, 466.63602f, 207.648f, 437.516f, -10.579998f,
378.05603f, -64.624f, 465.24f, -104.992f, 554.11206f, 95.43199f, 514.89197f, 259.02f});
// Polygon:
// clip.setVertices(
// new float[] { 94.0f, 84.0f, 45.0f, 165.0f, 218.0f, 292.0f, 476.0f, 227.0f, 480.0f, 125.0f, 325.0f, 191.0f, 333.0f, 77.0f,
// 302.0f, 30.0f, 175.0f, 140.0f });
// Rectangle:
clip.setVertices(
new float[] { 94.0f, 84.0f, 45.0f, 165.0f, 218.0f, 292.0f, 476.0f, 227.0f, 480.0f, 125.0f, 325.0f, 191.0f, 333.0f, 77.0f, 302.0f, 30.0f, 175.0f, 140.0f });
// new float[] { //
// -140, 50, //
// 250, 50, //
// 250, 350, //
// -140, 350, //
// });
// new float[] { //
// -140, 50, //
// 250, 50, //
// 250, 350, //
// -140, 350, //
// });
// Self intersection:
// clip.setVertices(new float[] { //
// -140, -50, //
// 120, 50, //
// 120, -50, //
// -140, 50, //
// });
for (int j = 0; j < clip.getVertices().length; j+=2) {
// clip.setVertices(new float[] { //
// -140, -50, //
// 120, 50, //
// 120, -50, //
// -140, 50, //
// });
for (int j = 0; j < clip.getVertices().length; j += 2) {
clip.getVertices()[j] = (clip.getVertices()[j] - 150f);
clip.getVertices()[j+1] = (clip.getVertices()[j+1] + 100);
clip.getVertices()[j + 1] = (clip.getVertices()[j + 1] + 100);
}
clip.setWorldVerticesLength(clip.getVertices().length);
clip.setEndSlot(skeleton.findSlot("front_hand").data.index);
@ -119,7 +137,7 @@ public class ClippingTest extends ApplicationAdapter {
}
public void render () {
state.update(Gdx.graphics.getDeltaTime() * 0.3f);
state.update(Gdx.graphics.getDeltaTime() * 0.3f);
state.update(0);
Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1);

View File

@ -47,8 +47,21 @@ public class ConvexDecomposerTest extends ApplicationAdapter {
image = new Texture("skin/skin.png");
font = new BitmapFont();
float[] v = new float[] { 94.0f, 84.0f, 45.0f, 165.0f, 218.0f, 292.0f, 476.0f, 227.0f, 480.0f, 125.0f, 325.0f, 191.0f, 333.0f, 77.0f, 302.0f, 30.0f, 175.0f, 140.0f };
float[] v = new float[] {430.90802f, 278.212f, 72.164f, 361.816f, 31.143997f, 128.804f, 191.896f, 61.0f, 291.312f,
175.73201f, 143.956f, 207.408f, 161.4f, 145.628f, 227.456f, 160.61601f, 224.392f, 126.535995f, 188.264f, 113.144f,
147.13199f, 108.87601f, 77.035995f, 158.212f, 86.15199f, 220.676f, 102.77199f, 240.716f, 174.74399f, 243.20801f,
250.572f, 216.74802f, 324.772f, 200.33202f, 309.388f, 124.968f, 258.168f, 60.503998f, 199.696f, 42.872f, 116.951996f,
6.7400017f, 11.332001f, 72.48f, -6.708008f, 143.136f, 1.0679932f, 239.92801f, 26.5f, 355.6f, -47.380005f, 377.52798f,
-40.608f, 303.1f, -53.584015f, 77.316f, 5.4600067f, 8.728001f, 113.343994f, -56.04f, 192.42801f, -45.112f, 274.564f,
-38.784f, 322.592f, -10.604f, 371.98f, 21.920002f, 405.16f, 60.896004f, 428.68f, 104.852005f, 406.996f, 188.976f,
364.58398f, 220.14401f, 309.3f, 238.788f, 263.232f, 244.75201f, 219.468f, 271.58002f, 210.824f, 294.176f, 250.664f,
295.2f, 295.972f, 276.02f, 357.46f, 269.172f, 420.008f, 242.37201f, 466.63602f, 207.648f, 437.516f, -10.579998f,
378.05603f, -64.624f, 465.24f, -104.992f, 554.11206f, 95.43199f, 514.89197f, 259.02f};
for (int i = 0, n = v.length; i < n; i++)
v[i] += 200;
// float[] v = new float[] { 94.0f, 84.0f, 45.0f, 165.0f, 218.0f, 292.0f, 476.0f, 227.0f, 480.0f, 125.0f, 325.0f, 191.0f,
// 333.0f, 77.0f, 302.0f, 30.0f, 175.0f, 140.0f };
// float[] v = {87, 288, 217, 371, 456, 361, 539, 175, 304, 194, 392, 290, 193, 214, 123, 15, 14, 137};
// float[] v = { 336, 153, 207, 184, 364, 333, 529, 326, 584, 130, 438, 224 };
polygon.addAll(v);
@ -255,6 +268,8 @@ public class ConvexDecomposerTest extends ApplicationAdapter {
public static void main (String[] args) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 800;
config.height = 600;
new LwjglApplication(new ConvexDecomposerTest(), config);
}
}