Exemplo n.º 1
1
    public void updatePosition(float dt) {
      if (fixed) {
        netForce.reset(); // Shouldn't accumulate forces if fixed
        return;
      }

      updateAcceleration(dt);
      updateVelocity(dt);

      Point prev = new Point(pos.x, pos.y);
      pos.add(vel.copy().scale(dt, dt));

      ensureInBounds();
    }
Exemplo n.º 2
1
    // f = m * a --> a = f / m
    private void updateAcceleration(float dt) {
      //    println("node = " + id + ", netforce = " + netForce);

      Vector prev = acc;

      Float f1 = new Float(netForce.x);
      Float f2 = new Float(netForce.y);

      if (f1.isNaN(f1) || f2.isNaN(f2)) {
        netForce = new Vector();
      }

      float scale = 1.0f / mass;
      this.acc = netForce.copy().scale(scale, scale);

      if (id.equals("*.1.0-10")) {
        // println("NewAcc = " + acc);
        // System.exit(1);
      }

      // reset netForce for next time
      netForce.reset();
    }