Exemplo n.º 1
0
 // create a look-at rotation matrix
 public void LookAt(Vector3d dir, Vector3d up)
 {
     //Vector3d dir = new Vector3d(direction.x, direction.y, direction.z);
     //dir.Normalize();
     Vector3d vx = up.Cross(dir);
     vx.Normalize();
     Vector3d vy = dir.Cross(vx);
     vy.Normalize();
     Matrix[0, 0] = vx.x;  Matrix[0, 1] = vx.y;  Matrix[0, 2] = vx.z;  Matrix[0, 3] = 0;
     Matrix[1, 0] = vy.x;  Matrix[1, 1] = vy.y;  Matrix[1, 2] = vy.z;  Matrix[1, 3] = 0;
     Matrix[2, 0] = dir.x; Matrix[2, 1] = dir.y; Matrix[2, 2] = dir.z; Matrix[2, 3] = 0;
     Matrix[3, 0] = 0;     Matrix[3, 1] = 0;     Matrix[3, 2] = 0;     Matrix[3, 3] = 1;
 }