Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 11, 2004, 12:53:43 AM (21 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/player.cc

    r2190 r2551  
    2828
    2929Player::~Player ()
     30
    3031{
    3132}
     
    3334void Player::post_spawn ()
    3435{
    35         travel_speed = 10.0;
     36        travel_speed = 15.0;
    3637        velocity = Vector();
    3738        bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     
    7172void Player::draw ()
    7273{
    73         glMatrixMode(GL_MODELVIEW);
    74         glLoadIdentity();
    75         float matrix[4][4];
    76 
    77         glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
     74  glMatrixMode(GL_MODELVIEW);
     75  glLoadIdentity();
     76  float matrix[4][4];
     77 
     78  glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
    7879  get_placement()->w.matrix (matrix);
    7980  glMultMatrixf ((float*)matrix);
    80        
    81         glBegin(GL_TRIANGLES);
    82         glColor3f(1,0,0);
    83         glVertex3f(0,0,0.5);
    84         glColor3f(0,1,0);
    85         glVertex3f(-0.5,0,-1);
    86         glColor3f(0,0,1);
    87         glVertex3f(0.5,0,-1);
    88         glEnd();
    89        
    90         printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z);
     81 
     82  glBegin(GL_TRIANGLES);
     83  glColor3f(1,1,1);
     84  glVertex3f(0,0,0.5);
     85  glVertex3f(-0.5,0,-1);
     86  glVertex3f(0.5,0,-1);
     87
     88  glVertex3f(0,0,0.5);
     89  glVertex3f(0,0.5,-1);
     90  glVertex3f(0,-0.5,-1);
     91  glEnd();
     92   
     93  glBegin(GL_QUADS);
     94  glColor3f(0,0,1);
     95  glVertex3f(0.5,0.5,-1);
     96  glVertex3f(0.5,-0.5,-1);
     97  glVertex3f(-0.5,-0.5,-1);
     98  glVertex3f(-0.5,0.5,-1);
     99  glEnd();
     100 
     101  //printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z);
    91102}
    92103
     
    103114void Player::move (float time)
    104115{
    105         float xAccel, yAccel, zAccel;
    106         xAccel = yAccel = zAccel = 0;
    107         if( bUp) xAccel += acceleration;
    108         if( bDown) xAccel -= acceleration;
    109         if( bLeft) yAccel += acceleration;
    110         if( bRight) yAccel -= acceleration;
    111         if( bAscend) zAccel += acceleration;
    112         if( bDescend) zAccel -= acceleration;
    113        
    114         Vector accel( xAccel, yAccel, zAccel);
    115        
    116         Location* l = get_location();
    117        
    118         // r(t) = r(0) + v(0)*t + 1/2*a*t^2
    119         // r = position
    120         // v = velocity
    121         // a = acceleration
    122        
    123         l->pos = l->pos + velocity*time + (accel*(0.5*time*time));
    124         l->dist += travel_speed * time;
    125        
    126         velocity = velocity + (accel * time);
    127         printf("Player|velocity %f/%f/%f\n", velocity.x, velocity.y, velocity.z);
     116  Vector accel(0.0, 0.0, 0.0);
     117  /* FIXME: calculating the direction and orthDirection every time_slice is redundant! save it somewhere */
     118  Placement *pos = get_placement();
     119  /* calculate the direction in which the craft is heading  */
     120  Vector direction(0.0, 0.0, 1.0);
     121  direction = pos->w.apply(direction);
     122  Vector orthDirection(0.0, 0.0, 1.0);
     123  orthDirection = orthDirection.cross(direction);
     124
     125  if( bUp) { accel = accel+(direction*acceleration); }
     126  if( bDown) { accel = accel-(direction*acceleration); }
     127  if( bLeft ) { accel = accel + (orthDirection*acceleration); }
     128  if( bRight ) { accel = accel - (orthDirection*acceleration); }
     129  if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
     130  if( bDescend) {/* FIXME */}
     131
     132  Location* l = get_location();
     133 
     134  // r(t) = r(0) + v(0)*t + 1/2*a*t^2
     135  // r = position
     136  // v = velocity
     137  // a = acceleration
     138
     139  /* this the base-speed of the player: determines how fast and how the player follows the track*/
     140  l->dist = l->dist + travel_speed * time;
     141
     142  /* this updates the player position on the track - user interaction */
     143  l->pos = l->pos + accel*time;
    128144}
    129145
Note: See TracChangeset for help on using the changeset viewer.