CS-184: Computer Graphics Lecture #7: BSP and AABB Trees Prof. James O’Brien University of California, Berkeley V2011-F-07-1.0 Announcements Assignment 4: due October 10 by 11pm 2
BSP-Trees • Binary Space Partition Trees • Split space along planes • Allows fast queries of some spatial relations • Simple construction algorithm • Select a plane as sub-tree root • Everything on one side to one child • Everything on the other side to other child • Use random polygon for splitting plane 3 BSP-Trees a,b,c,d,e,f,g e a d f b g c 4
BSP-Trees a e a b,c 1 ,d c 2 ,e,f,g d f c 2 b g c 1 5 BSP-Trees a e a b c 2 ,e,f,g d f c 1 d c 2 b g c 1 6
BSP-Trees a e 1 e 2 a b c 2 d f e 1 ,f c 1 d e 2 ,g c 2 b g c 1 7 BSP-Trees a e 1 e 2 a b c 2 d f c 1 d e 1 e 2 ,g c 2 b f g c 1 8
BSP-Trees a + - e 1 e 2 a + + b c 2 d f + - + - c 1 d e 1 e 2 + c 2 b + + + f g g c 1 9 BSP-Trees • Visibility Traversal • Variation of in-order-traversal • Child one • Sub-tree root • Child two • Select “child one” based on location of viewpoint • Child one on same side of sub-tree root as viewpoint 10
BSP-Trees a e 1 e 2 a b c 2 d f c 1 d e 1 e 2 c 2 b f g g c 1 c 1 :b:d:a:f:e 1 :c 2 :g:e 2 11 BSP-Trees a e 1 e 2 a b c 2 d f c 1 d e 1 e 2 c 2 b f g g c 1 g:e 2 :c 2 :f:e 1 :a:c 1 :b:d 12
Bounding Shapes • Bounding shape completely encloses associated object • Rays cannot hit object w/o intersecting bounding shape • Two objects cannot collide if shapes don’t overlap • Simplicity -vs- tightness 13 Axis-Aligned Bounding Boxes Max x,y,z Min x,y,z • Axis-aligned bounding box defined by min and max x,y,z 14
Axis-Aligned Bounding Boxes Transform box Min/max of new points Not axis-aligned Linear cost to compute 15 Axis-Aligned Bounding Boxes Min/max of transformed BB points Constant time Adds slop Cumulative slop if multiple transforms occur sequentially Why would we do this? 16
AABB Trees One of many variations Robot L.Arm Torso R.Arm Head L.Leg R.Leg Head Mouth L.Eye R.Eye Shape Leg Leg Group node L.Foot RFoot Shape Shape Geometry node Transformation stored at all nodes 17 AABB Trees One of many variations Robot Torso L.Arm Head R.Arm R.Leg L.Leg Head Mouth L.Eye R.Eye Shape Geometry node Leg Leg L.Foot RFoot Shape Shape Head Shape Scale 2x Geometry B.Box Transformation XF B.Box 18
AABB Trees One of many variations Robot Torso L.Arm Head R.Arm R.Leg L.Leg Head Mouth L.Eye R.Eye Shape Group node Leg Leg L.Foot RFoot Shape Shape Head Rot -25 Children Union B.Box Transformation XF B.Box XF B.Box 19 AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape Local Bounding Boxes 20
AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape Transformed Bounding Boxes 21 AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 22
AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 23 AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 24
AABB Trees One of many variations Robot Torso L.Arm R.Arm Head L.Leg R . L e g Head Mouth L.Eye R.Eye Shape Leg Leg L.Foot RFoot Shape Shape 25 Ray Test Against Bound Tree • RayHitSubTree(&ray,node) • If RayHitsBB(ray,node.xfBB) • ixfRay = Inverse(node.xf)*ray • If RayHitsBB(ixfRay,node.BB) • If node is group • Foreach child in node.children • RayHitSubTree(ixfRay,child) • else // node not group • RayHitGeometry(ixfRay,node.geom) • ray.collisionInfo.update(ixfRay) 26
Recommend
More recommend