当前位置: 首页>>代码示例>>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;未经允许,请勿转载。