Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    {
Note: See TracChangeset for help on using the changeset viewer.