@Override
  public void update(float tpf) {

    if (forward ^ backward) {
      //            float yCoord = charControl.getRigidBody().getLinearVelocity().getY();
      Vector3f charLocation = charControl.getPhysicsLocation();
      Vector3f walkDir =
          charLocation
              .subtract(app.getCamera().getLocation().clone().setY(charLocation.getY()))
              .normalizeLocal();
      if (backward) {
        walkDir.negateLocal();
      }

      charControl.setWalkDirection(walkDir);
      charControl.setMove(true);
    } else {
      charControl.setMove(false);
    }

    if (jump) {
      charControl.setJump();
      jump = false;
    }
    Vector3f camdir = app.getCamera().getDirection().clone();
    Quaternion newRot = new Quaternion();
    newRot.lookAt(camdir.setY(0), Vector3f.UNIT_Y);
    charControl.setRotationInUpdate(newRot);
  }
 public void updateSize() {
   float width = app.getCamera().getWidth();
   float height = app.getCamera().getHeight();
   float w, h;
   if (width < height * 1.75f) {
     h = height;
     w = (imageWidth * h) / imageHeight;
   } else {
     w = width;
     h = (w * imageHeight) / imageWidth;
   }
   splash.setWidth(w);
   splash.setHeight(h);
   splash.setLocalTranslation((width / 2) - (w / 2), (height / 2) - (h / 2), 0);
 }
Beispiel #3
0
  @Override
  protected void initialize(Application app) {

    ed = getState(EntityDataState.class).getEntityData();
    entities = ed.getEntities(Position.class, ModelType.class);

    // Calculate how big min/max needs to be to incorporate
    // the full view + margin at z = 0
    Camera cam = app.getCamera();
    float z = cam.getViewToProjectionZ(cam.getLocation().z);
    Vector3f worldMin = cam.getWorldCoordinates(new Vector2f(0, 0), z);
    Vector3f worldMax = cam.getWorldCoordinates(new Vector2f(cam.getWidth(), cam.getHeight()), z);
    min = worldMin.addLocal(-margin, -margin, 0);
    max = worldMax.addLocal(margin, margin, 0);
  }
 @Override
 protected void initialize(Application app) {
   this.camera = app.getCamera();
   this.listener = app.getListener();
 }