Changeset 4992 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Aug 13, 2005, 10:02:40 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/p_node.cc
r4991 r4992 114 114 this->toPosition = NULL; 115 115 this->toDirection = NULL; 116 this->bias = 1.0; 116 117 } 117 118 … … 182 183 } 183 184 184 void PNode::setRelCoorSoft(const Vector& relCoordSoft) 185 /** 186 * sets a new relative position smoothely 187 * @param relCoordSoft the new Position to iterate to 188 * @param bias how fast to iterate to this position 189 */ 190 void PNode::setRelCoorSoft(const Vector& relCoordSoft, float bias) 185 191 { 186 192 if (likely(this->toPosition == NULL)) … … 188 194 189 195 *this->toPosition = relCoordSoft; 190 } 191 192 193 /** 194 * set relative coordinates 196 this->bias = bias; 197 } 198 199 200 /** 201 * set relative coordinates smoothely 195 202 * @param x x-relative coordinates to its parent 196 203 * @param y y-relative coordinates to its parent 197 204 * @param z z-relative coordinates to its parent 198 \see void PNode::setRelCoor (const Vector& relCoord)199 */ 200 void PNode::setRelCoorSoft (float x, float y, float z )201 { 202 this->setRelCoorSoft(Vector(x, y, z) );205 \see void PNode::setRelCoorSoft (const Vector&, float) 206 */ 207 void PNode::setRelCoorSoft (float x, float y, float z, float bias) 208 { 209 this->setRelCoorSoft(Vector(x, y, z), bias); 203 210 } 204 211 … … 295 302 * sets the Relative Direction of this node to its parent in a Smoothed way 296 303 * @param relDirSoft the direction to iterate to smoothely. 297 */ 298 void PNode::setRelDirSoft(const Quaternion& relDirSoft) 304 * @param bias how fast to iterate to the new Direction 305 */ 306 void PNode::setRelDirSoft(const Quaternion& relDirSoft, float bias) 299 307 { 300 308 if (likely(this->toDirection == NULL)) … … 302 310 303 311 *this->toDirection = relDirSoft; 312 this->bias = bias; 304 313 } 305 314 … … 312 321 * main difference is, that here you give a directional vector, that will be translated into a Quaternion 313 322 */ 314 void PNode::setRelDirSoft(float x, float y, float z )315 { 316 this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)) );323 void PNode::setRelDirSoft(float x, float y, float z, float bias) 324 { 325 this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias); 317 326 } 318 327 … … 383 392 if( likely(pNode->parent != NULL)) 384 393 { 385 PRINTF( 3)("PNode::addChild() - reparenting node: removing it and adding it again\n");394 PRINTF(4)("PNode::addChild() - reparenting node: removing it and adding it again\n"); 386 395 pNode->parent->children->remove(pNode); 387 396 } … … 463 472 * @param parentNode the new Node to connect this node to. 464 473 */ 465 void PNode::softReparent(PNode* parentNode) 466 { 474 void PNode::softReparent(PNode* parentNode, float bias) 475 { 476 if (this->parent == parentNode) 477 return; 478 467 479 //this->setRelCoorSoft(this->getRelCoor()); 468 480 if (likely(this->toPosition == NULL)) … … 476 488 *this->toDirection = this->getRelDir(); 477 489 } 490 this->bias = bias; 478 491 479 492 … … 491 504 } 492 505 493 void PNode::softReparent(const char* parentName )506 void PNode::softReparent(const char* parentName, float bias) 494 507 { 495 508 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE)); 496 509 if (parentNode != NULL) 497 this->softReparent(parentNode );510 this->softReparent(parentNode, bias); 498 511 } 499 512 … … 555 568 if (unlikely(this->toPosition != NULL)) 556 569 { 557 Vector moveVect = (*this->toPosition - this->getRelCoor()) *dt ;570 Vector moveVect = (*this->toPosition - this->getRelCoor()) *dt*bias; 558 571 559 572 if (likely(moveVect.len() >= .001)) … … 570 583 if (unlikely(this->toDirection != NULL)) 571 584 { 572 Quaternion rotQuat = (*this->toDirection - this->getRelDir()) *dt ;585 Quaternion rotQuat = (*this->toDirection - this->getRelDir()) *dt*bias; 573 586 574 587 // if (likely(rotQuat.len() >= .001)) -
orxonox/trunk/src/lib/coord/p_node.h
r4991 r4992 62 62 void setRelCoor (const Vector& relCoord); 63 63 void setRelCoor (float x, float y, float z); 64 void setRelCoorSoft(const Vector& relCoordSoft );65 void setRelCoorSoft(float x, float y, float z );64 void setRelCoorSoft(const Vector& relCoordSoft, float bias = 1.0); 65 void setRelCoorSoft(float x, float y, float z, float bias = 1.0); 66 66 /** @returns the relative position */ 67 67 inline const Vector& getRelCoor () const { return this->relCoordinate; }; … … 74 74 void setRelDir (const Quaternion& relDir); 75 75 void setRelDir (float x, float y, float z); 76 void setRelDirSoft(const Quaternion& relDirSoft );77 void setRelDirSoft(float x, float y, float z );76 void setRelDirSoft(const Quaternion& relDirSoft, float bias = 1.0); 77 void setRelDirSoft(float x, float y, float z, float bias = 1.0); 78 78 /** @returns the relative Direction */ 79 79 inline const Quaternion& getRelDir () const { return this->relDirection; }; … … 104 104 PNode* getParent () const { return this->parent; }; 105 105 106 void softReparent(PNode* parentNode );107 void softReparent(const char* parentName );106 void softReparent(PNode* parentNode, float bias = 1.0); 107 void softReparent(const char* parentName, float bias = 1.0); 108 108 109 109 void setParentMode (PARENT_MODE parentMode); … … 144 144 Vector* toPosition; //!< a position to which to iterate. (This is used in conjunction with softReparent.and set*CoorSoft) 145 145 Quaternion* toDirection; //!< a direction to which to iterate. (This is used in conjunction with softReparent and set*DirSoft) 146 float bias; //!< how fast to iterate to the given position (default is 1) 146 147 147 148 PNode* parent; //!< a pointer to the parent node -
orxonox/trunk/src/lib/math/vector.h
r4966 r4992 29 29 /** @param index The index of the "array" @returns the x/y/z coordinate */ 30 30 inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; } 31 /** *@param v The vector to add @returns the addition between two vectors (this + v) */31 /** @param v The vector to add @returns the addition between two vectors (this + v) */ 32 32 inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); }; 33 /** *@param v The vector to add @returns the addition between two vectors (this + v) */33 /** @param v The vector to add @returns the addition between two vectors (this + v) */ 34 34 inline Vector operator+ (const sVec3D& v) const { return Vector(x + v[0], y + v[1], z + v[2]); }; 35 35 /** @param v The vector to add @returns the addition between two vectors (this += v) */ … … 57 57 /** @param f a factor to divide the vector with @returns the vector divided by f (this /= f) */ 58 58 inline const Vector& operator/= (float f) {if (unlikely(f == 0.0)) {this->x=0;this->y=0;this->z=0;} else {this->x /= f; this->y /= f; this->z /= f;} return *this; }; 59 /** \briefcopy constructor @todo (i do not know it this is faster) @param v the vector to assign to this vector. @returns the vector v */59 /** copy constructor @todo (i do not know it this is faster) @param v the vector to assign to this vector. @returns the vector v */ 60 60 inline const Vector& operator= (const Vector& v) { this->x = v.x; this->y = v.y; this->z = v.z; return *this; }; 61 /** \briefcopy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */61 /** copy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */ 62 62 inline const Vector& operator= (const sVec3D& v) { this->x = v[0]; this->y = v[1]; this->z = v[2]; } 63 63 /** @param v: the other vector \return the dot product of the vectors */ … … 65 65 /** @param v: the corss-product partner @returns the cross-product between this and v (this (x) v) */ 66 66 inline Vector cross (const Vector& v) const { return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); } 67 /** \briefscales the this vector with v* @param v the vector to scale this with */67 /** scales the this vector with v* @param v the vector to scale this with */ 68 68 void scale(const Vector& v) { x *= v.x; y *= v.y; z *= v.z; }; 69 69 /** @returns the length of the vector */ 70 70 inline float len() const { return sqrt (x*x+y*y+z*z); } 71 /** \briefnormalizes the vector */71 /** normalizes the vector */ 72 72 inline void normalize() { 73 73 float l = len(); -
orxonox/trunk/src/world_entities/camera.cc
r4989 r4992 98 98 99 99 /** 100 \briefSets a new clipping region101 * @param nearClip The near clip plane102 * @param farClip The far clip plane100 * Sets a new clipping region 101 * @param nearClip The near clip plane 102 * @param farClip The far clip plane 103 103 */ 104 104 void Camera::setClipRegion(float nearClip, float farClip) … … 119 119 case VIEW_NORMAL: 120 120 this->toFovy = 60.0; 121 this->setRelCoorSoft(Vector(-10, 5, 0)); 122 this->target->setRelCoorSoft(Vector(0,0,0)); 121 this->softReparent("TrackNode"); 122 this->target->softReparent("TrackNode"); 123 this->setRelCoorSoft(-10, 5, 0); 124 this->target->setRelCoorSoft(0,0,0); 123 125 break; 124 126 case VIEW_BEHIND: … … 131 133 else 132 134 this->target->softReparent("Player"); 135 this->getParent()->debug(0); 133 136 134 137 // this->setParent("main-Turret"); … … 138 141 break; 139 142 case VIEW_FRONT: 140 this->toFovy = 95.0; 141 this->setRelCoorSoft(Vector(10, 2, 0)); 142 this->target->setRelCoorSoft(Vector(0,0,0)); 143 this->toFovy = 120.0; 144 //this->softReparent("Player"); 145 this->target->softReparent("Player"); 146 this->setRelCoorSoft(4, 0, 0); 147 this->target->setRelCoorSoft(10,0,0); 143 148 break; 144 149 case VIEW_LEFT: 145 150 this->toFovy = 90; 146 this->setRelCoorSoft(Vector(0, 1, -10)); 147 this->target->setRelCoorSoft(Vector(0,0,0)); 151 this->softReparent("TrackNode"); 152 this->target->softReparent("TrackNode"); 153 this->setRelCoorSoft(0, 1, -10, .5); 154 this->target->setRelCoorSoft(0,0,0); 148 155 break; 149 156 case VIEW_RIGHT: 150 157 this->toFovy = 90; 158 this->softReparent("TrackNode"); 159 this->target->softReparent("TrackNode"); 151 160 this->setRelCoorSoft(Vector(0, 1, 10)); 152 this->target->setRelCoorSoft( Vector(0,0,0));161 this->target->setRelCoorSoft(0,0,0); 153 162 break; 154 163 case VIEW_TOP: 155 164 this->toFovy= 120; 165 this->softReparent("TrackNode"); 166 this->target->softReparent("TrackNode"); 156 167 this->setRelCoorSoft(Vector(0, 10, 0)); 157 this->target->setRelCoorSoft( Vector(0,0,0));168 this->target->setRelCoorSoft(0,0,0); 158 169 } 159 170 } … … 169 180 if (tmpFovy > .001) 170 181 this->fovy += (this->toFovy - this->fovy) * dt; 182 183 this->getParent()->debug(2); 184 //this->debug(1); 185 //this->target->debug(1); 171 186 } 172 187 -
orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
r4972 r4992 76 76 this->currentSlotConfig[i].currentWeapon = NULL; 77 77 this->currentSlotConfig[i].nextWeapon = NULL; 78 79 // NAMING 80 char* tmpName; 81 if (this->getName()) 82 { 83 tmpName = new char[strlen(this->getName()) + 10]; 84 sprintf(tmpName, "%s_slot%d", this->getName(), i); 85 } 86 else 87 { 88 tmpName = new char[30]; 89 sprintf(tmpName, "WeaponMan_slot%d", i); 90 } 91 this->currentSlotConfig[i].position.setName(tmpName); 92 delete tmpName; 78 93 } 79 94 … … 131 146 } 132 147 148 /** 149 * sets the Parent of the WeaponManager. 150 * @param parent the parent of the WeaponManager 151 * 152 * this is used, to identify to which ship/man/whatever this WeaponManager is connected. 153 * also all the Slots will be subconnected to this parent. 154 */ 133 155 void WeaponManager::setParent(PNode* parent) 134 156 {
Note: See TracChangeset
for help on using the changeset viewer.