#include <TeEngine.h>
Terrain Engine is responsible for several things:
Public Types | |
enum | GenMethod { FAULT_FORMATION = 0 } |
enum | FilterMethod { NONE = 0, LINEAR = 1 } |
Public Member Functions | |
TeEngine (SbVec2s hmapResolution=SbVec2s(65, 65), SbVec2f patch0Size=SbVec2f(64.f, 64.f)) | |
~TeEngine () | |
const SbVec2s & | getHMapResolution () const |
SbVec2s | getBuildMapResolution () const |
const SbVec2f & | getPatch0Size () const |
GenMethod | getCurrGen () |
void | setCurrGen (GenMethod m) |
FilterMethod | getCurrFilter () |
void | setCurrFilter (FilterMethod m) |
void | addObject (TeObject *obj) |
TeObject * | getObject (int idx) |
void | removeObject (TeObject *obj) |
void | setActiveObject (TeObject *obj) |
TeObject * | getActiveObject () |
void | setSceneRoot (SoSeparator *sep) |
SoSeparator * | getSceneRoot () |
void | addNode (SoNode *node) |
void | removeNode (SoNode *node) |
void | removePatch (TePatch *p) |
void | setHUDRoot (SoSeparator *sep) |
SoSeparator * | getHUDRoot () |
void | setSceneCamera (SoPerspectiveCamera *c) |
SoPerspectiveCamera * | getSceneCamera () |
void | setHUDCamera (SoPerspectiveCamera *c) |
SoPerspectiveCamera * | getHUDCamera () |
TePatch * | getPatch (const SbVec2f &pos, const int level=0, TePatch::PatchMissedPolicy policy=TePatch::CREATE) |
TePatch * | getRootPatch () |
int | getRootLevel () const |
void | advanceRootToPos (const SbVec2f &pos) |
TeHeightMap * | generateHMap (const SbVec2s &res) |
TeHeightMap * | generateHMapFF () |
TeHeightMap * | generateHMapFF (const SbVec2s &res) |
TeHeightMap * | generateHMapFF (const SbVec2s &res, const unsigned int seed, const int num_faults, const float min_delta, const float max_delta) |
void | initialize () |
void | timeTick (const SbTime delta) |
SbBool | genTick () |
void | onRootDestroy () |
Public Attributes | |
TeFaultFormation | faultFormation |
float | fps |
unsigned int | tasksInQueue |
unsigned int | patchesNum |
Private Member Functions | |
SbBool | isReady (SbVec2f patchPos) |
SbBool | isScheduled (SbVec2f patchPos) |
void | schedule (SbVec2f patchPos) |
void | done () |
void | prepareNeighbours (SbVec2f patchPos) |
void | updateGraph (TeObject *obj) |
SbVec2f | computePatchPosUnderPoint (SbVec3f pt) |
SbVec2f | computeNeighbourPos (SbVec2f patchPos, TePatch::Direction which) |
TePatch::Direction | computePosInsidePatch (SbVec2f patchPos, SbVec3f pt) |
Private Attributes | |
TePatch * | root |
int | rootLevel |
SbVec2s | hmapResolution |
SbVec2f | patch0Size |
TeLinearFilter | linearFilter |
TeGenerator * | generator |
GenMethod | currGen |
FilterMethod | currFilter |
SbList< TeETask > | taskQueue |
SbList< TeObject * > | objectList |
TeObject * | activeObject |
SoSeparator * | sceneRoot |
SoPerspectiveCamera * | sceneCamera |
SoSeparator * | HUDRoot |
SoPerspectiveCamera * | HUDCamera |
SbBSPTree | patchReadyTree |
SbBSPTree | patchScheduledTree |
Classes | |
struct | TeETask |
Struct that holds patch generating task status. More... |
|
Enumeration of all heightmap filtration methods. This corresponds with TeGenerator derived classes in order to use them in the engine.
|
|
Enumeration of all heightmap generation methods. This corresponds with TeGenerator derived classes in order to use them in the engine.
|
|
Default constructor. Does some default choices, that can be modified later. TeEngine::FAULT_FORMATION is selected as a generator and TeEngine::LINEAR as a filter.
|
|
Destructor.
|
|
Adds node to scene. This function checks, whether the node is already present. If it is, nothing happens. This prevents from adding the same node into the scene several times. Helpful when adding seams into the scene graph. Note, that modifications to the scene graph are not allowed during the rendering traversal of the tree. Violation of this condition results usually in application crash.
|
|
Adds object into the engine.
|
|
Documentation not available.
|
|
Computes position of the selected neighbour of the patch. The position can be used to get the neighbour using getPatch() method.
|
|
Computes position of the patch that is right under the point pt. The position can be used to get the patch using getPatch() method.
|
|
Computes position of the point pt above patch at patchPos relatively to the patch borders. The position can be used to determine the direction the object is moving.
|
|
Removes task from the queue and marks the patch as ready. Called after succesfull completion of each task.
|
|
Generates new height map of the given resolution. The appearance of the result can be influenced by choosing the generation and filtering method before calling this function. Note, that all generator parameters (including the random seed) can be set in order to customize the process of generating the result.
|
|
Generates new height map using fault-formation algorithm. This method is obsolete and should be removed. Use generateHMap() instead.
|
|
Generates new height map using fault-formation algorithm. This method is obsolete and should be removed. Use generateHMap() instead.
|
|
Generates new height map using fault-formation algorithm. This method is obsolete and should be removed. Use generateHMap() instead.
|
|
Internal patch generator tick function. This method performs one TeGenerator::genStep() for the 1st task in the queue. Process is controlled by the TeETask::TeETaskStatus values.
|
|
Gets active object.
|
|
Computes patch build maps resolution. Build maps have to have double sized dimensions than the resulting height map (minus 1).
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Gets object from the object list.
|
|
Documentation not available.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Private attribute accessor.
|
|
Initializes the engine. Checks if all necessary attributes are set, generates initial patches and creates HUD. If something is wrong terminates the execution and echoes the error. This function can be called only once and this should be done after adding all desired objects and correctly setting the active one, after attaching scene and HUD cameras. Repeated calls are simply ignored. |
|
Tests whether the patch is already generated or not. Patch is specified by its center in the world-space coordinates passed to this function in the patchPos argument. This is way how to uniquely describe each patch.
|
|
Tests whether the patch is scheduled for generating or not. Patch is specified by its center in the world-space coordinates passed to this function in the patchPos argument. This is way how to uniquely describe each patch.
|
|
Internal function.
|
|
Schedules generation of all not existing neighbours of the patch at patchPos. Patch at patchPos is likely to be under camera in a few moments, so look in scheduled and ready patches and schedule generation of all necessary neighbours. Little trick is used in this method: Count from 7 backwards is here because NORTH neighbour is represented by nr.7 and with the camera currently pointing to the north it is good to create north neighbour as the first one.
|
|
Removes node from scene. This function checks, whether the node is truly present. If it isn't, nothing happens. Note, that modifications to the scene graph are not allowed during the rendering traversal of the tree. Violation of this condition results usually in application crash.
|
|
Removes the object from engine.
|
|
Removes patch p and its seams from the scene.
|
|
Schedule generation of patch at patchPos. This function creates TeETask object, fills all its attributes and inserts it into the TeEngine::taskQueue. To control the generation process, modify TeEngine::currGen and TeEngine::currFilter attributes before calling this method.
|
|
Sets active object.
|
|
Sets currently selected filtration method to m. This method will be used when new task is scheduled or when generateHMap() method is called.
|
|
Sets currently selected generation method to m. This method will be used when new task is scheduled or when generateHMap() method is called.
|
|
Sets camera to be used to display the HUD.
|
|
Sets HUD scene root.
|
|
Sets camera to be used to observe the scene.
|
|
Sets whole scene root. All objects managed by the engine will be added to the scene as children of this node.
|
|
Time tick function of the engine. This function has to be called continuously by application that uses engine in order to have chance to do its work. This function is responsible for giving generators chance to work (it calls genTick() method) and checking if all cameras have whole visible terain ready to render (it calls updateGraph() for all engine objects and TeObject::timeTick() as well).
|
|
Updates scene graph to match object needs. This function is called continuously from the timeTick() method and works in three steps:
|
|
Currently active object. This is the object, that manages main camera, HUD camera and handles input events. This pointer is used for polymorph calls. |
|
Currently selected filtration method.
|
|
Currently selected generation method.
|
|
Instance of the fault-formation generator.
|
|
Current FPS number.
|
|
Currently used generator. This attribute is used for polymorph calls. |
|
Default heightmap resolution. SbVec2s(65,65) by default.
|
|
Camera for displaying HUD. It will be managed by the active object.
|
|
HUD static geometry root.
|
|
Instance of the linear filter generator.
|
|
List that holds pointers of attached objects.
|
|
Default size of the area occupied by the patch. SbVec2f(64.f,64.f) by default.
|
|
Total number of already generated patches.
|
|
List of already generated patches.
|
|
List of scheduled patches. It is probably faster than searching in the taskQueue.
|
|
Root of whole patch tree.
|
|
Level of the root of whole patch tree.
|
|
Camera that will be used to view the scene. It will be managed by the active object.
|
|
Whole scene root. Aditional patches are always added as a children of this root.
|
|
Scheduled tasks queue. It holds all the tasks that are currently under construction. Task at the front of the queue gets CPU-time and has the chance to be finished.
|
|
Current number of tasks in the queue.
|