- Timestamp:
- Oct 15, 2005, 7:13:23 PM (19 years ago)
- Location:
- branches/2d-recalc/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2d-recalc/src/lib/graphics/graphics_engine.cc
r5380 r5381 410 410 depending on how you have your OpenGL state set up. 411 411 */ 412 glPushAttrib(GL_ENABLE_BIT); 412 glPushAttrib(GL_ENABLE_BIT); // storte the state of all enable-bits. 413 413 glDisable(GL_DEPTH_TEST); 414 414 glDisable(GL_CULL_FACE); 415 glDisable(GL_LIGHTING); // will be set back when leaving 2D-mode 416 415 glDisable(GL_LIGHTING); 417 416 glViewport(0, 0, screen->w, screen->h); 418 417 -
branches/2d-recalc/src/lib/graphics/render2D/element_2d.cc
r5380 r5381 111 111 this->setActiveness(true); 112 112 this->setAlignment(E2D_ALIGN_NONE); 113 this->layer = E2D_ TOP;113 this->layer = E2D_DEFAULT_LAYER; 114 114 this->bindNode = NULL; 115 115 … … 254 254 /** 255 255 * sets a node, this 2D-Element should be shown upon 256 * @param bindNode the name of the Node (should be existing)256 * @param bindNode the name of the Node (should already be existing) 257 257 */ 258 258 void Element2D::setBindNode(const char* bindNode) … … 280 280 281 281 /** 282 * sets the relative coordinate of the Element2D to its Parent283 * @param x the x coordinate284 * @param y the y coordinate285 * @param z the z coordinate286 */287 void Element2D::setRelCoor2D (float x, float y, float z)288 {289 this->setRelCoor2D(Vector(x,y,z));290 }291 292 /**293 282 * sets the Relative coordinate to the parent in Pixels 294 283 * @param x the relCoord X … … 299 288 this->setRelCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 300 289 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(), 301 0 302 )); 290 0 )); 303 291 } 304 292 … … 332 320 333 321 /** 334 * set relative coordinates smoothely 335 * @param x x-relative coordinates to its parent 336 * @param y y-relative coordinates to its parent 337 * @param z z-relative coordinates to its parent 338 * @see void PNode::setRelCoorSoft (const Vector&, float) 339 */ 340 void Element2D::setRelCoorSoft2D(float x, float y, float depth, float bias) 341 { 342 this->setRelCoorSoft2D(Vector(x, y, depth), bias); 322 * @returns the Relative coordinate of the Element2D in pixels (as float-Vector) 323 */ 324 Vector Element2D::getRelCoor2Dpx() const 325 { 326 return Vector(this->prevRelCoordinate.x * (float)GraphicsEngine::getInstance()->getResolutionX(), 327 this->prevRelCoordinate.y * (float)GraphicsEngine::getInstance()->getResolutionY(), 328 0); 343 329 } 344 330 … … 374 360 375 361 /** 376 * @param x x-coordinate.377 * @param y y-coordinate.378 * @param z z-coordinate.379 * @see void PNode::setAbsCoor (const Vector& absCoord)380 */381 void Element2D::setAbsCoor2D (float x, float y, float depth)382 {383 this->setAbsCoor2D(Vector(x, y, depth));384 }385 386 /**387 362 * @param x x-coordinate in Pixels 388 363 * @param y y-coordinate in Pixels … … 398 373 399 374 /** 375 * @returns the absolute coordinate of the Element2D in pixels (as float-Vector) 376 */ 377 Vector Element2D::getAbsCoor2Dpx() const 378 { 379 return Vector(this->absCoordinate.x * (float)GraphicsEngine::getInstance()->getResolutionX(), 380 this->absCoordinate.y * (float)GraphicsEngine::getInstance()->getResolutionY(), 381 0); 382 } 383 384 /** 400 385 * shift coordinate ralative 401 386 * @param shift shift vector … … 407 392 this->relCoordinate += shift; 408 393 this->bRelCoorChanged = true; 409 410 394 } 411 395 … … 684 668 PRINTF(5)("Element2D::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 685 669 686 670 // update the direction 687 671 if( this->parentMode & E2D_PARENT_LOCAL_ROTATE && this->bRelDirChanged) 688 672 { 689 /* update the current absDirection - remember * means rotation around sth.*/690 673 this->prevRelDirection = this->relDirection; 691 674 this->absDirection = this->relDirection + parent->getAbsDir2D();; 692 675 } 693 694 676 695 677 if (this->alignment == E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged) … … 700 682 this->absCoordinate.z = 0.0; 701 683 } 702 else if (this->bindNode) 684 // align at the bindNode. 685 else if (unlikely(this->bindNode != NULL)) 703 686 { 704 687 GLdouble projectPos[3]; … … 715 698 this->absCoordinate.y = projectPos[1]/(float)GraphicsEngine::getInstance()->getResolutionY() + this->relCoordinate.y; 716 699 this->absCoordinate.z = projectPos[2] + this->relCoordinate.z; 700 //! @todo check for corectness. 701 // printf("%f, %f, %f\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 717 702 } 718 703 else -
branches/2d-recalc/src/lib/graphics/render2D/element_2d.h
r5380 r5381 2 2 * @file element_2d.h 3 3 * Definition of the 2D elements rendered on top through the GraphicsEngine 4 * 5 * @todo reimplement it, so it looks just like PNode. 6 */ 4 */ 7 5 8 6 #ifndef _ELEMENT_2D_H … … 37 35 E2D_ALIGN_RIGHT = 2, 38 36 E2D_ALIGN_CENTER = 4, 39 E2D_ALIGN_SCREEN_CENTER = 8 37 E2D_ALIGN_SCREEN_CENTER = 8, 40 38 } E2D_ALIGNMENT; 41 39 … … 98 96 inline bool isActive() { return this->active; }; 99 97 100 98 ///////////// 99 // SCALING // 100 ///////////// 101 101 inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; }; 102 102 void setSize2Dpx(int x, int y); … … 110 110 int getSizeY2Dpx() const; 111 111 112 // LIKE PNODE 113 public: 112 // PNODE-STYLE-behavioral 113 public: 114 ///////////////// 115 // COORDINATES // 116 ///////////////// 117 // RELATIVE // 114 118 void setRelCoor2D (const Vector& relCoord); 115 void setRelCoor2D (float x, float y, float dontCare = 1.0); 119 /** @param x x-coordinate. @param y y-coordinate. @param z z-coordinate. @see void PNode::setRelCoor2D (const Vector& absCoord) */ 120 void setRelCoor2D (float x, float y, float dontCare = 1.0) { this->setRelCoor2D(Vector(x, y, dontCare)); }; 116 121 void setRelCoor2Dpx (int x, int y); 122 inline void setRelCoor2Dpx (const Vector& relCoordpx) { this->setRelCoor2D(relCoordpx.x, relCoordpx.y); }; 117 123 void setRelCoorSoft2D (const Vector& relCoordSoft, float bias = 1.0); 118 void setRelCoorSoft2D (float x, float y, float dontCare = 1.0, float bias = 1.0); 124 /** set relative coordinates smoothely @param x x-relative coordinates to its parent 125 * @param y y-relative coordinates to its parent @param z z-relative coordinates to its parent 126 * @see void PNode::setRelCoorSoft (const Vector&, float) */ 127 void setRelCoorSoft2D (float x, float y, float dontCare = 1.0, float bias = 1.0) { this->setRelCoorSoft2D(Vector(x,y, dontCare), bias); }; 119 128 void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0); 120 129 /** @returns the relative position */ … … 122 131 /** @returns the Relative Coordinate Destination */ 123 132 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; }; 124 const Vector& getRelCoor2Dpx() const; 133 Vector getRelCoor2Dpx() const; 134 // ABSOLUTE // 125 135 void setAbsCoor2D (const Vector& absCoord); 126 void setAbsCoor2D (float x, float y, float depth = 1.0); 136 /** @param x x-coordinate. @param y y-coordinate. @param z z-coordinate. @see void PNode::setAbsCoor2D (const Vector& absCoord) */ 137 void setAbsCoor2D (float x, float y, float depth = 1.0) { this->setAbsCoor2D(Vector(x, y, depth)); }; 127 138 void setAbsCoor2Dpx (int x, int y); 128 139 /** @returns the absolute position */ 129 140 inline const Vector& getAbsCoor2D () const { return this->absCoordinate; }; 130 const Vector&getAbsCoor2Dpx () const;141 Vector getAbsCoor2Dpx () const; 131 142 132 143 void shiftCoor2D (const Vector& shift); 133 144 void shiftCoor2Dpx (int x, int y); 134 145 146 /** @returns the Speed of the Node */ 147 inline float getSpeed() const { return 0; }; 148 /** @returns the Velocity of the Node */ 149 inline const Vector& getVelocity() const { return this->velocity; }; 150 151 //////////////// 152 // DIRECTIONS // 153 //////////////// 154 // RELATIVE // 135 155 void setRelDir2D (float relDir); 136 156 void setRelDirSoft2D(float relDirSoft, float bias = 1.0); … … 139 159 /** @returns the Relative Directional Destination */ 140 160 inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; }; 161 // ABSOLUTE // 141 162 void setAbsDir2D (float absDir); 142 163 /** @returns the absolute Direction */ 143 164 inline float getAbsDir2D () const { return this->absDirection; }; 144 165 void shiftDir2D (float shiftDir); 145 146 /** @returns the Speed of the Node */ 147 inline float getSpeed() const { return 0; }; 148 /** @returns the Velocity of the Node */ 149 inline const Vector& getVelocity() const { return this->velocity; }; 150 151 166 /////////////// 167 // PARENTING // 168 /////////////// 152 169 void addChild2D (Element2D* child, int parentingMode = E2D_PARENT_NONE); 153 170 void addChild2D (const char* childName); … … 169 186 int getParentMode2D() const { return this->parentMode; }; 170 187 188 189 ////////////// 190 // HANDLING // 191 ////////////// 171 192 void update2D (float dt); 172 193 … … 192 213 private: 193 214 const PNode* bindNode; //!< a node over which to display this 2D-element 215 bool coordinateType; //!< true if type is [0-1],[0-1]-style, false if type is [0-ResolutionX][0-ResolutionY]-style. 216 194 217 float sizeX; //!< The size of the rendered item in x-direction 195 218 float sizeY; //!< The size of the rendered Item in y-direction … … 212 235 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 213 236 float prevRelDirection; //!< The last Relative Direciton from the last update-Cycle. 214 // float lastAbsDirection;215 237 216 238 Vector velocity; //!< Saves the velocity. -
branches/2d-recalc/src/lib/graphics/render2D/render_2d.cc
r5318 r5381 14 14 */ 15 15 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS 17 17 18 18 #include "render_2d.h" 19 #include "debug.h" 19 20 20 21 #include "graphics_engine.h" … … 88 89 void Render2D::moveToLayer(Element2D* element2D, E2D_LAYER to) 89 90 { 91 // prevent switching Layers if either Render2D is not Instanciated or element2D is NULL 92 if (unlikely(element2D == NULL || this == NULL)) 93 return; 94 if(to > pow(2, E2D_LAYER_COUNT)) 95 { 96 PRINTF(2)("trying to %s (%s) move to a to non-existing layer %d\n", element2D->getName(), element2D->getClassName() ); 97 to = E2D_DEFAULT_LAYER; 98 } 90 99 if (element2D->getLayer() != to) 91 100 { -
branches/2d-recalc/src/lib/graphics/render2D/render_2d.h
r4862 r5381 3 3 * @brief Definition of the 2D-rendering engine singleton Class 4 4 * @todo implement Layer-rendering 5 */5 */ 6 6 7 7 #ifndef _RENDER_2D_H -
branches/2d-recalc/src/lib/shell/shell.cc
r5380 r5381 57 57 ->defaultValues(1, SHELL_DEFAULT_FONT); 58 58 59 59 60 /** 60 61 * standard constructor … … 81 82 this->backgroundMaterial = new Material; 82 83 // Element2D and generals 83 this->textSize = .001;84 this->lineSpacing = .001;84 this->textSize = 16; 85 this->lineSpacing = 1; 85 86 this->bActive = false; 86 87 this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1]; … … 96 97 ShellBuffer::getInstance()->registerShell(this); 97 98 } 99 98 100 99 101 /** … … 115 117 } 116 118 119 117 120 /** 118 121 * activates the shell … … 139 142 } 140 143 144 141 145 /** 142 146 * deactiveates the Shell. … … 162 166 this->bufferOffset = 0; 163 167 } 168 164 169 165 170 /** … … 183 188 this->rebuildText(); 184 189 } 190 185 191 186 192 /** … … 199 205 } 200 206 207 201 208 /** 202 209 * sets the color of the Font. … … 229 236 this->backgroundMaterial->setTransparency(a); 230 237 } 238 231 239 232 240 /** … … 271 279 } 272 280 281 273 282 /** 274 283 * rebuilds the Text's … … 285 294 this->setBufferDisplaySize(this->bufferDisplaySize); 286 295 } 296 287 297 288 298 /** … … 319 329 } 320 330 331 321 332 /** 322 333 * deletes all the Buffers … … 334 345 // BUFFER FLUSHING 335 346 } 347 336 348 337 349 /** … … 374 386 } 375 387 388 376 389 /** 377 390 * moves the Display buffer (up or down) … … 424 437 } 425 438 439 426 440 /** 427 441 * clears the Shell (empties all buffers) … … 432 446 ShellBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL); 433 447 } 448 434 449 435 450 /** … … 459 474 } 460 475 476 461 477 /** 462 478 * displays the Shell … … 487 503 } 488 504 505 489 506 /////////////////////// 490 507 // HELPER FUNCTIONS // 491 508 /////////////////////// 492 493 509 /** 494 510 * calculates the position of a Buffer-Display Line … … 500 516 return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) + this->textSize, 0); 501 517 } 502 503 518 504 519 -
branches/2d-recalc/src/world_entities/weapons/crosshair.cc
r5378 r5381 65 65 this->setLayer(E2D_TOP); 66 66 this->setRotationSpeed(5); 67 this->setSize( GraphicsEngine::getInstance()->getResolutionX()/10.0);67 this->setSize(0.1); 68 68 69 this->setBindNode(this);69 // this->setBindNode(this); 70 70 this->material = new Material; 71 71 … … 73 73 74 74 // center the mouse on the screen, and also hide the cursors 75 SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);75 // SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); 76 76 GraphicsEngine::showMouse(false); 77 77 GraphicsEngine::stealWMEvents(true); … … 121 121 if (event.type == EV_MOUSE_MOTION) 122 122 { 123 this->setAbsCoor2D (event.x, event.y);123 this->setAbsCoor2Dpx(event.x, event.y); 124 124 } 125 125 } … … 134 134 this->shiftDir2D(dt * rotationSpeed); 135 135 136 137 136 float z = 0.0f; 138 glReadPixels ((int)this->getAbsCoor2D ().x,139 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D ().y-1,137 glReadPixels ((int)this->getAbsCoor2Dpx().x, 138 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2Dpx().y-1, 140 139 1, 141 140 1, … … 146 145 147 146 GLdouble objX=.0, objY=.0, objZ=.0; 148 gluUnProject(this->getAbsCoor2D ().x,149 GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D ().y-1,147 gluUnProject(this->getAbsCoor2Dpx().x, 148 GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2Dpx().y-1, 150 149 .99, // z 151 150 GraphicsEngine::modMat, … … 166 165 glPushMatrix(); 167 166 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 167 // printf("%f, %f\n", this->getAbsCoor2D().x, this->getAbsCoor2D().y); 168 168 169 169 glRotatef(this->getAbsDir2D(), 0,0,1); -
branches/2d-recalc/src/world_entities/weapons/weapon_manager.cc
r5208 r5381 106 106 this->crossHairSizeAnim = new tAnimation<Crosshair>(this->crosshair, &Crosshair::setSize); 107 107 this->crossHairSizeAnim->setInfinity(ANIM_INF_REWIND); 108 this->crossHairSizeAnim->addKeyFrame( 50, .1, ANIM_LINEAR);109 this->crossHairSizeAnim->addKeyFrame( 100, .05, ANIM_LINEAR);110 this->crossHairSizeAnim->addKeyFrame( 50, .01, ANIM_LINEAR);108 this->crossHairSizeAnim->addKeyFrame(.1, .1, ANIM_LINEAR); 109 this->crossHairSizeAnim->addKeyFrame(.2, .05, ANIM_LINEAR); 110 this->crossHairSizeAnim->addKeyFrame(.1, .01, ANIM_LINEAR); 111 111 } 112 112
Note: See TracChangeset
for help on using the changeset viewer.