Ejemplo n.º 1
0
  /**
   * Call from the JPanelFlythruMove.
   *
   * @param command move command.
   */
  public void move(String command) {

    if (command.equals("lookup")) {
      // pitch - look up
      Vector3f kRight = new Vector3f();
      kRight.UnitCross(m_kViewDirection, m_kViewUp);
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(kRight, (float) Math.toRadians(1));
      kRotate.Mult(m_kViewDirection, m_kViewDirection);
      kRotate.Mult(m_kViewUp, m_kViewUp);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("lookdown")) {
      // pitch - look down
      Vector3f kRight = new Vector3f();
      kRight.UnitCross(m_kViewDirection, m_kViewUp);
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(kRight, (float) Math.toRadians(-1));
      kRotate.Mult(m_kViewDirection, m_kViewDirection);
      kRotate.Mult(m_kViewUp, m_kViewUp);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("lookleft")) {
      // yaw - look left
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(m_kViewUp, (float) Math.toRadians(1));
      kRotate.Mult(m_kViewDirection, m_kViewDirection);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("lookright")) {
      // case KeyEvent.VK_RIGHT:
      // yaw - look right
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(m_kViewUp, (float) Math.toRadians(-1));
      kRotate.Mult(m_kViewDirection, m_kViewDirection);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("counterclockwise")) {
      // case KeyEvent.VK_F3:
      // roll - counterclockwise
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(m_kViewDirection, (float) Math.toRadians(-1));
      kRotate.Mult(m_kViewUp, m_kViewUp);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("clockwise")) {
      // roll - clockwise
      Matrix3f kRotate = new Matrix3f();
      kRotate.FromAxisAngle(m_kViewDirection, (float) Math.toRadians(1));
      kRotate.Mult(m_kViewUp, m_kViewUp);
      // Notify listener that we are updated.
      notifyCallback(EVENT_CHANGE_POSITION);
    } else if (command.equals("escape")) {

      // VK_ESCAPE
      setIdentityViewOrientation();
    } else if (command.equals("home")) {

      // case KeyEvent.VK_HOME:
      // reset position to the beginning of the path
      if (!m_bChooseBranch && (null == m_akBranchChoice)) {
        setPathDist(0.0f);
      } else {
        beep();
      }
    } else if (command.equals("end")) {

      // case KeyEvent.VK_END:
      // reset position to the end of the path
      if (!m_bChooseBranch && (null == m_akBranchChoice)) {
        setPathDist(1.0f);
      } else {
        beep();
      }
    } else if (command.equals("forward")) {

      // case KeyEvent.VK_UP:
      // move forward along the path
      if (!m_bChooseBranch) {
        doPathStep(1);
      } else {
        beep();
      }
    } else if (command.equals("backward")) {

      // case KeyEvent.VK_DOWN:
      // move backward along the path
      if (!m_bChooseBranch) {
        doPathStep(-1);
      } else {
        beep();
      }
    } else if (command.equals("reverse")) {

      // case KeyEvent.VK_R:
      // follow path in reverse heading
      m_kBranchState.m_bMoveForward = !m_kBranchState.m_bMoveForward;
      setPathDist(m_kBranchState.m_fNormalizedPathDist);

    } else if (command.equals("prevAnnotatePt")) {

      // case KeyEvent.VK_F5:
      // go to previous annotate point
      if (!m_bChooseBranch && (m_kAnnotateList.getNumItems() > 0)) {

        if (--m_iAnnotateListItemSelected < 0) {
          m_iAnnotateListItemSelected = m_kAnnotateList.getNumItems() - 1;
        }

        setCurvePathAnnotateItem(m_iAnnotateListItemSelected);
      } else {
        beep();
      }
    } else if (command.equals("nextAnnotatePt")) {

      // case KeyEvent.VK_F6:
      // go to next annotate point
      if (!m_bChooseBranch && (m_kAnnotateList.getNumItems() > 0)) {

        if (++m_iAnnotateListItemSelected >= m_kAnnotateList.getNumItems()) {
          m_iAnnotateListItemSelected = 0;
        }

        setCurvePathAnnotateItem(m_iAnnotateListItemSelected);
      } else {
        beep();
      }
    } else if (command.equals("nextBranch")) {

      // case KeyEvent.VK_SPACE:
      // select next branch choice
      if (null != m_akBranchChoice) {
        setClosestChoiceBranch();
      } else {
        beep();
      }
    } else if (command.equals("stepDistanceIncrease")) {
      m_fPathStep += 0.1f;
      setPathDist(m_kBranchState.m_fNormalizedPathDist);
    } else if (command.equals("stepDistanceDecrease")) {
      m_fPathStep -= 0.1f;

      if (m_fPathStep < 0.1f) {
        m_fPathStep = 0.1f;
        beep();
      }

      setPathDist(m_kBranchState.m_fNormalizedPathDist);
    } else if (command.equals("gazeDistanceDecrease")) {
      m_fGazeDist -= 1.0f;

      if (m_fGazeDist < 0.0f) {
        m_fGazeDist = 0.0f;
        beep();
      }

      setPathDist(m_kBranchState.m_fNormalizedPathDist);
    } else if (command.equals("gazeDistanceIncrease")) {
      m_fGazeDist += 1.0f;
      setPathDist(m_kBranchState.m_fNormalizedPathDist);
    }
  }