Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4609 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Jun 12, 2005, 11:37:57 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: obb subdivision algorithm started, some modifications in the vector class to support additions with sVec3D

Location:
orxonox/trunk/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/obb_tree.cc

    r4590 r4609  
    9898  int const length = 3;
    9999  sVec3D* vertList = new sVec3D[length];
    100   sVec3D data[length]  = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}};//, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}};
     100  sVec3D data[length]  = {{5.0, 0.0, 0.0},{2.0, 0.0, 0.5},{14.0, 0.0, 0.0}};//, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}};
    101101
    102102  for(int i = 0; i < length; ++i)
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4589 r4609  
    190190  Jacobi(C, D, V);                                            /* do the jacobi decomposition */
    191191
    192   printf("we got a result! YES: \n");
     192  printf("\nwe got a result! YES: \n");
    193193
    194194  for(int j = 1; j < 4; ++j)
     
    207207  box->axis = axis;
    208208
    209   printf("eigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
     209  printf("\neigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
    210210  printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
    211211  printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
     
    216216  float*              halfLength = new float[3];             //!< half length of the axis
    217217  float               tmpLength;                             //!< tmp save point for the length
    218 
    219 
    220   Plane p0(*box->axis[0], *box->center);
    221   Plane p1(*box->axis[1], *box->center);
    222   Plane p2(*box->axis[2], *box->center);
     218  Plane               p0(*box->axis[0], *box->center);       //!< the axis planes
     219  Plane               p1(*box->axis[1], *box->center);
     220  Plane               p2(*box->axis[2], *box->center);
    223221
    224222  halfLength[0] = -1.0f;
     
    249247
    250248
    251   printf("we got length: \n");
     249  printf("\nwe got length: \n");
    252250  for(int i = 0; i < 3; ++i)
    253251    printf("length[%i] = %f\n", i, box->halfLength[i]);
     
    255253
    256254
     255
     256/**
     257  \brief this separates an ob-box in the middle
     258  \param box: the box to separate
     259
     260  this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis
     261 */
    257262void OBBTreeNode::forkBox(OBB* box)
    258263{
    259264  /* get the longest axis of the box */
    260   float aLength = -1.0f;
    261   int axisNr = 0;
     265  float               aLength = -1.0f;                     //!< the length of the longest axis
     266  int                 axisIndex = 0;                       //!< this is the nr of the longest axis
     267
    262268  for(int i = 0; i < 3; ++i)
    263     {
    264       if( aLength < box->axis[i]->len())
    265         {
    266           aLength = box->axis[i]->len();
    267           axisNr = i;
    268         }
    269     }
     269  {
     270    if( aLength < box->halfLength[i])
     271    {
     272      aLength = box->halfLength[i];
     273      axisIndex = i;
     274    }
     275  }
     276
     277  printf("\nlongest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength);
     278
    270279
    271280  /* get the closest vertex near the center */
     281  float               dist = 0.0f;                         //!< the smallest distance to each vertex
     282  float               tmpDist;                             //!< temporary distance
     283  int                 vertexIndex;
     284  Plane               separationPlane(*box->axis[axisIndex], *box->center); //!< the separation plane definition
     285
     286  for(int i = 0; i < box->numOfVertices; ++i)
     287  {
     288    tmpDist = fabs(separationPlane.distancePoint(vertices[i]));
     289    if( tmpDist > dist)
     290      dist = tmpDist;
     291  }
     292
     293
     294  printf("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
     295
    272296
    273297}
  • orxonox/trunk/src/lib/math/vector.h

    r4585 r4609  
    3131  /**  \param v The vector to add \returns the addition between two vectors (this + v) */
    3232  inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); };
     33  /**  \param v The vector to add \returns the addition between two vectors (this + v) */
     34  inline Vector operator+ (const sVec3D& v) const { return Vector(x + v[0], y + v[1], z + v[2]); };
    3335  /** \param v The vector to add  \returns the addition between two vectors (this += v) */
    3436  inline const Vector& operator+= (const Vector& v) { this->x += v.x; this->y += v.y; this->z += v.z; return *this; };
    3537  /** \param v The vector to substract  \returns the substraction between two vectors (this - v) */
     38  inline const Vector& operator+= (const sVec3D& v) { this->x += v[0]; this->y += v[1]; this->z += v[2]; return *this; };
     39  /** \param v The vector to substract  \returns the substraction between two vectors (this - v) */
    3640  inline Vector operator- (const Vector& v) const { return Vector(x - v.x, y - v.y, z - v.z); }
     41  /** \param v The vector to substract  \returns the substraction between two vectors (this - v) */
     42  inline Vector operator- (const sVec3D& v) const { return Vector(x - v[0], y - v[1], z - v[2]); }
    3743  /** \param v The vector to substract  \returns the substraction between two vectors (this -= v) */
    3844  inline const Vector& operator-= (const Vector& v) { this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this; };
     45  /** \param v The vector to substract  \returns the substraction between two vectors (this -= v) */
     46  inline const Vector& operator-= (const sVec3D& v) { this->x -= v[0]; this->y -= v[1]; this->z -= v[2]; return *this; };
    3947  /** \param v the second vector  \returns The dotProduct between two vector (this (dot) v) */
    4048  inline float operator* (const Vector& v) const { return x * v.x + y * v.y + z * v.z; };
Note: See TracChangeset for help on using the changeset viewer.