javax.vecmath.Quat4f Java Examples
The following examples show how to use
javax.vecmath.Quat4f.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VMDMotion.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public final void readFromStream(DataInputStreamLittleEndian is) throws IOException { boneName = is.readString(15); boneIndex = -1; // for(int i=0;i<vmdFile.boneNames.size();i++) { // if (boneName.equals(vmdFile.boneNames.get(i))) { // boneIndex = (short)i; // break; // } // } boneIndex = (short)vmdFile.boneNames.indexOf(boneName); if (boneIndex < 0) { vmdFile.boneNames.add(boneName); // boneIndex = (short)(vmdFile.boneNames.size() - 1); boneIndex = (short)vmdFile.boneNames.indexOf(boneName); } frameNo = is.readInt(); location = new Point3f(); location.x = is.readFloat(); location.y = is.readFloat(); location.z = -is.readFloat(); rotation = new Quat4f(is.readFloat(), is.readFloat(), -is.readFloat(), -is.readFloat()); int pos = 0; while(pos < 64) { pos += is.read(interpolation, pos, 64 - pos); } }
Example #2
Source File: OrientationInfoGenerator.java From OpenModsLib with MIT License | 5 votes |
private static Multimap<Orientation, XYZRotation> calculateXyzRotations(Map<Matrix3f, Orientation> fromMatrix) { final Multimap<Orientation, XYZRotation> toXYZRotation = HashMultimap.create(); for (Rotation x : Rotation.values()) for (Rotation y : Rotation.values()) for (Rotation z : Rotation.values()) { final XYZRotation rotation = new XYZRotation(x, y, z); Quat4f q = new Quat4f(0, 0, 0, 1); Quat4f tmp = new Quat4f(); tmp.set(new AxisAngle4f(0, 0, 1, z.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(0, 1, 0, y.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(1, 0, 0, x.angle)); q.mul(tmp); Matrix3f m = new Matrix3f(); m.set(q); roundMatrixElements(m); final Orientation orientation = fromMatrix.get(m); Preconditions.checkNotNull(orientation, rotation); toXYZRotation.put(orientation, rotation); } return toXYZRotation; }
Example #3
Source File: BufferUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static Quat4f readQuat4f(ByteBuffer bb, Quat4f q) { q.x = bb.getFloat(); q.y = bb.getFloat(); q.z = bb.getFloat(); q.w = bb.getFloat(); return q; }
Example #4
Source File: Jbullet.java From BowlerStudio with GNU General Public License v3.0 | 4 votes |
public static void main(String[] args) { BroadphaseInterface broadphase = new DbvtBroadphase(); DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration(); CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration); SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver(); DiscreteDynamicsWorld dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); // set the gravity of our world dynamicsWorld.setGravity(new Vector3f(0, -10, 0)); // setup our collision shapes CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 1); CollisionShape fallShape = new SphereShape(1); // setup the motion state DefaultMotionState groundMotionState = new DefaultMotionState( new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f))); RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0)); RigidBody groundRigidBody = new RigidBody(groundRigidBodyCI); dynamicsWorld.addRigidBody(groundRigidBody); // add our ground to the // dynamic world.. // setup the motion state for the ball DefaultMotionState fallMotionState = new DefaultMotionState( new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, 100, 0), 1.0f))); // This we're going to give mass so it responds to gravity int mass = 1; Vector3f fallInertia = new Vector3f(0, 0, 0); fallShape.calculateLocalInertia(mass, fallInertia); RigidBodyConstructionInfo fallRigidBodyCI = new RigidBodyConstructionInfo(mass, fallMotionState, fallShape, fallInertia); RigidBody fallRigidBody = new RigidBody(fallRigidBodyCI); // now we add it to our physics simulation dynamicsWorld.addRigidBody(fallRigidBody); for (int i = 0; i < 300; i++) { dynamicsWorld.stepSimulation(1 / 60.f, 10); Transform trans = new Transform(); fallRigidBody.getMotionState().getWorldTransform(trans); System.out.println("sphere height: " + trans.origin.y); } }
Example #5
Source File: BufferUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public static void writeQuat4f(ByteBuffer bb, Quat4f q) { bb.putFloat(q.x); bb.putFloat(q.y); bb.putFloat(q.z); bb.putFloat(q.w); }
Example #6
Source File: VMDMotion.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public VMDMotion() { location = new Point3f(); rotation = new Quat4f(); }
Example #7
Source File: VMDMotion.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public Quat4f getRotation() { return rotation; }
Example #8
Source File: VMDMotion.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setRotation(Quat4f rotation) { this.rotation = rotation; }