The following works fine, if you want to have some kind of first person view. Ie there's a camera x/y/z-position in the universe and the camera's alignment as three angles.
The rotation happens in angle degrees (0-360°), and in the order: Y, X, Z which is like Lightwave's Head, Pitch, Bend philosophy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| private Transform3D mTransform = new Transform3D(); private Transform3D mRotation = new Transform3D();
mView .. Canvas3d's View, connected to the Universe
private void moveCamera(Point3f position, Tuple3f angle) { mTransform.set(position);
mRotation.rotY((float) Math.toRadians(angle.y)); mTransform.mul(mRotation);
mRotation.rotX((float) Math.toRadians(angle.x)); mTransform.mul(mRotation);
mRotation.rotZ((float) Math.toRadians(angle.z)); mTransform.mul(mRotation);
mView.setTransform(mTransform); } |