1 / 47

BSP Trees

BSP Trees. Binary space partitioning trees. Used to store a collection of objects in n-dimensional space. Tree recursively divides n-dimensional space using (n-1)-dimensional hyperplanes. Space Partitioning. d-dimensional space. splitting hyperplane (d-1)-dimensional

tedk
Download Presentation

BSP Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BSP Trees • Binary space partitioning trees. • Used to store a collection of objects in n-dimensional space. • Tree recursively divides n-dimensional space using (n-1)-dimensional hyperplanes.

  2. Space Partitioning d-dimensional space splitting hyperplane (d-1)-dimensional a1x1 + a2x2 + … adxd + ad+1 = 0 ax + by + c = 0 (2D) ax+by+cz+d = 0 (3D)

  3. Space Partitioning +ve half space ax + by + c > 0 ax+by+cz+d > 0 d-dimensional space coincident ax + by + c = 0 ax+by+cz+d = 0 -ve half space ax + by + c < 0 ax+by+cz+d < 0

  4. Space Partitioning d-dimensional space coincident list +ve -ve +ve -ve

  5. Objects in 2D a g e b h c f d

  6. Objects in 2D a g e b h c f d

  7. Objects in 2D a g a-d e-h e b h c f d

  8. Objects in 2D a g a-d e-h e b h c f d

  9. c-d e-f g-h a-b Objects in 2D a g e b h c f d

  10. Objects in 2D a g e b h c f a b c d g h f d e

  11. Collision Detection a g e b h c f a b c d g h f d e

  12. Visibility Ordering a g e b h c f a b c d g h f d e

  13. BSP Tree Construction • Select partitioning hyperplanes. • Partition objects. • Repeat on partitions.

  14. Partitioning Hyperplane Selection • Face of an object. a g e b h c f d

  15. Partitioning Hyperplane Selection • Face of an object. a g e b h c f d

  16. Autopartition • Only object faces are used as splitting hyperplanes a g e b h c f d

  17. Partitioning Hyperplane Selection • Axis-aligned orthogonal hyperplanes a g e b h c f d

  18. Partitioning Hyperplane Selection • Axis-aligned orthogonal hyperplanes a g e b h c f d

  19. Partitioning Hyperplane Selection • Balance # objects (pieces) on each side of hyperplane • Minimize increase in number of objects/pieces. a g e b h c f d

  20. 3D Example

  21. 3D Example

  22. 3D Example

  23. 3D Example

  24. Another 3D Example

  25. Another 3D Example

  26. a a BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left.

  27. a b a b BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left.

  28. a c a b BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left. b c

  29. a c a d b BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left. b c d

  30. a c e a d b BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left. b e c d

  31. a c e f a d b BSP Tree of an Object • Each leaf represents a region that is either wholly inside or outside the object. • Object surface is considered inside object. • Surface planes are used as partitioning planes. • Orient partitioning hyperplanes so that interior is to left. b e c d f

  32. a c e f a d b BSP Tree of an Object • Orient partitioning hyperplanes so that interior is to left. • With this orientation, left leaves are interior and right leaves are exterior. b e c d f

  33. BSP Tree Construction • Node structure: • ph = equation of partitioning hyperplane • cList = list of objects coincident with ph • leftChild • rightChild

  34. BSP Tree Construction BSPtree(O) // O is object set if O is empty, return null; Create a new node N; N.ph = partitioning hyperplane for O; lList = rList = N.cList = null; for each object z in O do if z is coincident to ph, add z to N.cList; if z is left of ph, add z to lList; if z is right of ph, add z to rList; if z spans ph, split z and add pieces to lList and rList; N.leftChild = BSPTree(lList); N.rightChild = BSPTree(rList); return N;

  35. Classifying Object z • In 2D, ph is the line ax + by + c = 0. • Compute ax + by + c for all vertices of z. • If all values are < 0; z is left of ph. • If all values are > 0; z is right of ph. • If all values are = 0; z is coincident to ph. • Otherwise, z spans ph and is to be split by finding intersection points with ph.

  36. 2D a g e b h c f d Equation of ph is x – 6 = 0 6

  37. 2D a g e b h c f 2 d Equation of ph is y –x –2 = 0

  38. 3D Equation of ph is z –2 = 0 General: ax + by + cz + d = 0 y z x

  39. Basic Draw Back to Front draw(N) if eye left of N.ph {draw(N.rightChild); draw N.cList; draw(N.leftChild)}; else if eye right of N.ph {draw(N.leftChild); draw N.cList; draw(N.rightChild)}; else // eye coincident to N.ph {draw(N.leftChild); draw(N.rightChild)};

  40. Basic Draw Front to Back draw(N) if eye left of N.ph {draw(N.leftChild); draw N.cList; draw(N.reightChild)}; else if eye right of N.ph {draw(N.rightChild); draw N.cList; draw(N.leftChild)}; else // eye coincident to N.ph {draw(N.rightChild); draw(N.leftChild)};

  41. Randomization • Autopartition. • Splitting hyperplane is randomly selected to be one of the object faces. • Lines in 2D; planes in 3D. a g e b h

  42. Randomization—2D Analysis • Start with n (nonintersecting) line segments. • Total number of line segments in autopartition bsp is expected to be <= n + 2n ln n. • If this bound is exceeded; rerun construction. • Expected number of construction rounds before this bound is not exceeded is 2. 8 8 n = 29 4 3 6

  43. Randomization —2D Analysis • So, number of nodes in bsp is O(n log n). • Construction time at each node is O(n) as at each node O(n) segments need to be partitioned. • Time is O(n2log n) per construction round. • 2 rounds expected. • Expected complexity is O(n2log n). 8 8 n = 29 4 3 6

  44. Randomization—3D Analysis • Start with n (nonintersecting) triangles. • Total number of triangles in autopartition bsp using a weaker variant is O(n2). • There exist n-triangle examples for which every autopartition has W(n2) triangle. n = 24

  45. Free Partitions • One that does not split an object. • Do a free partition whenever possible; otherwise, randomly select a segment/face as partitioning hyperplane. 8 8 4 3 6

  46. Free Partitions • A segment, both of whose end points lie on previously used split lines, results in a free partition. Portion of black segment bounded by red (previous) splitting lines may be used to partition blue region. No segments in blue region can be split as line segments are non-intersecting.

  47. Free Partitions • A segment, both of whose end points lie on previously used split lines, results in a free partition. When green segment is used to partition blue region, segments in blue region may be split.

More Related