Package org.jbox2d.common

Examples of org.jbox2d.common.Vec2


  /**
   * Get the bounding box that encloses this body and all of its constituent shapes
   * @return bounding box of all shapes enclosed in this body
   */
  public BoundingBox getBoundingBox(){
    AABB bodyAABB = new AABB(new AABB(new Vec2(Float.MAX_VALUE, Float.MAX_VALUE), new Vec2(Float.MIN_VALUE, Float.MIN_VALUE)));
    AABB shapeAABB = new AABB();
    for(org.jbox2d.collision.shapes.Shape jshape : shape.getJBoxShapes()){
      jshape.computeAABB(shapeAABB, jboxBody.m_xf);
      if(shapeAABB.lowerBound.x < bodyAABB.lowerBound.x){
        bodyAABB.lowerBound.x = shapeAABB.lowerBound.x;
View Full Code Here


  }
 
  @Override
  protected void applyOffset(float x, float y, float angle) {
    final Transform xf = new Transform();
    xf.position.set(new Vec2(x, y));
    xf.R.set(angle);
    // Transform vertices and normals.
    for (int i = 0; i < shape.getVertexCount(); ++i) {
      Vec2 vertex = shape.getVertex(i);
      // TODO Max: not sure this is right -- none of the examples test it.  Probably?
      Transform.mulTransToOut(xf, vertex, vertex);
    }
  }
View Full Code Here

  public World() {
    this(DEFAULT_GRAVITY);
  }

  public World(float gravity) {
    this(new Vec2(0f, gravity));
  }
View Full Code Here

   *            x-coordinate of upper-right coordinate
   * @param y2
   *            y-coordinate of upper-right coordinate
   */
  public void setBounds(float x1, float y1, float x2, float y2) {
    worldAABB = new AABB(new Vec2(x1, y1), new Vec2(x2, y2));
    outOfBoundsRegions = new AABB[] {
        // everything below-left and directly left of worldAABB
        new AABB(new Vec2(Float.MIN_VALUE, Float.MIN_VALUE), new Vec2(
            x1, y2)),
        // everything above-left and directly above worldAABB
        new AABB(new Vec2(Float.MIN_VALUE, y2), new Vec2(x2,
            Float.MAX_VALUE)),
        // everything above-right and directly right of worldAABB
        new AABB(new Vec2(x2, y1), new Vec2(Float.MAX_VALUE,
            Float.MAX_VALUE)),
        // everything below-right and directly below worldAABB
        new AABB(new Vec2(x1, Float.MIN_VALUE), new Vec2(
            Float.MAX_VALUE, y1)) };
  }
View Full Code Here

    } else {
      lowerY = y2;
      upperY = y1;
    }

    AABB aabb = new AABB(new Vec2(lowerX, lowerY), new Vec2(upperX, upperY));
    final List<Body<?>> bodies = new LinkedList<Body<?>>();
    jboxWorld.queryAABB(new BodyQueryCallbackHelper(bodies), aabb);
    return bodies;
  }
View Full Code Here

   *            horizontal pull
   * @param yGravity
   *            vertical pull
   */
  public void setGravity(float xGravity, float yGravity) {
    jboxWorld.setGravity(new Vec2(xGravity, yGravity));
  }
View Full Code Here

      if (x < leftmostXFromExplosion && leftmostXFromExplosion != 1000000f) continue;
      if (x > rightmostXFromExplosion && rightmostXFromExplosion != -1f) continue;

      Polygon temp = new Polygon();
      CompoundShape compoundTemp = new CompoundShape();
      Vec2 firstPoint = null;
      Vec2 lastPoint = null;

      for (int y = 0; y < Constants.MAX_HEIGHT * 2; y++) {
        if (terrainBitmap[x][y] > 0.5) {
          if (firstPoint == null)
            firstPoint = new Vec2(x, y);
          else
            lastPoint = new Vec2(x, y);
        } else {
          if (firstPoint != null) {
            if (lastPoint == null)
              lastPoint = new Vec2(firstPoint.x + 0.1f,
                  firstPoint.y);
            temp.setPoints(new Vec2[] { firstPoint, lastPoint });
            compoundTemp.add(temp);
            temp = new Polygon();
            firstPoint = null;
            lastPoint = null;
          }
        }
      }
      if (firstPoint != null) {
        if (lastPoint == null)
          lastPoint = new Vec2(firstPoint.x + 0.1f, firstPoint.y);
        temp.setPoints(new Vec2[] { lastPoint, firstPoint });
        compoundTemp.add(temp);
        temp = new Polygon();
        firstPoint = null;
        lastPoint = null;
View Full Code Here

    Polygon top = new Polygon();
    Polygon left = new Polygon();
    Polygon right = new Polygon();
    Polygon bottom = new Polygon();
    Vec2[] topP = {
        new Vec2(width, height),
        new Vec2(-width, height)
    };
    top.setPoints(topP);

    Vec2[] leftP = {
        new Vec2(-width, height),
        new Vec2(-width, -height)
    };
    left.setPoints(leftP);

    Vec2[] rightP = {
        new Vec2(width, -height),
        new Vec2(width, height)
    };
    right.setPoints(rightP);

    Vec2[] bottomP = {
        new Vec2(width, -height),
        new Vec2(-width, -height)
    }
    bottom.setPoints(bottomP);

    CompoundShape boundaryShape = new CompoundShape();
    boundaryShape.add(top);
View Full Code Here

    public float normalMass;
    public float tangentMass;
    public float velocityBias;

    public ContactConstraintPoint() {
        localPoint = new Vec2();
        rA = new Vec2();
        rB = new Vec2();
    }
View Full Code Here

        points = new ContactConstraintPoint[Settings.maxManifoldPoints];
        for (int i = 0; i < Settings.maxManifoldPoints; i++) {
            points[i] = new ContactConstraintPoint();
        }
        pointCount = 0;
        localNormal = new Vec2();
        localPoint = new Vec2();
        normal = new Vec2();
        normalMass = new Mat22();
        K = new Mat22();

    }
View Full Code Here

TOP

Related Classes of org.jbox2d.common.Vec2

Copyright © 2018 www.massapicom. 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.