Bsp

Post on 22-Nov-2014

748 views 2 download

Tags:

description

 

transcript

BSP (Binary Space Partitioning)

Lee SangHoon

Contents

Introduction

BSP Generation

PVS (Potential Visibility Sets)

Generating Lightmap

Collision detection

Introduction of Fake III

Introduction

Fast collision detection

What is not seen, is not drawn

Lightning calculations of the map

Can be used to optimize networking

BSP Generation

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

Portal Rendering

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

PVS

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);

}

Radiosity

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

Collision detection

Fake III

Q/A & IDEA