Package eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.shapes

Examples of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.shapes.Polygon


    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
    Polygon polyA = (Polygon) bodyA.getBodyShape();
    Circle circle = (Circle) bodyB.getBodyShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only the circle
    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());

   
    int[][] collPairs = getCollisionCandidates(vertsA, centroidA, circle.getRadius(), bodyB.getPosition());

View Full Code Here


    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
    Polygon poly = (Polygon) bodyA.getBodyShape();
    Box box = (Box) bodyB.getBodyShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only one shape
    // specifically the box, because it has fewer vertices.
    Vector2f[] vertsA = poly.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = box.getPoints(bodyB.getPosition(), bodyB.getRotation());
   
    // TODO: use a sweepline that has the smallest projection of the box
    // now we use just an arbitrary one
    Vector2f sweepline = new Vector2f(vertsB[1]);
View Full Code Here

       
        for (int i = 0; i < pol.nPoints(); i++) {
            vecs[i] = new Vector2f((float) pol.get(i).x, (float) pol.get(i).y);
        }
       
        Polygon p = new Polygon(vecs);
        return p;
    }
View Full Code Here

   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
    Line line = (Line) bodyA.getBodyShape();
    Polygon poly = (Polygon) bodyB.getBodyShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only one shape
    // specifically the line, because it has only two vertices
    Vector2f[] vertsA = line.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = poly.getVertices(bodyB.getPosition(), bodyB.getRotation());

    Vector2f pos = poly.getCentroid(bodyB.getPosition(), bodyB.getRotation());
   
    // using the z axis of a 3d cross product we determine on what side B is
    boolean isLeftOf = 0 > (pos.x - vertsA[0].x) * (vertsA[1].y - vertsA[0].y) - (vertsA[1].x - vertsA[0].x) * (pos.y - vertsA[0].y);
   
    // to get the proper intersection pairs we make sure
View Full Code Here

    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
    Polygon polyA = (Polygon) bodyA.getBodyShape();
    Polygon polyB = (Polygon) bodyB.getBodyShape();

    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = polyB.getVertices(bodyB.getPosition(), bodyB.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());
    Vector2f centroidB = new Vector2f(polyB.getCentroid());
    centroidB.add(bodyB.getPosition());
   
    int[][] collEdgeCands = getCollisionCandidates(vertsA, vertsB, centroidA, centroidB);
    Intersection[][] intersections = getIntersectionPairs(vertsA, vertsB, collEdgeCands);   
    return populateContacts(contacts, vertsA, vertsB, intersections);
View Full Code Here

    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, Body bodyA, Body bodyB) {
    Polygon poly = (Polygon) bodyA.getShape();
    Box box = (Box) bodyB.getShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only one shape
    // specifically the box, because it has fewer vertices.
    Vector2f[] vertsA = poly.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = box.getPoints(bodyB.getPosition(), bodyB.getRotation());
   
    // TODO: use a sweepline that has the smallest projection of the box
    // now we use just an arbitrary one
    Vector2f sweepline = new Vector2f(vertsB[1]);
View Full Code Here

    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, Body bodyA, Body bodyB) {
    Polygon polyA = (Polygon) bodyA.getShape();
    Polygon polyB = (Polygon) bodyB.getShape();

    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = polyB.getVertices(bodyB.getPosition(), bodyB.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());
    Vector2f centroidB = new Vector2f(polyB.getCentroid());
    centroidB.add(bodyB.getPosition());
   
    int[][] collEdgeCands = getCollisionCandidates(vertsA, vertsB, centroidA, centroidB);
    Intersection[][] intersections = getIntersectionPairs(vertsA, vertsB, collEdgeCands);   
    return populateContacts(contacts, vertsA, vertsB, intersections);
View Full Code Here

   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, Body bodyA, Body bodyB) {
    Line line = (Line) bodyA.getShape();
    Polygon poly = (Polygon) bodyB.getShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only one shape
    // specifically the line, because it has only two vertices
    Vector2f[] vertsA = line.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = poly.getVertices(bodyB.getPosition(), bodyB.getRotation());

    Vector2f pos = poly.getCentroid(bodyB.getPosition(), bodyB.getRotation());
   
    // using the z axis of a 3d cross product we determine on what side B is
    boolean isLeftOf = 0 > (pos.x - vertsA[0].x) * (vertsA[1].y - vertsA[0].y) - (vertsA[1].x - vertsA[0].x) * (pos.y - vertsA[0].y);
   
    // to get the proper intersection pairs we make sure
View Full Code Here

    /**
   * @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
   */
  @Override
    public int collide(Contact[] contacts, Body bodyA, Body bodyB) {
    Polygon polyA = (Polygon) bodyA.getShape();
    Circle circle = (Circle) bodyB.getShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only the circle
    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());

   
    int[][] collPairs = getCollisionCandidates(vertsA, centroidA, circle.getRadius(), bodyB.getPosition());

View Full Code Here

TOP

Related Classes of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.shapes.Polygon

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.