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); } }
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); }
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); }
public int Compare(GeometryObject a, GeometryObject b) { aabb box_left = null, box_right = null; if (!a.bounding_box(0, 0, out box_left) || !b.bounding_box(0, 0, out box_right)) { Console.WriteLine("no bounding box!"); } if (box_left.Min.Z - box_right.Min.Z < 0) { return(-1); } else { return(1); } }
public override bool bounding_box(double t0, double t1, out aabb box) { box = new aabb(new Point3D(x0, k - 1e-4, z0), new Point3D(x1, k + 1e-4, z1)); return(true); }
public override bool bounding_box(double t0, double t1, out aabb box) { bool rhs = obj.bounding_box(t0, t1, out box); return(rhs); }
public override bool bounding_box(double t0, double t1, out aabb box) { box = _box; return(true); }
public override bool bounding_box(double t0, double t1, out aabb box) { return(boundary.bounding_box(t0, t1, out box)); }
public override bool bounding_box(double t0, double t1, out aabb box) { box = new aabb(pmin, pmax); return(true); }
public override bool bounding_box(double t0, double t1, out aabb box) { box = new aabb(new Point3D(0, 0, 0), new Point3D(1, 1, 1)); return(true); }
public override bool bounding_box(double t0, double t1, out aabb box) { box = new aabb(bbox.Min, bbox.Max); return(hasBox); }
public override bool bounding_box(double t0, double t1, out aabb box) { box = bbox; return(hasBox); }