/** * Constructor instantiates a new <code>Quaternion</code> object from a * collection of rotation angles. * * @param angles * the angles of rotation (x, y, z) that will define the * <code>Quaternion</code>. */ public Quaternion(float[] angles) { fromAngles(angles); }
/** * <code>fromAngles</code> builds a quaternion from the Euler rotation * angles (x,y,z) aka (pitch, yaw, roll). * * @param angles * the Euler angles of rotation (in radians). */ public Quaternion fromAngles(float[] angles) { if (angles.length != 3) { throw new IllegalArgumentException( "Angles array must have three elements"); } return fromAngles(angles[0], angles[1], angles[2]); }
void set(float x, float y, float z) { float[] a = {x, y, z}; rotation.fromAngles(a); eulerAngles.set(x, y, z); } }
/** * Converts the euler angles from {@link #getVector3Value(long)} to * a quaternion rotation. * @param time Time at which to get the euler angles. * @return The rotation at time */ public Quaternion getQuaternionValue(long time) { Vector3f eulerAngles = getVector3Value(time); System.out.println("\tT: " + time + ". Rotation: " + eulerAngles.x + ", " + eulerAngles.y + ", " + eulerAngles.z); Quaternion q = new Quaternion(); q.fromAngles(eulerAngles.x * FastMath.DEG_TO_RAD, eulerAngles.y * FastMath.DEG_TO_RAD, eulerAngles.z * FastMath.DEG_TO_RAD); return q; }
/** * This constructor parses the given blender version and stores the result. Some functionalities may differ in different blender * versions. * @param blenderVersion * the version read from the blend file * @param blenderContext * the blender context */ public AbstractBlenderHelper(String blenderVersion, BlenderContext blenderContext) { this.blenderVersion = Integer.parseInt(blenderVersion); this.blenderContext = blenderContext; fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis(); if (fixUpAxis) { upAxisRotationQuaternion = new Quaternion().fromAngles(-FastMath.HALF_PI, 0, 0); } }
/** * Rotates the spatial by the xAngle, yAngle and zAngle angles (in radians), * (aka pitch, yaw, roll) in the local coordinate space. * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial rotate(float xAngle, float yAngle, float zAngle) { TempVars vars = TempVars.get(); Quaternion q = vars.quat1; q.fromAngles(xAngle, yAngle, zAngle); rotate(q); vars.release(); return this; }
@Override public void simpleUpdate(float tpf){ Quaternion q = new Quaternion(); angle += tpf; angle %= FastMath.TWO_PI; q.fromAngles(angle, 0, angle); offBox.setLocalRotation(q); offBox.updateLogicalState(tpf); offBox.updateGeometricState(); }
@Override public void simpleUpdate(float tpf){ Quaternion q = new Quaternion(); angle += tpf; angle %= FastMath.TWO_PI; q.fromAngles(angle, 0, angle); offBox.setLocalRotation(q); offBox.updateLogicalState(tpf); offBox.updateGeometricState(); } }
double y = (Double) e2.properties.get(5); double z = (Double) e2.properties.get(6); localRotation.fromAngles((float) x * FastMath.DEG_TO_RAD, (float) y * FastMath.DEG_TO_RAD, (float) z * FastMath.DEG_TO_RAD); } else if (propName.equals("Lcl Scaling")) { double x = (Double) e2.properties.get(4);
private void attachRandomGeometry(Node node, Material mat) { Box box = new Box(0.25f, 0.25f, 0.25f); Torus torus = new Torus(16, 16, 0.2f, 0.8f); Geometry[] boxes = new Geometry[]{ new Geometry("box1", box), new Geometry("box2", box), new Geometry("box3", box), new Geometry("torus1", torus), new Geometry("torus2", torus), new Geometry("torus3", torus) }; for (int i = 0; i < boxes.length; i++) { Geometry geometry = boxes[i]; geometry.setLocalTranslation((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10); geometry.setLocalRotation(new Quaternion().fromAngles((float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI)); geometry.setLocalScale((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10); geometry.setMaterial(mat); node.attachChild(geometry); } }
@Override public void simpleUpdate(float tpf){ Quaternion q = new Quaternion(); if (offView.isEnabled()) { angle += tpf; angle %= FastMath.TWO_PI; q.fromAngles(angle, 0, angle); offBox.setLocalRotation(q); offBox.updateLogicalState(tpf); offBox.updateGeometricState(); } }
float angleZ = parseFloat(attribs.getValue("angleZ")); Quaternion q = new Quaternion(); q.fromAngles(angleX, angleY, angleZ); return q;
ownerTransform.getRotation().fromAngles(angles);
@Override public void simpleUpdate(float tpf){ Bone b = control.getSkeleton().getBone("spinehigh"); Bone b2 = control.getSkeleton().getBone("uparm.left"); angle += tpf * rate; if (angle > FastMath.HALF_PI / 2f){ angle = FastMath.HALF_PI / 2f; rate = -1; }else if (angle < -FastMath.HALF_PI / 2f){ angle = -FastMath.HALF_PI / 2f; rate = 1; } Quaternion q = new Quaternion(); q.fromAngles(0, angle, 0); b.setUserControl(true); b.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ); b2.setUserControl(true); b2.setUserTransforms(Vector3f.ZERO, Quaternion.IDENTITY, new Vector3f(1+angle,1+ angle, 1+angle)); }
ownerRotation.fromAngles(ownerAngles).multLocal(offset);
rotations[index] = new Quaternion(quaternionRotation[0], quaternionRotation[1], quaternionRotation[2], quaternionRotation[3]); } else { rotations[index] = new Quaternion().fromAngles(eulerRotation);
cam.setFrustumFar(3000); cam.setLocation(new Vector3f(-700, 100, 300)); cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));
pickUp.setShadowMode(ShadowMode.CastAndReceive); pickUp.setMaterial(materialYellow); pickUp.setLocalRotation(rotation.fromAngles( FastMath.rand.nextFloat() * FastMath.TWO_PI, FastMath.rand.nextFloat() * FastMath.TWO_PI, FastMath.rand.nextFloat() * FastMath.TWO_PI)); rotation.fromAngles(0.0f, angle, 0.0f); rotation.mult(translation, pickUp.getLocalTranslation()); pickUps.attachChild(pickUp);
/** * Constructor instantiates a new <code>Quaternion</code> object from a * collection of rotation angles. * * @param angles * the angles of rotation (x, y, z) that will define the * <code>Quaternion</code>. */ public Quaternion(float[] angles) { fromAngles(angles); }
cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));