using System; //Bounding volume, do not set transforms in any way! //The values are returned directly, so the inverse must //be stored directly with the object. public class BoundingVolume:Primitive { public Primitive bv; public Primitive obj; public BoundingVolume() { } public BoundingVolume(Primitive bv, Primitive obj) { this.bv=bv; this.obj=obj; } //prevent (partially) setting of transforms public override void Translate(double x, double y, double z) { throw new Exception("Transforms not supported on BV!"); } public override void Rotate(double theta, double x, double y, double z) { throw new Exception("Transforms not supported on BV!"); } public override void Scale(double x, double y, double z) { throw new Exception("Transforms not supported on BV!"); } public override void Scale(double s) { throw new Exception("Transforms not supported on BV!"); } public override IntersectInfo intersect(Vector o, Vector dir) { Vector to; Vector td; IntersectInfo info; to=bv.W*o; td=bv.W*dir; info=bv.intersect(to, td); if (info!=null) { to=obj.W*o; td=obj.W*dir; info=obj.intersect(to, td); } return info; } public override object Clone() { object o=new BoundingVolume(bv, obj); return o; } public override BBox getExtent() { return bv.getExtent(); } public override BBox getLocalExtent() { return bv.getLocalExtent(); } public override string ToString() { return "Primitive::BoundingVolume()";} }