示例#1
0
 /**
  * Handles mouse button input.
  *
  * @param deltaX
  * @param deltaY
  * @param button
  * @return
  */
 protected boolean process(float deltaX, float deltaY, int button) {
   if (button == rotateButton) {
     tmpV1.set(screen.active().direction).crs(screen.active().up).y = 0f;
     screen.active().rotateAround(target, tmpV1.nor(), deltaY * rotateAngle);
     screen.active().rotateAround(target, Vector3.Y, deltaX * -rotateAngle);
   } else if (button == translateButton) {
     screen
         .active()
         .translate(
             tmpV1
                 .set(screen.active().direction)
                 .crs(screen.active().up)
                 .nor()
                 .scl(-deltaX * translateUnits));
     screen.active().translate(tmpV2.set(screen.active().up).scl(-deltaY * translateUnits));
     if (translateTarget) target.add(tmpV1).add(tmpV2);
   } else if (button == interactButton) {
     /**
      * @TODO Make the interact button interact here. No zooming. zoom code.
      * screen.active().translate(tmpV1.set(screen.active().direction).scl(deltaY *
      * translateUnits));
      */
   }
   if (autoUpdate) screen.active().update();
   return true;
 }
示例#2
0
 /**
  * 1st from keyboard zoom also, called in update() Maybe move this to the screen? It's the last in
  * chain from scrolled at least?
  *
  * <p>Or just set camera field to screen.active()
  *
  * @param amount
  * @return
  */
 public boolean zoom(float amount) {
   screen.active().translate(tmpV1.set(screen.active().direction).scl(amount));
   if (scrollTarget) target.add(tmpV1);
   if (autoUpdate) screen.active().update();
   return true;
 }
示例#3
0
  public void update() {
    if (rotateRightPressed
        || rotateLeftPressed
        || forwardPressed
        || backwardPressed
        || leftPressed
        || rightPressed
        || zoomInPressed
        || zoomOutPressed) {
      final float delta = Gdx.graphics.getDeltaTime();
      //			if (rotateRightPressed) screen.active().rotate(screen.active().up, -delta * rotateAngle);
      //			if (rotateLeftPressed) screen.active().rotate(screen.active().up, delta * rotateAngle);
      if (forwardPressed) {
        // check to correct for lock when looking straight down.
        if (screen.active().direction.equals(new Vector3(0, -1, 0)))
          screen.active().rotate(new Vector3(-1, 0, 0), -1);

        screen
            .active()
            .translate(
                tmpV1
                    .set(screen.active().direction.x, 0, screen.active().direction.z)
                    .nor()
                    .scl(delta * translateUnits));

        if (forwardTarget) target.add(tmpV1);
      }
      if (backwardPressed) {
        // check to correct for lock when looking straight down.
        if (screen.active().direction.equals(new Vector3(0, -1, 0)))
          screen.active().rotate(new Vector3(-1, 0, 0), 1);

        screen
            .active()
            .translate(
                tmpV1
                    .set(screen.active().direction.x, 0, screen.active().direction.z)
                    .nor()
                    .scl(-delta * translateUnits));
        if (forwardTarget) target.add(tmpV1);
      }
      if (leftPressed) {
        Vector3 left = new Vector3().set(screen.active().direction).crs(screen.active().up).nor();
        screen.active().translate(tmpV1.set(left).scl(-delta * translateUnits));
        if (lateralTarget) target.add(tmpV1);
      }
      if (rightPressed) {
        Vector3 right =
            new Vector3().set(screen.active().direction).crs(screen.active().up).nor().scl(-1f);
        screen.active().translate(tmpV1.set(right).scl(-delta * translateUnits));
        if (lateralTarget) target.add(tmpV1);
      }
      if (zoomInPressed) {
        zoom(delta * translateUnits);
        if (zoomTarget) target.add(tmpV1);
      }
      if (zoomOutPressed) {
        zoom(-delta * translateUnits);
        if (zoomTarget) target.add(tmpV1);
      }
      if (autoUpdate) screen.active().update();
    }
  }