Search in sources :

Example 1 with ConvexHullShape

use of org.terasology.physics.shapes.ConvexHullShape in project Terasology by MovingBlocks.

the class BlockShapeTest method testConvexHull.

@Test
public void testConvexHull() {
    BlockShape blockShape = assetManager.getAsset("engine:halfSlope", BlockShape.class).get();
    CollisionShape shape = blockShape.getCollisionShape(Rotation.rotate(Yaw.CLOCKWISE_90));
    Assert.assertEquals(shape instanceof ConvexHullShape, true);
    if (shape instanceof ConvexHullShape) {
        Vector3f[] test = new Vector3f[] { new Vector3f(0.49999997f, 0.0f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, 0.0f, 0.49999997f) };
        BulletConvexHullShape bulletConvexHullShape = (BulletConvexHullShape) shape;
        ObjectArrayList<javax.vecmath.Vector3f> points = ((com.bulletphysics.collision.shapes.ConvexHullShape) bulletConvexHullShape.underlyingShape).getPoints();
        for (int x = 0; x < points.size(); x++) {
            fuzzVectorTest(test[x], VecMath.from(points.get(x)));
        }
    }
}
Also used : CollisionShape(org.terasology.physics.shapes.CollisionShape) BlockShape(org.terasology.world.block.shapes.BlockShape) Vector3f(org.terasology.math.geom.Vector3f) BulletConvexHullShape(org.terasology.physics.bullet.shapes.BulletConvexHullShape) ConvexHullShape(org.terasology.physics.shapes.ConvexHullShape) BulletConvexHullShape(org.terasology.physics.bullet.shapes.BulletConvexHullShape) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Vector3f (org.terasology.math.geom.Vector3f)1 BulletConvexHullShape (org.terasology.physics.bullet.shapes.BulletConvexHullShape)1 CollisionShape (org.terasology.physics.shapes.CollisionShape)1 ConvexHullShape (org.terasology.physics.shapes.ConvexHullShape)1 BlockShape (org.terasology.world.block.shapes.BlockShape)1