The class represents a BSP Tree node, implementing the Composite design pattern. More...
#include "BspTreeNode.hpp"
Classes | |
struct | LeafT |
struct | NodeT |
Public Member Functions | |
BspTreeNodeT (float LightMapPatchSize, float SHLMapPatchSize) | |
The constructor. More... | |
~BspTreeNodeT () | |
The destructor. More... | |
float | GetLightMapPatchSize () const |
float | GetSHLMapPatchSize () const |
void | InitDrawing () |
double | ClipLine (const VectorT &P, const VectorT &U, double Min, double Max, unsigned long NodeNr=0, bool NodeIsLeaf=false) const |
Clips the line segment defined by P+U*Min and P+U*Max against the map and returns a value Hit such that P+U*Hit yields the point where the line segment intersects the BSP tree, with Min<=Hit<=Max. More... | |
void | WriteTo (std::ostream &OutFile, aux::PoolT &Pool) const |
const BoundingBox3T< double > & | GetBoundingBox () const |
Returns the bounding box of the contents of this scene node. More... | |
bool | IsOpaque () const |
TODO / FIXME: This method is a hot-fix for getting the render order with translucent Bezier Patches right. More... | |
void | DrawAmbientContrib (const Vector3dT &ViewerPos) const |
Draws the contents of this scene node. More... | |
void | DrawStencilShadowVolumes (const Vector3dT &LightPos, const float LightRadius) const |
void | DrawLightSourceContrib (const Vector3dT &ViewerPos, const Vector3dT &LightPos) const |
void | DrawTranslucentContrib (const Vector3dT &ViewerPos) const |
unsigned long | WhatLeaf (const VectorT &Position) const |
In what leaf is 'Position' located? This function MUST NOT BE CALLED ON AN EMPTY MAP! More... | |
void | WhatLeaves (ArrayT< unsigned long > &ResultLeaves, const BoundingBox3T< double > &BoundingBox, unsigned long NodeNr=0) const |
In what leaves is 'BoundingBox' located? This function MUST NOT BE CALLED ON AN EMPTY MAP! The result will be APPENDED to the contents of the array 'ResultLeaves'. More... | |
void | GetLeavesOrderedBackToFront (ArrayT< unsigned long > &OrderedFaces, const VectorT &Origin) const |
This function traverses the BSP tree back-to-front, and stores the index numbers of the leaves it encounters in OrderedLeaves. More... | |
bool | IsInPVS (const unsigned long QueryLeafNr, unsigned long LeafNr) const |
Returns 'true' if leaf 'QueryLeafNr' is in the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map. More... | |
bool | IsInPVS (const VectorT &Position, unsigned long LeafNr) const |
Returns 'true' if 'Position' is in the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map. More... | |
bool | IsInPVS (const BoundingBox3T< double > &BoundingBox, unsigned long LeafNr) const |
Returns 'true' if 'BoundingBox' is in or touches the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map. More... | |
BspTreeNodeT (const BspTreeNodeT &) | |
Use of the Copy Constructor is not allowed. More... | |
void | operator= (const BspTreeNodeT &) |
Use of the Assignment Operator is not allowed. More... | |
Public Member Functions inherited from cf::SceneGraph::GenericNodeT | |
virtual | ~GenericNodeT () |
The virtual destructor, so that derived classes can safely be deleted via a GenericNodeT (base class) pointer. More... | |
virtual void | InitDefaultLightMaps (const float LightMapPatchSize) |
If this NodeT uses lightmaps, this methods initializes default (full-bright) lightmaps for it at the proper size. More... | |
virtual void | CreatePatchMeshes (ArrayT< PatchMeshT > &PatchMeshes, ArrayT< ArrayT< ArrayT< Vector3dT > > > &SampleCoords, const float LightMapPatchSize) const |
Creates the patch meshes for this NodeT for the purpose of radiosity computations (CaLight). More... | |
virtual void | BackToLightMap (const PatchMeshT &PatchMesh, const float LightMapPatchSize) |
Takes the patches of the given patch mesh back into the lightmap of this node. More... | |
Static Public Member Functions | |
static BspTreeNodeT * | CreateFromFile_cw (std::istream &InFile, aux::PoolT &Pool, LightMapManT &LMM, SHLMapManT &SMM, PlantDescrManT &PDM, const ArrayT< const TerrainT * > &ShTe, ModelManagerT &ModelMan) |
Named constructor. More... | |
Static Public Member Functions inherited from cf::SceneGraph::GenericNodeT | |
static GenericNodeT * | CreateFromFile_cw (std::istream &InFile, aux::PoolT &Pool, LightMapManT &LMM, SHLMapManT &SMM, PlantDescrManT &PDM, const ArrayT< const TerrainT * > &ShTe, ModelManagerT &ModelMan) |
Reads a GenericNodeT from InFile. More... | |
Public Attributes | |
ArrayT< NodeT > | Nodes |
ArrayT< LeafT > | Leaves |
ArrayT< uint32_t > | PVS |
BoundingBox3T< double > | BB |
ArrayT < cf::SceneGraph::FaceNodeT * > | FaceChildren |
The list of all the face children of the BSP tree. More... | |
ArrayT < cf::SceneGraph::GenericNodeT * > | OtherChildren |
The list of all the other children of the BSP tree. More... | |
ArrayT< Vector3dT > | GlobalDrawVertices |
The class represents a BSP Tree node, implementing the Composite design pattern.
BSP tree nodes are special group nodes that implement acceleration structures.
BspTreeNodeT::BspTreeNodeT | ( | float | LightMapPatchSize, |
float | SHLMapPatchSize | ||
) |
The constructor.
Needed e.g. by the named constructor CreateFromFile_cw() below.
BspTreeNodeT::~BspTreeNodeT | ( | ) |
The destructor.
cf::SceneGraph::BspTreeNodeT::BspTreeNodeT | ( | const BspTreeNodeT & | ) |
Use of the Copy Constructor is not allowed.
double BspTreeNodeT::ClipLine | ( | const VectorT & | P, |
const VectorT & | U, | ||
double | Min, | ||
double | Max, | ||
unsigned long | NodeNr = 0 , |
||
bool | NodeIsLeaf = false |
||
) | const |
Clips the line segment defined by P+U*Min and P+U*Max against the map and returns a value Hit such that P+U*Hit yields the point where the line segment intersects the BSP tree, with Min<=Hit<=Max.
This is the classical "clip ray against BSP tree" implementation, used e.g. for PVS purposes: it works solely with the BSP tree and does not take "other" leaf contents etc. into account. This function MUST NOT BE CALLED ON AN EMPTY BSP TREE! The NodeNr and NodeIsLeaf parameters are for internal recursion only. They specify the recursion start and should always be omitted by the immediate caller.
|
static |
Named constructor.
|
virtual |
Draws the contents of this scene node.
ViewerPos | Position of the viewer. |
Reimplemented from cf::SceneGraph::GenericNodeT.
|
virtual |
Returns the bounding box of the contents of this scene node.
Reimplemented from cf::SceneGraph::GenericNodeT.
void BspTreeNodeT::GetLeavesOrderedBackToFront | ( | ArrayT< unsigned long > & | OrderedFaces, |
const VectorT & | Origin | ||
) | const |
This function traverses the BSP tree back-to-front, and stores the index numbers of the leaves it encounters in OrderedLeaves.
The result is a permutation of the numbers 0...Leaves.Size()-1, such that a back-to-front sorting is obtained for the Origin. The cardinality of OrderedLeaves MUST MATCH THE CARDINALITY OF Leaves!
bool BspTreeNodeT::IsInPVS | ( | const unsigned long | QueryLeafNr, |
unsigned long | LeafNr | ||
) | const |
Returns 'true' if leaf 'QueryLeafNr' is in the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map.
bool BspTreeNodeT::IsInPVS | ( | const VectorT & | Position, |
unsigned long | LeafNr | ||
) | const |
Returns 'true' if 'Position' is in the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map.
bool BspTreeNodeT::IsInPVS | ( | const BoundingBox3T< double > & | BoundingBox, |
unsigned long | LeafNr | ||
) | const |
Returns 'true' if 'BoundingBox' is in or touches the PVS of leaf 'LeafNr', and false otherwise. Do not call on empty map.
|
virtual |
TODO / FIXME: This method is a hot-fix for getting the render order with translucent Bezier Patches right.
It should be removed again and the whole system should be replaced with something as in the Q3 renderer!
Reimplemented from cf::SceneGraph::GenericNodeT.
void cf::SceneGraph::BspTreeNodeT::operator= | ( | const BspTreeNodeT & | ) |
Use of the Assignment Operator is not allowed.
unsigned long BspTreeNodeT::WhatLeaf | ( | const VectorT & | Position | ) | const |
In what leaf is 'Position' located? This function MUST NOT BE CALLED ON AN EMPTY MAP!
void BspTreeNodeT::WhatLeaves | ( | ArrayT< unsigned long > & | ResultLeaves, |
const BoundingBox3T< double > & | BoundingBox, | ||
unsigned long | NodeNr = 0 |
||
) | const |
In what leaves is 'BoundingBox' located? This function MUST NOT BE CALLED ON AN EMPTY MAP! The result will be APPENDED to the contents of the array 'ResultLeaves'.
The third parameter is for recursion only and should always be omitted by the immediate caller.
ArrayT<cf::SceneGraph::FaceNodeT*> cf::SceneGraph::BspTreeNodeT::FaceChildren |
The list of all the face children of the BSP tree.
ArrayT<cf::SceneGraph::GenericNodeT*> cf::SceneGraph::BspTreeNodeT::OtherChildren |
The list of all the other children of the BSP tree.