Examples of Vec2


Examples of org.jbox2d.common.Vec2

                    body.applyAngularImpulse(+0.01f);
                } else if (Keyboard.isKeyDown(Keyboard.KEY_D) && !Keyboard.isKeyDown(Keyboard.KEY_A)) {
                    body.applyAngularImpulse(-0.01f);
                }
                if (Mouse.isButtonDown(0)) {
                    Vec2 mousePosition = new Vec2(Mouse.getX(), Mouse.getY()).mul(0.5f).mul(1 / 30f);
                    Vec2 bodyPosition = body.getPosition();
                    Vec2 force = mousePosition.sub(bodyPosition);
                    body.applyForce(force, body.getPosition());
                }
            }
        }
    }
View Full Code Here

Examples of org.jbox2d.common.Vec2

  public static void init(int w,int h){
    width=w;
    height=h;
  }
  public static Vec2 coordPixelToWorld(Point p){
    return new Vec2(scalerPixelsToWorld(p.getX()-width/2.0),scalerPixelsToWorld(height/2.0-p.getY()));
  }
View Full Code Here

Examples of org.jbox2d.common.Vec2

  }
  public static Vec2 coordPixelToWorld(Point p){
    return new Vec2(scalerPixelsToWorld(p.getX()-width/2.0),scalerPixelsToWorld(height/2.0-p.getY()));
  }
  public static Vec2 vectorPixelToWorld(Vector v){
    return new Vec2(scalerPixelsToWorld(v.getVectorX()),scalerPixelsToWorld(-v.getVectorY()));
  }
View Full Code Here

Examples of org.jbox2d.common.Vec2

      this.checker=new Checker(fixtures);
     
      body.setTransform(body.getPosition(),(float)-angle);
      aabb=new AABB();
      aabb.combine(fixtures[0].getAABB(), fixtures[1].getAABB());
      forceVec=new Vec2((float)(radius*FORCE_MAGNITUDE_FACTOR*Math.cos(-angle)),(float)(radius*FORCE_MAGNITUDE_FACTOR*Math.sin(-angle)));
     
    }else{
      this.forceVec=null;
      this.radius=0;
    }
 
View Full Code Here

Examples of org.jbox2d.common.Vec2

    Point brP=bmP.clone();
    blP.translate(-7.5f, 0);
    brP.translate(7.5f, 0);
    points=Point.getRotatedPoint(getPosition(), getAngle(),tlP,trP,crossP,bmP,blP,brP);
   
    Vec2 crossV=CoordinateConverter.vectorPixelToWorld(position.delta(crossP));
   
    BodyDef bodyD=new BodyDef();
    PolygonShape[] edges=new PolygonShape[]{new PolygonShape(),new PolygonShape(),new PolygonShape(),new PolygonShape()};
   
    bodyD.type=BodyType.STATIC;
View Full Code Here

Examples of org.jbox2d.common.Vec2

      PolygonShape lineP=new PolygonShape();
     
      this.hL=getWidth()/2;
       
      lineP.setAsBox(CoordinateConverter.scalerPixelsToWorld(getWidth())/2
          ,CoordinateConverter.scalerPixelsToWorld(1),new Vec2(),0);
           
      fixD.density=1.2f;
      fixD.shape=lineP;
      fixD.restitution=0.75f;
      fixD.friction=0.4f;
View Full Code Here

Examples of org.jbox2d.common.Vec2

  public void update() {
    if(lastShapesCount>0){
      double angle=lastShapesCount*PORTION_ANGLE;
      Point pos=this.position.clone();
      pos.translate(new Vector(spoutDistance,angle,true));
      Vec2 impulse=new Vec2((float)(this.impulseMag*Math.cos(angle)),(float)(this.impulseMag*Math.sin(angle)));
     
      PhysicalShape shape=generateShape(pos,angle);
      if(shape.isVerified()){
        shape.getBody().applyLinearImpulse(impulse,shape.getBody().getWorldCenter());
        lastShapesCount--;
View Full Code Here

Examples of org.jbox2d.common.Vec2

    public boolean isRotating(){
      return gravityAngle!=nextGravityAngle;
    }
   
    private void fireGravityChangedEvents(){
      GravityChangedEvent event=new GravityChangedEvent(this,new Vec2(gravity));
      for(int i=listenerList.size()-1;i>=0;i--){
        listenerList.get(i).gravityChanged(event);
      }
     
    }
View Full Code Here

Examples of org.jbox2d.common.Vec2

      }
      RotationUnit=delta/Math.abs(delta);
      Settings.velocityThreshold=DEFAULT_VELOCITY_THRESHOLD;
    }
    private static Vec2 getGravityByDegrees(int angleInDegree){
      return new Vec2((float)(GRAVITY_MAGNITUDE*Math.cos(Math.toRadians(angleInDegree))),
               (float)(GRAVITY_MAGNITUDE*Math.sin(Math.toRadians(-angleInDegree))));
    }
 
View Full Code Here

Examples of org.jbox2d.common.Vec2

   * @param angle
   */
  public Cross(Point p,double angle) {
    super(0, p, 15*(1+SQRT_2), 15*(1+SQRT_2/2),angle);
   
    Vec2 crossV=CoordinateConverter.vectorPixelToWorld(position.delta(getX(),getTopY()+getWidth()/2));
    Point nwP=this.getPositionAt(PositionType.NORTHWEST);
    Point neP=this.getPositionAt(PositionType.NORTHEAST);
    Point seP=nwP.clone();
    Point swP=neP.clone();
    seP.translate(getHeight(), getHeight());
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.