Example #1
0
 /** A view matrix defined by an eye and target position (same as gluLookAt) */
 public static Mat4f lookAt(
     float eyeX,
     float eyeY,
     float eyeZ,
     float centerX,
     float centerY,
     float centerZ,
     float upX,
     float upY,
     float upZ) {
   Vec3f f = new Vec3f(centerX - eyeX, centerY - eyeY, centerZ - eyeZ).normalize();
   Vec3f up = new Vec3f(upX, upY, upZ).normalize();
   Vec3f s = f.cross(up).normalize();
   Vec3f u = s.cross(f).normalize();
   Mat4f m1 =
       new Mat4f(
           new float[] {s.x, u.x, -f.x, 0, s.y, u.y, -f.y, 0, s.z, u.z, -f.z, 0, 0, 0, 0, 1});
   Mat4f m2 = translation(-eyeX, -eyeY, -eyeZ);
   return m1.times(m2);
 }
 public void setTransform(Mat4f xform) {
   Mat4f totalXform = xform.mul(offsetTransform);
   for (int i = 0; i < getNumChildren(); i++) {
     getChild(i).setTransform(totalXform);
   }
 }
 public ManipPartTransform() {
   super();
   offsetTransform = new Mat4f();
   offsetTransform.makeIdent();
 }
Example #4
0
 public void push(State state) {
   ModelMatrixElement prev = (ModelMatrixElement) getNextInStack();
   if (prev != null) {
     matrix.set(prev.matrix);
   }
 }
Example #5
0
 public ModelMatrixElement() {
   matrix = new Mat4f();
   matrix.makeIdent();
 }
Example #6
0
 /** Multiplies this element by the given matrix. */
 public void multElt(Mat4f matrix) {
   temp.set(this.matrix);
   this.matrix.mul(temp, matrix);
 }
Example #7
0
 /** Sets this element to the identity matrix. */
 public void makeEltIdent() {
   matrix.makeIdent();
 }