Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

GBE::GDynamicGeneratorOctreeNode Class Reference

The generation space is structured with octrees. More...

#include <GDynamicGeneratorAgent.cpp>

Collaboration diagram for GBE::GDynamicGeneratorOctreeNode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GDynamicGeneratorOctreeNode (unsigned long rand_seed, const GCS::GVector3 &position, double segment_size)
 ~GDynamicGeneratorOctreeNode ()
unsigned long getRandomSeed ()
GCS::GVector3 getPosition ()
double getSegmentSize ()
bool isPositionInsideNode (const GCS::GVector3 &position)
bool isAreaInsideNode (const GVector3 &position, double radius)
bool touchesArea (const GCS::GVector3 &position, double radius)
void setGenerated ()
bool isGenerated ()
QPtrList< GDynamicGeneratorOctreeNodegetChildNodes ()
bool isNodeExpanded ()
bool expandNode (Util::PseudoRNG &rng)
void reduceNode ()
void reduceGenerated (bool recursive=true)
GDynamicGeneratorOctreeNodegetChildNodeForPosition (const GCS::GVector3 &position)
QPtrList< GDynamicGeneratorOctreeNodegetChildNodesForArea (const GCS::GVector3 &position, double radius)
GCS::GVector3 getRandomPositionInCube (Util::PseudoRNG &rng)

Protected Attributes

unsigned long RandomSeed
GCS::GVector3 Position
double SegmentSize
bool Generated
GDynamicGeneratorOctreeNodeChildren [8]

Detailed Description

The generation space is structured with octrees.

Author:
Raphael Langerhorst Basically a node serves three purposes: 1) It serves as starting point for generating all child nodes in the nodes area, 2) it stores the seed value for the pseudo RNG to generate the child nodes and 3) it stores the size of the area in which a child element would potentially be created.


Constructor & Destructor Documentation

GBE::GDynamicGeneratorOctreeNode::GDynamicGeneratorOctreeNode unsigned long  rand_seed,
const GCS::GVector3 position,
double  segment_size
 

Constructor.

GBE::GDynamicGeneratorOctreeNode::~GDynamicGeneratorOctreeNode  ) 
 

Destructor, deletes all child nodes.


Member Function Documentation

bool GBE::GDynamicGeneratorOctreeNode::expandNode Util::PseudoRNG &  rng  ) 
 

Creates all 8 child nodes for this octree node.

Parameters:
rng specifies the random number generator to use.
Returns:
true when all child nodes have been successfully created.

false on out of memory errors.

GDynamicGeneratorOctreeNode * GBE::GDynamicGeneratorOctreeNode::getChildNodeForPosition const GCS::GVector3 position  ) 
 

the child node of this octree node that covers given position. NULL if position is completely outside of this node!

Todo:
write a test case for this.

QPtrList< GDynamicGeneratorOctreeNode > GBE::GDynamicGeneratorOctreeNode::getChildNodes  ) 
 

a pointer list with all child nodes.

QPtrList< GDynamicGeneratorOctreeNode > GBE::GDynamicGeneratorOctreeNode::getChildNodesForArea const GCS::GVector3 position,
double  radius
 

all child nodes that cover part of given area;

Todo:
write a test case for this.

GVector3 GBE::GDynamicGeneratorOctreeNode::getPosition  ) 
 

the position of this node.

GVector3 GBE::GDynamicGeneratorOctreeNode::getRandomPositionInCube Util::PseudoRNG &  rng  ) 
 

Returns:
a deterministic random position based on RandomSeed inside this node's cube.

unsigned long GBE::GDynamicGeneratorOctreeNode::getRandomSeed  ) 
 

the seed for the RNG for this node.

double GBE::GDynamicGeneratorOctreeNode::getSegmentSize  ) 
 

the segment size of the enclosing node cube.

bool GBE::GDynamicGeneratorOctreeNode::isAreaInsideNode const GVector3 position,
double  radius
 

true when given area is enclosed by the cube of this octree node.

bool GBE::GDynamicGeneratorOctreeNode::isGenerated  ) 
 

true when an element was already created at this node position.

See also:
Generated

bool GBE::GDynamicGeneratorOctreeNode::isNodeExpanded  ) 
 

Returns:
true when child nodes are created (so they are in memory).

bool GBE::GDynamicGeneratorOctreeNode::isPositionInsideNode const GCS::GVector3 position  ) 
 

true when given position is inside the cube of this octree node.

void GBE::GDynamicGeneratorOctreeNode::reduceGenerated bool  recursive = true  ) 
 

Reduces all child nodes that have been used for element creation (isGenerated()==true)

void GBE::GDynamicGeneratorOctreeNode::reduceNode  ) 
 

Deletes all child nodes.

void GBE::GDynamicGeneratorOctreeNode::setGenerated  ) 
 

Sets Generated to true.

See also:
Generated

bool GBE::GDynamicGeneratorOctreeNode::touchesArea const GCS::GVector3 position,
double  radius
 

true when given area touches the cube of this octree node.


Member Data Documentation

GDynamicGeneratorOctreeNode* GBE::GDynamicGeneratorOctreeNode::Children[8] [protected]
 

Array of child nodes. Seen FROM positive y: the first four are the first four (mathematical) quadrants and the second four children are the last four quadrants.

bool GBE::GDynamicGeneratorOctreeNode::Generated [protected]
 

Set to true when this node is an end node and the element for this node has been created. If this node is not an end node but all child nodes have been used for creating elements then this is also set to true.

This means that if Generated is set to true then the whole cubic area this node covers had been generated. Thus it is possible to reduce nodes and save memory. In the end, when the whole element was created, there will be only one node left: the top node, and its Generated attribute will be set to true.

GCS::GVector3 GBE::GDynamicGeneratorOctreeNode::Position [protected]
 

The position relative to the element centre.

Todo:
it should somehow be possible to respond to radius changes of the element's form.

unsigned long GBE::GDynamicGeneratorOctreeNode::RandomSeed [protected]
 

The RNG seed number for this node. THIS is the actual data we need for child generation at the node's position.

double GBE::GDynamicGeneratorOctreeNode::SegmentSize [protected]
 

Segment size of the enclosing cube. This value is both required to generate positions and sizes of child nodes as well as to be able to "randomly" place the created child element somewhere in this cube. If this second functionality were not given, a randomly created element content (=children of one specific element) could look like a grid.

See also:
Position


The documentation for this class was generated from the following file:
Generated on Thu Oct 21 21:18:06 2004 for G System by doxygen 1.3.6