示例#1
0
  /**
   * <code>rotateUpTo</code> is a utility function that alters the local rotation to point the Y
   * axis in the direction given by newUp.
   *
   * @param newUp the up vector to use - assumed to be a unit vector.
   */
  public void rotateUpTo(Vector3f newUp) {
    TempVars vars = TempVars.get();

    Vector3f compVecA = vars.vect1;
    Quaternion q = vars.quat1;

    // First figure out the current up vector.
    Vector3f upY = compVecA.set(Vector3f.UNIT_Y);
    Quaternion rot = localTransform.getRotation();
    rot.multLocal(upY);

    // get angle between vectors
    float angle = upY.angleBetween(newUp);

    // figure out rotation axis by taking cross product
    Vector3f rotAxis = upY.crossLocal(newUp).normalizeLocal();

    // Build a rotation quat and apply current local rotation.
    q.fromAngleNormalAxis(angle, rotAxis);
    q.mult(rot, rot);

    vars.release();

    setTransformRefresh();
  }
示例#2
0
 /**
  * <code>setLocalRotation</code> sets the local rotation of this node by using a {@link Matrix3f}.
  *
  * @param rotation the new local rotation.
  */
 public void setLocalRotation(Matrix3f rotation) {
   localTransform.getRotation().fromRotationMatrix(rotation);
   setTransformRefresh();
 }
示例#3
0
 /**
  * <code>getLocalRotation</code> retrieves the local rotation of this node.
  *
  * @return the local rotation of this node.
  */
 public Quaternion getLocalRotation() {
   return localTransform.getRotation();
 }
示例#4
0
 /**
  * <code>getWorldRotation</code> retrieves the absolute rotation of the Spatial.
  *
  * @return the Spatial's world rotation quaternion.
  */
 public Quaternion getWorldRotation() {
   checkDoTransformUpdate();
   return worldTransform.getRotation();
 }