Title: Ray Tracing Simulation 2
1Ray Tracing Simulation (2)
2COMPOUND OBJECTBOOLEAN OPERATIONS ON OBJECTS
- Constructive solid geometry(CSG)
- Boolean operators
- Union
- Intersection
- difference
3Ray Tracing CSG Objects
4Data Structure for Boolean Objects
class Boolean public GeomObj public GeomObj
left, right Boolean()left(NULL),right(NULL)
virtual bool hit(Ray r, Intersection
inter)return false virtual void
makeExtentPoints(PointCluster clust) virtual
void drawOpenGL() // just draw its
children if(left)left-gtdrawOpenGL() if(right)
right-gtdrawOpenGL()
5Intersecting Rays with Boolean Object
- Union? logical operators
- combInside lftInside rtInside
- Intersection? logical operators
- combInside lftInside rtInside
- Difference? logical operators
- combInside lftInside !rtInside
6Building and Using Extents for CSG Object
- During a preprocessing step, the tree for the CSG
object is scanned and extents are built for each
node and stored within the node itself. - Making Box Extents
- Union
- Intersection
- Difference
Cuboid UnionBool makeBoxExtent() Cuboid lft
left -gt makeBoxExtent() Cuboid rt right -gt
makeBoxExtent() Cuboid tmp tmp.left
min(lft.left, rt.left) //form the
union tmp.top max(lft.top, rt.top) //etc.
for the other four values worldBoxExtent tmp
//store it in the object return tmp
7Cuboid UnionBool makeBoxExtent() Cuboid lft
left -gt makeBoxExtent() Cuboid rt right -gt
makeBoxExtent() Cuboid tmp tmp.left
min(lft.left, rt.left) //form the
union tmp.top max(lft.top, rt.top) //etc.
for the other four values worldBoxExtent tmp
//store it in the object return tmp