Exemplo n.º 1
0
 public override bool bounding_box(double t0, double t1, out aabb box)
 {
     if (ptr.bounding_box(t0, t1, out box))
     {
         box = new aabb(box.Min + offset, box.Max + offset);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public RotateZ(GeometryObject p, double angle)
        {
            ptr = p;
            double radians = (Math.PI / 180.0) * angle;

            sinTheta = Math.Sin(radians);
            cosTheta = Math.Cos(radians);
            hasBox   = ptr.bounding_box(0, 1, out bbox);
            Point3D min = new Point3D(1e30, 1e30, 1e30);
            Point3D max = new Point3D(-1e30, -1e30, -1e30);

            for (int i = 0; i < 2; ++i)
            {
                for (int j = 0; j < 2; ++j)
                {
                    for (int k = 0; k < 2; ++k)
                    {
                        double  x     = i * bbox.Max.X + (1 - i) * bbox.Min.X;
                        double  y     = j * bbox.Max.Y + (1 - j) * bbox.Min.Y;
                        double  z     = k * bbox.Max.Z + (1 - k) * bbox.Min.Z;
                        double  newX  = cosTheta * x + sinTheta * y;
                        double  newY  = -sinTheta * x + cosTheta * y;
                        Point3D tster = new Point3D(newX, newY, z);
                        if (tster.X > max.X)
                        {
                            max.X = tster.X;
                        }
                        if (tster.X < min.X)
                        {
                            min.X = tster.X;
                        }
                        if (tster.Y > max.Y)
                        {
                            max.Y = tster.Y;
                        }
                        if (tster.Y < min.Y)
                        {
                            min.Y = tster.Y;
                        }
                        if (tster.Z > max.Z)
                        {
                            max.Z = tster.Z;
                        }
                        if (tster.Z < min.Z)
                        {
                            min.Z = tster.Z;
                        }
                    }
                }
            }
            bbox = new aabb(min, max);
        }
Exemplo n.º 3
0
        public bvh_node(List <GeometryObject> l)
        {
            int axis = (int)(3 * Form2.random());

            if (axis == 0)
            {
                l.Sort(new Cmp_x().Compare);
            }
            else if (axis == 1)
            {
                l.Sort(new Cmp_y().Compare);
            }
            else
            {
                l.Sort(new Cmp_z().Compare);
            }

            int n = l.Count();

            if (n == 1)
            {
                left = right = l[0];
            }
            else if (n == 2)
            {
                left  = l[0];
                right = l[1];
            }
            else
            {
                List <GeometryObject> left_l = new List <GeometryObject>(), right_l = new List <GeometryObject>();
                for (int i = 0; i < n / 2; ++i)
                {
                    left_l.Add(l[i]);
                }
                for (int i = n / 2; i < n; ++i)
                {
                    right_l.Add(l[i]);
                }
                left  = new bvh_node(left_l);
                right = new bvh_node(right_l);
            }

            aabb box_left = null, box_right = null;

            if (!left.bounding_box(0, 1, out box_left) || !right.bounding_box(0, 1, out box_right))
            {
                Console.WriteLine("no bounding box!");
            }
            _box = aabb.surrounding_box(box_left, box_right);
        }
Exemplo n.º 4
0
        public override bool bounding_box(double t0, double t1, out aabb box)
        {
            bool rhs = obj.bounding_box(t0, t1, out box);

            return(rhs);
        }
Exemplo n.º 5
0
 public override bool bounding_box(double t0, double t1, out aabb box)
 {
     return(boundary.bounding_box(t0, t1, out box));
 }