Exemplo n.º 1
0
  public void update(float delta) {
    // tmp.set(acceleration);
    // tmp.scl(delta);
    // velocity.add(tmp);
    // velocity = velocity.scl(0.95f);
    tmp.set(velocity);
    tmp.scl(delta);
    position.add(tmp);

    transform.setTranslation(position);
    collisionObject.setWorldTransform(transform);
  }
Exemplo n.º 2
0
  public Projectile(
      Vector3 startingPosition, Vector3 direction, float msSpeed, btCollisionWorld world) {
    btCollisionShape sphere = new btSphereShape(0.5f);
    collisionObject = new btCollisionObject();
    collisionObject.setCollisionShape(sphere);
    collisionObject.userData = this;
    world.addCollisionObject(collisionObject);

    position = new Vector3(startingPosition);
    /*
    acceleration = new Vector3(direction);
    acceleration.nor().scl(msSpeed);*/

    velocity = new Vector3(direction);
    velocity.nor().scl(msSpeed);
    transform = new Matrix4();
    transform.setTranslation(position);
    collisionObject.setWorldTransform(transform);
  }