Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5419 in orxonox.OLD


Ignore:
Timestamp:
Oct 22, 2005, 10:55:51 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: MUCH better algorithm for the QuaternionSlerp in PNodes rotate-to function
also updated the Quaternion class, to now hold dot-product and distance

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5414 r5419  
    1111   ### File Specific:
    1212   main-programmer: Patrick Boenzli
    13    co-programmer:
     13   co-programmer: Benjamin Grauer
    1414*/
    1515
     
    630630      if (unlikely(this->toDirection != NULL))
    631631      {
    632         Quaternion rotQuat = Quaternion::quatSlerp(Quaternion(), (*this->toDirection / this->relDirection), fabsf(dt)*this->bias);
    633         if (likely(rotQuat.getSpacialAxisAngle() > PNODE_ITERATION_DELTA))
     632        Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, fabsf(dt)*this->bias);
     633        if (this->relDirection.distance(rotQuat) >PNODE_ITERATION_DELTA)
    634634        {
    635           this->shiftDir(rotQuat);
     635          this->relDirection = rotQuat;
     636          this->bRelDirChanged;
    636637        }
    637638        else
  • trunk/src/lib/graphics/text_engine/text.cc

    r5418 r5419  
    251251        {
    252252          glBegin(GL_QUADS);
     253
    253254          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    254255          glVertex2d(posX, - tmpGlyph->bearingY * this->size);
     256
    255257          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    256258          glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     259
    257260          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    258261          glVertex2d(posX+tmpGlyph->width*this->size, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     262
    259263          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    260264          glVertex2d(posX+tmpGlyph->width*this->size, - tmpGlyph->bearingY*this->size);
     265
    261266          glEnd();
    262267          glEndList();
    263           posX += tmpGlyph->width*this->size;
     268          posX += tmpGlyph->advance * this->size;
    264269        }
    265         tmpText++;
     270        ++tmpText;
    266271      }
    267272    }
  • trunk/src/lib/math/vector.h

    r5215 r5419  
    157157  /** @returns the inverted Quaterntion of this */
    158158  inline Quaternion inverse () const { return conjugate() / (w*w + v.x*v.x + v.y*v.y + v.z*v.z); };
     159  /** @returns the dot Product of a Quaternion */
     160  inline float dot (const Quaternion& q) const { return v.x*q.v.x + v.y*q.v.y + v.z*q.v.z + w*q.w; };
     161  /** @retuns the Distance between two Quaternions */
     162  inline float distance(const Quaternion& q) const { return 2*acos(fabsf(this->dot(q))); };
    159163  /** @param v: the Vector  @return a new Vector representing v rotated by the Quaternion */
    160164  inline Vector apply (const Vector& v) const { return (*this * Quaternion(v, 0) * conjugate()).v; };
  • trunk/src/world_entities/environment.cc

    r5378 r5419  
    3838  this->loadModel("models/ships/bolido.obj");
    3939
    40   if(this->obbTree == NULL)
    41     this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     40/*  if(this->obbTree == NULL)
     41    this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());*/
    4242}
    4343
  • trunk/src/world_entities/test_entity.cc

    r5378 r5419  
    3737//   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    3838// this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    39   this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
     39//  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    4040
    4141  this->md2Model->setAnim(RUN);
  • trunk/src/world_entities/world_entity.cc

    r5378 r5419  
    9898bool WorldEntity::buildObbTree(unsigned int depth)
    9999{
    100   if (this->obbTree)
    101     delete this->obbTree;
    102 
    103   if (this->model)
    104   {
    105     PRINTF(4)("creating obb tree\n");
    106     this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    107     return true;
    108   }
    109   else
    110   {
    111     PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");
    112     this->obbTree = NULL;
    113     return false;
    114   }
     100//   if (this->obbTree)
     101//     delete this->obbTree;
     102//
     103//   if (this->model)
     104//   {
     105//     PRINTF(4)("creating obb tree\n");
     106//     this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     107//     return true;
     108//   }
     109//   else
     110//   {
     111//     PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");
     112//     this->obbTree = NULL;
     113//     return false;
     114//  }
    115115}
    116116
Note: See TracChangeset for help on using the changeset viewer.