本文整理汇总了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);
}
示例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();
}
示例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();
}