Exemplo n.º 1
0
 public BoundingBox getWorldBounds(Matrix4 o2w)
 {
     BoundingBox bounds = new BoundingBox();
     if (o2w == null)
     {
         for (int i = 0; i < points.Length; i += 3)
             bounds.include(points[i], points[i + 1], points[i + 2]);
     }
     else
     {
         // transform vertices first
         for (int i = 0; i < points.Length; i += 3)
         {
             float x = points[i];
             float y = points[i + 1];
             float z = points[i + 2];
             float wx = o2w.transformPX(x, y, z);
             float wy = o2w.transformPY(x, y, z);
             float wz = o2w.transformPZ(x, y, z);
             bounds.include(wx, wy, wz);
         }
     }
     return bounds;
 }
Exemplo n.º 2
0
 /**
  * Create a new ray by transforming the supplied one by the given matrix. If
  * the matrix is <code>null</code>, the original ray is returned.
  *
  * @param m matrix to transform the ray by
  */
 public Ray transform(Matrix4 m)
 {
     if (m == null)
         return this;
     Ray r = new Ray();
     r.ox = m.transformPX(ox, oy, oz);
     r.oy = m.transformPY(ox, oy, oz);
     r.oz = m.transformPZ(ox, oy, oz);
     r.dx = m.transformVX(dx, dy, dz);
     r.dy = m.transformVY(dx, dy, dz);
     r.dz = m.transformVZ(dx, dy, dz);
     r.tMin = tMin;
     r.tMax = tMax;
     return r;
 }
Exemplo n.º 3
0
 public BoundingBox getWorldBounds(Matrix4 o2w)
 {
     BoundingBox bounds = new BoundingBox();
     if (o2w == null)
     {
         for (int i = 0; i < triangleMesh.uvs.data.Length; i += 2)
             bounds.include(triangleMesh.uvs.data[i], triangleMesh.uvs.data[i + 1], 0);
     }
     else
     {
         // transform vertices first
         for (int i = 0; i < triangleMesh.uvs.data.Length; i += 2)
         {
             float x = triangleMesh.uvs.data[i];
             float y = triangleMesh.uvs.data[i + 1];
             float wx = o2w.transformPX(x, y, 0);
             float wy = o2w.transformPY(x, y, 0);
             float wz = o2w.transformPZ(x, y, 0);
             bounds.include(wx, wy, wz);
         }
     }
     return bounds;
 }
Exemplo n.º 4
0
 public BoundingBox getWorldBounds(Matrix4 o2w)
 {
     BoundingBox bounds = new BoundingBox();
     if (o2w == null)
     {
         for (int i = 0; i < patches.Length; i++)
         {
             float[] patch = patches[i];
             for (int j = 0; j < patch.Length; j += 3)
                 bounds.include(patch[j], patch[j + 1], patch[j + 2]);
         }
     }
     else
     {
         // transform vertices first
         for (int i = 0; i < patches.Length; i++)
         {
             float[] patch = patches[i];
             for (int j = 0; j < patch.Length; j += 3)
             {
                 float x = patch[j];
                 float y = patch[j + 1];
                 float z = patch[j + 2];
                 float wx = o2w.transformPX(x, y, z);
                 float wy = o2w.transformPY(x, y, z);
                 float wz = o2w.transformPZ(x, y, z);
                 bounds.include(wx, wy, wz);
             }
         }
     }
     return bounds;
 }