Changeset 7316 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- Apr 17, 2006, 1:49:05 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r7221 r7316 246 246 * @param relCoord the relative coordinate to the parent 247 247 */ 248 void Element2D::setRelCoor2D (const Vector & relCoord)248 void Element2D::setRelCoor2D (const Vector2D& relCoord) 249 249 { 250 250 if (this->toCoordinate!= NULL) … … 261 261 * @param x the x coordinate 262 262 * @param y the y coordinate 263 * @param z the z coordinate 264 */ 265 void Element2D::setRelCoor2D (float x, float y, float z) 266 { 267 this->setRelCoor2D(Vector(x,y,z)); 263 */ 264 void Element2D::setRelCoor2D (float x, float y) 265 { 266 this->setRelCoor2D(Vector2D(x,y)); 268 267 } 269 268 … … 275 274 void Element2D::setRelCoor2Dpx (int x, int y) 276 275 { 277 this->setRelCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 278 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(), 279 0 280 )); 276 this->setRelCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 277 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 281 278 } 282 279 … … 286 283 * @param bias how fast to iterate to this position 287 284 */ 288 void Element2D::setRelCoorSoft2D(const Vector & relCoordSoft, float bias)285 void Element2D::setRelCoorSoft2D(const Vector2D& relCoordSoft, float bias) 289 286 { 290 287 if (likely(this->toCoordinate == NULL)) 291 this->toCoordinate = new Vector ();288 this->toCoordinate = new Vector2D(); 292 289 293 290 *this->toCoordinate = relCoordSoft; … … 303 300 void Element2D::setRelCoorSoft2Dpx (int x, int y, float bias) 304 301 { 305 this->setRelCoorSoft2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 306 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(), 307 0), 302 this->setRelCoorSoft2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 303 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()), 308 304 bias); 309 305 } … … 314 310 * @param y y-relative coordinates to its parent 315 311 * @param z z-relative coordinates to its parent 316 * @see void PNode::setRelCoorSoft (const Vector &, float)317 */ 318 void Element2D::setRelCoorSoft2D(float x, float y, float depth, floatbias)319 { 320 this->setRelCoorSoft2D(Vector (x, y, depth), bias);312 * @see void PNode::setRelCoorSoft (const Vector2D&, float) 313 */ 314 void Element2D::setRelCoorSoft2D(float x, float y, float bias) 315 { 316 this->setRelCoorSoft2D(Vector2D(x, y), bias); 321 317 } 322 318 … … 324 320 * @param absCoord set absolute coordinate 325 321 */ 326 void Element2D::setAbsCoor2D (const Vector & absCoord)322 void Element2D::setAbsCoor2D (const Vector2D& absCoord) 327 323 { 328 324 if (this->toCoordinate!= NULL) … … 355 351 * @param y y-coordinate. 356 352 * @param z z-coordinate. 357 * @see void PNode::setAbsCoor (const Vector & absCoord)358 */ 359 void Element2D::setAbsCoor2D (float x, float y , float depth)360 { 361 this->setAbsCoor2D(Vector (x, y, depth));353 * @see void PNode::setAbsCoor (const Vector2D& absCoord) 354 */ 355 void Element2D::setAbsCoor2D (float x, float y) 356 { 357 this->setAbsCoor2D(Vector2D(x, y)); 362 358 } 363 359 … … 365 361 * @param x x-coordinate in Pixels 366 362 * @param y y-coordinate in Pixels 367 * @see void PNode::setAbsCoor (const Vector & absCoord)363 * @see void PNode::setAbsCoor (const Vector2D& absCoord) 368 364 */ 369 365 void Element2D::setAbsCoor2Dpx (int x, int y) 370 366 { 371 this->setAbsCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 372 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(), 373 0 374 )); 367 this->setAbsCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 368 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 375 369 } 376 370 … … 379 373 * @param bias how fast to iterato to the new Coordinate 380 374 */ 381 void Element2D::setAbsCoorSoft2D (const Vector & absCoordSoft, float bias)375 void Element2D::setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias) 382 376 { 383 377 if (this->toCoordinate == NULL) 384 this->toCoordinate = new Vector ();378 this->toCoordinate = new Vector2D(); 385 379 386 380 if( likely(this->parentMode & E2D_PARENT_MOVEMENT)) … … 407 401 * @param y y-coordinate. 408 402 * @param z z-coordinate. 409 * @see void PNode::setAbsCoor (const Vector & absCoord)410 */ 411 void Element2D::setAbsCoorSoft2D (float x, float y, float depth, floatbias)412 { 413 this->setAbsCoorSoft2D(Vector (x, y, depth), bias);403 * @see void PNode::setAbsCoor (const Vector2D& absCoord) 404 */ 405 void Element2D::setAbsCoorSoft2D (float x, float y, float bias) 406 { 407 this->setAbsCoorSoft2D(Vector2D(x, y), bias); 414 408 } 415 409 … … 418 412 * @param shift shift vector 419 413 * 420 * This simply adds the shift-Vector to the relative Coordinate421 */ 422 void Element2D::shiftCoor2D (const Vector & shift)414 * This simply adds the shift-Vector2D to the relative Coordinate 415 */ 416 void Element2D::shiftCoor2D (const Vector2D& shift) 423 417 { 424 418 this->relCoordinate += shift; … … 434 428 void Element2D::shiftCoor2Dpx (int x, int y) 435 429 { 436 this->shiftCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 437 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(), 438 0)); 430 this->shiftCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 431 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 439 432 } 440 433 … … 673 666 if (likely(this->toCoordinate == NULL)) 674 667 { 675 this->toCoordinate = new Vector ();668 this->toCoordinate = new Vector2D(); 676 669 *this->toCoordinate = this->getRelCoor2D(); 677 670 } … … 684 677 685 678 686 Vector tmpV = this->getAbsCoor2D();679 Vector2D tmpV = this->getAbsCoor2D(); 687 680 float tmpQ = this->getAbsDir2D(); 688 681 … … 779 772 if (unlikely(this->toCoordinate != NULL)) 780 773 { 781 Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;774 Vector2D moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias; 782 775 783 776 if (likely(moveVect.len() >= .001))//PNODE_ITERATION_DELTA)) … … 787 780 else 788 781 { 789 Vector tmp = *this->toCoordinate;782 Vector2D tmp = *this->toCoordinate; 790 783 this->setRelCoor2D(tmp); 791 784 PRINTF(5)("SmoothMove of %s finished\n", this->getName()); … … 825 818 this->lastAbsCoordinate = this->absCoordinate; 826 819 827 PRINTF(5)("Element2D::update - %s - (%f, %f , %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);820 PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y); 828 821 829 822 … … 841 834 this->absCoordinate.x = .5 + this->relCoordinate.x; 842 835 this->absCoordinate.y = .5 + this->relCoordinate.y; 843 this->absCoordinate.z = 0.0;844 836 } 845 837 else if (unlikely(this->bindNode != NULL)) … … 864 856 this->prevRelCoordinate.x = this->absCoordinate.x = projectPos[0] /* /(float)GraphicsEngine::getInstance()->getResolutionX() */ + this->relCoordinate.x; 865 857 this->prevRelCoordinate.y = this->absCoordinate.y = (float)GraphicsEngine::getInstance()->getResolutionY() - projectPos[1] + this->relCoordinate.y; 866 this->prevRelCoordinate.z = this->absCoordinate.z = projectPos[2] + this->relCoordinate.z;867 858 this->bRelCoorChanged = true; 868 859 } … … 893 884 else 894 885 { 895 PRINTF(5)("Element2D::update - (%f, %f , %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);886 PRINTF(5)("Element2D::update - (%f, %f)\n", this->absCoordinate.x, this->absCoordinate.y); 896 887 if (this->bRelCoorChanged) 897 888 { -
trunk/src/lib/graphics/render2D/element_2d.h
r7221 r7316 139 139 // LIKE PNODE 140 140 public: 141 void setRelCoor2D (const Vector & relCoord);142 void setRelCoor2D (float x, float y , float dontCare = 1.0);141 void setRelCoor2D (const Vector2D& relCoord); 142 void setRelCoor2D (float x, float y); 143 143 void setRelCoor2Dpx (int x, int y); 144 void setRelCoorSoft2D (const Vector & relCoordSoft, float bias = 1.0);145 void setRelCoorSoft2D (float x, float y, float dontCare = 1.0, floatbias = 1.0);144 void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0); 145 void setRelCoorSoft2D (float x, float y, float bias = 1.0); 146 146 void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0); 147 147 /** @returns the relative position */ 148 inline const Vector & getRelCoor2D () const { return this->prevRelCoordinate; };148 inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; }; 149 149 /** @returns the Relative Coordinate Destination */ 150 inline const Vector & getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };151 const Vector & getRelCoor2Dpx() const;152 void setAbsCoor2D (const Vector & absCoord);153 void setAbsCoor2D (float x, float y , float depth = 1.0);150 inline const Vector2D& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; }; 151 const Vector2D& getRelCoor2Dpx() const; 152 void setAbsCoor2D (const Vector2D& absCoord); 153 void setAbsCoor2D (float x, float y); 154 154 void setAbsCoor2Dpx (int x, int y); 155 void setAbsCoorSoft2D (const Vector & absCoordSoft, float bias = 1.0);156 void setAbsCoorSoft2D (float x, float y, float depth = 1.0, floatbias = 1.0);155 void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0); 156 void setAbsCoorSoft2D (float x, float y, float bias = 1.0); 157 157 /** @returns the absolute position */ 158 inline const Vector & getAbsCoor2D () const { return this->absCoordinate; };159 const Vector & getAbsCoor2Dpx () const;160 161 void shiftCoor2D (const Vector & shift);158 inline const Vector2D& getAbsCoor2D () const { return this->absCoordinate; }; 159 const Vector2D& getAbsCoor2Dpx () const; 160 161 void shiftCoor2D (const Vector2D& shift); 162 162 void shiftCoor2Dpx (int x, int y); 163 163 … … 177 177 inline float getSpeed() const { return 0; }; 178 178 /** @returns the Velocity of the Node */ 179 inline const Vector & getVelocity() const { return this->velocity; };179 inline const Vector2D& getVelocity() const { return this->velocity; }; 180 180 181 181 … … 225 225 inline void parentDirChanged2D () { this->bRelDirChanged = true; } 226 226 /** @returns the last calculated coordinate */ 227 inline Vector getLastAbsCoor2D() { return this->lastAbsCoordinate; }227 inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; } 228 228 229 229 void reparent2D(); … … 247 247 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked 248 248 249 Vector 250 Vector 249 Vector2D relCoordinate; //!< coordinates relative to the parent 250 Vector2D absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) ) 251 251 float relDirection; //!< direction relative to the parent 252 252 float absDirection; //!< absolute diretion in the world ( from (0,0,1) ) 253 253 254 Vector 255 Vector 254 Vector2D prevRelCoordinate; //!< The last Relative Coordinate from the last update-Cycle. 255 Vector2D lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 256 256 float prevRelDirection; //!< The last Relative Direciton from the last update-Cycle. 257 257 258 Vector 259 260 Vector *toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)258 Vector2D velocity; //!< Saves the velocity. 259 260 Vector2D* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft) 261 261 float* toDirection; //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft) 262 262 float bias; //!< how fast to iterate to the given position (default is 1)
Note: See TracChangeset
for help on using the changeset viewer.