Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3238 in orxonox.OLD for orxonox/branches/sound/src/player.cc


Ignore:
Timestamp:
Dec 20, 2004, 2:42:54 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches: updated branches: buerli, nico, sound. And moved bezierTrack to old.bezierTrack. Conflicts resolved in a usefull order.
Conflics mostly resolved in favor of trunk
merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/src/player.cc

    r2640 r3238  
    2525Player::Player(bool isFree) : WorldEntity(isFree)
    2626{
    27 }
    2827
    29 Player::~Player ()
     28  this->obj = new Object("reaplow.obj");
     29  /*
     30  objectList = glGenLists(1);
     31  glNewList (objectList, GL_COMPILE);
    3032
    31 {
    32 }
    33 
    34 void Player::post_spawn ()
    35 {
    36         travel_speed = 15.0;
    37         velocity = Vector();
    38         bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    39         bFire = false;
    40         acceleration = 10.0;
    41         set_collision (new CollisionCluster (1.0, Vector(0,0,0)));
    42 }
    43 
    44 void Player::tick (float time)
    45 {
    46         // movement
    47         move (time);
    48 }
    49 
    50 void Player::hit (WorldEntity* weapon, Vector loc)
    51 {
    52 }
    53 
    54 void Player::destroy ()
    55 {
    56 }
    57 
    58 void Player::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags)
    59 {
    60 }
    61 
    62 void Player::command (Command* cmd)
    63 {
    64   //printf("Player|recieved command [%s]\n", cmd->cmd);
    65   if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
    66   else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
    67   else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
    68   else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
    69   else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
    70 }
    71 
    72 void Player::draw ()
    73 {
    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);
    79   get_placement()->w.matrix (matrix);
    80   glMultMatrixf ((float*)matrix);
    81  
    8233  glBegin(GL_TRIANGLES);
    8334  glColor3f(1,1,1);
     
    9950  glEnd();
    10051 
    101   //printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z);
     52  glEndList ();
     53  */
    10254}
    10355
    104 void Player::get_lookat (Location* locbuf)
     56Player::~Player()
    10557{
    106         *locbuf = *get_location();
    107         //locbuf->dist += 5.0;
     58  delete this->obj;
    10859}
    10960
    110 void Player::left_world ()
     61void Player::postSpawn()
     62{
     63  travelSpeed = 15.0;
     64  velocity = Vector();
     65  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     66  bFire = false;
     67  acceleration = 10.0;
     68  setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
     69}
     70
     71void Player::tick(float time)
     72{
     73  // movement
     74  move (time);
     75}
     76
     77void Player::hit(WorldEntity* weapon, Vector loc)
    11178{
    11279}
    11380
    114 void Player::move (float time)
     81void Player::destroy()
     82{
     83}
     84
     85void Player::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)
     86{
     87}
     88
     89void Player::command(Command* cmd)
     90{
     91  //printf("Player|recieved command [%s]\n", cmd->cmd);
     92  if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
     93  else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
     94  else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
     95  else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
     96  else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
     97}
     98
     99void Player::draw()
     100{
     101  glMatrixMode(GL_MODELVIEW);
     102  glLoadIdentity();
     103  float matrix[4][4];
     104 
     105  glTranslatef(getPlacement()->r.x, getPlacement()->r.y, getPlacement()->r.z);
     106  getPlacement()->w.matrix (matrix);
     107  glMultMatrixf((float*)matrix);
     108 
     109  glMatrixMode(GL_MODELVIEW);
     110  glRotatef(-90, 0,1,0);
     111  obj->draw();
     112  // glCallList(objectList);
     113
     114 
     115 
     116}
     117
     118void Player::getLookat(Location* locbuf)
     119{
     120  *locbuf = *getLocation();
     121  //locbuf->dist += 5.0;
     122}
     123
     124void Player::leftWorld()
     125{
     126}
     127
     128void Player::move(float time)
    115129{
    116130  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();
     131  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
     132  Placement *pos = getPlacement();
    119133  /* calculate the direction in which the craft is heading  */
    120134  Vector direction(0.0, 0.0, 1.0);
     
    128142  if( bRight ) { accel = accel - (orthDirection*acceleration); }
    129143  if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
    130   if( bDescend) {/* FIXME */}
     144  if( bDescend) {/* FIXME */} /* \todo up and down player movement */
    131145
    132   Location* l = get_location();
     146  Location* l = getLocation();
    133147 
    134148  // r(t) = r(0) + v(0)*t + 1/2*a*t^2
     
    138152
    139153  /* 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;
     154  l->dist = l->dist + travelSpeed * time;
    141155
    142156  /* this updates the player position on the track - user interaction */
    143157  l->pos = l->pos + accel*time;
    144158}
    145 
    146 
    147 
    148 
    149 
    150 
    151 
    152 
    153 
    154 
    155 
    156 
    157 
    158 
    159 
    160 
    161 
    162 
Note: See TracChangeset for help on using the changeset viewer.