[3311] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[3433] | 12 | main-programmer: Benjamin Grauer |
---|
[3311] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[3591] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_TRACK_MANAGER |
---|
[3311] | 17 | |
---|
| 18 | #include "track_manager.h" |
---|
[3495] | 19 | |
---|
[3608] | 20 | #include "base_object.h" |
---|
[3433] | 21 | #include "p_node.h" |
---|
[3528] | 22 | #include "track_node.h" |
---|
[3608] | 23 | #include "stdincl.h" |
---|
| 24 | #include "list.h" |
---|
[3528] | 25 | |
---|
[3608] | 26 | |
---|
| 27 | |
---|
[3495] | 28 | #include <stdarg.h> |
---|
| 29 | |
---|
[3311] | 30 | using namespace std; |
---|
| 31 | |
---|
[3331] | 32 | /** |
---|
| 33 | \brief initializes a TrackElement (sets the default values) |
---|
| 34 | */ |
---|
| 35 | TrackElement::TrackElement(void) |
---|
| 36 | { |
---|
[3332] | 37 | this->isFresh = true; |
---|
[3354] | 38 | this->isHotPoint = false; |
---|
[3331] | 39 | this->isSavePoint = false; |
---|
| 40 | this->isFork = false; |
---|
| 41 | this->isJoined = false; |
---|
[3356] | 42 | this->mainJoin = false; |
---|
[3331] | 43 | this->ID = -1; |
---|
[3588] | 44 | this->startingTime = 0; |
---|
| 45 | this->duration = TMAN_DEFAULT_DURATION; |
---|
[3433] | 46 | this->endTime = 1; |
---|
| 47 | this->jumpTime = 0; |
---|
[3596] | 48 | this->width = TMAN_DEFAULT_WIDTH; |
---|
[3331] | 49 | this->nodeCount = 0; |
---|
[3348] | 50 | this->childCount = 0; |
---|
[3332] | 51 | this->name = NULL; |
---|
[3331] | 52 | this->curve = NULL; |
---|
| 53 | this->children = NULL; |
---|
[3527] | 54 | |
---|
| 55 | this->history = NULL; |
---|
| 56 | |
---|
[3522] | 57 | this->condFunc = &TrackElement::random; |
---|
[3331] | 58 | } |
---|
[3311] | 59 | |
---|
[3331] | 60 | /** |
---|
[3332] | 61 | \brief destroys all alocated memory) |
---|
[3331] | 62 | \todo eventually when deleting a TrackElement you would not like to delete all its preceding TrackElements |
---|
| 63 | */ |
---|
| 64 | TrackElement::~TrackElement(void) |
---|
| 65 | { |
---|
[3332] | 66 | if (this->name) |
---|
| 67 | delete []name; |
---|
[3331] | 68 | if (this->curve) |
---|
| 69 | delete this->curve; |
---|
[3356] | 70 | if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin)) |
---|
[3331] | 71 | { |
---|
[3661] | 72 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 73 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 74 | while (enumElem) |
---|
| 75 | { |
---|
| 76 | delete enumElem; |
---|
[3661] | 77 | enumElem = iterator->nextElement(); |
---|
[3594] | 78 | } |
---|
[3661] | 79 | delete iterator; |
---|
[3356] | 80 | delete this->children; |
---|
[3331] | 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
[3332] | 84 | /** |
---|
| 85 | \brief Searches through all the TrackElements for trackID. |
---|
| 86 | \param trackID The ID to search for. |
---|
| 87 | \returns The TrackElement if Found, NULL otherwise. |
---|
| 88 | |
---|
| 89 | \todo make this more modular, to search for different things |
---|
| 90 | */ |
---|
| 91 | TrackElement* TrackElement::findByID(unsigned int trackID) |
---|
| 92 | { |
---|
| 93 | // return if Found. |
---|
| 94 | if (this->ID == trackID) |
---|
| 95 | return this; |
---|
| 96 | // search on. |
---|
| 97 | if (this->childCount > 0) |
---|
[3594] | 98 | { |
---|
[3661] | 99 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 100 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 101 | TrackElement* tmpElem; |
---|
| 102 | while (enumElem) |
---|
| 103 | { |
---|
| 104 | if ((tmpElem = enumElem->findByID(trackID))) |
---|
| 105 | return tmpElem; |
---|
[3661] | 106 | enumElem = iterator->nextElement(); |
---|
[3594] | 107 | } |
---|
[3661] | 108 | delete iterator; |
---|
[3594] | 109 | } |
---|
| 110 | else |
---|
| 111 | return NULL; |
---|
[3332] | 112 | } |
---|
[3331] | 113 | |
---|
| 114 | |
---|
[3522] | 115 | /** |
---|
| 116 | \brief checks if there are any BackLoops in the Track |
---|
| 117 | \param trackElem the trackElement to check about |
---|
| 118 | it simply does this by looking if the current trackElem is found again somewhere else in the Track |
---|
| 119 | */ |
---|
| 120 | bool TrackElement::backLoopCheck(TrackElement* trackElem) |
---|
| 121 | { |
---|
| 122 | if (this->childCount == 0) |
---|
| 123 | return true; |
---|
| 124 | else |
---|
| 125 | { |
---|
[3661] | 126 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 127 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 128 | while (enumElem) |
---|
| 129 | { |
---|
| 130 | if(!enumElem->backLoopCheck(trackElem)) |
---|
| 131 | return false; |
---|
[3661] | 132 | enumElem = iterator->nextElement(); |
---|
[3594] | 133 | } |
---|
[3661] | 134 | delete iterator; |
---|
[3522] | 135 | |
---|
| 136 | return true; |
---|
| 137 | } |
---|
| 138 | } |
---|
[3331] | 139 | |
---|
[3522] | 140 | /** |
---|
[3594] | 141 | \param childNumber which child to return |
---|
| 142 | \returns the n-the children (starting at 0) |
---|
| 143 | */ |
---|
| 144 | TrackElement* TrackElement::getChild(int childCount) |
---|
| 145 | { |
---|
| 146 | if (this->childCount == 0) |
---|
| 147 | return NULL; |
---|
| 148 | if (childCount > this->childCount) |
---|
| 149 | childCount = this->childCount; |
---|
| 150 | |
---|
[3832] | 151 | // TrackElement* enumElem = this->children->enumerate(); |
---|
| 152 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 153 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 154 | for (int i = 0; i < childCount; i++) |
---|
[3832] | 155 | enumElem = iterator->nextElement(); |
---|
| 156 | delete iterator; |
---|
[3594] | 157 | return enumElem; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | /** |
---|
[3588] | 161 | \param name the Name to set. |
---|
| 162 | */ |
---|
| 163 | void TrackElement::setName(const char* name) |
---|
| 164 | { |
---|
| 165 | // delete the old name |
---|
| 166 | if (this->name) |
---|
| 167 | delete []this->name; |
---|
| 168 | // if a name was given already. |
---|
| 169 | if (name) |
---|
| 170 | { |
---|
| 171 | this->name = new char[strlen(name)+1]; |
---|
| 172 | strcpy(this->name, name); |
---|
| 173 | } |
---|
| 174 | else |
---|
| 175 | this->name = NULL; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | /** |
---|
| 179 | \returns The name of this TrackElement |
---|
| 180 | */ |
---|
| 181 | char* TrackElement::getName(void) const |
---|
| 182 | { |
---|
| 183 | return this->name; |
---|
| 184 | } |
---|
| 185 | |
---|
[3593] | 186 | /** |
---|
| 187 | \brief prints out debug information about this TrackElement |
---|
| 188 | */ |
---|
| 189 | void TrackElement::debug(void) |
---|
| 190 | { |
---|
| 191 | PRINT(0)("--== TrackElement:%i ==--", this->ID); |
---|
| 192 | if(this->getName()) |
---|
| 193 | PRINT(0)("Name: %s::", this->getName()); |
---|
| 194 | if(this->isFresh) |
---|
| 195 | PRINT(0)(" -- has not jet eddited in any way --\n"); |
---|
| 196 | PRINT(0)("\n TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime); |
---|
| 197 | PRINT(0)(" consists of %d Points\n", this->nodeCount); |
---|
| 198 | if (this->childCount == 0) |
---|
| 199 | PRINT(0)(" has no child\n"); |
---|
| 200 | else if (this->childCount == 1) |
---|
[3594] | 201 | PRINT(0)(" has 1 child: =%d=\n", this->getChild(0)->ID); |
---|
[3593] | 202 | else if (this->childCount > 1) |
---|
| 203 | { |
---|
| 204 | PRINT(0)(" has %d children: ", this->childCount); |
---|
[3832] | 205 | //TrackElement* enumElem = this->children->enumerate(); |
---|
| 206 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 207 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 208 | while (enumElem) |
---|
| 209 | { |
---|
| 210 | PRINT(0)("=%d= ", enumElem->ID); |
---|
[3832] | 211 | enumElem = iterator->nextElement(); |
---|
[3594] | 212 | } |
---|
[3832] | 213 | delete iterator; |
---|
[3593] | 214 | PRINT(0)("\n"); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | if(this->isHotPoint) |
---|
| 218 | PRINT(0)(" is a special Point:\n"); |
---|
| 219 | if(this->isSavePoint) |
---|
| 220 | PRINT(0)(" is a SavePoint\n"); |
---|
| 221 | if(this->isFork) |
---|
| 222 | { |
---|
| 223 | PRINT(0)(" is A Fork with with %d children.\n", this->childCount); |
---|
| 224 | } |
---|
| 225 | if(this->isJoined) |
---|
| 226 | PRINT(0)(" is Joined at the End\n"); |
---|
| 227 | |
---|
| 228 | if(!this->backLoopCheck(this)) /* this should not happen */ |
---|
| 229 | PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n"); |
---|
| 230 | } |
---|
[3588] | 231 | |
---|
| 232 | /** |
---|
[3522] | 233 | \brief CONDITION that chooses the first child for the decision (static) |
---|
| 234 | \param nothing Nothing in this function |
---|
| 235 | \returns the chosen child |
---|
| 236 | */ |
---|
| 237 | int TrackElement::lowest(void* nothing) |
---|
| 238 | { |
---|
| 239 | return 0; |
---|
| 240 | } |
---|
[3332] | 241 | |
---|
[3522] | 242 | /** |
---|
| 243 | \brief CONDITION that chooses the last child for the decision (static) |
---|
| 244 | \param nothing Nothing in this function |
---|
| 245 | \returns the chosen child |
---|
| 246 | */ |
---|
| 247 | int TrackElement::highest(void* nothing) |
---|
| 248 | { |
---|
| 249 | return this->childCount-1; |
---|
| 250 | } |
---|
[3332] | 251 | |
---|
[3522] | 252 | /** |
---|
| 253 | \brief CONDITION that chooses a random child for the decision (static) |
---|
| 254 | \param nothing Nothing in this function |
---|
| 255 | \returns the chosen child |
---|
| 256 | */ |
---|
| 257 | int TrackElement::random(void* nothing) |
---|
| 258 | { |
---|
| 259 | int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); |
---|
| 260 | if (i >= this->childCount) |
---|
| 261 | return this->childCount-1; |
---|
| 262 | else |
---|
| 263 | return i; |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | /** |
---|
| 267 | \brief CONDITION that chooses child 0, if the node(probably Player) |
---|
| 268 | is left of its parent (z<0)) and 1/right otherwise. |
---|
| 269 | \param node The node to act upon. |
---|
| 270 | \returns the chosen child |
---|
| 271 | */ |
---|
| 272 | int TrackElement::leftRight(void* node) |
---|
| 273 | { |
---|
| 274 | PNode* tmpNode = (PNode*)node; |
---|
| 275 | |
---|
[3675] | 276 | if (tmpNode->getRelCoor()->z < 0) |
---|
[3522] | 277 | return 0; |
---|
| 278 | else |
---|
| 279 | return 1; |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | /** |
---|
| 284 | \brief CONDITION that chooses the child, that has the nearest distance to the node (probably player). |
---|
| 285 | \param node The node to act upon. |
---|
| 286 | \returns the chosen child |
---|
| 287 | |
---|
| 288 | This is rather dangerous, because one must carefully set the points on the curve. |
---|
| 289 | The best Way is to set the nodes as wide away of each other as possible, |
---|
| 290 | but take into consideration, that if the nodes are to far from a center node, the center will be chosen. |
---|
| 291 | (play with this!!). |
---|
| 292 | */ |
---|
| 293 | int TrackElement::nearest(void* node) |
---|
| 294 | { |
---|
| 295 | PNode* tmpNode = (PNode*)node; |
---|
| 296 | |
---|
[3675] | 297 | Vector nodeRelCoord = *tmpNode->getRelCoor(); |
---|
[3522] | 298 | float minDist = 100000000; |
---|
[3594] | 299 | int childNumber = 0; |
---|
| 300 | int i = 0; |
---|
| 301 | |
---|
[3832] | 302 | //TrackElement* enumElem = this->children->enumerate(); |
---|
| 303 | tIterator<TrackElement>* iterator = this->children->getIterator(); |
---|
| 304 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 305 | while (enumElem) |
---|
[3522] | 306 | { |
---|
[3594] | 307 | float dist = (nodeRelCoord - enumElem->curve->getNode(4)).len(); |
---|
[3522] | 308 | if (dist < minDist) |
---|
| 309 | { |
---|
| 310 | minDist = dist; |
---|
[3594] | 311 | childNumber = i; |
---|
[3522] | 312 | } |
---|
[3594] | 313 | i++; |
---|
[3832] | 314 | enumElem = iterator->nextElement(); |
---|
[3522] | 315 | } |
---|
[3832] | 316 | delete iterator; |
---|
[3594] | 317 | |
---|
| 318 | PRINTF(4)("PathDecision with nearest algorithm: %d\n", childNumber); |
---|
| 319 | return childNumber; |
---|
[3522] | 320 | } |
---|
| 321 | |
---|
| 322 | |
---|
[3599] | 323 | //////////////////////// |
---|
| 324 | ///// TRACKMANAGER ///// |
---|
| 325 | //////////////////////// |
---|
[3311] | 326 | /** |
---|
| 327 | \brief standard constructor |
---|
| 328 | |
---|
| 329 | */ |
---|
[3354] | 330 | TrackManager::TrackManager(void) |
---|
[3311] | 331 | { |
---|
[3594] | 332 | this->setClassName("TrackManager"); |
---|
[3528] | 333 | |
---|
[3594] | 334 | TrackManager::singletonRef = this; |
---|
[3331] | 335 | |
---|
| 336 | PRINTF(3)("Initializing the TrackManager\n"); |
---|
[3348] | 337 | this->firstTrackElem = new TrackElement(); |
---|
| 338 | this->firstTrackElem->ID = 1; |
---|
[3331] | 339 | this->currentTrackElem = firstTrackElem; |
---|
| 340 | this->localTime = 0; |
---|
| 341 | this->maxTime = 0; |
---|
[3348] | 342 | this->trackElemCount = 1; |
---|
[3594] | 343 | this->setBindSlave(this->trackNode = new TrackNode()); |
---|
[3311] | 344 | } |
---|
| 345 | |
---|
| 346 | |
---|
| 347 | /** |
---|
[3331] | 348 | \brief standard destructor |
---|
[3311] | 349 | */ |
---|
[3354] | 350 | TrackManager::~TrackManager(void) |
---|
[3330] | 351 | { |
---|
[3331] | 352 | PRINTF(3)("Destruct TrackManager\n"); |
---|
[3311] | 353 | |
---|
[3594] | 354 | PRINTF(4)("Deleting all the TrackElements\n"); |
---|
[3331] | 355 | delete this->firstTrackElem; |
---|
[3335] | 356 | |
---|
[3331] | 357 | // we do not have a TrackManager anymore |
---|
[3594] | 358 | TrackManager::singletonRef = NULL; |
---|
[3330] | 359 | } |
---|
| 360 | |
---|
[3543] | 361 | //! Singleton Reference to TrackManager |
---|
[3331] | 362 | TrackManager* TrackManager::singletonRef = NULL; |
---|
| 363 | |
---|
[3330] | 364 | /** |
---|
[3331] | 365 | \returns The reference on the TrackManager. |
---|
| 366 | |
---|
| 367 | If the TrackManager does not exist, it will be created. |
---|
| 368 | */ |
---|
| 369 | TrackManager* TrackManager::getInstance(void) |
---|
| 370 | { |
---|
[3594] | 371 | if (!TrackManager::singletonRef) |
---|
| 372 | TrackManager::singletonRef = new TrackManager(); |
---|
| 373 | return TrackManager::singletonRef; |
---|
[3331] | 374 | } |
---|
| 375 | |
---|
| 376 | /** |
---|
[3335] | 377 | \brief reserves Space for childCount children |
---|
| 378 | \param childCount The Count of children to make space for. |
---|
| 379 | */ |
---|
| 380 | void TrackManager::initChildren(unsigned int childCount) |
---|
| 381 | { |
---|
| 382 | this->currentTrackElem->childCount = childCount; |
---|
[3433] | 383 | this->currentTrackElem->mainJoin = true; |
---|
[3594] | 384 | this->currentTrackElem->children = new tList<TrackElement>(); |
---|
| 385 | for (int i = 0; i < childCount; i++) |
---|
[3348] | 386 | { |
---|
[3594] | 387 | TrackElement* newElem = new TrackElement(); |
---|
| 388 | this->currentTrackElem->children->add(newElem); |
---|
| 389 | newElem->ID = ++trackElemCount; |
---|
| 390 | newElem->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime; |
---|
| 391 | this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->getChild(i)); |
---|
[3348] | 392 | } |
---|
[3588] | 393 | if (childCount == 1) |
---|
[3594] | 394 | this->currentTrackElem->getChild(0)->setName(this->currentTrackElem->getName()); |
---|
[3335] | 395 | } |
---|
| 396 | |
---|
| 397 | /** |
---|
[3330] | 398 | \brief Searches for a given trackID. |
---|
| 399 | \param trackID the trackID to search for. |
---|
[3332] | 400 | \returns The TrackElement #trackID if found, NULL otherwise. |
---|
[3330] | 401 | */ |
---|
[3332] | 402 | TrackElement* TrackManager::findTrackElementByID(unsigned int trackID) const |
---|
[3330] | 403 | { |
---|
[3332] | 404 | return firstTrackElem->findByID(trackID); |
---|
[3330] | 405 | } |
---|
| 406 | |
---|
| 407 | // INITIALIZE // |
---|
| 408 | |
---|
| 409 | /** |
---|
| 410 | \brief Sets the trackID we are working on. |
---|
| 411 | \param trackID the trackID we are working on |
---|
| 412 | */ |
---|
[3332] | 413 | void TrackManager::workOn(unsigned int trackID) |
---|
[3330] | 414 | { |
---|
[3355] | 415 | TrackElement* tmpElem = findTrackElementByID(trackID); |
---|
| 416 | if (tmpElem) |
---|
| 417 | this->currentTrackElem = tmpElem; |
---|
| 418 | else |
---|
[3594] | 419 | PRINTF(2)("TrackElement not Found, leaving unchanged\n"); |
---|
| 420 | PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID); |
---|
[3355] | 421 | |
---|
[3330] | 422 | } |
---|
| 423 | |
---|
| 424 | /** |
---|
| 425 | \brief Sets the Type of the Curve |
---|
[3522] | 426 | \param curveType The Type to set |
---|
| 427 | \param trackElem the TrackElement that should get a new Curve. |
---|
[3330] | 428 | */ |
---|
[3433] | 429 | void TrackManager::setCurveType(CurveType curveType, TrackElement* trackElem) |
---|
[3330] | 430 | { |
---|
[3433] | 431 | if (!trackElem->isFresh) |
---|
[3332] | 432 | { |
---|
| 433 | PRINTF(2)("It is not possible to change the type of a Curve after you have have appended some points to it\n"); |
---|
| 434 | return; |
---|
| 435 | } |
---|
[3588] | 436 | this->curveType = curveType; |
---|
[3332] | 437 | switch (curveType) |
---|
| 438 | { |
---|
| 439 | case BEZIERCURVE: |
---|
[3433] | 440 | trackElem->curve = new BezierCurve(); |
---|
[3332] | 441 | break; |
---|
[3595] | 442 | |
---|
[3332] | 443 | } |
---|
[3330] | 444 | } |
---|
| 445 | |
---|
| 446 | /** |
---|
[3333] | 447 | \brief Sets the duration of the current path in seconds. |
---|
| 448 | \param time The duration in seconds. |
---|
[3330] | 449 | */ |
---|
| 450 | |
---|
[3333] | 451 | void TrackManager::setDuration(float time) |
---|
[3330] | 452 | { |
---|
[3333] | 453 | this->currentTrackElem->duration = time; |
---|
[3433] | 454 | this->currentTrackElem->endTime = this->currentTrackElem->startingTime + time; |
---|
[3330] | 455 | } |
---|
| 456 | |
---|
| 457 | /** |
---|
| 458 | \brief adds a point to the current TrackElement |
---|
| 459 | \param newPoint The point to add. |
---|
| 460 | */ |
---|
[3333] | 461 | bool TrackManager::addPoint(Vector newPoint) |
---|
[3330] | 462 | { |
---|
[3352] | 463 | return this->addPoint(newPoint, this->currentTrackElem); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | /** |
---|
| 467 | \brief adds a point to trackElem |
---|
| 468 | \param newPoint The point to add. |
---|
| 469 | \param trackElem The TrackElement to add the Point to |
---|
| 470 | */ |
---|
| 471 | bool TrackManager::addPoint(Vector newPoint, TrackElement* trackElem) |
---|
| 472 | { |
---|
| 473 | if (trackElem->isFresh) |
---|
[3332] | 474 | { |
---|
[3588] | 475 | this->setCurveType(TMAN_DEFAULT_CURVETYPE, trackElem); |
---|
[3352] | 476 | trackElem->isFresh = false; |
---|
[3332] | 477 | } |
---|
[3352] | 478 | trackElem->curve->addNode(newPoint); |
---|
| 479 | trackElem->nodeCount++; |
---|
[3330] | 480 | } |
---|
| 481 | |
---|
| 482 | /** |
---|
| 483 | \brief adds save/splitpoint. |
---|
| 484 | \param newPoint The point to add. |
---|
[3333] | 485 | \returns A Pointer to a newly appended Curve |
---|
[3330] | 486 | */ |
---|
[3333] | 487 | int TrackManager::addHotPoint(Vector newPoint) |
---|
[3330] | 488 | { |
---|
[3594] | 489 | PRINTF(4)("setting up a HotPoint\n"); |
---|
[3332] | 490 | if (this->currentTrackElem->isFresh) |
---|
| 491 | { |
---|
| 492 | this->setCurveType(BEZIERCURVE); |
---|
| 493 | this->currentTrackElem->isFresh = false; |
---|
| 494 | } |
---|
[3330] | 495 | |
---|
[3332] | 496 | // \todo HotPoint Handling. |
---|
| 497 | this->currentTrackElem->curve->addNode(newPoint); |
---|
[3351] | 498 | this->currentTrackElem->nodeCount++; |
---|
[3354] | 499 | this->initChildren(1); |
---|
[3594] | 500 | this->currentTrackElem = this->currentTrackElem->getChild(0); |
---|
[3330] | 501 | } |
---|
| 502 | |
---|
| 503 | /** |
---|
| 504 | \brief Sets the last HotPoint into a savePoint. |
---|
[3333] | 505 | \returns A Pointer to a newly appended Curve |
---|
[3330] | 506 | |
---|
| 507 | If no HotPoint was defined the last added Point will be rendered into a savePoint. \n |
---|
| 508 | If the HotPoint was defined as a fork the Point will \b not be set into a savePoint. |
---|
| 509 | */ |
---|
[3333] | 510 | int TrackManager::setSavePoint(void) |
---|
[3330] | 511 | { |
---|
[3594] | 512 | PRINTF(4)("setting up a SavePoint.\n"); |
---|
[3332] | 513 | if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint) |
---|
[3594] | 514 | { |
---|
| 515 | PRINTF(2)("%d is already finished \n", currentTrackElem->ID); |
---|
| 516 | return this->currentTrackElem->getChild(0)->ID; |
---|
| 517 | } |
---|
[3332] | 518 | this->currentTrackElem->isSavePoint = true; |
---|
[3354] | 519 | this->currentTrackElem->isHotPoint = true; |
---|
[3332] | 520 | |
---|
[3335] | 521 | this->initChildren(1); |
---|
[3594] | 522 | this->currentTrackElem = this->currentTrackElem->getChild(0); |
---|
[3330] | 523 | } |
---|
| 524 | |
---|
| 525 | /** |
---|
| 526 | \brief adds some interessting non-linear movments through the level. |
---|
| 527 | \param count The Count of childrens the current HotPoint will have. |
---|
| 528 | |
---|
| 529 | If no HotPoint was defined the last added Point will be rendered into a fork. \n |
---|
| 530 | If the HotPoint was defined as a savePoint the Point will \b not be set into a fork. |
---|
| 531 | */ |
---|
[3332] | 532 | void TrackManager::fork(unsigned int count, ...) |
---|
[3330] | 533 | { |
---|
[3351] | 534 | int* trackIDs = new int[count]; |
---|
| 535 | this->forkV(count, trackIDs); |
---|
[3332] | 536 | va_list ID; |
---|
| 537 | va_start (ID, count); |
---|
| 538 | for(int i = 0; i < count; i++) |
---|
| 539 | { |
---|
[3351] | 540 | *va_arg (ID, int*) = trackIDs[i]; |
---|
[3332] | 541 | } |
---|
[3351] | 542 | va_end(ID); |
---|
[3332] | 543 | delete []trackIDs; |
---|
[3330] | 544 | } |
---|
| 545 | |
---|
| 546 | /** |
---|
| 547 | \brief adds some interessting non-linear movments through the level. |
---|
| 548 | \param count The Count of childrens the current HotPoint will have. |
---|
| 549 | \param trackIDs A Pointer to an Array of ints which will hold the trackID's (the user will have to reserve space for this). |
---|
| 550 | |
---|
| 551 | \see void TrackManager::fork(int count, ...) |
---|
[3332] | 552 | |
---|
| 553 | \todo initialisation is wrong!! also in setSavePoint. |
---|
[3330] | 554 | */ |
---|
[3332] | 555 | void TrackManager::forkV(unsigned int count, int* trackIDs) |
---|
[3330] | 556 | { |
---|
[3594] | 557 | PRINTF(4)("Forking with %d children\n", count); |
---|
[3332] | 558 | if (this->currentTrackElem->isSavePoint) |
---|
| 559 | return; |
---|
| 560 | this->currentTrackElem->isFork = true; |
---|
[3354] | 561 | this->currentTrackElem->isHotPoint = true; |
---|
[3351] | 562 | for(int i = 0; i < count; i++) |
---|
| 563 | trackIDs[i]=this->trackElemCount+1+i; |
---|
[3335] | 564 | this->initChildren(count); |
---|
[3330] | 565 | } |
---|
| 566 | |
---|
| 567 | /** |
---|
| 568 | \brief decides under what condition a certain Path will be chosen. |
---|
[3522] | 569 | \param cond the CONDITION of the decision |
---|
| 570 | \param subject the Subject that will be decided upon with CONDITION cond. |
---|
| 571 | */ |
---|
| 572 | void TrackManager::condition(CONDITION cond, void* subject) |
---|
| 573 | { |
---|
| 574 | this->condition(this->currentTrackElem->ID, cond, subject); |
---|
| 575 | } |
---|
| 576 | /** |
---|
| 577 | \brief decides under what condition a certain Path will be chosen. |
---|
[3330] | 578 | \param groupID the ID on which to choose the preceding move |
---|
[3522] | 579 | \param cond the CONDITION of the decision |
---|
| 580 | \param subject the Subject that will be decided upon with CONDITION cond. |
---|
[3330] | 581 | */ |
---|
[3522] | 582 | void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject) |
---|
[3330] | 583 | { |
---|
[3522] | 584 | TrackElement* tmpElem = this->findTrackElementByID(groupID); |
---|
[3594] | 585 | if (!tmpElem->isFork) |
---|
[3522] | 586 | { |
---|
[3594] | 587 | PRINTF(2)("%d is not a Fork, and no condition can be set in this case\n", tmpElem->ID); |
---|
| 588 | return; |
---|
[3522] | 589 | } |
---|
[3594] | 590 | else |
---|
| 591 | { |
---|
| 592 | switch (cond) |
---|
| 593 | { |
---|
| 594 | case LOWEST: |
---|
| 595 | tmpElem->condFunc = &TrackElement::lowest; |
---|
| 596 | break; |
---|
| 597 | case HIGHEST: |
---|
| 598 | tmpElem->condFunc = &TrackElement::highest; |
---|
| 599 | break; |
---|
| 600 | case RANDOM: |
---|
| 601 | tmpElem->condFunc = &TrackElement::random; |
---|
| 602 | break; |
---|
| 603 | case LEFTRIGHT: |
---|
| 604 | tmpElem->condFunc = &TrackElement::leftRight; |
---|
| 605 | break; |
---|
| 606 | case NEAREST: |
---|
| 607 | tmpElem->condFunc = &TrackElement::nearest; |
---|
| 608 | break; |
---|
| 609 | case ENEMYKILLED: |
---|
| 610 | break; |
---|
| 611 | } |
---|
| 612 | tmpElem->subject=subject; |
---|
| 613 | } |
---|
[3330] | 614 | } |
---|
| 615 | |
---|
[3522] | 616 | |
---|
[3330] | 617 | /** |
---|
| 618 | \brief joins some tracks together again. |
---|
| 619 | \param count The count of Paths to join. |
---|
| 620 | |
---|
| 621 | Join will set the localTime to the longest time a Path has to get to this Point. \n |
---|
[3354] | 622 | Join will join all curves to the first curve, meaning that all the tangents will be matched. |
---|
[3330] | 623 | */ |
---|
[3332] | 624 | void TrackManager::join(unsigned int count, ...) |
---|
[3330] | 625 | { |
---|
[3332] | 626 | int* trackIDs = new int [count]; |
---|
| 627 | va_list ID; |
---|
| 628 | va_start (ID, count); |
---|
| 629 | for(int i = 0; i < count; i++) |
---|
| 630 | { |
---|
| 631 | trackIDs[i] = va_arg (ID, int); |
---|
| 632 | } |
---|
| 633 | va_end(ID); |
---|
| 634 | this->joinV(count, trackIDs); |
---|
| 635 | delete []trackIDs; |
---|
[3330] | 636 | } |
---|
| 637 | |
---|
| 638 | /** |
---|
| 639 | \brief joins some tracks together again. |
---|
| 640 | \param count The count of Paths to join. |
---|
| 641 | \param trackIDs an Array with the trackID's to join |
---|
| 642 | |
---|
| 643 | \see void TrackManager::join(int count, ...) |
---|
| 644 | */ |
---|
[3332] | 645 | void TrackManager::joinV(unsigned int count, int* trackIDs) |
---|
[3330] | 646 | { |
---|
[3594] | 647 | PRINTF(3)("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]); |
---|
[3354] | 648 | |
---|
[3522] | 649 | // checking if there is a back-loop-connection and ERROR if it is. |
---|
| 650 | TrackElement* tmpTrackElem = this->findTrackElementByID(trackIDs[0]); |
---|
| 651 | if (!tmpTrackElem->backLoopCheck(tmpTrackElem)) |
---|
[3594] | 652 | PRINTF(2)("Backloop connection detected at joining trackElements\n"); |
---|
[3522] | 653 | |
---|
[3354] | 654 | // chanching work-on to temporary value. going back at the end. |
---|
| 655 | int tmpCurrentWorkingID = this->currentTrackElem->ID; |
---|
| 656 | this->workOn(trackIDs[0]); |
---|
[3433] | 657 | TrackElement* firstJoint = this->currentTrackElem; |
---|
| 658 | float tmpLatestTime = firstJoint->endTime; |
---|
[3354] | 659 | |
---|
| 660 | Vector tmpEndPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()); |
---|
[3433] | 661 | Vector tmpTangentPoint = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-1); |
---|
| 662 | Vector tmpc2Point = firstJoint->curve->getNode(firstJoint->curve->getNodeCount()-2); |
---|
[3354] | 663 | firstJoint->isJoined = true; |
---|
[3433] | 664 | // firstJoint->mainJoin = true; |
---|
[3354] | 665 | if(!firstJoint->isHotPoint) |
---|
| 666 | this->setSavePoint(); |
---|
[3433] | 667 | // Timing: |
---|
| 668 | for (int i = 0; i < count; i++) |
---|
| 669 | { |
---|
| 670 | TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]); |
---|
| 671 | if (tmpJoinElem->childCount == 0 |
---|
| 672 | && tmpJoinElem->endTime > tmpLatestTime) |
---|
| 673 | tmpLatestTime = tmpJoinElem->endTime; |
---|
| 674 | } |
---|
| 675 | // time the main Join. |
---|
| 676 | firstJoint->jumpTime = tmpLatestTime - firstJoint->endTime; |
---|
| 677 | |
---|
| 678 | // Joining: |
---|
[3354] | 679 | for (int i = 1; i < count; i++) |
---|
[3352] | 680 | { |
---|
| 681 | TrackElement* tmpJoinElem = this->findTrackElementByID(trackIDs[i]); |
---|
[3354] | 682 | if (tmpJoinElem->childCount > 0) |
---|
| 683 | printf("!!This Curve has children, and as such will not be joined!!\n You can try joining other childless TrackElements to this one!"); |
---|
| 684 | else |
---|
| 685 | { |
---|
[3433] | 686 | this->addPoint(tmpc2Point, tmpJoinElem); |
---|
[3354] | 687 | this->addPoint(tmpTangentPoint, tmpJoinElem); |
---|
| 688 | this->addPoint(tmpEndPoint, tmpJoinElem); |
---|
[3433] | 689 | // time all other Joins |
---|
| 690 | tmpJoinElem->jumpTime = tmpLatestTime - tmpJoinElem->endTime; |
---|
[3354] | 691 | |
---|
| 692 | //Copying Joint-Info |
---|
| 693 | tmpJoinElem->children = firstJoint->children; |
---|
| 694 | tmpJoinElem->childCount = firstJoint->childCount; |
---|
| 695 | tmpJoinElem->isSavePoint = firstJoint->isSavePoint; |
---|
| 696 | tmpJoinElem->isFork = firstJoint->isFork; |
---|
[3433] | 697 | |
---|
[3354] | 698 | tmpJoinElem->isJoined = true; |
---|
| 699 | } |
---|
[3352] | 700 | } |
---|
[3433] | 701 | if(firstJoint->childCount > 0) |
---|
[3594] | 702 | { |
---|
[3832] | 703 | //TrackElement* enumElem = firstJoint->children->enumerate(); |
---|
| 704 | tIterator<TrackElement>* iterator = firstJoint->children->getIterator(); |
---|
| 705 | TrackElement* enumElem = iterator->nextElement(); |
---|
[3594] | 706 | while (enumElem) |
---|
| 707 | { |
---|
| 708 | PRINTF(4)("Setting startingTime of %d to %f.\n", enumElem->ID, tmpLatestTime); |
---|
| 709 | enumElem->startingTime = tmpLatestTime; |
---|
| 710 | enumElem->endTime = tmpLatestTime + enumElem->duration; |
---|
| 711 | |
---|
[3832] | 712 | enumElem = iterator->nextElement(); |
---|
[3594] | 713 | } |
---|
[3832] | 714 | delete iterator; |
---|
[3594] | 715 | } |
---|
[3354] | 716 | // returning to the TrackElement we were working on. |
---|
| 717 | this->workOn(tmpCurrentWorkingID); |
---|
[3330] | 718 | } |
---|
| 719 | |
---|
[3433] | 720 | /** |
---|
| 721 | \brief finalizes the TrackSystem. after this it will not be editable anymore |
---|
| 722 | |
---|
| 723 | \todo check for any inconsistencies, output errors |
---|
| 724 | */ |
---|
| 725 | void TrackManager::finalize(void) |
---|
| 726 | { |
---|
| 727 | for (int i = 1; i<= trackElemCount ;i++) |
---|
| 728 | { |
---|
| 729 | TrackElement* tmpElem = findTrackElementByID(i); |
---|
[3832] | 730 | if( tmpElem->childCount > 0 && tmpElem->mainJoin) |
---|
[3433] | 731 | { |
---|
[3832] | 732 | tIterator<TrackElement>* iterator = tmpElem->children->getIterator(); |
---|
| 733 | TrackElement* enumElem = iterator->nextElement(); |
---|
| 734 | //TrackElement* enumElem = tmpElem->children->enumerate(); |
---|
[3594] | 735 | while (enumElem) |
---|
[3433] | 736 | { |
---|
| 737 | |
---|
| 738 | // c1-continuity |
---|
[3594] | 739 | enumElem->curve->addNode(enumElem->curve->getNode(0) + |
---|
| 740 | ((enumElem->curve->getNode(0) - |
---|
[3433] | 741 | tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) |
---|
| 742 | ),2); |
---|
[3594] | 743 | enumElem->nodeCount++; |
---|
[3433] | 744 | // c2-continuity |
---|
[3594] | 745 | enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())- |
---|
[3433] | 746 | tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 + |
---|
| 747 | tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3); |
---|
[3594] | 748 | enumElem->nodeCount++; |
---|
| 749 | PRINTF(5)("accelerations: %d-in: count: %d, %f, %f, %f\n %d-out: count: %d %f, %f, %f\n", |
---|
[3433] | 750 | tmpElem->ID, tmpElem->nodeCount, |
---|
| 751 | tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z, |
---|
[3594] | 752 | enumElem->ID, enumElem->nodeCount, |
---|
| 753 | enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z); |
---|
| 754 | |
---|
[3832] | 755 | enumElem = iterator->nextElement(); |
---|
[3433] | 756 | } |
---|
[3832] | 757 | delete iterator; |
---|
[3433] | 758 | } |
---|
| 759 | } |
---|
[3601] | 760 | for (int i = 1; i <=trackElemCount;i++) |
---|
| 761 | if (this->findTrackElementByID(i)->endTime > this->maxTime) |
---|
| 762 | this->maxTime = findTrackElementByID(i)->endTime; // very bad implemented :/ |
---|
[3433] | 763 | } |
---|
| 764 | |
---|
| 765 | |
---|
[3330] | 766 | // RUNTIME // |
---|
| 767 | |
---|
| 768 | /** |
---|
| 769 | \brief calculates the Position for the localTime of the Track. |
---|
| 770 | \returns the calculated Position |
---|
| 771 | */ |
---|
[3332] | 772 | Vector TrackManager::calcPos() const |
---|
[3330] | 773 | { |
---|
[3348] | 774 | return this->currentTrackElem->curve->calcPos((this->localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration); |
---|
[3330] | 775 | } |
---|
| 776 | |
---|
| 777 | /** |
---|
| 778 | \brief calculates the Rotation for the localTime of the Track. |
---|
| 779 | \returns the calculated Rotation |
---|
| 780 | */ |
---|
[3332] | 781 | Vector TrackManager::calcDir() const |
---|
[3330] | 782 | { |
---|
[3433] | 783 | return this->currentTrackElem->curve->calcDir((this->localTime - this->currentTrackElem->startingTime)/this->currentTrackElem->duration); |
---|
[3330] | 784 | } |
---|
| 785 | |
---|
| 786 | /** |
---|
[3596] | 787 | \returns the current Width of the track |
---|
| 788 | */ |
---|
| 789 | float TrackManager::getWidth(void) const |
---|
| 790 | { |
---|
| 791 | return this->currentTrackElem->width; |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | /** |
---|
[3330] | 795 | \brief Advances the local-time of the Track around dt |
---|
| 796 | \param dt The time about which to advance. |
---|
[3333] | 797 | |
---|
| 798 | This function also checks, if the TrackElement has to be changed. |
---|
[3330] | 799 | */ |
---|
| 800 | void TrackManager::tick(float dt) |
---|
| 801 | { |
---|
[3433] | 802 | dt /= 1000; |
---|
[3591] | 803 | PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt); |
---|
[3348] | 804 | if (this->localTime <= this->firstTrackElem->duration) |
---|
| 805 | this->jumpTo(this->localTime); |
---|
[3601] | 806 | if (this->localTime <= this->maxTime) |
---|
| 807 | this->localTime += dt; |
---|
[3433] | 808 | if (this->localTime > this->currentTrackElem->endTime |
---|
| 809 | && this->currentTrackElem->children) |
---|
| 810 | { |
---|
[3527] | 811 | if (this->currentTrackElem->jumpTime != 0.0) |
---|
[3433] | 812 | this->jumpTo(this->localTime + this->currentTrackElem->jumpTime); |
---|
[3527] | 813 | // jump to the next TrackElement and also set the history of the new Element to the old one. |
---|
| 814 | TrackElement* tmpHistoryElem = this->currentTrackElem; |
---|
[3594] | 815 | this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem)); |
---|
[3527] | 816 | this->currentTrackElem->history = tmpHistoryElem; |
---|
[3433] | 817 | } |
---|
| 818 | if (this->bindSlave) |
---|
| 819 | { |
---|
| 820 | Vector tmp = this->calcPos(); |
---|
| 821 | Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z)); |
---|
[3539] | 822 | |
---|
| 823 | Vector v(0.0, 1.0, 0.0); |
---|
[3543] | 824 | Quaternion q(-PI/2, v); |
---|
[3539] | 825 | quat = quat * q; |
---|
| 826 | |
---|
[3809] | 827 | this->bindSlave->setAbsCoor(tmp); |
---|
| 828 | this->bindSlave->setAbsDir(quat); |
---|
[3433] | 829 | } |
---|
[3330] | 830 | } |
---|
| 831 | |
---|
| 832 | /** |
---|
[3331] | 833 | \brief Jumps to a certain point on the Track. |
---|
| 834 | \param time The time on the Track to jump to. |
---|
| 835 | |
---|
| 836 | This should be used to Jump backwards on a Track, because moving forward means to change between the Path. (it then tries to choose the default.) |
---|
| 837 | Max is trackLengthMax. |
---|
| 838 | */ |
---|
| 839 | void TrackManager::jumpTo(float time) |
---|
| 840 | { |
---|
[3348] | 841 | if (time == 0) |
---|
| 842 | this->currentTrackElem = this->firstTrackElem; |
---|
| 843 | this->localTime = time; |
---|
[3331] | 844 | } |
---|
| 845 | |
---|
| 846 | /** |
---|
[3330] | 847 | \brief a Function that decides which Path we should follow. |
---|
[3522] | 848 | \param trackElem The Path to choose. |
---|
[3330] | 849 | |
---|
| 850 | */ |
---|
[3522] | 851 | int TrackManager::choosePath(TrackElement* trackElem) |
---|
[3330] | 852 | { |
---|
[3522] | 853 | return (trackElem->*(trackElem->condFunc))(trackElem->subject); |
---|
[3330] | 854 | } |
---|
| 855 | |
---|
[3433] | 856 | /** |
---|
| 857 | \brief Sets the PNode, that should be moved along the Tack |
---|
| 858 | \param bindSlave the PNode to set |
---|
| 859 | */ |
---|
| 860 | void TrackManager::setBindSlave(PNode* bindSlave) |
---|
| 861 | { |
---|
[3556] | 862 | this->bindSlave = bindSlave; |
---|
[3433] | 863 | } |
---|
[3350] | 864 | |
---|
[3556] | 865 | /** |
---|
| 866 | \returns the main TrackNode |
---|
| 867 | */ |
---|
| 868 | PNode* TrackManager::getTrackNode(void) |
---|
| 869 | { |
---|
| 870 | return this->trackNode; |
---|
| 871 | } |
---|
[3350] | 872 | |
---|
| 873 | // DEBUG // |
---|
| 874 | |
---|
| 875 | /** |
---|
| 876 | \brief Imports a model of the Graph into the OpenGL-environment. |
---|
| 877 | \param dt The Iterator used in seconds for Painting the Graph. |
---|
| 878 | |
---|
| 879 | This is for testing facility only. Do this if you want to see the Path inside the Level. |
---|
| 880 | eventually this will all be packed into a gl-list. |
---|
| 881 | */ |
---|
| 882 | void TrackManager::drawGraph(float dt) const |
---|
| 883 | { |
---|
| 884 | for (int i = 1; i <= trackElemCount; i++) |
---|
| 885 | { |
---|
[3352] | 886 | glBegin(GL_LINE_STRIP); |
---|
[3350] | 887 | TrackElement* tmpElem = this->findTrackElementByID(i); |
---|
| 888 | if (tmpElem->curve) |
---|
| 889 | for(float f = 0.0; f < 1.0; f+=dt) |
---|
| 890 | { |
---|
| 891 | // printf("%f, %f, %f\n",trackManager->calcPos().x, trackManager->calcPos().y, trackManager->calcPos().z); |
---|
| 892 | Vector tmpVector = tmpElem->curve->calcPos(f); |
---|
| 893 | glVertex3f(tmpVector.x, tmpVector.y, tmpVector.z); |
---|
| 894 | } |
---|
[3710] | 895 | glEnd(); |
---|
[3350] | 896 | } |
---|
| 897 | } |
---|
| 898 | |
---|
[3433] | 899 | /** |
---|
| 900 | \brief outputs debug information about the trackManager |
---|
| 901 | \param level how much debug |
---|
| 902 | */ |
---|
[3350] | 903 | void TrackManager::debug(unsigned int level) const |
---|
| 904 | { |
---|
[3522] | 905 | PRINT(0)("=========================================\n"); |
---|
| 906 | PRINT(0)("= CLASS TRACKMANAGER::debug information =\n"); |
---|
| 907 | PRINT(0)("=========================================\n"); |
---|
| 908 | // PRINT(0)("Status is: % |
---|
| 909 | PRINT(0)(" Consists of %d elements\n", this->trackElemCount); |
---|
| 910 | PRINT(0)(" localTime is: %f\n", this->localTime); |
---|
[3350] | 911 | if (level >= 2) |
---|
| 912 | { |
---|
| 913 | for (int i = 1; i <= trackElemCount; i++) |
---|
| 914 | { |
---|
| 915 | TrackElement* tmpElem = this->findTrackElementByID(i); |
---|
[3593] | 916 | tmpElem->debug(); |
---|
[3350] | 917 | } |
---|
| 918 | } |
---|
[3522] | 919 | PRINT(0)("-----------------------------------------\n"); |
---|
[3350] | 920 | } |
---|