C# Class Axiom.SceneManagers.Bsp.BspSceneManager

Specialisation of the SceneManager class to deal with indoor scenes based on a BSP tree.
This class refines the behaviour of the default SceneManager to manage a scene whose bulk of geometry is made up of an indoor environment which is organised by a Binary Space Partition (BSP) tree.

A BSP tree progressively subdivides the space using planes which are the nodes of the tree. At some point we stop subdividing and everything in the remaining space is part of a 'leaf' which contains a number of polygons. Typically we traverse the tree to locate the leaf in which a point in space is (say the camera origin) and work from there. A second structure, the Potentially Visible Set, tells us which other leaves can been seen from this leaf, and we test their bounding boxes against the camera frustum to see which we need to draw. Leaves are also a good place to start for collision detection since they divide the level into discrete areas for testing.

This BSP and PVS technique has been made famous by engines such as Quake and Unreal. Ogre provides support for loading Quake3 level files to populate your world through this class, by calling the BspSceneManager.LoadWorldGeometry. Note that this interface is made available at the top level of the SceneManager class so you don't have to write your code specifically for this class - just call Root::getSceneManager passing a SceneType of ST_INDOOR and in the current implementation you will get a BspSceneManager silently disguised as a standard SceneManager.

Inheritance: Axiom.Core.SceneManager
Show file Open project: WolfgangSt/axiom Class Usage Examples

Protected Properties

Property Type Description
aaBGeometry Axiom.Graphics.RenderOperation
bspGeometry BspGeometry
faceGroupChecked bool>.Dictionary
level BspLevel
lightAddedToFrustum bool[]
matFaceGroupMap BspStaticFaceGroup>.Collections.MultiMap
objectsForRendering Axiom.Collections.MovableObjectCollection
renderOp Axiom.Graphics.RenderOperation
showNodeAABs bool
spotlightFrustum SpotlightFrustum
textureLightMaterial Axiom.Graphics.Material
textureLightPass Axiom.Graphics.Pass

Public Methods

Method Description
BspSceneManager ( string name ) : System
CreateIntersectionQuery ( uint mask ) : IntersectionSceneQuery

Creates an IntersectionSceneQuery for this scene manager.

This method creates a new instance of a query object for locating intersecting objects. See SceneQuery and IntersectionSceneQuery for full details.

CreateRayQuery ( Ray ray, uint mask ) : RaySceneQuery

Creates a RaySceneQuery for this scene manager.

This method creates a new instance of a query object for this scene manager, looking for objects which fall along a ray. See SceneQuery and RaySceneQuery for full details.

CreateSceneNode ( ) : SceneNode

Creates a specialized Plugin_BSPSceneManager.BspSceneNode.

CreateSceneNode ( string name ) : SceneNode

Creates a specialized Plugin_BSPSceneManager.BspSceneNode.

CreateSphereRegionQuery ( Sphere sphere, uint mask ) : SphereRegionSceneQuery

Creates a SphereSceneQuery for this scene manager.

This method creates a new instance of a query object for this scene manager, for a spherical region. See SceneQuery and SphereSceneQuery for full details.

EstimateWorldGeometry ( Stream stream, string typeName ) : int
EstimateWorldGeometry ( string filename ) : int
FindVisibleObjects ( Camera camera, bool onlyShadowCasters ) : void

Overriden from SceneManager.

GetSuggestedViewpoint ( bool random ) : ViewPoint

Specialised to suggest viewpoints.

LoadWorldGeometry ( ) : void
LoadWorldGeometry ( string filename ) : void

Specialized from SceneManager to support Quake3 bsp files.

SetWorldGeometry ( Stream stream, string typeName ) : void
SetWorldGeometry ( string filename ) : void

Protected Methods

Method Description
AddBoundingBox ( AxisAlignedBox aab, bool visible ) : void

Adds a bounding box to draw if turned on.

CacheGeometry ( IntPtr indexes, BspStaticFaceGroup faceGroup ) : int

Caches a face group for imminent rendering.

CacheLightGeometry ( TextureLight light, uint pIndexes, TextureLightMap pTexLightMaps, BspVertex pVertices, BspStaticFaceGroup faceGroup ) : int

Caches a face group and calculates texture lighting coordinates.

FindShadowCastersForLight ( Light light, Camera camera ) : IList
InitTextureLighting ( ) : void
OnRenderQueueEnded ( RenderQueueGroupID group, string invocation ) : bool
ProcessVisibleLeaf ( Axiom.SceneManagers.Bsp.BspNode leaf, Camera camera, bool onlyShadowCasters ) : void

Tags geometry in the leaf specified for later rendering.

RenderSingleObject ( IRenderable renderable, Pass pass, bool doLightIteration, LightList manualLightList ) : void

Overriden from SceneManager.

RenderStaticGeometry ( ) : void

Renders the static level geometry tagged in Plugin_BSPSceneManager.BspSceneManager.WalkTree.

RenderTextureLighting ( Light light ) : void

Renders the texture lighting tagged in the specified light

RenderTextureShadowOnGeometry ( ) : void

Renders texture shadow on tagged in level geometry.

WalkTree ( Camera camera, bool onlyShadowCasters ) : Axiom.SceneManagers.Bsp.BspNode

Walks the BSP tree looking for the node which the camera is in, and tags any geometry which is in a visible leaf for later processing.

Private Methods

Method Description
NotifyObjectDetached ( Axiom.Core.MovableObject obj ) : void

Internal method for notifying the level that an object has been detached from a node.

NotifyObjectMoved ( Axiom.Core.MovableObject obj, Vector3 pos ) : void

Internal method for tagging Plugin_BSPSceneManager.BspNode's with objects which intersect them.

Method Details

AddBoundingBox() protected method

Adds a bounding box to draw if turned on.
protected AddBoundingBox ( AxisAlignedBox aab, bool visible ) : void
aab Axiom.Math.AxisAlignedBox
visible bool
return void

BspSceneManager() public method

public BspSceneManager ( string name ) : System
name string
return System

CacheGeometry() protected method

Caches a face group for imminent rendering.
protected CacheGeometry ( IntPtr indexes, BspStaticFaceGroup faceGroup ) : int
indexes System.IntPtr
faceGroup BspStaticFaceGroup
return int

CacheLightGeometry() protected method

Caches a face group and calculates texture lighting coordinates.
protected CacheLightGeometry ( TextureLight light, uint pIndexes, TextureLightMap pTexLightMaps, BspVertex pVertices, BspStaticFaceGroup faceGroup ) : int
light TextureLight
pIndexes uint
pTexLightMaps TextureLightMap
pVertices BspVertex
faceGroup BspStaticFaceGroup
return int

CreateIntersectionQuery() public method

Creates an IntersectionSceneQuery for this scene manager.
This method creates a new instance of a query object for locating intersecting objects. See SceneQuery and IntersectionSceneQuery for full details.
public CreateIntersectionQuery ( uint mask ) : IntersectionSceneQuery
mask uint The query mask to apply to this query; can be used to filter out certain objects; see SceneQuery for details.
return Axiom.Core.IntersectionSceneQuery

CreateRayQuery() public method

Creates a RaySceneQuery for this scene manager.
This method creates a new instance of a query object for this scene manager, looking for objects which fall along a ray. See SceneQuery and RaySceneQuery for full details.
public CreateRayQuery ( Ray ray, uint mask ) : RaySceneQuery
ray Axiom.Math.Ray Details of the ray which describes the region for this query.
mask uint The query mask to apply to this query; can be used to filter out certain objects; see SceneQuery for details.
return Axiom.Core.RaySceneQuery

CreateSceneNode() public method

Creates a specialized Plugin_BSPSceneManager.BspSceneNode.
public CreateSceneNode ( ) : SceneNode
return Axiom.Core.SceneNode

CreateSceneNode() public method

Creates a specialized Plugin_BSPSceneManager.BspSceneNode.
public CreateSceneNode ( string name ) : SceneNode
name string
return Axiom.Core.SceneNode

CreateSphereRegionQuery() public method

Creates a SphereSceneQuery for this scene manager.
This method creates a new instance of a query object for this scene manager, for a spherical region. See SceneQuery and SphereSceneQuery for full details.
public CreateSphereRegionQuery ( Sphere sphere, uint mask ) : SphereRegionSceneQuery
sphere Axiom.Math.Sphere Details of the sphere which describes the region for this query.
mask uint The query mask to apply to this query; can be used to filter out certain objects; see SceneQuery for details.
return Axiom.Core.SphereRegionSceneQuery

EstimateWorldGeometry() public method

public EstimateWorldGeometry ( Stream stream, string typeName ) : int
stream Stream
typeName string
return int

EstimateWorldGeometry() public method

public EstimateWorldGeometry ( string filename ) : int
filename string
return int

FindShadowCastersForLight() protected method

protected FindShadowCastersForLight ( Light light, Camera camera ) : IList
light Axiom.Core.Light
camera Axiom.Core.Camera
return IList

FindVisibleObjects() public method

Overriden from SceneManager.
public FindVisibleObjects ( Camera camera, bool onlyShadowCasters ) : void
camera Axiom.Core.Camera
onlyShadowCasters bool
return void

GetSuggestedViewpoint() public method

Specialised to suggest viewpoints.
public GetSuggestedViewpoint ( bool random ) : ViewPoint
random bool
return Axiom.Core.ViewPoint

InitTextureLighting() protected method

protected InitTextureLighting ( ) : void
return void

LoadWorldGeometry() public method

public LoadWorldGeometry ( ) : void
return void

LoadWorldGeometry() public method

Specialized from SceneManager to support Quake3 bsp files.
public LoadWorldGeometry ( string filename ) : void
filename string
return void

OnRenderQueueEnded() protected method

protected OnRenderQueueEnded ( RenderQueueGroupID group, string invocation ) : bool
group RenderQueueGroupID
invocation string
return bool

ProcessVisibleLeaf() protected method

Tags geometry in the leaf specified for later rendering.
protected ProcessVisibleLeaf ( Axiom.SceneManagers.Bsp.BspNode leaf, Camera camera, bool onlyShadowCasters ) : void
leaf Axiom.SceneManagers.Bsp.BspNode
camera Axiom.Core.Camera
onlyShadowCasters bool
return void

RenderSingleObject() protected method

Overriden from SceneManager.
protected RenderSingleObject ( IRenderable renderable, Pass pass, bool doLightIteration, LightList manualLightList ) : void
renderable IRenderable
pass Axiom.Graphics.Pass
doLightIteration bool
manualLightList LightList
return void

RenderStaticGeometry() protected method

Renders the static level geometry tagged in Plugin_BSPSceneManager.BspSceneManager.WalkTree.
protected RenderStaticGeometry ( ) : void
return void

RenderTextureLighting() protected method

Renders the texture lighting tagged in the specified light
protected RenderTextureLighting ( Light light ) : void
light Axiom.Core.Light
return void

RenderTextureShadowOnGeometry() protected method

Renders texture shadow on tagged in level geometry.
protected RenderTextureShadowOnGeometry ( ) : void
return void

SetWorldGeometry() public method

public SetWorldGeometry ( Stream stream, string typeName ) : void
stream Stream
typeName string
return void

SetWorldGeometry() public method

public SetWorldGeometry ( string filename ) : void
filename string
return void

WalkTree() protected method

Walks the BSP tree looking for the node which the camera is in, and tags any geometry which is in a visible leaf for later processing.
protected WalkTree ( Camera camera, bool onlyShadowCasters ) : Axiom.SceneManagers.Bsp.BspNode
camera Axiom.Core.Camera
onlyShadowCasters bool
return Axiom.SceneManagers.Bsp.BspNode

Property Details

aaBGeometry protected property

protected RenderOperation,Axiom.Graphics aaBGeometry
return Axiom.Graphics.RenderOperation

bspGeometry protected property

protected BspGeometry,Axiom.SceneManagers.Bsp bspGeometry
return BspGeometry

faceGroupChecked protected property

protected Dictionary faceGroupChecked
return bool>.Dictionary

level protected property

protected BspLevel,Axiom.SceneManagers.Bsp level
return BspLevel

lightAddedToFrustum protected property

protected bool[] lightAddedToFrustum
return bool[]

matFaceGroupMap protected property

protected Collections.MultiMap matFaceGroupMap
return BspStaticFaceGroup>.Collections.MultiMap

objectsForRendering protected property

protected MovableObjectCollection,Axiom.Collections objectsForRendering
return Axiom.Collections.MovableObjectCollection

renderOp protected property

protected RenderOperation,Axiom.Graphics renderOp
return Axiom.Graphics.RenderOperation

showNodeAABs protected property

protected bool showNodeAABs
return bool

spotlightFrustum protected property

protected SpotlightFrustum,Axiom.SceneManagers.Bsp spotlightFrustum
return SpotlightFrustum

textureLightMaterial protected property

protected Material,Axiom.Graphics textureLightMaterial
return Axiom.Graphics.Material

textureLightPass protected property

protected Pass,Axiom.Graphics textureLightPass
return Axiom.Graphics.Pass