BSP
(Binary Space Partitioning)

             Lee SangHoon
   Introduction

   BSP Generation

   PVS (Potential Visibility Sets)

   Generating Lightmap

   Collision detection

   Introduction of Fake III



Contents
   Fast collision detection

   What is not seen, is not drawn

   Lightning calculations of the map

   Can be used to optimize networking



Introduction
   GENERATE-BSP-TREE (Node, PolygonSet)
    ◦   1 if (IS-CONVEX-SET (PolygonSet))
    ◦   2 Tree ← BSPTreeNode (PolygonSet)
    ◦   3 Divider ← CHOOSE-DIVIDING-POLYGON (PolygonSet)
    ◦   4 PositiveSet ← {}
    ◦   5 NegativeSet ← {}
    ◦   6 for each polygon P1 in PolygonSet
    ◦   7 Value ← CALCULATE-SIDE (Divider, P1)
    ◦   8 if (Value = INFRONT)
    ◦   9             PositiveSet ← PositiveSet U P1
    ◦   10 else if (Value = BEHIND)
    ◦   11            NegativeSet ← NegativeSet U P1
    ◦   12 else if (Value = SPANNING)
    ◦   13            Split_Polygon (P1, Divider, Front, Back)
    ◦   14            PositiveSet ← PositiveSet U Front
    ◦   15            NegativeSet ← NegativeSet U Back
    ◦   16 GENERATE-BSP-TREE (Tree.RightChild, PositiveSet)
    ◦   17 GENERATE-BSP-TREE (Tree.LeftChild, NegativeSet)




BSP Generation
   Convex set




BSP Generation
   CHOOSE-DIVIDING-POLYGON




BSP Generation
   CHOOSE-DIVIDING-POLYGON

    ◦ Loop to find the polygon that best divides the
      set.
      Count the number of polygons on the positive side,
       negative side.
      Compare the results given by the current polygon
       to the best this far & set the new candidate.

    ◦ return BestPolygon



BSP Generation
BSP Generation
BSP Generation
BSP Generation
BSP Generation
Portal Rendering
◦ RENDER-PORTAL-ENGINE (Sector, ViewFrustum)
   for each polygon P1 in Sector
    ◦ if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum,
     P1))
      NewFrustum ← CLIP-FRUSTUM (ViewFrustum, P1)
      NewSector ← Get the sector that is connected with the
       current sector through portal P1
   ◦ RENDER-PORTAL-ENGINE (NewSector, NewFrustum)
   ◦ else if (P1 has not been drawn yet)
      draw




Portal Rendering
   Portal Rendering Problem
    ◦ Occurs calculation and clipping when drawing
      the scene


   Solution
    ◦ PVS (Potentially Visible Set)
      Calculation is done in the pre-rendering of the
       map




Portal Rendering
   Distribute sample points along the splitting planes in the
    tree




PVS
   RAY-INTERSECTS-SOMETHING-IN-TREE (Node, Ray)

   If the ray spans the splitting plane of this node or if the ray is
    coinciding with the plane, send it down to both children

   If the ray is only on the positive side of the splitting plane send
    the ray down the right child. The or in the if statement is because
    one of the points might be coinciding with the plane.

   If the ray is only on the positive side of the splitting plane send
    the ray down the right child. The or in the if statement is because
    one of the points might be coinciding with the plane.

   There was no intersection anywhere, pass that upwards




PVS
   CurrentCluster = FindCluster(vPosCamera);

   TurnAllFacesOff();
   for(int i=0; i<NumVisibleLeaves; i++)
   {
         for(int f = 0; f < m_pLeaves[i].NumFaces; f++)
           ◦ TurnFaceOn(pLeafFaces);
   }




PVS
Radiosity
Radiosity
   Radiosity using PVS

    ◦ RADIOSITY (Tree)
      for(each leaf L in Tree)
       ◦ for(each light S in L)
           for(each leaf V that is in L’s PVS)
            ◦ Send S’s energy to the patches in V




Radiosity
Collision detection
Fake III
Q/A & IDEA

Bsp

  • 1.
  • 2.
    Introduction  BSP Generation  PVS (Potential Visibility Sets)  Generating Lightmap  Collision detection  Introduction of Fake III Contents
  • 3.
    Fast collision detection  What is not seen, is not drawn  Lightning calculations of the map  Can be used to optimize networking Introduction
  • 4.
    GENERATE-BSP-TREE (Node, PolygonSet) ◦ 1 if (IS-CONVEX-SET (PolygonSet)) ◦ 2 Tree ← BSPTreeNode (PolygonSet) ◦ 3 Divider ← CHOOSE-DIVIDING-POLYGON (PolygonSet) ◦ 4 PositiveSet ← {} ◦ 5 NegativeSet ← {} ◦ 6 for each polygon P1 in PolygonSet ◦ 7 Value ← CALCULATE-SIDE (Divider, P1) ◦ 8 if (Value = INFRONT) ◦ 9 PositiveSet ← PositiveSet U P1 ◦ 10 else if (Value = BEHIND) ◦ 11 NegativeSet ← NegativeSet U P1 ◦ 12 else if (Value = SPANNING) ◦ 13 Split_Polygon (P1, Divider, Front, Back) ◦ 14 PositiveSet ← PositiveSet U Front ◦ 15 NegativeSet ← NegativeSet U Back ◦ 16 GENERATE-BSP-TREE (Tree.RightChild, PositiveSet) ◦ 17 GENERATE-BSP-TREE (Tree.LeftChild, NegativeSet) BSP Generation
  • 5.
    Convex set BSP Generation
  • 6.
    CHOOSE-DIVIDING-POLYGON BSP Generation
  • 7.
    CHOOSE-DIVIDING-POLYGON ◦ Loop to find the polygon that best divides the set.  Count the number of polygons on the positive side, negative side.  Compare the results given by the current polygon to the best this far & set the new candidate. ◦ return BestPolygon BSP Generation
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
    ◦ RENDER-PORTAL-ENGINE (Sector,ViewFrustum)  for each polygon P1 in Sector ◦ if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum, P1))  NewFrustum ← CLIP-FRUSTUM (ViewFrustum, P1)  NewSector ← Get the sector that is connected with the current sector through portal P1 ◦ RENDER-PORTAL-ENGINE (NewSector, NewFrustum) ◦ else if (P1 has not been drawn yet)  draw Portal Rendering
  • 14.
    Portal Rendering Problem ◦ Occurs calculation and clipping when drawing the scene  Solution ◦ PVS (Potentially Visible Set)  Calculation is done in the pre-rendering of the map Portal Rendering
  • 15.
    Distribute sample points along the splitting planes in the tree PVS
  • 16.
    RAY-INTERSECTS-SOMETHING-IN-TREE (Node, Ray)  If the ray spans the splitting plane of this node or if the ray is coinciding with the plane, send it down to both children  If the ray is only on the positive side of the splitting plane send the ray down the right child. The or in the if statement is because one of the points might be coinciding with the plane.  If the ray is only on the positive side of the splitting plane send the ray down the right child. The or in the if statement is because one of the points might be coinciding with the plane.  There was no intersection anywhere, pass that upwards PVS
  • 17.
    CurrentCluster = FindCluster(vPosCamera);   TurnAllFacesOff();  for(int i=0; i<NumVisibleLeaves; i++)  {  for(int f = 0; f < m_pLeaves[i].NumFaces; f++) ◦ TurnFaceOn(pLeafFaces);  } PVS
  • 18.
  • 19.
  • 20.
    Radiosity using PVS ◦ RADIOSITY (Tree)  for(each leaf L in Tree) ◦ for(each light S in L)  for(each leaf V that is in L’s PVS) ◦ Send S’s energy to the patches in V Radiosity
  • 21.
  • 22.
  • 23.