/** * <code>fromAngleAxis</code> sets this quaternion to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this quaternion */ public Quaternion fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); return this; }
private static Quaternion toQuat(float ax1v, Vector3f ax1, float ax2v, Vector3f ax2, float ax3v, Vector3f ax3) { // TODO It has some potential in optimization Quaternion q1 = new Quaternion().fromAngleNormalAxis(ax1v, ax1); Quaternion q2 = new Quaternion().fromAngleNormalAxis(ax2v, ax2); Quaternion q3 = new Quaternion().fromAngleNormalAxis(ax3v, ax3); return q1.multLocal(q2).multLocal(q3); } }
/** * rotate the camera around the target */ protected void rotateCamera() { verticalRotation = FastMath.clamp(verticalRotation, minVerticalRotation, maxVerticalRotation); TempVars vars = TempVars.get(); Quaternion rot = vars.quat1; Quaternion rot2 = vars.quat2; rot.fromAngleNormalAxis(verticalRotation, leftVector); rot2.fromAngleNormalAxis(horizontalRotation, upVector); rot2.multLocal(rot); target.setLocalRotation(rot2); vars.release(); }
rotation.fromAngleNormalAxis(angle, Vector3f.UNIT_Y); floor.setLocalRotation(rotation); sky.setLocalRotation(rotation);
rotation = new Quaternion(); axis.normalizeLocal(); rotation.fromAngleNormalAxis(angle, axis); angle = 0; axis = null;
TempVars vars = TempVars.get(); vars.vect1.set(faceNormal).normalizeLocal(); vars.quat1.fromAngleNormalAxis(p.angle, vars.vect1); vars.quat1.multLocal(left); vars.quat1.multLocal(up);
/** * Forcefully takes over Camera adding functionality and placing it behind the character * @param tpf Tickes Per Frame */ private void camTakeOver(float tpf) { cam.setLocation(player.getLocalTranslation().add(-8, 2, 0)); cam.lookAt(player.getLocalTranslation(), Vector3f.UNIT_Y); Quaternion rot = new Quaternion(); rot.fromAngleNormalAxis(camAngle, Vector3f.UNIT_Z); cam.setRotation(cam.getRotation().mult(rot)); camAngle *= FastMath.pow(.99f, fpsRate * tpf); }
/** * <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(); }
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); motionControl.setInitialDuration(10f); motionControl.setSpeed(2f);
/** * <code>fromAngleAxis</code> sets this quaternion to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this quaternion */ public Quaternion fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); return this; }
/** * <code>fromAngleAxis</code> sets this quaternion to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this quaternion */ public Quaternion fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); return this; }
private static Quaternion toQuat(float ax1v, Vector3f ax1, float ax2v, Vector3f ax2, float ax3v, Vector3f ax3) { // TODO It has some potential in optimization Quaternion q1 = new Quaternion().fromAngleNormalAxis(ax1v, ax1); Quaternion q2 = new Quaternion().fromAngleNormalAxis(ax2v, ax2); Quaternion q3 = new Quaternion().fromAngleNormalAxis(ax3v, ax3); return q1.multLocal(q2).multLocal(q3); } }
/** * rotate the camera around the target */ protected void rotateCamera() { verticalRotation = FastMath.clamp(verticalRotation, minVerticalRotation, maxVerticalRotation); TempVars vars = TempVars.get(); Quaternion rot = vars.quat1; Quaternion rot2 = vars.quat2; rot.fromAngleNormalAxis(verticalRotation, leftVector); rot2.fromAngleNormalAxis(horizontalRotation, upVector); rot2.multLocal(rot); target.setLocalRotation(rot2); vars.release(); }
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); motionControl.setInitialDuration(20f); motionControl.setSpeed(0.1f);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); motionControl.setInitialDuration(20f); motionControl.setSpeed(0.1f);
/** * Forcefully takes over Camera adding functionality and placing it behind the character * @param tpf Tickes Per Frame */ private void camTakeOver(float tpf) { cam.setLocation(player.getLocalTranslation().add(-8, 2, 0)); cam.lookAt(player.getLocalTranslation(), Vector3f.UNIT_Y); Quaternion rot = new Quaternion(); rot.fromAngleNormalAxis(camAngle, Vector3f.UNIT_Z); cam.setRotation(cam.getRotation().mult(rot)); camAngle *= FastMath.pow(.99f, fpsRate * tpf); }
(MotionTrack.Direction.PathAndRotation); motionControl.setRotation (new Quaternion().fromAngleNormalAxis (-FastMath.HALF_PI, Vector3f.UNIT_Y)); motionControl.setInitialDuration(20f);
/** * <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(); }
/** * <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(); }
q = q.fromAngleNormalAxis((float) Math.PI / 8, new Vector3f(0, 0, 1)); node.skeleton = skeleton; temp.release();