Ejemplo n.º 1
0
 public override BBox WorldBound()
 {
     BBox worldBounds = new BBox();
     for (int i = 0; i < nverts; i++)
         worldBounds = BBox.Union(worldBounds, p[i]);
     return worldBounds;
 }
Ejemplo n.º 2
0
 public override BBox ObjectBound()
 {
     BBox objectBounds = new BBox();
     for (int i = 0; i < nverts; i++)
         objectBounds = BBox.Union(objectBounds, (WorldToObject)[p[i]]);
     return objectBounds;
 }
Ejemplo n.º 3
0
 public void Union(BBox b2)
 {
     var min = new Point();
     min.X = MathHelper.Min(Min.X, b2.Min.X);
     min.Y = MathHelper.Min(Min.Y, b2.Min.Y);
     min.Z = MathHelper.Min(Min.Z, b2.Min.Z);
     Min = min;
     var max = new Point();
     max.X = MathHelper.Max(Max.X, b2.Max.X);
     max.Y = MathHelper.Max(Max.Y, b2.Max.Y);
     max.Z = MathHelper.Max(Max.Z, b2.Max.Z);
     Max = max;
 }
Ejemplo n.º 4
0
 public static BBox Union(BBox box, Point point)
 {
     BBox ret = box;
     var min = new Point();
     min.X = MathHelper.Min(box.Min.X, point.X);
     min.Y = MathHelper.Min(box.Min.Y, point.Y);
     min.Z = MathHelper.Min(box.Min.Z, point.Z);
     ret.Min = min;
     var max = new Point();
     max.X = MathHelper.Max(box.Max.X, point.X);
     max.Y = MathHelper.Max(box.Max.Y, point.Y);
     max.Z = MathHelper.Max(box.Max.Z, point.Z);
     ret.Max = max;
     return ret;
 }
Ejemplo n.º 5
0
 public BBox MotionBounds(BBox b, bool useInverse)
 {
     if (!actuallyAnimated) return Transform.Inverse(startTransform)[b];
     BBox ret = new BBox();
     int nSteps = 128;
     for (int i = 0; i < nSteps; ++i)
     {
         Transform t = new Transform();
         float time = MathHelper.Lerp(((float)i) / ((float)nSteps - 1), startTime, endTime);
         Interpolate(time, t);
         if (useInverse) t = Transform.Inverse(t);
         ret = BBox.Union(ret, t[b]);
     }
     return ret;
 }
Ejemplo n.º 6
0
 public BBox this[BBox b]
 {
     get
     {
         Transform M = this;
         BBox ret = new BBox(M[new Point(b.Min.X, b.Min.Y, b.Min.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Max.X, b.Min.Y, b.Min.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Min.X, b.Max.Y, b.Min.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Min.X, b.Min.Y, b.Max.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Min.X, b.Max.Y, b.Max.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Max.X, b.Max.Y, b.Min.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Max.X, b.Min.Y, b.Max.Z)]);
         ret = BBox.Union(ret, M[new Point(b.Max.X, b.Max.Y, b.Max.Z)]);
         return ret;
     }
 }
Ejemplo n.º 7
0
 public bool Overlaps(BBox b)
 {
     bool x = (Max.X >= b.Min.X) && (Min.X <= b.Max.X);
     bool y = (Max.Y >= b.Min.Y) && (Min.Y <= b.Max.Y);
     bool z = (Max.Z >= b.Min.Z) && (Min.Z <= b.Max.Z);
     return (x && y && z);
 }
Ejemplo n.º 8
0
 public static BBox Union(BBox b1, BBox b2)
 {
     b1.Union(b2);
     return b1;
 }