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