Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7316 in orxonox.OLD


Ignore:
Timestamp:
Apr 17, 2006, 1:49:05 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: Element2D uses Vector2D instead of Vector whenever possible

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r7221 r7316  
    212212
    213213  // always update the screen center, it could be, that the window is resized
    214   this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f);
     214  this->screenCenter = Vector2D(State::getResX()/2.0f, State::getResY()/2.0f);
    215215
    216216  // flare vector is the direction from the center to the light source
    217217  this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter;
    218   this->flareVector.z = 0.0f;
    219218  this->distance = this->flareVector.len();
    220219  this->flareVector.normalize();
  • trunk/src/lib/graphics/effects/lense_flare.h

    r7221 r7316  
    1111#include <vector>
    1212
    13 #include "vector.h"
     13#include "vector2D.h"
    1414#include "plane.h"
    1515
     
    5252    std::vector<Billboard*>  flares;             //!< the flares array
    5353
    54     Vector                   flareVector;        //!< the axis to draw the flares on
     54    Vector2D                 flareVector;        //!< the axis to draw the flares on
    5555    float                    distance;           //!< distance from center to source
    56     Vector                   screenCenter;       //!< the vector marking the center of the screen
     56    Vector2D                 screenCenter;       //!< the vector marking the center of the screen
    5757
    5858    float*                   flareMatrix;
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7221 r7316  
    246246 * @param relCoord the relative coordinate to the parent
    247247 */
    248 void Element2D::setRelCoor2D (const Vector& relCoord)
     248void Element2D::setRelCoor2D (const Vector2D& relCoord)
    249249{
    250250  if (this->toCoordinate!= NULL)
     
    261261 * @param x the x coordinate
    262262 * @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 */
     264void Element2D::setRelCoor2D (float x, float y)
     265{
     266  this->setRelCoor2D(Vector2D(x,y));
    268267}
    269268
     
    275274void Element2D::setRelCoor2Dpx (int x, int y)
    276275{
    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()));
    281278}
    282279
     
    286283 * @param bias how fast to iterate to this position
    287284 */
    288 void Element2D::setRelCoorSoft2D(const Vector& relCoordSoft, float bias)
     285void Element2D::setRelCoorSoft2D(const Vector2D& relCoordSoft, float bias)
    289286{
    290287  if (likely(this->toCoordinate == NULL))
    291     this->toCoordinate = new Vector();
     288    this->toCoordinate = new Vector2D();
    292289
    293290  *this->toCoordinate = relCoordSoft;
     
    303300void Element2D::setRelCoorSoft2Dpx (int x, int y, float bias)
    304301{
    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()),
    308304                         bias);
    309305}
     
    314310 * @param y y-relative coordinates to its parent
    315311 * @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, float bias)
    319 {
    320   this->setRelCoorSoft2D(Vector(x, y, depth), bias);
     312 * @see  void PNode::setRelCoorSoft (const Vector2D&, float)
     313 */
     314void Element2D::setRelCoorSoft2D(float x, float y, float bias)
     315{
     316  this->setRelCoorSoft2D(Vector2D(x, y), bias);
    321317}
    322318
     
    324320 * @param absCoord set absolute coordinate
    325321 */
    326 void Element2D::setAbsCoor2D (const Vector& absCoord)
     322void Element2D::setAbsCoor2D (const Vector2D& absCoord)
    327323{
    328324  if (this->toCoordinate!= NULL)
     
    355351 * @param y y-coordinate.
    356352 * @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 */
     355void Element2D::setAbsCoor2D (float x, float y)
     356{
     357  this->setAbsCoor2D(Vector2D(x, y));
    362358}
    363359
     
    365361 * @param x x-coordinate in Pixels
    366362 * @param y y-coordinate in Pixels
    367  * @see void PNode::setAbsCoor (const Vector& absCoord)
     363 * @see void PNode::setAbsCoor (const Vector2D& absCoord)
    368364 */
    369365void Element2D::setAbsCoor2Dpx (int x, int y)
    370366{
    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()));
    375369}
    376370
     
    379373 * @param bias how fast to iterato to the new Coordinate
    380374 */
    381 void Element2D::setAbsCoorSoft2D (const Vector& absCoordSoft, float bias)
     375void Element2D::setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias)
    382376{
    383377  if (this->toCoordinate == NULL)
    384     this->toCoordinate = new Vector();
     378    this->toCoordinate = new Vector2D();
    385379
    386380  if( likely(this->parentMode & E2D_PARENT_MOVEMENT))
     
    407401 * @param y y-coordinate.
    408402 * @param z z-coordinate.
    409  * @see void PNode::setAbsCoor (const Vector& absCoord)
    410  */
    411 void Element2D::setAbsCoorSoft2D (float x, float y, float depth, float bias)
    412 {
    413   this->setAbsCoorSoft2D(Vector(x, y, depth), bias);
     403 * @see void PNode::setAbsCoor (const Vector2D& absCoord)
     404 */
     405void Element2D::setAbsCoorSoft2D (float x, float y, float bias)
     406{
     407  this->setAbsCoorSoft2D(Vector2D(x, y), bias);
    414408}
    415409
     
    418412 * @param shift shift vector
    419413 *
    420  * This simply adds the shift-Vector to the relative Coordinate
    421  */
    422 void Element2D::shiftCoor2D (const Vector& shift)
     414 * This simply adds the shift-Vector2D to the relative Coordinate
     415 */
     416void Element2D::shiftCoor2D (const Vector2D& shift)
    423417{
    424418  this->relCoordinate += shift;
     
    434428void Element2D::shiftCoor2Dpx (int x, int y)
    435429{
    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()));
    439432}
    440433
     
    673666  if (likely(this->toCoordinate == NULL))
    674667  {
    675     this->toCoordinate = new Vector();
     668    this->toCoordinate = new Vector2D();
    676669    *this->toCoordinate = this->getRelCoor2D();
    677670  }
     
    684677
    685678
    686   Vector tmpV = this->getAbsCoor2D();
     679  Vector2D tmpV = this->getAbsCoor2D();
    687680  float tmpQ = this->getAbsDir2D();
    688681
     
    779772    if (unlikely(this->toCoordinate != NULL))
    780773    {
    781       Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
     774      Vector2D moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
    782775
    783776      if (likely(moveVect.len() >= .001))//PNODE_ITERATION_DELTA))
     
    787780      else
    788781      {
    789         Vector tmp = *this->toCoordinate;
     782        Vector2D tmp = *this->toCoordinate;
    790783        this->setRelCoor2D(tmp);
    791784        PRINTF(5)("SmoothMove of %s finished\n", this->getName());
     
    825818    this->lastAbsCoordinate = this->absCoordinate;
    826819
    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);
    828821
    829822
     
    841834      this->absCoordinate.x = .5 + this->relCoordinate.x;
    842835      this->absCoordinate.y = .5 + this->relCoordinate.y;
    843       this->absCoordinate.z = 0.0;
    844836    }
    845837    else if (unlikely(this->bindNode != NULL))
     
    864856      this->prevRelCoordinate.x = this->absCoordinate.x = projectPos[0] /* /(float)GraphicsEngine::getInstance()->getResolutionX() */ + this->relCoordinate.x;
    865857      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;
    867858      this->bRelCoorChanged = true;
    868859    }
     
    893884  else
    894885  {
    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);
    896887    if (this->bRelCoorChanged)
    897888    {
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7221 r7316  
    139139    // LIKE PNODE
    140140  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);
    143143    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, float bias = 1.0);
     144    void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0);
     145    void setRelCoorSoft2D (float x, float y, float bias = 1.0);
    146146    void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
    147147    /** @returns the relative position */
    148     inline const Vector& getRelCoor2D () const { return this->prevRelCoordinate; };
     148    inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; };
    149149    /** @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);
    154154    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, float bias = 1.0);
     155    void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
     156    void setAbsCoorSoft2D (float x, float y, float bias = 1.0);
    157157    /** @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);
    162162    void shiftCoor2Dpx (int x, int y);
    163163
     
    177177    inline float getSpeed() const { return 0; };
    178178    /** @returns the Velocity of the Node */
    179     inline const Vector& getVelocity() const { return this->velocity; };
     179    inline const Vector2D& getVelocity() const { return this->velocity; };
    180180
    181181
     
    225225    inline void parentDirChanged2D () { this->bRelDirChanged = true; }
    226226    /** @returns the last calculated coordinate */
    227     inline Vector getLastAbsCoor2D() { return this->lastAbsCoordinate; }
     227    inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; }
    228228
    229229    void reparent2D();
     
    247247    bool                    bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
    248248
    249     Vector                  relCoordinate;      //!< coordinates relative to the parent
    250     Vector                  absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
     249    Vector2D                relCoordinate;      //!< coordinates relative to the parent
     250    Vector2D                absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
    251251    float                   relDirection;       //!< direction relative to the parent
    252252    float                   absDirection;       //!< absolute diretion in the world ( from (0,0,1) )
    253253
    254     Vector                  prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
    255     Vector                  lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
     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
    256256    float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    257257
    258     Vector                  velocity;           //!< Saves the velocity.
    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)
    261261    float*                  toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
    262262    float                   bias;               //!< how fast to iterate to the given position (default is 1)
  • trunk/src/lib/shell/shell.cc

    r7315 r7316  
    128128  EventHandler::getInstance()->withUNICODE(true);
    129129
    130   this->setRelCoorSoft2D(0, 0, 1, 5);
     130  this->setRelCoorSoft2D(0, 0, 5);
    131131
    132132  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
     
    157157  EventHandler::getInstance()->popState();
    158158
    159   this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5);
     159  this->setRelCoorSoft2D(0, -(int)this->shellHeight, 5);
    160160
    161161  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
     
    370370    lastText->setRelDir2D(-90);
    371371    lastText->setRelDirSoft2D(0, 20);
    372     lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0));
     372    lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
    373373    lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10);
    374374
     
    493493
    494494/**
    495  * calculates the position of a Buffer-Display Line
     495 * @brief calculates the position of a Buffer-Display Line
    496496 * @param lineNumber the lineNumber from the bottom to calculate the position from
    497497 * @returns the Position of the Line.
    498498 */
    499 Vector Shell::calculateLinePosition(unsigned int lineNumber)
    500 {
    501   return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber - 2) + this->textSize, 0);
    502 }
    503 
    504 
    505 
    506 /**
    507  * displays some nice output from the Shell
     499Vector2D Shell::calculateLinePosition(unsigned int lineNumber)
     500{
     501  return Vector2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber - 2) + this->textSize);
     502}
     503
     504
     505
     506/**
     507 * @brief displays some nice output from the Shell
    508508 */
    509509void Shell::debug() const
  • trunk/src/lib/shell/shell.h

    r7315 r7316  
    8080  private:
    8181    // helpers //
    82     Vector calculateLinePosition(unsigned int lineNumber);
     82    Vector2D calculateLinePosition(unsigned int lineNumber);
    8383
    8484    //     void testI (int i);
  • trunk/src/lib/shell/shell_buffer.cc

    r7315 r7316  
    2626
    2727/**
    28  * standard constructor
     28 * @brief standard constructor
    2929 */
    3030ShellBuffer::ShellBuffer ()
     
    4545
    4646/**
    47  * standard deconstructor
     47 * @brief standard deconstructor
    4848 */
    4949ShellBuffer::~ShellBuffer ()
     
    6262
    6363/**
    64  * registers the Shell to the Buffer
     64 * @brief registers the Shell to the Buffer
    6565 * @param shell the Shell to register.
    6666 */
     
    7474
    7575/**
    76  * unregisters the Shell from the Buffer
     76 * @brief unregisters the Shell from the Buffer
    7777 * @param shell the Shell to unregister.
    7878 */
     
    8686
    8787/**
    88  * deletes all the Buffers
     88 * @brief deletes all the Buffers
    8989 */
    9090void ShellBuffer::flush()
     
    9494
    9595/**
    96  * adds a new Line to the List of Buffers
     96 * @brief adds a new Line to the List of Buffers
    9797 * @param line the Line as in the first argument in printf
    9898 */
     
    121121
    122122/**
    123  * add a Line to the List of Buffers
     123 * @brief add a Line to the List of Buffers
    124124 * @param line
    125125 * @param arguments
  • trunk/src/story_entities/simple_game_menu.cc

    r7287 r7316  
    181181      this->menuStartGame->setBindNode((const PNode*)NULL);
    182182      this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f,
    183                                         State::getResY() / 2.0f - 60.0f,
    184                                         0.0f);
     183                                        State::getResY() / 2.0f - 60.0f);
    185184      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    186185
     
    191190      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
    192191      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
    193                                                    State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f),
    194                                                    0.0f);
     192                                                   State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
    195193      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    196194    }
     
    200198      this->menuQuitGame->setBindNode((const PNode*)NULL);
    201199      this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f,
    202                                        State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f),
    203                                        0.0f);
     200                                       State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f));
    204201      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    205202    }
     
    225222      te->setVisibility(false);
    226223      te->setText(se->getName());
    227       te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f), 0.0f);
     224      te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f));
    228225      this->menuLayers[1].menuList.push_back(te);
    229226
     
    233230      ie->setBindNode((const PNode*)NULL);
    234231      ie->setTexture(se->getMenuScreenshoot());
    235       ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f, 0.0f);
     232      ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f);
    236233      ie->setSize2D(140.0f, 105.0f);
    237234      this->menuLayers[1].screenshootList.push_back(ie);
     
    453450  if (bias > 0.0)
    454451  {
    455     this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector(0, element->getSizeY2D() *.5,0), bias);
     452    this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias);
    456453    this->menuSelector->setSizeSoft2D(element->getSizeX2D(), element->getSizeY2D(), bias);
    457454  }
    458455  else
    459456  {
    460     this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector(0, element->getSizeY2D() *.5,0));
     457    this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5));
    461458    this->menuSelector->setSize2D(element->getSizeX2D(), element->getSizeY2D());
    462459  }
Note: See TracChangeset for help on using the changeset viewer.