Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3342 in orxonox.OLD for orxonox/branches/parenting/src/track.cc


Ignore:
Timestamp:
Jan 5, 2005, 3:18:28 PM (20 years ago)
Author:
patrick
Message:

orxonox/branches/parenting: removed old coordinates.h system now using parenting for the game

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/track.cc

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