當前位置: 首頁>>代碼示例>>Java>>正文


Java Quaternion.fromAxes方法代碼示例

本文整理匯總了Java中com.jme3.math.Quaternion.fromAxes方法的典型用法代碼示例。如果您正苦於以下問題:Java Quaternion.fromAxes方法的具體用法?Java Quaternion.fromAxes怎麽用?Java Quaternion.fromAxes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.math.Quaternion的用法示例。


在下文中一共展示了Quaternion.fromAxes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rotateCamera

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
protected void rotateCamera(float value, Vector3f axis){
        if (dragToRotate){
            if (canRotate){
//                value = -value;
            }else{
                return;
            }
        }

        Matrix3f mat = new Matrix3f();
        mat.fromAngleNormalAxis(rotationSpeed * value, axis);

        Vector3f up = cam.getUp();
        Vector3f left = cam.getLeft();
        Vector3f dir = cam.getDirection();

        mat.mult(up, up);
        mat.mult(left, left);
        mat.mult(dir, dir);

        Quaternion q = new Quaternion();
        q.fromAxes(left, up, dir);
        q.normalize();

        cam.setAxes(q);
    }
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:27,代碼來源:FlyByCamera.java

示例2: calculateNewForward

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * This method works similar to Camera.lookAt but where lookAt sets the priority on
 * the direction, this method sets the priority on the up vector so that the result
 * direction vector and rotation is guaranteed to be perpendicular to the up vector.
 *
 * @param rotation The rotation to set the result on or null to create a new
 * Quaternion, this will be set to the new "z-forward" rotation if not null
 * @param direction The direction to base the new look direction on, will be set to
 * the new direction
 * @param worldUpVector The up vector to use, the result direction will be
 * perpendicular to this
 * @return
 */
protected final void calculateNewForward(Quaternion rotation, Vector3f direction, Vector3f worldUpVector) {
    if (direction == null) {
        return;
    }
    TempVars vars = TempVars.get();
    Vector3f newLeft = vars.vect1;
    Vector3f newLeftNegate = vars.vect2;

    newLeft.set(worldUpVector).crossLocal(direction).normalizeLocal();
    if (newLeft.equals(Vector3f.ZERO)) {
        if (direction.x != 0) {
            newLeft.set(direction.y, -direction.x, 0f).normalizeLocal();
        } else {
            newLeft.set(0f, direction.z, -direction.y).normalizeLocal();
        }
        logger.log(Level.INFO, "Zero left for direction {0}, up {1}", new Object[]{direction, worldUpVector});
    }
    newLeftNegate.set(newLeft).negateLocal();
    direction.set(worldUpVector).crossLocal(newLeftNegate).normalizeLocal();
    if (direction.equals(Vector3f.ZERO)) {
        direction.set(Vector3f.UNIT_Z);
        logger.log(Level.INFO, "Zero left for left {0}, up {1}", new Object[]{newLeft, worldUpVector});
    }
    if (rotation != null) {
        rotation.fromAxes(newLeft, worldUpVector, direction);
    }
    vars.release();
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:42,代碼來源:AdvancedCharacterControl.java

示例3: calculateNewForward

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * This method works similar to Camera.lookAt but where lookAt sets the
 * priority on the direction, this method sets the priority on the up vector
 * so that the result direction vector and rotation is guaranteed to be
 * perpendicular to the up vector.
 *
 * @param rotation The rotation to set the result on or null to create a new
 * Quaternion, this will be set to the new "z-forward" rotation if not null
 * @param direction The direction to base the new look direction on, will be
 * set to the new direction
 * @param worldUpVector The up vector to use, the result direction will be
 * perpendicular to this
 * @return
 */
protected final void calculateNewForward(Quaternion rotation, Vector3f direction, Vector3f worldUpVector) {
    if (direction == null) {
        return;
    }
    TempVars vars = TempVars.get();
    Vector3f newLeft = vars.vect1;
    Vector3f newLeftNegate = vars.vect2;

    newLeft.set(worldUpVector).crossLocal(direction).normalizeLocal();
    if (newLeft.equals(Vector3f.ZERO)) {
        if (direction.x != 0) {
            newLeft.set(direction.y, -direction.x, 0f).normalizeLocal();
        } else {
            newLeft.set(0f, direction.z, -direction.y).normalizeLocal();
        }
        logger.log(Level.INFO, "Zero left for direction {0}, up {1}", new Object[]{direction, worldUpVector});
    }
    newLeftNegate.set(newLeft).negateLocal();
    direction.set(worldUpVector).crossLocal(newLeftNegate).normalizeLocal();
    if (direction.equals(Vector3f.ZERO)) {
        direction.set(Vector3f.UNIT_Z);
        logger.log(Level.INFO, "Zero left for left {0}, up {1}", new Object[]{newLeft, worldUpVector});
    }
    if (rotation != null) {
        rotation.fromAxes(newLeft, worldUpVector, direction);
    }
    vars.release();
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:43,代碼來源:BetterCharacterControl.java


注:本文中的com.jme3.math.Quaternion.fromAxes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。