Examples of CircleShape


Examples of org.jbox2d.collision.shapes.CircleShape

     * in use.
     */
    public final void set(final Shape shape, int index) {
      switch (shape.getType()) {
        case CIRCLE:
          final CircleShape circle = (CircleShape) shape;
          m_vertices[0].set(circle.m_p);
          m_count = 1;
          m_radius = circle.m_radius;

          break;
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

  private final Vec2Array tlvertices = new Vec2Array();

  private void drawShape(Fixture fixture, Transform xf, Color3f color, boolean wireframe) {
    switch (fixture.getType()) {
      case CIRCLE: {
        CircleShape circle = (CircleShape) fixture.getShape();

        // Vec2 center = Mul(xf, circle.m_p);
        Transform.mulToOutUnsafe(xf, circle.m_p, center);
        float radius = circle.m_radius;
        xf.q.getXAxis(axis);
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

            context.translate(center.x, center.y);
            context.rotate(body.getAngle());
            for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
                Shape shape = fixture.getShape();
                if (shape.getType() == ShapeType.CIRCLE) {
                    CircleShape circle = (CircleShape)shape;
                    context.beginPath();
                    context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
                    context.closePath();
                    context.stroke();
                } else if (shape.getType() == ShapeType.POLYGON) {
                    PolygonShape poly = (PolygonShape)shape;
                    Vec2[] vertices = poly.getVertices();
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

        BodyDef axisDef = new BodyDef();
        axisDef.type = BodyType.STATIC;
        axisDef.position = new Vec2(3, 3);
        axis = world.createBody(axisDef);

        CircleShape axisShape = new CircleShape();
        axisShape.setRadius(0.02f);
        axisShape.m_p.set(0, 0);

        FixtureDef axisFixture = new FixtureDef();
        axisFixture.shape = axisShape;
        axis.createFixture(axisFixture);
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

        ballDef.type = BodyType.DYNAMIC;
        FixtureDef fixtureDef = new FixtureDef();
        fixtureDef.friction = 0.3f;
        fixtureDef.restitution = 0.3f;
        fixtureDef.density = 0.2f;
        CircleShape shape = new CircleShape();
        shape.m_radius = ballRadius;
        fixtureDef.shape = shape;

        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

            context.translate(center.x, center.y);
            context.rotate(body.getAngle());
            for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
                Shape shape = fixture.getShape();
                if (shape.getType() == ShapeType.CIRCLE) {
                    CircleShape circle = (CircleShape)shape;
                    context.beginPath();
                    context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
                    context.closePath();
                    context.stroke();
                } else if (shape.getType() == ShapeType.POLYGON) {
                    PolygonShape poly = (PolygonShape)shape;
                    Vec2[] vertices = poly.getVertices();
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

      bod.createFixture(sides);
    }

    // turney
    {
      CircleShape cd;
      FixtureDef fd = new FixtureDef();
      BodyDef bd = new BodyDef();
      bd.type = BodyType.DYNAMIC;
      int numPieces = 5;
      float radius = 4f;
      bd.position = new Vec2(0.0f, 25.0f);
      Body body = world.createBody(bd);
      for (int i = 0; i < numPieces; i++) {
        cd = new CircleShape();
        cd.m_radius = .5f;
        fd.shape = cd;
        fd.density = 25;
        fd.friction = .1f;
        fd.restitution = .9f;
        float xPos = radius * (float) Math.cos(2f * Math.PI * (i / (float) (numPieces)));
        float yPos = radius * (float) Math.sin(2f * Math.PI * (i / (float) (numPieces)));
        cd.m_p.set(xPos, yPos);

        body.createFixture(fd);
      }

      RevoluteJointDef rjd = new RevoluteJointDef();
      rjd.initialize(body, ground, body.getPosition());
      rjd.motorSpeed = MathUtils.PI;
      rjd.maxMotorTorque = 1000000.0f;
      rjd.enableMotor = true;
      world.createJoint(rjd);
    }

    {
      Body prevBody = ground;

      // Define crank.
      {
        PolygonShape shape = new PolygonShape();
        shape.setAsBox(0.5f, 2.0f);

        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        bd.position.set(0.0f, 7.0f);
        Body body = world.createBody(bd);
        body.createFixture(shape, 2.0f);

        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 5.0f));
        rjd.motorSpeed = 1.0f * MathUtils.PI;
        rjd.maxMotorTorque = 20000;
        rjd.enableMotor = true;
        m_joint1 = (RevoluteJoint) world.createJoint(rjd);

        prevBody = body;
      }

      // Define follower.
      {
        PolygonShape shape = new PolygonShape();
        shape.setAsBox(0.5f, 4.0f);

        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        bd.position.set(0.0f, 13.0f);
        Body body = world.createBody(bd);
        body.createFixture(shape, 2.0f);

        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 9.0f));
        rjd.enableMotor = false;
        world.createJoint(rjd);

        prevBody = body;
      }

      // Define piston
      {
        PolygonShape shape = new PolygonShape();
        shape.setAsBox(7f, 2f);

        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        bd.position.set(0.0f, 17.0f);
        Body body = world.createBody(bd);
        FixtureDef piston = new FixtureDef();
        piston.shape = shape;
        piston.density = 2;
        piston.filter.categoryBits = 1;
        piston.filter.maskBits = 2;
        body.createFixture(piston);

        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f));
        world.createJoint(rjd);

        PrismaticJointDef pjd = new PrismaticJointDef();
        pjd.initialize(ground, body, new Vec2(0.0f, 17.0f), new Vec2(0.0f, 1.0f));

        pjd.maxMotorForce = 1000.0f;
        pjd.enableMotor = true;

        m_joint2 = (PrismaticJoint) world.createJoint(pjd);
      }

      // Create a payload
      {
        PolygonShape sd = new PolygonShape();
        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        FixtureDef fixture = new FixtureDef();
        Body body;
        for (int i = 0; i < 100; ++i) {
          sd.setAsBox(0.4f, 0.3f);
          bd.position.set(-1.0f, 23.0f + i);

          bd.bullet = false;
          body = world.createBody(bd);
          fixture.shape = sd;
          fixture.density = .1f;
          fixture.filter.categoryBits = 2;
          fixture.filter.maskBits = 1 | 4 | 2;
          body.createFixture(fixture);
        }

        CircleShape cd = new CircleShape();
        cd.m_radius = 0.36f;
        for (int i = 0; i < 100; ++i) {
          bd.position.set(1.0f, 23.0f + i);
          bd.bullet = false;
          fixture.shape = cd;
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

     * must remain in scope while the proxy is in use.
     */
    public final void set(final Shape shape){
      switch(shape.getType()){
        case CIRCLE:
          final CircleShape circle = (CircleShape) shape;
          m_vertices[0].set(circle.m_p);
          m_count = 1;
          m_radius = circle.m_radius;
         
          break;
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

  private final Vec2Array tlvertices = new Vec2Array();
 
  private void drawShape(Fixture fixture, Transform xf, Color3f color) {
    switch (fixture.getType()) {
      case CIRCLE : {
        CircleShape circle = (CircleShape) fixture.getShape();
       
        // Vec2 center = Mul(xf, circle.m_p);
        Transform.mulToOut(xf, circle.m_p, center);
        float radius = circle.m_radius;
        axis.x = xf.R.m11;
View Full Code Here

Examples of org.jbox2d.collision.shapes.CircleShape

    /** Initialize the proxy using the given shape. The shape must remain in scope while the proxy is in use. */
    public final void set (final Shape shape, int index) {
      switch (shape.getType()) {
      case CIRCLE:
        final CircleShape circle = (CircleShape)shape;
        m_vertices[0].set(circle.m_p);
        m_count = 1;
        m_radius = circle.m_radius;

        break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.