Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 11, 2004, 12:53:43 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: minor changes - enhanced sc controll, fixed uncontrolled rotation effect, added some debug outputs for testing purposes, reformatted some src files from win style but not all

File:
1 edited

Legend:

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

    r2190 r2551  
    5454
    5555/**
    56         \brief calculate a camera Placement from a "look at"-Location
    57         \param lookat: the Location the camera should be centered on
    58         \param camplc: pointer to a buffer where the new camera Placement should be put into
    59        
    60         Theoretically you can place the camera wherever you want, but for the sake of common sense I suggest that you at least
    61         try to keep the thing that should be looked at inside camera boundaries.
     56   \brief calculate a camera Placement from a "look at"-Location
     57   \param lookat: the Location the camera should be centered on
     58   \param camplc: pointer to a buffer where the new camera Placement should be put into
     59   
     60   Theoretically you can place the camera wherever you want, but for the sake of
     61   common sense I suggest that you at least try to keep the thing that should be looked
     62   at inside camera boundaries.
    6263*/
    6364void Track::map_camera (Location* lookat, Placement* camplc)
    6465{
    65         Line trace(*offset, *end - *offset);
    66         float l = trace.len ();
    67        
    68 //      camplc->r = *offset + Vector(0,0,0.5);
    69 //      camplc->w = Quaternion (trace.a, Vector(0,0,1));
    70         float r = (lookat->dist)*PI / l;
    71         camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
    72         camplc->w = Quaternion(Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r)), Vector(0,sin(r),cos(r)));
    73        
     66  Line trace(*offset, *end - *offset);
     67  float l = trace.len ();
     68 
     69  //    camplc->r = *offset + Vector(0,0,0.5);
     70  //    camplc->w = Quaternion (trace.a, Vector(0,0,1));
     71  float r = (lookat->dist)*PI / l;
     72  camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
     73 
     74  Vector w(0.0,0.0,0.0);
     75  w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
     76  //Vector up(0.0,sin(r),cos(r)); // corrupt...
     77  Vector up(0.0, 0.0, 1.0);
     78
     79  camplc->w = Quaternion(w, up);
     80
     81  //printf("\n------\nup vector: [%f, %f, %f]\n", up.x, up.y, up.z);
     82  //printf("direction: [%f, %f, %f]\n", w.x, w.y, w.z);
     83  //printf("quaternion: w[ %f ], v[ %f, %f, %f ]\n", camplc->w.w, camplc->w.v.x, camplc->w.v.y, camplc->w.v.z);
    7484}
    7585
    7686/**
    77         \brief calculate a Placement from a given Location
    78         \param loc: the Location the entity is in
    79         \param plc: a pointer to a buffer where the corresponding Placement should be put into
    80        
    81         There are no limitations to how you transform a Location into a Placement, but for the sake of placement compatibility between
    82         track parts you should make sure that the resulting Placement at dist == 0 is equal to the offset Vector and the Placement at
    83         dist == len() is equal to the end Vector. Elseway there will be ugly artifacts when transfering between track parts.
     87   \brief calculate a Placement from a given Location
     88   \param loc: the Location the entity is in
     89   \param plc: a pointer to a buffer where the corresponding Placement should be put
     90   into
     91   \return: true if track changes - false if track stays
     92   
     93   There are no limitations to how you transform a Location into a Placement, but for
     94   the sake of placement compatibility between track parts you should make sure that
     95   the resulting Placement at dist == 0 is equal to the offset Vector and the Placement
     96   at dist == len() is equal to the end Vector. Elseway there will be ugly artifacts
     97   when transfering between track parts.
    8498*/
    8599bool Track::map_coords (Location* loc, Placement* plc)
     
    88102        float l = trace.len ();
    89103       
     104        /* change to the next track? */
    90105        if( loc->dist > l)
    91106        {
    92107                loc->dist -= l;
    93108                loc->part = nextID;
     109                //FIXME: loc->track = this;
    94110                return true;
    95111        }
    96112       
    97         Quaternion dir(trace.a, Vector(0,0,1));
    98        
     113        /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of
     114         * the track */
     115        Quaternion dir(trace.a, Vector(0,0,1));
     116
    99117        plc->r = trace.r + (trace.a * ((loc->dist) / l)) + /*dir.apply*/(loc->pos);
    100118        plc->w = dir * loc->rot;
     
    107125        \param entity: pointer to the WorldEntity in question
    108126       
    109         You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
     127        You can do stuff like add or remove effects, do some coordinate finetuning
     128        or whatever in here.
    110129*/
    111130void Track::post_enter (WorldEntity* entity)
     
    117136        \param entity: pointer to the WorldEntity in question
    118137       
    119         You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
     138        You can do stuff like add or remove effects, do some coordinate finetuning
     139        or whatever in here.
    120140*/
    121141void Track::post_leave (WorldEntity* entity)
Note: See TracChangeset for help on using the changeset viewer.