Search in sources :

Example 21 with PolygonShape

use of spacegraph.space2d.phys.collision.shapes.PolygonShape in project narchy by automenta.

the class Racer method initRacetrackBorders.

private void initRacetrackBorders() {
    // final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
    final PolygonShape bottomOuter = PolygonShape.box(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2);
    final PolygonShape topOuter = PolygonShape.box(0, 0, CAMERA_WIDTH, 2);
    final PolygonShape leftOuter = PolygonShape.box(0, 0, 2, CAMERA_HEIGHT);
    final PolygonShape rightOuter = PolygonShape.box(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT);
    final PolygonShape bottomInner = PolygonShape.box(RACETRACK_WIDTH, CAMERA_HEIGHT - 2 - RACETRACK_WIDTH, CAMERA_WIDTH - 2 * RACETRACK_WIDTH, 2);
    final PolygonShape topInner = PolygonShape.box(RACETRACK_WIDTH, RACETRACK_WIDTH, CAMERA_WIDTH - 2 * RACETRACK_WIDTH, 2);
    final PolygonShape leftInner = PolygonShape.box(RACETRACK_WIDTH, RACETRACK_WIDTH, 2, CAMERA_HEIGHT - 2 * RACETRACK_WIDTH);
    final PolygonShape rightInner = PolygonShape.box(CAMERA_WIDTH - 2 - RACETRACK_WIDTH, RACETRACK_WIDTH, 2, CAMERA_HEIGHT - 2 * RACETRACK_WIDTH);
    // final FixtureDef wallFixtureDef = new FixtureDef(bottomOuter, 0, 0.5f);
    // //        wallFixtureDef.restitution = 0.5f;
    this.mPhysicsWorld.addStatic(new FixtureDef(bottomOuter, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(leftOuter, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(rightOuter, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(topOuter, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(bottomInner, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(leftInner, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(rightInner, 0, 0.5f));
    this.mPhysicsWorld.addStatic(new FixtureDef(topInner, 0, 0.5f));
}
Also used : PolygonShape(spacegraph.space2d.phys.collision.shapes.PolygonShape) FixtureDef(spacegraph.space2d.phys.dynamics.FixtureDef)

Aggregations

PolygonShape (spacegraph.space2d.phys.collision.shapes.PolygonShape)21 spacegraph.util.math.v2 (spacegraph.util.math.v2)8 CircleShape (spacegraph.space2d.phys.collision.shapes.CircleShape)7 Vec2 (spacegraph.space2d.phys.common.Vec2)6 BodyDef (spacegraph.space2d.phys.dynamics.BodyDef)6 Body (spacegraph.space2d.phys.dynamics.Body)4 Fixture (spacegraph.space2d.phys.dynamics.Fixture)4 RevoluteJointDef (spacegraph.space2d.phys.dynamics.joints.RevoluteJointDef)4 Tuple2f (spacegraph.util.math.Tuple2f)4 EdgeShape (spacegraph.space2d.phys.collision.shapes.EdgeShape)3 Shape (spacegraph.space2d.phys.collision.shapes.Shape)3 FixtureDef (spacegraph.space2d.phys.dynamics.FixtureDef)3 Physics2dBody (ptrman.difficultyEnvironment.physics.Physics2dBody)2 Body2D (spacegraph.space2d.phys.dynamics.Body2D)2 DistanceJointDef (spacegraph.space2d.phys.dynamics.joints.DistanceJointDef)2 RevoluteJoint (spacegraph.space2d.phys.dynamics.joints.RevoluteJoint)2 PolygonFixture (spacegraph.space2d.phys.fracture.PolygonFixture)2 MyList (spacegraph.space2d.phys.fracture.util.MyList)2 ParticleGroupDef (spacegraph.space2d.phys.particle.ParticleGroupDef)2 Random (java.util.Random)1