- Timestamp:
- Oct 15, 2005, 8:22:30 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r5372 r5382 235 235 } 236 236 237 237 238 /** 238 239 * @param absCoord set absolute coordinate … … 266 267 } 267 268 269 268 270 /** 269 271 * @param x x-coordinate. … … 287 289 someNode->shiftCoor(objectMovement); 288 290 289 elsewhere you would have to:291 otherwise you would have to: 290 292 PNode* someNode = ...; 291 293 Vector objectMovement = calculateShift(); … … 293 295 Vector newCoor = currentCoor + objectMovement; 294 296 someNode->setRelCoor(newCoor); 295 296 yea right... shorter...297 297 * 298 */298 */ 299 299 void PNode::shiftCoor (const Vector& shift) 300 300 { … … 405 405 * adds a child and makes this node to a parent 406 406 * @param child child reference 407 * @param parentMode on which changes the child should also change ist state408 *409 407 * use this to add a child to this node. 410 408 */ 411 void PNode::addChild (PNode* child , int parentMode)409 void PNode::addChild (PNode* child) 412 410 { 413 411 if( likely(child->parent != NULL)) … … 416 414 child->parent->children->remove(child); 417 415 } 418 child->parentMode = parentMode;419 416 child->parent = this; 420 417 this->children->add(child); … … 461 458 while( pn != NULL) 462 459 { 463 NullParent::getInstance()->addChild(pn , pn->getParentMode());460 NullParent::getInstance()->addChild(pn); 464 461 pn = iterator->nextElement(); 465 462 } … … 494 491 * @param bias the speed to iterate to this new Positions 495 492 */ 496 void PNode::softReparent(PNode* parentNode, float bias) 497 { 493 void PNode::setParentSoft(PNode* parentNode, float bias) 494 { 495 // return if the new parent and the old one match 498 496 if (this->parent == parentNode) 499 497 return; 500 498 499 // store the Valures to iterate to. 501 500 if (likely(this->toCoordinate == NULL)) 502 501 { … … 517 516 parentNode->addChild(this); 518 517 519 if (this->parentMode & PNODE_ROTATE_MOVEMENT )520 this-> setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()));518 if (this->parentMode & PNODE_ROTATE_MOVEMENT && this->parent != NULL) 519 this->relCoordinate = this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()); 521 520 else 522 this-> setRelCoor(tmpV - parentNode->getAbsCoor());523 524 this->setRelDir(tmpQ / parentNode->getAbsDir());521 this->relCoordinate = tmpV - parentNode->getAbsCoor(); 522 523 this->relDirection = tmpQ / parentNode->getAbsDir(); 525 524 } 526 525 … … 530 529 * @param bias the speed to iterate to this new Positions 531 530 */ 532 void PNode::s oftReparent(const char* parentName, float bias)531 void PNode::setParentSoft(const char* parentName, float bias) 533 532 { 534 533 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE)); 535 534 if (parentNode != NULL) 536 this->s oftReparent(parentNode, bias);535 this->setParentSoft(parentNode, bias); 537 536 } 538 537 … … 561 560 if (unlikely(this->toCoordinate != NULL)) 562 561 { 563 Vector moveVect = (*this->toCoordinate - this->getRelCoor()) *fabsf(dt)*bias; 564 562 Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias; 565 563 if (likely(moveVect.len() >= PNODE_ITERATION_DELTA)) 566 564 { … … 701 699 displays the PNode at its position with its rotation as a cube. 702 700 */ 703 void PNode::debugDraw(unsigned int depth, float size, Vectorcolor) const701 void PNode::debugDraw(unsigned int depth, float size, const Vector& color) const 704 702 { 705 703 glMatrixMode(GL_MODELVIEW); -
trunk/src/lib/coord/p_node.h
r5356 r5382 96 96 97 97 98 void addChild (PNode* child , int parentingMode = PNODE_PARENT_MODE_DEFAULT);98 void addChild (PNode* child); 99 99 void addChild (const char* childName); 100 100 void removeChild (PNode* child); … … 106 106 PNode* getParent () const { return this->parent; }; 107 107 108 void s oftReparent(PNode* parentNode, float bias = 1.0);109 void s oftReparent(const char* parentName, float bias = 1.0);108 void setParentSoft(PNode* parentNode, float bias = 1.0); 109 void setParentSoft(const char* parentName, float bias = 1.0); 110 110 111 111 /** @param parentMode sets the parentingMode of this Node */ … … 118 118 119 119 void debug (unsigned int depth = 1, unsigned int level = 0) const; 120 void debugDraw(unsigned int depth = 1, float size = 1.0, Vectorcolor = Vector(1,1,1)) const;120 void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1,1,1)) const; 121 121 122 122 … … 150 150 Vector velocity; //!< Saves the velocity. 151 151 152 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with s oftReparent.and set*CoorSoft)153 Quaternion* toDirection; //!< a direction to which to iterate. (This is used in conjunction with s oftReparent and set*DirSoft)152 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft) 153 Quaternion* toDirection; //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft) 154 154 float bias; //!< how fast to iterate to the given position (default is 1) 155 155 -
trunk/src/lib/graphics/render2D/element_2d.cc
r5378 r5382 555 555 * @param bias the speed to iterate to this new Positions 556 556 */ 557 void Element2D::s oftReparent2D(Element2D* parentNode, float bias)557 void Element2D::setParentSoft2D(Element2D* parentNode, float bias) 558 558 { 559 559 if (this->parent == parentNode) … … 578 578 parentNode->addChild2D(this); 579 579 580 if (this->parentMode & PNODE_ROTATE_MOVEMENT) 580 if (this->parentMode & PNODE_ROTATE_MOVEMENT) //! @todo implement this. 581 581 ;//this->setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor())); 582 582 else 583 this->setRelCoor2D(tmpV - parentNode->getAbsCoor2D()); 584 585 this->setRelDir2D(tmpQ - parentNode->getAbsDir2D()); 583 this->relCoordinate = (tmpV - parentNode->getAbsCoor2D()); 584 this->bRelCoorChanged = true; 585 586 this->relDirection = (tmpQ - parentNode->getAbsDir2D()); 587 this->bRelDirChanged = true; 586 588 } 587 589 … … 591 593 * @param bias the speed to iterate to this new Positions 592 594 */ 593 void Element2D::s oftReparent2D(const char* parentName, float bias)595 void Element2D::setParentSoft2D(const char* parentName, float bias) 594 596 { 595 597 Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D)); 596 598 if (parentNode != NULL) 597 this->s oftReparent2D(parentNode, bias);599 this->setParentSoft2D(parentNode, bias); 598 600 } 599 601 … … 852 854 853 855 854 855 856 /////////////////// 856 857 // NullElement2D // -
trunk/src/lib/graphics/render2D/element_2d.h
r5378 r5382 155 155 Element2D* getParent () const { return this->parent; }; 156 156 157 void s oftReparent2D(Element2D* parentNode, float bias = 1.0);158 void s oftReparent2D(const char* parentName, float bias = 1.0);157 void setParentSoft2D(Element2D* parentNode, float bias = 1.0); 158 void setParentSoft2D(const char* parentName, float bias = 1.0); 159 159 160 160 /** @param parentMode sets the parentingMode of this Node */ … … 207 207 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 208 208 float prevRelDirection; //!< The last Relative Direciton from the last update-Cycle. 209 // float lastAbsDirection;210 209 211 210 Vector velocity; //!< Saves the velocity. 212 211 213 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with s oftReparent.and set*CoorSoft)214 float* toDirection; //!< a direction to which to iterate. (This is used in conjunction with s oftReparent and set*DirSoft)212 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft) 213 float* toDirection; //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft) 215 214 float bias; //!< how fast to iterate to the given position (default is 1) 216 215 -
trunk/src/lib/graphics/render2D/render_2d.cc
r5318 r5382 66 66 void Render2D::registerElement2D(Element2D* element2D) 67 67 { 68 this->element2DList[(int)log2(E2D_DEFAULT_LAYER)]->add(element2D); 68 if (likely(element2D != NULL)) 69 this->element2DList[(int)log2(E2D_DEFAULT_LAYER)]->add(element2D); 69 70 } 71 70 72 71 73 /** … … 88 90 void Render2D::moveToLayer(Element2D* element2D, E2D_LAYER to) 89 91 { 92 if (element2D == NULL) 93 return; 94 95 if (unlikely(pow(2, E2D_LAYER_COUNT ) > to)) 96 to = E2D_DEFAULT_LAYER; 90 97 if (element2D->getLayer() != to) 91 98 { -
trunk/src/lib/shell/shell.cc
r5377 r5382 364 364 2: 365 365 */ 366 lastText->setRelDir2D(- 90);367 lastText->setRelDirSoft2D(0, 10);366 lastText->setRelDir2D(-360); 367 lastText->setRelDirSoft2D(0, 5); 368 368 lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0)); 369 369 lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10); -
trunk/src/world_entities/camera.cc
r5357 r5382 120 120 case VIEW_NORMAL: 121 121 this->toFovy = 60.0; 122 this->s oftReparent("TrackNode");123 this->target->s oftReparent("TrackNode");122 this->setParentSoft("TrackNode"); 123 this->target->setParentSoft("TrackNode"); 124 124 this->setRelCoorSoft(-10, 5, 0); 125 125 this->target->setRelCoorSoft(0,0,0); … … 131 131 132 132 if (!strcmp(this->target->getParent()->getName(), "Player")) 133 this->target->s oftReparent("TrackNode");133 this->target->setParentSoft("TrackNode"); 134 134 else 135 this->target->s oftReparent("Player");135 this->target->setParentSoft("Player"); 136 136 this->getParent()->debug(0); 137 137 138 138 // this->setParent("main-Turret"); 139 139 // this->setParentMode(PNODE_ALL); 140 // this->target->s oftReparent("Player");140 // this->target->setParentSoft("Player"); 141 141 142 142 break; 143 143 case VIEW_FRONT: 144 144 this->toFovy = 120.0; 145 this->s oftReparent("Player");146 this->target->s oftReparent("Player");145 this->setParentSoft("Player"); 146 this->target->setParentSoft("Player"); 147 147 this->setRelCoorSoft(4, 0, 0, 5); 148 148 this->target->setRelCoorSoft(Vector(10,0,0), 5); … … 151 151 case VIEW_LEFT: 152 152 this->toFovy = 90; 153 this->s oftReparent("TrackNode");154 this->target->s oftReparent("TrackNode");153 this->setParentSoft("TrackNode"); 154 this->target->setParentSoft("TrackNode"); 155 155 this->setRelCoorSoft(0, 1, -10, .5); 156 156 this->target->setRelCoorSoft(0,0,0); … … 158 158 case VIEW_RIGHT: 159 159 this->toFovy = 90; 160 this->s oftReparent("TrackNode");161 this->target->s oftReparent("TrackNode");160 this->setParentSoft("TrackNode"); 161 this->target->setParentSoft("TrackNode"); 162 162 this->setRelCoorSoft(Vector(0, 1, 10)); 163 163 this->target->setRelCoorSoft(0,0,0); … … 165 165 case VIEW_TOP: 166 166 this->toFovy= 120; 167 this->s oftReparent("TrackNode");168 this->target->s oftReparent("TrackNode");167 this->setParentSoft("TrackNode"); 168 this->target->setParentSoft("TrackNode"); 169 169 this->setRelCoorSoft(Vector(0, 10, 0)); 170 170 this->target->setRelCoorSoft(0,0,0); … … 215 215 // switching back to Modeling Matrix 216 216 glMatrixMode (GL_MODELVIEW); 217 //this->target->getParent()->getParent()->debugDraw(0, 2, Vector(1,0,0));217 this->target->getParent()->getParent()->debugDraw(0, 2, Vector(1,0,0)); 218 218 } 219 219 -
trunk/src/world_entities/weapons/test_gun.cc
r5357 r5382 62 62 Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); 63 63 //parent->addChild(this->objectComponent1, PNODE_ALL); 64 this->addChild(this->objectComponent1 , PNODE_ALL);64 this->addChild(this->objectComponent1); 65 65 66 66 animation1->setInfinity(ANIM_INF_CONSTANT);
Note: See TracChangeset
for help on using the changeset viewer.