GBE::GDynamicGeneratorAgent Class Reference
Implements deterministic random element content generation.
More...
#include <GDynamicGeneratorAgent.h>
Inheritance diagram for GBE::GDynamicGeneratorAgent:
[legend]Collaboration diagram for GBE::GDynamicGeneratorAgent:
[legend]List of all members.
|
Public Member Functions |
| | GDynamicGeneratorAgent (unsigned long rand_seed, QPtrList< GDynamicGeneratorCategory > categories, const QDateTime &initial_creation_time, unsigned short density, bool create_all_at_once=false, QObject *parent=0, const char *name=0) |
| virtual | ~GDynamicGeneratorAgent () |
| virtual void | receiveInfluence (GCS::GElementInfluence &influence) |
Protected Member Functions |
| void | generateInArea (const GCS::GVector3 &position, double radius) |
| void | recursiveGeneration (GDynamicGeneratorOctreeNode *node, const GCS::GVector3 &position, double radius, short unsigned depth) |
| virtual GCS::GElement * | createElement (const GDynamicGeneratorCategory &category, const GCS::GVector3 &position) |
Protected Attributes |
| unsigned long | RandomSeed |
| QPtrList< GDynamicGeneratorCategory > | Categories |
| QDateTime | CreationTime |
| unsigned short | Density |
| bool | CreateAllAtOnce |
| Util::PseudoRNG | RNG |
| GDynamicGeneratorOctreeNode * | TopNode |
Detailed Description
Implements deterministic random element content generation.
- Author:
- Martin Reinsprecht (idea), Raphael Langerhorst (implementation)
Dynamic world generation is a key concept in creating huge worlds. This class serves as base class for content creating agents for specific elements.
A random number generator (RNG) is used to create a series of random numbers which are mapped to coordinates octree inside the element. According to a mapping it is possible to tell what kind of child element is created at a certain location. This child element is given a seed value for its own RNG according to the current RNG state. Categories are used to create the child elements. The correct category is chosen by the random number.
This mechanism results in a random but deterministic universe according to the seed value for the first element.
Good examples for using this agent are galaxies, solar systems, planet surface generation, ...
- Note:
- This agent can only work if the element has a form attribute!
- Todo:
- Make this Agent thread safe - especially receiveInfluence!! Or put generation into a separate thread.
The energy used for creation is NOT deterministic as we GEnergy::take() some out of the current element(!)
Constructor & Destructor Documentation
| GBE::GDynamicGeneratorAgent::GDynamicGeneratorAgent |
( |
unsigned long |
rand_seed, |
|
|
QPtrList< GDynamicGeneratorCategory > |
categories, |
|
|
const QDateTime & |
initial_creation_time, |
|
|
unsigned short |
density, |
|
|
bool |
create_all_at_once = false, |
|
|
QObject * |
parent = 0, |
|
|
const char * |
name = 0 |
|
) |
|
|
|
|
Constructor. - Parameters:
-
| rand_seed | tells the agent where to start the RNG. |
| initial_creation_time | tells the agent how long the element already exists. This is also used for child generation. |
| density | specifies octree depth |
| create_all_at_once | tells the agent if all of the element content should be created at once. |
|
Member Function Documentation
|
|
Creates an element at a given position. For special creation routines this method can be reimplemented. |
| void GBE::GDynamicGeneratorAgent::generateInArea |
( |
const GCS::GVector3 & |
position, |
|
|
double |
radius |
|
) |
[protected] |
|
|
|
Generates elements in given sphere area. If active elements are detected by receiveInfluence() then this method is used to do the actual element generation. - See also:
- receiveInfluence()
|
|
|
Reacts to user influences and creates contents of the element accordingly. That means, if a user is recognised at a certain location this agent will create element content in this area so it is visible and active for the user. - See also:
- generateInArea()
Reimplemented from GCS::GAgent. |
|
|
Implements recursive generation of elements in area. When the lowest level is reached (depth==this->Density) then a random value between 0 and 1 is generated with the seed of the node with which the category can be determined. Categories have a range. The Categories list will be iterated through and the range attribute of every category will be added. As soon as the determined random value is reached the currently selected category is used for element creation. |
Member Data Documentation
|
|
Stores all available category implementations, these are used to generate child elements at certain nodes. - Note:
- It is VERY important to have a total range size < 1 because the random value used to determine the category is between 0 and 1. If the random value is bigger than the sum of all categories then nothing is created at that position.
- See also:
- recursiveGeneration(), GDynamicGeneratorCategory
|
|
|
Determines if all the element content should be created in one go as soon as a user influence is recognised. This is required if child elements heavily influence each other. Otherwise (like solar systems or galaxies) it can be set to false. Default value is false. |
|
|
Holds the time at which this element was created. - See also:
- GDynamicGeneratorCategory::createElement()
|
|
|
Specifies the density of the octree for element generation. A higher value gives finer grained child creation. - Note:
- Every step means at maximum eight times more octree nodes!! High values should be avoided, a density of 5 can already give 32768 octree nodes! Still, the dynamic management of nodes minimises this memory exhaustion.
|
|
|
The seed with which the RNG starts at the initial position. |
|
|
The random number generator. |
|
|
The top node of the octree which is used for content creation. |
The documentation for this class was generated from the following files:
Generated on Thu Oct 21 21:18:08 2004 for G System by
1.3.6