Changeset 4570 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 10, 2005, 12:42:35 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/coord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/p_node.cc
r4448 r4570 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 17 17 \todo Smooth-Parent: delay, speed … … 40 40 \brief standard constructor 41 41 */ 42 PNode::PNode () 42 PNode::PNode () 43 43 { 44 44 init(NULL); … … 54 54 this->init(NULL); 55 55 this->loadParams(root); 56 56 57 57 NullParent::getInstance()->addChild(this); 58 58 } … … 80 80 \brief standard deconstructor 81 81 */ 82 PNode::~PNode () 82 PNode::~PNode () 83 83 { 84 84 tIterator<PNode>* iterator = this->children->getIterator(); 85 85 PNode* pn = iterator->nextElement(); 86 while( pn != NULL) 87 { 86 while( pn != NULL) 87 { 88 88 delete pn; 89 89 pn = iterator->nextElement(); … … 106 106 this->bRelDirChanged = true; 107 107 this->bAbsDirChanged = false; 108 this->parent = parent; 108 this->parent = parent; 109 109 } 110 110 … … 161 161 Vector newCoor = currentCoor + objectMovement; 162 162 someNode->setRelCoor(newCoor); 163 163 164 164 yea right... shorter... 165 165 … … 172 172 this->absCoordinate += shift; 173 173 } 174 else 174 else 175 175 { 176 176 this->relCoordinate += shift; … … 223 223 Quaternion newCoor = currentCoor + objectMovement; 224 224 someNode->setRelCoor(newCoor); 225 225 226 226 yea right... shorter... 227 227 … … 278 278 tIterator<PNode>* iterator = this->children->getIterator(); 279 279 PNode* pn = iterator->nextElement(); 280 281 while( pn != NULL) 282 { 280 281 while( pn != NULL) 282 { 283 283 nullParent->addChild(pn, pn->getParentMode()); 284 284 pn = iterator->nextElement(); … … 311 311 /** 312 312 \brief has to be called, if the parent coordinate has changed 313 313 314 314 normaly this will be done by the parent itself automaticaly. If you call this, you 315 315 will force an update of the coordinated of the node. … … 327 327 328 328 this is used to go through the parent-tree to update all the absolute coordinates 329 and directions. this update should be done by the engine, so you don't have to 329 and directions. this update should be done by the engine, so you don't have to 330 330 worry, normaly... 331 331 */ … … 340 340 341 341 if( likely(this->parentMode & PNODE_MOVEMENT)) 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;/* update the current absCoordinate */360 361 362 342 { 343 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 344 { 345 /* if you have set the absolute coordinates this overrides all other changes */ 346 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 347 } 348 if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 349 350 { 351 /*this is bad style... must be deleted later - just for testing*/ 352 353 /* 354 if( unlikely(this->parent == NULL)) 355 { 356 *this->absCoordinate = *this->relCoordinate; 357 } 358 else */ 359 this->absCoordinate = parent->getAbsCoor() + this->relCoordinate; /* update the current absCoordinate */ 360 } 361 } 362 363 363 if( this->parentMode & PNODE_LOCAL_ROTATE) 364 365 366 367 368 369 370 371 372 373 374 375 376 364 { 365 if( unlikely(this->bAbsDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 366 { 367 /* if you have set the absolute coordinates this overrides all other changes */ 368 this->relDirection = this->absDirection - parent->getAbsDir(); 369 } 370 else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 371 { 372 /* update the current absDirection - remember * means rotation around sth.*/ 373 this->absDirection = parent->getAbsDir() * this->relDirection; 374 } 375 } 376 377 377 if( this->parentMode & PNODE_ROTATE_MOVEMENT) 378 379 380 381 382 383 384 385 386 387 388 389 390 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);/* update the current absCoordinate */391 392 393 394 378 { 379 if( unlikely(this->bAbsCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 380 { 381 /* if you have set the absolute coordinates this overrides all other changes */ 382 this->relCoordinate = this->absCoordinate - parent->getAbsCoor (); 383 } 384 else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/) 385 { 386 /*this is bad style... must be deleted later - just for testing*/ 387 /*if( this->parent == NULL) 388 *this->absCoordinate = *this->relCoordinate; 389 else*/ 390 this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate); /* update the current absCoordinate */ 391 } 392 } 393 394 395 395 tIterator<PNode>* iterator = this->children->getIterator(); 396 396 //PNode* pn = this->children->enumerate(); 397 397 PNode* pn = iterator->nextElement(); 398 while( pn != NULL) 399 { 400 401 402 403 404 405 406 407 408 409 398 while( pn != NULL) 399 { 400 /* if this node has changed, make sure, that all children are updated also */ 401 if( likely(this->bRelCoorChanged || this->bAbsCoorChanged)) 402 pn->parentCoorChanged (); 403 if( likely(this->bRelDirChanged || this->bAbsDirChanged)) 404 pn->parentDirChanged (); 405 406 pn->update(dt); 407 //pn = this->children->nextElement(); 408 pn = iterator->nextElement(); 409 } 410 410 delete iterator; 411 411 … … 425 425 //PNode* pn = this->children->enumerate (); 426 426 PNode* pn = iterator->nextElement(); 427 while( pn != NULL) 428 { 429 430 431 432 433 434 435 436 437 427 while( pn != NULL) 428 { 429 /* if this node has changed, make sure, that all children are updated also */ 430 if( this->bRelCoorChanged || this->bAbsCoorChanged) 431 pn->parentCoorChanged (); 432 if( this->bRelDirChanged || this->bAbsDirChanged) 433 pn->parentDirChanged (); 434 pn->update (dt); 435 //pn = this->children->nextElement (); 436 pn = iterator->nextElement(); 437 } 438 438 439 439 this->bRelCoorChanged = false; … … 449 449 void PNode::debug() 450 450 { 451 PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 452 this->absCoordinate.x, 453 this->absCoordinate.y, 454 this->absCoordinate.z); 455 } 456 451 PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n", 452 this->absCoordinate.x, 453 this->absCoordinate.y, 454 this->absCoordinate.z); 455 } 456 457 /** 458 @brief displays the PNode at its position with its rotation as a cube. 459 */ 460 void PNode::debugDraw(float size) const 461 { 462 glMatrixMode(GL_MODELVIEW); 463 glPushMatrix(); 464 float matrix[4][4]; 465 466 /* translate */ 467 glTranslatef (this->getAbsCoor ().x, 468 this->getAbsCoor ().y, 469 this->getAbsCoor ().z); 470 /* rotate */ 471 this->getAbsDir ().matrix (matrix); 472 glMultMatrixf((float*)matrix); 473 { 474 glBegin(GL_LINE_STRIP); 475 glVertex3f( .5, .5, -.5); 476 glVertex3f( .5, .5, .5); 477 glVertex3f(-.5, .5, .5); 478 glVertex3f(-.5, -.5, .5); 479 glVertex3f( .5, .5, -.5); 480 glVertex3f( .5, -.5, -.5); 481 glVertex3f(-.5, -.5, -.5); 482 glVertex3f(-.5, .5, -.5); 483 glEnd(); 484 glBegin(GL_LINE_STRIP); 485 glVertex3f(-.5, -.5, -.5); 486 glVertex3f(-.5, -.5, .5); 487 glVertex3f( .5, -.5, .5); 488 glVertex3f( .5, -.5, -.5); 489 glEnd(); 490 glBegin(GL_LINES); 491 glVertex3f( .5, -.5, .5); 492 glVertex3f( .5, .5, .5); 493 glVertex3f(-.5, -.5, .5); 494 glVertex3f(-.5, .5, .5); 495 glEnd(); 496 } 497 498 glPopMatrix(); 499 } -
orxonox/trunk/src/lib/coord/p_node.h
r4448 r4570 1 /*! 1 /*! 2 2 \file p_node.h 3 3 \brief Definition of a parenting node … … 9 9 10 10 absCoordinate, absDirection have to be recalculated as soon as there was a change in 11 place or ortientation. this is only the case if 11 place or ortientation. this is only the case if 12 12 o bDirChanged is true (so changed) AND timeStamp != now 13 13 o bCoorChanged is true (so moved) AND timeStamp != now … … 78 78 79 79 /** \returns the Speed of the Node */ 80 inline float getSpeed() const {return this->velocity.len();} 80 inline float getSpeed() const {return this->velocity.len();} 81 81 /** \returns the Velocity of the Node */ 82 82 inline const Vector& getVelocity() const {return this->velocity;} … … 95 95 96 96 void debug (); 97 97 void debugDraw(float size = 1.0) const; 98 98 99 99 private: … … 128 128 129 129 #endif /* _P_NODE_H */ 130 130
Note: See TracChangeset
for help on using the changeset viewer.