/** * * <code>fromAxes</code> creates a <code>Quaternion</code> that * represents the coordinate system defined by three axes. These axes are * assumed to be orthogonal and no error checking is applied. Thus, the user * must insure that the three axes being provided indeed represents a proper * right handed coordinate system. * * @param axis * the array containing the three vectors representing the * coordinate system. */ public Quaternion fromAxes(Vector3f[] axis) { if (axis.length != 3) { throw new IllegalArgumentException( "Axis array must have three elements"); } return fromAxes(axis[0], axis[1], axis[2]); }
/** * <code>setAxes</code> sets the axes (left, up and direction) for this * camera. * * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the direction the camera is facing. * * @see Camera#setAxes(com.jme3.math.Quaternion) */ public void setAxes(Vector3f left, Vector3f up, Vector3f direction) { this.rotation.fromAxes(left, up, direction); onFrameChange(); }
/** * <code>setFrame</code> sets the orientation and location of the camera. * * @param location the point position of the camera. * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the facing of the camera. * @see Camera#setFrame(com.jme3.math.Vector3f, * com.jme3.math.Vector3f, com.jme3.math.Vector3f, com.jme3.math.Vector3f) */ public void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction) { this.location = location; this.rotation.fromAxes(left, up, direction); onFrameChange(); }
/** * <code>lookAt</code> is a convienence method for auto-setting the * quaternion based on a direction and an up vector. It computes * the rotation to transform the z-axis to point into 'direction' * and the y-axis to 'up'. * * @param direction * where to look at in terms of local coordinates * @param up * a vector indicating the local up direction. * (typically {0, 1, 0} in jME.) */ public void lookAt(Vector3f direction, Vector3f up) { TempVars vars = TempVars.get(); vars.vect3.set(direction).normalizeLocal(); vars.vect1.set(up).crossLocal(direction).normalizeLocal(); vars.vect2.set(direction).crossLocal(vars.vect1).normalizeLocal(); fromAxes(vars.vect1, vars.vect2, vars.vect3); vars.release(); }
rotation.fromAxes(newLeft, worldUpVector, direction);
rotation.fromAxes(newLeft, worldUpVector, direction);
q.fromAxes(left, up, dir); q.normalizeLocal();
this.rotation.fromAxes(newLeft, newUp, newDirection); this.rotation.normalizeLocal(); vars.release();
/** * * <code>fromAxes</code> creates a <code>Quaternion</code> that * represents the coordinate system defined by three axes. These axes are * assumed to be orthogonal and no error checking is applied. Thus, the user * must insure that the three axes being provided indeed represents a proper * right handed coordinate system. * * @param axis * the array containing the three vectors representing the * coordinate system. */ public Quaternion fromAxes(Vector3f[] axis) { if (axis.length != 3) { throw new IllegalArgumentException( "Axis array must have three elements"); } return fromAxes(axis[0], axis[1], axis[2]); }
/** * * <code>fromAxes</code> creates a <code>Quaternion</code> that * represents the coordinate system defined by three axes. These axes are * assumed to be orthogonal and no error checking is applied. Thus, the user * must insure that the three axes being provided indeed represents a proper * right handed coordinate system. * * @param axis * the array containing the three vectors representing the * coordinate system. */ public Quaternion fromAxes(Vector3f[] axis) { if (axis.length != 3) { throw new IllegalArgumentException( "Axis array must have three elements"); } return fromAxes(axis[0], axis[1], axis[2]); }
/** * <code>setAxes</code> sets the axes (left, up and direction) for this * camera. * * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the direction the camera is facing. * * @see Camera#setAxes(com.jme3.math.Quaternion) */ public void setAxes(Vector3f left, Vector3f up, Vector3f direction) { this.rotation.fromAxes(left, up, direction); onFrameChange(); }
/** * <code>setAxes</code> sets the axes (left, up and direction) for this * camera. * * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the direction the camera is facing. * * @see Camera#setAxes(com.jme3.math.Quaternion) */ public void setAxes(Vector3f left, Vector3f up, Vector3f direction) { this.rotation.fromAxes(left, up, direction); onFrameChange(); }
/** * <code>setFrame</code> sets the orientation and location of the camera. * * @param location the point position of the camera. * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the facing of the camera. * @see Camera#setFrame(com.jme3.math.Vector3f, * com.jme3.math.Vector3f, com.jme3.math.Vector3f, com.jme3.math.Vector3f) */ public void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction) { this.location = location; this.rotation.fromAxes(left, up, direction); onFrameChange(); }
/** * <code>setFrame</code> sets the orientation and location of the camera. * * @param location the point position of the camera. * @param left the left axis of the camera. * @param up the up axis of the camera. * @param direction the facing of the camera. * @see Camera#setFrame(com.jme3.math.Vector3f, * com.jme3.math.Vector3f, com.jme3.math.Vector3f, com.jme3.math.Vector3f) */ public void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction) { this.location = location; this.rotation.fromAxes(left, up, direction); onFrameChange(); }
private void rotate(float value, Vector3f axis) { Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(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); cam.setAxes(q); }
/** * <code>lookAt</code> is a convienence method for auto-setting the * quaternion based on a direction and an up vector. It computes * the rotation to transform the z-axis to point into 'direction' * and the y-axis to 'up'. * * @param direction * where to look at in terms of local coordinates * @param up * a vector indicating the local up direction. * (typically {0, 1, 0} in jME.) */ public void lookAt(Vector3f direction, Vector3f up) { TempVars vars = TempVars.get(); vars.vect3.set(direction).normalizeLocal(); vars.vect1.set(up).crossLocal(direction).normalizeLocal(); vars.vect2.set(direction).crossLocal(vars.vect1).normalizeLocal(); fromAxes(vars.vect1, vars.vect2, vars.vect3); vars.release(); }
/** * <code>lookAt</code> is a convienence method for auto-setting the * quaternion based on a direction and an up vector. It computes * the rotation to transform the z-axis to point into 'direction' * and the y-axis to 'up'. * * @param direction * where to look at in terms of local coordinates * @param up * a vector indicating the local up direction. * (typically {0, 1, 0} in jME.) */ public void lookAt(Vector3f direction, Vector3f up) { TempVars vars = TempVars.get(); vars.vect3.set(direction).normalizeLocal(); vars.vect1.set(up).crossLocal(direction).normalizeLocal(); vars.vect2.set(direction).crossLocal(vars.vect1).normalizeLocal(); fromAxes(vars.vect1, vars.vect2, vars.vect3); vars.release(); }
public 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.normalizeLocal(); cam.setAxes(q); }
protected void rotate(float value, boolean sideways) { Matrix3f mat = new Matrix3f(); if (sideways) { mat.fromAngleNormalAxis(ROTATION_SPEED * value, Vector3f.UNIT_Y.clone()); } else { mat.fromAngleNormalAxis(ROTATION_SPEED * value, camera.getLeft().clone()); } Vector3f up = camera.getUp(); Vector3f left = camera.getLeft(); Vector3f dir = camera.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); if (dir.y < -Y_ANGLE_MAX || dir.y > Y_ANGLE_MAX) { return; } Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); camera.setAxes(q); }
/** * Rotating is circling around the camera look at point, or similar * * @param value */ public void rotateAround(float value) { Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(value, Vector3f.UNIT_Y.clone()); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); Vector3f pos = cam.getLocation(); Vector3f look = getLookAt(); pos.subtractLocal(look); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); mat.mult(pos, pos); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); cam.setLocation(look.addLocal(pos)); cam.setAxes(q); }