Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3365 in orxonox.OLD for orxonox/trunk/src/track.cc


Ignore:
Timestamp:
Jan 7, 2005, 1:14:33 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged branches/parenting back to the.
merged with command:
svn merge branches/parenting trunk -r 3247:HEAD
resolved all conflicts in favor of parenting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/track.cc

    r3232 r3365  
    2929  this->end = NULL;
    3030  this->nextID = 0;
     31  this->setClassName ("Track");
    3132}
    3233
     
    4445  this->end = finish;
    4546  this->nextID = next;
     47  this->setClassName ("Track");
    4648}
    4749
     
    5961
    6062
    61 /**
    62    \brief calculate a camera Placement from a "look at"-Location
    63    \param lookat: the Location the camera should be centered on
    64    \param camplc: pointer to a buffer where the new camera Placement should be put into
    65    
    66    Theoretically you can place the camera wherever you want, but for the sake of
    67    common sense I suggest that you at least try to keep the thing that should be looked
    68    at inside camera boundaries.
    69 */
    70 void Track::mapCamera (Location* lookat, Placement* camplc)
    71 {
    72   Line trace(*offset, *end - *offset);
    73   float l = trace.len ();
    74  
    75   //    camplc->r = *offset + Vector(0,0,0.5);
    76   //    camplc->w = Quaternion (trace.a, Vector(0,0,1));
    77   float r = (lookat->dist)*PI / l;
    78   camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
    79  
    80   Vector w(0.0,0.0,0.0);
    81   w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
    82   //Vector up(0.0,sin(r),cos(r)); // corrupt...
    83   Vector up(0.0, 0.0, 1.0);
    8463
    85   camplc->w = Quaternion(w, up);
    86 
    87   //printf("\n------\nup vector: [%f, %f, %f]\n", up.x, up.y, up.z);
    88   //printf("direction: [%f, %f, %f]\n", w.x, w.y, w.z);
    89   //printf("quaternion: w[ %f ], v[ %f, %f, %f ]\n", camplc->w.w, camplc->w.v.x, camplc->w.v.y, camplc->w.v.z);
    90 }
    91 
    92 /**
    93    \brief calculate a Placement from a given Location
    94    \param loc: the Location the entity is in
    95    \param plc: a pointer to a buffer where the corresponding Placement should be put
    96    into
    97    \return: true if track changes - false if track stays
    98    
    99    There are no limitations to how you transform a Location into a Placement, but for
    100    the sake of placement compatibility between track parts you should make sure that
    101    the resulting Placement at dist == 0 is equal to the offset Vector and the Placement
    102    at dist == len() is equal to the end Vector. Elseway there will be ugly artifacts
    103    when transfering between track parts.
    104 */
    105 bool Track::mapCoords (Location* loc, Placement* plc)
    106 {
    107   Line trace(*offset, *end - *offset);
    108   float l = trace.len ();
    109  
    110   /* change to the next track? */
    111   if( loc->dist > l)
    112     {
    113       loc->dist -= l;
    114       loc->part = nextID;
    115       //FIXME: loc->track = this;
    116       return true;
    117     }
    118  
    119   /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of
    120    * the track */
    121   Quaternion dir(trace.a, Vector(0,0,1));
    122  
    123   plc->r = trace.r + (trace.a * ((loc->dist) / l)) + /*dir.apply*/(loc->pos);
    124   plc->w = dir * loc->rot;
    125  
    126   return false;
    127 }
    12864
    12965
Note: See TracChangeset for help on using the changeset viewer.