[3246] | 1 | |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
| 12 | |
---|
| 13 | ### File Specific: |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
[3551] | 15 | co-programmer: |
---|
[3365] | 16 | |
---|
| 17 | \todo Smooth-Parent: delay, speed |
---|
[3246] | 18 | */ |
---|
| 19 | |
---|
[3590] | 20 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PNODE |
---|
[3246] | 21 | |
---|
| 22 | #include "p_node.h" |
---|
[3607] | 23 | #include "stdincl.h" |
---|
[3860] | 24 | #include "compiler.h" |
---|
[3543] | 25 | |
---|
[3608] | 26 | #include "error.h" |
---|
| 27 | #include "debug.h" |
---|
| 28 | #include "list.h" |
---|
| 29 | #include "vector.h" |
---|
[3521] | 30 | #include "null_parent.h" |
---|
[3608] | 31 | |
---|
[3607] | 32 | //#include "vector.h" |
---|
| 33 | //#include "quaternion.h" |
---|
[3246] | 34 | |
---|
| 35 | using namespace std; |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | \brief standard constructor |
---|
| 40 | |
---|
| 41 | \todo this constructor is not jet implemented - do it |
---|
| 42 | */ |
---|
[3365] | 43 | PNode::PNode () |
---|
| 44 | { |
---|
[3552] | 45 | init(NULL); |
---|
[3529] | 46 | |
---|
| 47 | NullParent* np = NullParent::getInstance(); |
---|
| 48 | np->addChild(this); |
---|
[3365] | 49 | } |
---|
[3246] | 50 | |
---|
| 51 | |
---|
[3799] | 52 | |
---|
[3246] | 53 | /** |
---|
[3365] | 54 | \brief constructor with coodinates |
---|
[3450] | 55 | \param absCoordinate the Absolute coordinate of the Object |
---|
| 56 | \param parent The parent-node of this node. |
---|
[3365] | 57 | */ |
---|
[3809] | 58 | PNode::PNode (const Vector& absCoordinate, PNode* parent ) |
---|
[3365] | 59 | { |
---|
[3552] | 60 | this->init(parent); |
---|
[3365] | 61 | |
---|
[3809] | 62 | *this->absCoordinate = absCoordinate; |
---|
[3800] | 63 | |
---|
[3860] | 64 | if (likely(parent != NULL)) |
---|
[3800] | 65 | { |
---|
| 66 | *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor (); |
---|
| 67 | parent->addChild (this); |
---|
| 68 | } |
---|
[3554] | 69 | else |
---|
[3813] | 70 | this->relCoordinate = new Vector(); |
---|
[3365] | 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
[3246] | 74 | \brief standard deconstructor |
---|
| 75 | */ |
---|
[3365] | 76 | PNode::~PNode () |
---|
| 77 | { |
---|
[3804] | 78 | tIterator<PNode>* iterator = this->children->getIterator(); |
---|
| 79 | PNode* pn = iterator->nextElement(); |
---|
[3544] | 80 | while( pn != NULL) |
---|
| 81 | { |
---|
[3560] | 82 | delete pn; |
---|
[3804] | 83 | pn = iterator->nextElement(); |
---|
[3551] | 84 | } |
---|
[3804] | 85 | delete iterator; |
---|
[3544] | 86 | /* this deletes all children in the list */ |
---|
| 87 | delete this->children; |
---|
[3804] | 88 | this->parent = NULL; |
---|
| 89 | delete []this->objectName; |
---|
[3544] | 90 | |
---|
[3804] | 91 | delete this->relCoordinate; |
---|
| 92 | delete this->absCoordinate; |
---|
| 93 | delete this->relDirection; |
---|
| 94 | delete this->absDirection; |
---|
| 95 | delete this->lastAbsCoordinate; |
---|
| 96 | delete this->diffCoordinate; |
---|
[3365] | 97 | } |
---|
[3246] | 98 | |
---|
[3607] | 99 | |
---|
[3552] | 100 | void PNode::init(PNode* parent) |
---|
| 101 | { |
---|
| 102 | this->children = new tList<PNode>(); |
---|
| 103 | this->bRelCoorChanged = true; |
---|
| 104 | this->bAbsCoorChanged = false; |
---|
| 105 | this->bRelDirChanged = true; |
---|
| 106 | this->bAbsDirChanged = false; |
---|
| 107 | this->parent = parent; |
---|
| 108 | this->objectName = NULL; |
---|
[3813] | 109 | this->time = 1.0; /* set time to 1 to make divisions by zero impossible */ |
---|
[3607] | 110 | |
---|
| 111 | this->absCoordinate = new Vector(); |
---|
| 112 | this->relCoordinate = new Vector(); |
---|
| 113 | this->absDirection = new Quaternion(); |
---|
| 114 | this->relDirection = new Quaternion(); |
---|
[3644] | 115 | this->lastAbsCoordinate = new Vector(); |
---|
[3802] | 116 | this->diffCoordinate = new Vector(); |
---|
[3552] | 117 | } |
---|
[3365] | 118 | |
---|
| 119 | |
---|
[3531] | 120 | |
---|
[3365] | 121 | /** |
---|
| 122 | \brief get relative coordinates |
---|
| 123 | \returns relative coordinates to its parent |
---|
[3675] | 124 | |
---|
| 125 | the reference that is returned is a pointer to the real relCoor, so don't |
---|
| 126 | change it unless you realy know what you are doing. |
---|
[3365] | 127 | */ |
---|
[3804] | 128 | //Vector* PNode::getRelCoor () const |
---|
[3365] | 129 | |
---|
| 130 | |
---|
[3804] | 131 | |
---|
[3365] | 132 | /** |
---|
| 133 | \brief set relative coordinates |
---|
[3450] | 134 | \param relCoord relative coordinates to its parent |
---|
[3365] | 135 | |
---|
| 136 | it is very importand, that you use this function, if you want to update the |
---|
| 137 | relCoordinates. If you don't use this, the PNode won't recognize, that something |
---|
| 138 | has changed and won't update the children Nodes. |
---|
| 139 | */ |
---|
[3810] | 140 | /* |
---|
[3365] | 141 | void PNode::setRelCoor (Vector* relCoord) |
---|
| 142 | { |
---|
| 143 | this->bRelCoorChanged = true; |
---|
[3607] | 144 | *this->relCoordinate = *relCoord; |
---|
[3365] | 145 | } |
---|
[3810] | 146 | */ |
---|
[3365] | 147 | |
---|
| 148 | |
---|
| 149 | /** |
---|
[3675] | 150 | \brief set relative coordinates |
---|
| 151 | \param relCoord relative coordinates to its parent |
---|
| 152 | |
---|
| 153 | it is very importand, that you use this function, if you want to update the |
---|
| 154 | relCoordinates. If you don't use this, the PNode won't recognize, that something |
---|
| 155 | has changed and won't update the children Nodes. |
---|
| 156 | */ |
---|
[3810] | 157 | void PNode::setRelCoor (const Vector& relCoord) |
---|
[3675] | 158 | { |
---|
| 159 | this->bRelCoorChanged = true; |
---|
| 160 | *this->relCoordinate = relCoord; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | /** |
---|
[3365] | 165 | \brief get absolute coordinates |
---|
| 166 | \returns absolute coordinates from (0,0,0) |
---|
| 167 | */ |
---|
[3804] | 168 | //Vector PNode::getAbsCoor () const |
---|
[3365] | 169 | |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | /** |
---|
[3675] | 175 | \param absCoord set absolute coordinate |
---|
| 176 | |
---|
| 177 | it is very importand, that you use this function, if you want to update the |
---|
| 178 | absCoordinates. If you don't use this, the PNode won't recognize, that something |
---|
| 179 | has changed and won't update the children Nodes. |
---|
| 180 | */ |
---|
[3809] | 181 | void PNode::setAbsCoor (const Vector& absCoord) |
---|
[3675] | 182 | { |
---|
| 183 | this->bAbsCoorChanged = true; |
---|
| 184 | *this->absCoordinate = absCoord; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | /** |
---|
[3365] | 189 | \brief shift coordinate (abs and rel) |
---|
| 190 | \param shift vector |
---|
| 191 | |
---|
| 192 | this function shifts the current coordinates about the vector shift. this is |
---|
| 193 | usefull because from some place else you can: |
---|
| 194 | PNode* someNode = ...; |
---|
| 195 | Vector objectMovement = calculateShift(); |
---|
| 196 | someNode->shiftCoor(objectMovement); |
---|
| 197 | |
---|
| 198 | elsewhere you would have to: |
---|
| 199 | PNode* someNode = ...; |
---|
| 200 | Vector objectMovement = calculateShift(); |
---|
| 201 | Vector currentCoor = someNode->getRelCoor(); |
---|
| 202 | Vector newCoor = currentCoor + objectMovement; |
---|
| 203 | someNode->setRelCoor(newCoor); |
---|
| 204 | |
---|
| 205 | yea right... shorter... |
---|
| 206 | |
---|
| 207 | */ |
---|
[3809] | 208 | void PNode::shiftCoor (const Vector& shift) |
---|
[3683] | 209 | { |
---|
[3800] | 210 | |
---|
[3860] | 211 | if( unlikely(this->bAbsCoorChanged)) |
---|
[3683] | 212 | { |
---|
| 213 | *this->absCoordinate = *this->absCoordinate + shift; |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
| 217 | *this->relCoordinate = *this->relCoordinate + shift; |
---|
| 218 | this->bRelCoorChanged = true; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | /** |
---|
[3365] | 225 | \brief get relative direction |
---|
| 226 | \returns relative direction to its parent |
---|
| 227 | */ |
---|
[3804] | 228 | //Quaternion* PNode::getRelDir () const |
---|
[3365] | 229 | |
---|
| 230 | |
---|
[3804] | 231 | |
---|
[3365] | 232 | /** |
---|
| 233 | \brief set relative direction |
---|
[3450] | 234 | \param relDir to its parent |
---|
[3365] | 235 | |
---|
| 236 | it is very importand, that you use this function, if you want to update the |
---|
| 237 | relDirection. If you don't use this, the PNode won't recognize, that something |
---|
| 238 | has changed and won't update the children Nodes. |
---|
| 239 | */ |
---|
[3810] | 240 | void PNode::setRelDir (const Quaternion& relDir) |
---|
[3675] | 241 | { |
---|
| 242 | this->bRelCoorChanged = true; |
---|
| 243 | *this->relDirection = relDir; |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | |
---|
[3365] | 247 | /** |
---|
| 248 | \brief gets the absolute direction (0,0,1) |
---|
| 249 | \returns absolute coordinates |
---|
| 250 | */ |
---|
[3804] | 251 | //Quaternion PNode::getAbsDir () const |
---|
[3365] | 252 | |
---|
| 253 | |
---|
[3804] | 254 | |
---|
[3365] | 255 | /** |
---|
| 256 | \brief sets the absolute direction (0,0,1) |
---|
[3450] | 257 | \param absDir absolute coordinates |
---|
[3365] | 258 | |
---|
| 259 | it is very importand, that you use this function, if you want to update the |
---|
| 260 | absDirection. If you don't use this, the PNode won't recognize, that something |
---|
| 261 | has changed and won't update the children Nodes. |
---|
| 262 | */ |
---|
[3810] | 263 | void PNode::setAbsDir (const Quaternion& absDir) |
---|
[3675] | 264 | { |
---|
| 265 | this->bAbsDirChanged = true; |
---|
| 266 | *this->absDirection = absDir; |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | /** |
---|
[3365] | 272 | \brief shift coordinate (abs and rel) |
---|
| 273 | \param shift vector |
---|
| 274 | |
---|
| 275 | this function shifts the current coordinates about the vector shift. this is |
---|
| 276 | usefull because from some place else you can: |
---|
| 277 | PNode* someNode = ...; |
---|
| 278 | Quaternion objectMovement = calculateShift(); |
---|
| 279 | someNode->shiftCoor(objectMovement); |
---|
| 280 | |
---|
| 281 | elsewhere you would have to: |
---|
| 282 | PNode* someNode = ...; |
---|
| 283 | Quaternion objectMovement = calculateShift(); |
---|
| 284 | Quaternion currentCoor = someNode->getRelCoor(); |
---|
| 285 | Quaternion newCoor = currentCoor + objectMovement; |
---|
| 286 | someNode->setRelCoor(newCoor); |
---|
| 287 | |
---|
| 288 | yea right... shorter... |
---|
| 289 | |
---|
[3450] | 290 | \todo implement this |
---|
[3365] | 291 | */ |
---|
[3802] | 292 | void PNode::shiftDir (const Quaternion& shift) |
---|
| 293 | { |
---|
| 294 | this->bRelDirChanged = true; |
---|
| 295 | *this->relDirection = *this->relDirection * shift; |
---|
| 296 | } |
---|
[3365] | 297 | |
---|
[3644] | 298 | |
---|
[3683] | 299 | |
---|
| 300 | /** |
---|
[3644] | 301 | \brief this calculates the current movement speed of the node |
---|
| 302 | */ |
---|
[3802] | 303 | float PNode::getSpeed() const |
---|
[3644] | 304 | { |
---|
[3802] | 305 | *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate; |
---|
| 306 | return this->diffCoordinate->len() / this->time; |
---|
[3644] | 307 | } |
---|
| 308 | |
---|
| 309 | |
---|
| 310 | /** |
---|
[3365] | 311 | \brief adds a child and makes this node to a parent |
---|
[3450] | 312 | \param pNode child reference |
---|
| 313 | \param mode on which changes the child should also change ist state |
---|
[3365] | 314 | |
---|
| 315 | use this to add a child to this node. |
---|
| 316 | */ |
---|
[3565] | 317 | void PNode::addChild (PNode* pNode, int parentingMode) |
---|
[3365] | 318 | { |
---|
[3860] | 319 | if( likely(pNode->parent != NULL)) |
---|
[3521] | 320 | { |
---|
[3668] | 321 | PRINTF(3)("PNode::addChild() - reparenting node: removing it and adding it again\n"); |
---|
[3547] | 322 | pNode->parent->children->remove(pNode); |
---|
[3521] | 323 | } |
---|
[3565] | 324 | pNode->mode = parentingMode; |
---|
[3529] | 325 | pNode->parent = this; |
---|
| 326 | this->children->add(pNode); |
---|
[3365] | 327 | } |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | /** |
---|
[3450] | 331 | \brief removes a child from the node |
---|
| 332 | \param pNode the child to remove from this pNode. |
---|
[3547] | 333 | |
---|
| 334 | Children from pNode will not be lost, they are referenced to NullPointer |
---|
[3365] | 335 | */ |
---|
| 336 | void PNode::removeChild (PNode* pNode) |
---|
| 337 | { |
---|
[3547] | 338 | pNode->remove(); |
---|
[3669] | 339 | this->children->remove (pNode); |
---|
[3521] | 340 | pNode->parent = NULL; |
---|
[3365] | 341 | } |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | /** |
---|
[3537] | 345 | \brief remove this pnode from the tree and adds all following to NullParent |
---|
| 346 | |
---|
| 347 | this can be the case, if an entity in the world is been destroyed. |
---|
| 348 | */ |
---|
| 349 | void PNode::remove() |
---|
| 350 | { |
---|
[3662] | 351 | NullParent* nullParent = NullParent::getInstance(); |
---|
| 352 | |
---|
[3668] | 353 | tIterator<PNode>* iterator = this->children->getIterator(); |
---|
| 354 | PNode* pn = iterator->nextElement(); |
---|
| 355 | |
---|
[3537] | 356 | while( pn != NULL) |
---|
| 357 | { |
---|
[3662] | 358 | nullParent->addChild(pn, pn->getMode()); |
---|
[3668] | 359 | pn = iterator->nextElement(); |
---|
[3537] | 360 | } |
---|
[3668] | 361 | delete iterator; |
---|
[3669] | 362 | this->parent->children->remove(this); |
---|
[3537] | 363 | } |
---|
| 364 | |
---|
| 365 | |
---|
| 366 | /** |
---|
[3365] | 367 | \brief sets the parent of this PNode |
---|
[3450] | 368 | \param parent the Parent to set |
---|
[3365] | 369 | */ |
---|
| 370 | void PNode::setParent (PNode* parent) |
---|
| 371 | { |
---|
[3511] | 372 | parent->addChild(this); |
---|
[3365] | 373 | } |
---|
| 374 | |
---|
[3535] | 375 | |
---|
[3365] | 376 | /** |
---|
| 377 | \brief set the mode of this parent manualy |
---|
[3450] | 378 | \param mode the mode of the bind-type. |
---|
[3365] | 379 | */ |
---|
[3565] | 380 | void PNode::setMode (int parentingMode) |
---|
[3365] | 381 | { |
---|
[3565] | 382 | this->mode = parentingMode; |
---|
[3365] | 383 | } |
---|
| 384 | |
---|
[3537] | 385 | |
---|
[3365] | 386 | /** |
---|
[3537] | 387 | \brief gets the mode of this parent manualy |
---|
| 388 | \return the mode of the bind-type. |
---|
| 389 | */ |
---|
[3811] | 390 | int PNode::getMode() const |
---|
[3537] | 391 | { |
---|
| 392 | return this->mode; |
---|
| 393 | } |
---|
| 394 | |
---|
[3811] | 395 | |
---|
[3537] | 396 | /** |
---|
[3365] | 397 | \brief has to be called, if the parent coordinate has changed |
---|
| 398 | |
---|
| 399 | normaly this will be done by the parent itself automaticaly. If you call this, you |
---|
| 400 | will force an update of the coordinated of the node. |
---|
| 401 | */ |
---|
[3813] | 402 | /* |
---|
[3365] | 403 | void PNode::parentCoorChanged () |
---|
| 404 | { |
---|
| 405 | this->bRelCoorChanged = true; |
---|
| 406 | } |
---|
[3813] | 407 | */ |
---|
[3365] | 408 | |
---|
| 409 | |
---|
| 410 | /** |
---|
| 411 | \brief has to be called, if the parent direction has changed |
---|
| 412 | |
---|
| 413 | normaly this will be done by the parent itself automaticaly. If you call this, you |
---|
| 414 | will force an update of the direction of the node. |
---|
| 415 | */ |
---|
[3813] | 416 | /* |
---|
[3365] | 417 | void PNode::parentDirChanged () |
---|
| 418 | { |
---|
| 419 | this->bRelDirChanged = true; |
---|
| 420 | } |
---|
[3813] | 421 | */ |
---|
[3365] | 422 | |
---|
| 423 | |
---|
| 424 | /** |
---|
| 425 | \brief updates the absCoordinate/absDirection |
---|
[3450] | 426 | \param timeStamp The timestanp used for to look if calculations should be done |
---|
[3365] | 427 | |
---|
| 428 | this is used to go through the parent-tree to update all the absolute coordinates |
---|
| 429 | and directions. this update should be done by the engine, so you don't have to |
---|
| 430 | worry, normaly... |
---|
| 431 | */ |
---|
[3644] | 432 | void PNode::update (float dt) |
---|
[3365] | 433 | { |
---|
[3687] | 434 | *this->lastAbsCoordinate = *this->absCoordinate; |
---|
[3644] | 435 | this->time = dt; |
---|
[3617] | 436 | PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z); |
---|
[3800] | 437 | |
---|
| 438 | |
---|
[3860] | 439 | if( likely(this->mode & PNODE_MOVEMENT)) |
---|
[3565] | 440 | { |
---|
[3860] | 441 | if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3365] | 442 | { |
---|
[3565] | 443 | /* if you have set the absolute coordinates this overrides all other changes */ |
---|
[3607] | 444 | *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor (); |
---|
[3365] | 445 | } |
---|
[3860] | 446 | if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3800] | 447 | |
---|
[3365] | 448 | { |
---|
[3565] | 449 | /*this is bad style... must be deleted later - just for testing*/ |
---|
[3800] | 450 | |
---|
| 451 | /* |
---|
[3860] | 452 | if( unlikely(this->parent == NULL)) |
---|
[3365] | 453 | { |
---|
[3607] | 454 | *this->absCoordinate = *this->relCoordinate; |
---|
[3365] | 455 | } |
---|
[3800] | 456 | else */ |
---|
| 457 | *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate; /* update the current absCoordinate */ |
---|
[3534] | 458 | } |
---|
[3565] | 459 | } |
---|
| 460 | |
---|
| 461 | if( this->mode & PNODE_LOCAL_ROTATE) |
---|
| 462 | { |
---|
[3860] | 463 | if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3534] | 464 | { |
---|
[3565] | 465 | /* if you have set the absolute coordinates this overrides all other changes */ |
---|
[3607] | 466 | *this->relDirection = *this->absDirection - parent->getAbsDir(); |
---|
[3534] | 467 | } |
---|
[3860] | 468 | else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3565] | 469 | { |
---|
| 470 | /* update the current absDirection - remember * means rotation around sth.*/ |
---|
[3607] | 471 | *this->absDirection = parent->getAbsDir() * *this->relDirection; |
---|
[3565] | 472 | } |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | if( this->mode & PNODE_ROTATE_MOVEMENT) |
---|
| 476 | { |
---|
[3860] | 477 | if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3565] | 478 | { |
---|
| 479 | /* if you have set the absolute coordinates this overrides all other changes */ |
---|
[3607] | 480 | *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor (); |
---|
[3565] | 481 | } |
---|
[3860] | 482 | else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) |
---|
[3565] | 483 | { |
---|
| 484 | /*this is bad style... must be deleted later - just for testing*/ |
---|
[3800] | 485 | /*if( this->parent == NULL) |
---|
[3607] | 486 | *this->absCoordinate = *this->relCoordinate; |
---|
[3800] | 487 | else*/ |
---|
| 488 | *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate); /* update the current absCoordinate */ |
---|
[3565] | 489 | } |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | |
---|
[3669] | 493 | tIterator<PNode>* iterator = this->children->getIterator(); |
---|
| 494 | //PNode* pn = this->children->enumerate(); |
---|
| 495 | PNode* pn = iterator->nextElement(); |
---|
[3365] | 496 | while( pn != NULL) |
---|
| 497 | { |
---|
| 498 | /* if this node has changed, make sure, that all children are updated also */ |
---|
[3860] | 499 | if( likely(this->bRelCoorChanged || this->bAbsCoorChanged)) |
---|
[3365] | 500 | pn->parentCoorChanged (); |
---|
[3860] | 501 | if( likely(this->bRelDirChanged || this->bAbsDirChanged)) |
---|
[3365] | 502 | pn->parentDirChanged (); |
---|
[3608] | 503 | |
---|
[3644] | 504 | pn->update(dt); |
---|
[3669] | 505 | //pn = this->children->nextElement(); |
---|
| 506 | pn = iterator->nextElement(); |
---|
[3365] | 507 | } |
---|
[3669] | 508 | delete iterator; |
---|
[3365] | 509 | |
---|
| 510 | this->timeStamp = timeStamp; |
---|
| 511 | this->bRelCoorChanged = false; |
---|
| 512 | this->bAbsCoorChanged = false; |
---|
| 513 | this->bRelDirChanged = false; |
---|
| 514 | this->bAbsDirChanged = false; |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | |
---|
[3450] | 518 | /** |
---|
[3365] | 519 | \brief tick |
---|
[3450] | 520 | \param dt time to tick |
---|
[3365] | 521 | */ |
---|
| 522 | void PNode::processTick (float dt) |
---|
| 523 | { |
---|
[3551] | 524 | //this->tick (dt); |
---|
[3832] | 525 | /* |
---|
[3365] | 526 | PNode* pn = this->children->enumerate(); |
---|
| 527 | while( pn != NULL) |
---|
| 528 | { |
---|
| 529 | pn->processTick (dt); |
---|
| 530 | pn = this->children->nextElement(); |
---|
| 531 | } |
---|
[3832] | 532 | */ |
---|
[3365] | 533 | } |
---|
| 534 | |
---|
| 535 | |
---|
[3450] | 536 | /** |
---|
| 537 | \brief displays some information about this pNode |
---|
| 538 | */ |
---|
[3365] | 539 | void PNode::debug() |
---|
| 540 | { |
---|
[3546] | 541 | PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", |
---|
[3607] | 542 | this->absCoordinate->x, |
---|
| 543 | this->absCoordinate->y, |
---|
| 544 | this->absCoordinate->z); |
---|
[3365] | 545 | } |
---|
| 546 | |
---|
| 547 | |
---|
[3450] | 548 | /** |
---|
[3365] | 549 | \brief set the name of the node |
---|
| 550 | |
---|
| 551 | for debug purposes realy usefull, not used to work properly |
---|
| 552 | */ |
---|
| 553 | void PNode::setName (char* newName) |
---|
| 554 | { |
---|
[3552] | 555 | this->objectName = new char[strlen(newName)+1]; |
---|
| 556 | strcpy(this->objectName,newName); |
---|
[3365] | 557 | } |
---|
| 558 | |
---|
| 559 | |
---|
[3450] | 560 | /** |
---|
[3365] | 561 | \brief gets the name of the node |
---|
| 562 | */ |
---|
| 563 | char* PNode::getName () |
---|
| 564 | { |
---|
| 565 | return this->objectName; |
---|
| 566 | } |
---|
[3521] | 567 | |
---|