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