/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix3 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix3.M00], matrix.val[Matrix3.M01], matrix.val[Matrix3.M02], matrix.val[Matrix3.M10], matrix.val[Matrix3.M11], matrix.val[Matrix3.M12], matrix.val[Matrix3.M20], matrix.val[Matrix3.M21], matrix.val[Matrix3.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix3 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix3.M00], matrix.val[Matrix3.M01], matrix.val[Matrix3.M02], matrix.val[Matrix3.M10], matrix.val[Matrix3.M11], matrix.val[Matrix3.M12], matrix.val[Matrix3.M20], matrix.val[Matrix3.M21], matrix.val[Matrix3.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix4 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix4.M00], matrix.val[Matrix4.M01], matrix.val[Matrix4.M02], matrix.val[Matrix4.M10], matrix.val[Matrix4.M11], matrix.val[Matrix4.M12], matrix.val[Matrix4.M20], matrix.val[Matrix4.M21], matrix.val[Matrix4.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix4 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix4.M00], matrix.val[Matrix4.M01], matrix.val[Matrix4.M02], matrix.val[Matrix4.M10], matrix.val[Matrix4.M11], matrix.val[Matrix4.M12], matrix.val[Matrix4.M20], matrix.val[Matrix4.M21], matrix.val[Matrix4.M22]); }
/** <p> * Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal. * </p> * * <p> * Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at * ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z. * </p> * * @param xx x-axis x-coordinate * @param xy x-axis y-coordinate * @param xz x-axis z-coordinate * @param yx y-axis x-coordinate * @param yy y-axis y-coordinate * @param yz y-axis z-coordinate * @param zx z-axis x-coordinate * @param zy z-axis y-coordinate * @param zz z-axis z-coordinate */ public Quaternion setFromAxes (float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) { return setFromAxes(false, xx, xy, xz, yx, yy, yz, zx, zy, zz); }
/** <p> * Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal. * </p> * * <p> * Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at * ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z. * </p> * * @param xx x-axis x-coordinate * @param xy x-axis y-coordinate * @param xz x-axis z-coordinate * @param yx y-axis x-coordinate * @param yy y-axis y-coordinate * @param yz y-axis z-coordinate * @param zx z-axis x-coordinate * @param zy z-axis y-coordinate * @param zz z-axis z-coordinate */ public Quaternion setFromAxes (float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) { return setFromAxes(false, xx, xy, xz, yx, yy, yz, zx, zy, zz); }
/** Sets the rotation of this decal based on the (normalized) direction and up vector. * @param dir the direction vector * @param up the up vector */ public void setRotation (Vector3 dir, Vector3 up) { tmp.set(up).crs(dir).nor(); tmp2.set(dir).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, dir.x, tmp.y, tmp2.y, dir.y, tmp.z, tmp2.z, dir.z); updated = false; }
/** Sets the rotation of this decal based on the (normalized) direction and up vector. * @param dir the direction vector * @param up the up vector */ public void setRotation (Vector3 dir, Vector3 up) { tmp.set(up).crs(dir).nor(); tmp2.set(dir).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, dir.x, tmp.y, tmp2.y, dir.y, tmp.z, tmp2.z, dir.z); updated = false; }
@Override public void update () { for (int i = 0, accelOffset = 0, c = i + controller.particles.size * rotationChannel.strideSize; i < c; i += rotationChannel.strideSize, accelOffset += accellerationChannel.strideSize) { Vector3 axisZ = TMP_V1.set(accellerationChannel.data[accelOffset + ParticleChannels.XOffset], accellerationChannel.data[accelOffset + ParticleChannels.YOffset], accellerationChannel.data[accelOffset + ParticleChannels.ZOffset]).nor(), axisY = TMP_V2.set(TMP_V1) .crs(Vector3.Y).nor().crs(TMP_V1).nor(), axisX = TMP_V3.set(axisY).crs(axisZ).nor(); TMP_Q.setFromAxes(false, axisX.x, axisY.x, axisZ.x, axisX.y, axisY.y, axisZ.y, axisX.z, axisY.z, axisZ.z); rotationChannel.data[i + ParticleChannels.XOffset] = TMP_Q.x; rotationChannel.data[i + ParticleChannels.YOffset] = TMP_Q.y; rotationChannel.data[i + ParticleChannels.ZOffset] = TMP_Q.z; rotationChannel.data[i + ParticleChannels.WOffset] = TMP_Q.w; } }
@Override public void update () { for (int i = 0, accelOffset = 0, c = i + controller.particles.size * rotationChannel.strideSize; i < c; i += rotationChannel.strideSize, accelOffset += accellerationChannel.strideSize) { Vector3 axisZ = TMP_V1.set(accellerationChannel.data[accelOffset + ParticleChannels.XOffset], accellerationChannel.data[accelOffset + ParticleChannels.YOffset], accellerationChannel.data[accelOffset + ParticleChannels.ZOffset]).nor(), axisY = TMP_V2.set(TMP_V1) .crs(Vector3.Y).nor().crs(TMP_V1).nor(), axisX = TMP_V3.set(axisY).crs(axisZ).nor(); TMP_Q.setFromAxes(false, axisX.x, axisY.x, axisZ.x, axisX.y, axisY.y, axisZ.y, axisX.z, axisY.z, axisZ.z); rotationChannel.data[i + ParticleChannels.XOffset] = TMP_Q.x; rotationChannel.data[i + ParticleChannels.YOffset] = TMP_Q.y; rotationChannel.data[i + ParticleChannels.ZOffset] = TMP_Q.z; rotationChannel.data[i + ParticleChannels.WOffset] = TMP_Q.w; } }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix4 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix4.M00], matrix.val[Matrix4.M01], matrix.val[Matrix4.M02], matrix.val[Matrix4.M10], matrix.val[Matrix4.M11], matrix.val[Matrix4.M12], matrix.val[Matrix4.M20], matrix.val[Matrix4.M21], matrix.val[Matrix4.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix3 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix3.M00], matrix.val[Matrix3.M01], matrix.val[Matrix3.M02], matrix.val[Matrix3.M10], matrix.val[Matrix3.M11], matrix.val[Matrix3.M12], matrix.val[Matrix3.M20], matrix.val[Matrix3.M21], matrix.val[Matrix3.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix4 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix4.M00], matrix.val[Matrix4.M01], matrix.val[Matrix4.M02], matrix.val[Matrix4.M10], matrix.val[Matrix4.M11], matrix.val[Matrix4.M12], matrix.val[Matrix4.M20], matrix.val[Matrix4.M21], matrix.val[Matrix4.M22]); }
/** Sets the Quaternion from the given matrix, optionally removing any scaling. */ public Quaternion setFromMatrix (boolean normalizeAxes, Matrix3 matrix) { return setFromAxes(normalizeAxes, matrix.val[Matrix3.M00], matrix.val[Matrix3.M01], matrix.val[Matrix3.M02], matrix.val[Matrix3.M10], matrix.val[Matrix3.M11], matrix.val[Matrix3.M12], matrix.val[Matrix3.M20], matrix.val[Matrix3.M21], matrix.val[Matrix3.M22]); }
/** <p> * Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal. * </p> * * <p> * Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at * ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z. * </p> * * @param xx x-axis x-coordinate * @param xy x-axis y-coordinate * @param xz x-axis z-coordinate * @param yx y-axis x-coordinate * @param yy y-axis y-coordinate * @param yz y-axis z-coordinate * @param zx z-axis x-coordinate * @param zy z-axis y-coordinate * @param zz z-axis z-coordinate */ public Quaternion setFromAxes (float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) { return setFromAxes(false, xx, xy, xz, yx, yy, yz, zx, zy, zz); }
/** <p> * Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal. * </p> * * <p> * Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at * ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z. * </p> * * @param xx x-axis x-coordinate * @param xy x-axis y-coordinate * @param xz x-axis z-coordinate * @param yx y-axis x-coordinate * @param yy y-axis y-coordinate * @param yz y-axis z-coordinate * @param zx z-axis x-coordinate * @param zy z-axis y-coordinate * @param zz z-axis z-coordinate */ public Quaternion setFromAxes (float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz) { return setFromAxes(false, xx, xy, xz, yx, yy, yz, zx, zy, zz); }
/** Sets the rotation of this decal based on the (normalized) direction and up vector. * @param dir the direction vector * @param up the up vector */ public void setRotation (Vector3 dir, Vector3 up) { tmp.set(up).crs(dir).nor(); tmp2.set(dir).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, dir.x, tmp.y, tmp2.y, dir.y, tmp.z, tmp2.z, dir.z); updated = false; }
/** * Sets the rotation of this decal based on the (normalized) direction and * up vector. * * @param direction * the direction vector * @param up * the up vector */ public static void setBillboardRotation(Quaternion rotation, final Vector3d direction, final Vector3d up) { tmp.set((float) up.x, (float) up.y, (float) up.z).crs((float) direction.x, (float) direction.y, (float) direction.z).nor(); tmp2.set((float) direction.x, (float) direction.y, (float) direction.z).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, (float) direction.x, tmp.y, tmp2.y, (float) direction.y, tmp.z, tmp2.z, (float) direction.z); }
/** * Sets the rotation of this decal based on the (normalized) direction and * up vector. * * @param rotation * out-parameter, quaternion where the result is set * @param direction * the direction vector * @param up * the up vector */ public static void setBillboardRotation(Quaternion rotation, final Vector3 direction, final Vector3 up) { tmp.set(up).crs(direction).nor(); tmp2.set(direction).crs(tmp).nor(); rotation.setFromAxes(tmp.x, tmp2.x, direction.x, tmp.y, tmp2.y, direction.y, tmp.z, tmp2.z, direction.z); }
@Override public void update () { for (int i = 0, accelOffset = 0, c = i + controller.particles.size * rotationChannel.strideSize; i < c; i += rotationChannel.strideSize, accelOffset += accellerationChannel.strideSize) { Vector3 axisZ = TMP_V1.set(accellerationChannel.data[accelOffset + ParticleChannels.XOffset], accellerationChannel.data[accelOffset + ParticleChannels.YOffset], accellerationChannel.data[accelOffset + ParticleChannels.ZOffset]).nor(), axisY = TMP_V2.set(TMP_V1) .crs(Vector3.Y).nor().crs(TMP_V1).nor(), axisX = TMP_V3.set(axisY).crs(axisZ).nor(); TMP_Q.setFromAxes(false, axisX.x, axisY.x, axisZ.x, axisX.y, axisY.y, axisZ.y, axisX.z, axisY.z, axisZ.z); rotationChannel.data[i + ParticleChannels.XOffset] = TMP_Q.x; rotationChannel.data[i + ParticleChannels.YOffset] = TMP_Q.y; rotationChannel.data[i + ParticleChannels.ZOffset] = TMP_Q.z; rotationChannel.data[i + ParticleChannels.WOffset] = TMP_Q.w; } }