Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3365 in orxonox.OLD for orxonox/trunk/src/player.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/player.cc

    r3233 r3365  
    1919#include "stdincl.h"
    2020#include "collision.h"
     21#include "importer/model.h"
    2122
    2223using namespace std;
     
    2627{
    2728
    28   this->obj = new Object("reaplow.obj");
     29  this->model = new Model("reaplow.obj");
    2930  /*
    3031  objectList = glGenLists(1);
     
    5455}
    5556
    56 Player::~Player()
     57Player::~Player ()
    5758{
    58   delete this->obj;
     59  delete this->model;
    5960}
    6061
    61 void Player::postSpawn()
     62void Player::postSpawn ()
    6263{
    6364  travelSpeed = 15.0;
     
    6970}
    7071
    71 void Player::tick(float time)
     72void Player::tick (float time)
    7273{
    7374  // movement
    74   move (time);
     75  this->move (time);
    7576}
    7677
    77 void Player::hit(WorldEntity* weapon, Vector loc)
     78void Player::hit (WorldEntity* weapon, Vector loc)
    7879{
    7980}
    8081
    81 void Player::destroy()
     82void Player::destroy ()
    8283{
    8384}
    8485
    85 void Player::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)
     86void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)
    8687{
    8788}
    8889
    89 void Player::command(Command* cmd)
     90void Player::command (Command* cmd)
    9091{
    9192  //printf("Player|recieved command [%s]\n", cmd->cmd);
     
    9798}
    9899
    99 void Player::draw()
     100void Player::draw ()
    100101{
    101102  glMatrixMode(GL_MODELVIEW);
     
    103104  float matrix[4][4];
    104105 
    105   glTranslatef(getPlacement()->r.x, getPlacement()->r.y, getPlacement()->r.z);
    106   getPlacement()->w.matrix (matrix);
     106  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
     107  //rotate
     108  this->getAbsDir ().matrix (matrix);
    107109  glMultMatrixf((float*)matrix);
    108110 
    109111  glMatrixMode(GL_MODELVIEW);
    110   glRotatef(-90, 0,1,0);
    111   obj->draw();
     112  this->model->draw();
    112113  // glCallList(objectList);
    113 
    114  
    115  
    116114}
    117115
     116
     117/*PN
    118118void Player::getLookat(Location* locbuf)
    119119{
     
    121121  //locbuf->dist += 5.0;
    122122}
     123*/
    123124
    124 void Player::leftWorld()
     125void Player::leftWorld ()
    125126{
    126127}
    127128
    128 void Player::move(float time)
     129void Player::move (float time)
    129130{
    130131  Vector accel(0.0, 0.0, 0.0);
    131132  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    132   Placement *pos = getPlacement();
     133  //Placement *pos = getPlacement();
     134 
    133135  /* calculate the direction in which the craft is heading  */
    134   Vector direction(0.0, 0.0, 1.0);
    135   direction = pos->w.apply(direction);
    136   Vector orthDirection(0.0, 0.0, 1.0);
    137   orthDirection = orthDirection.cross(direction);
     136  Vector direction (1.0, 0.0, 0.0);
     137  //direction = this->absDirection.apply (direction);
     138  Vector orthDirection (0.0, 0.0, 1.0);
     139  //orthDirection = orthDirection.cross (direction);
    138140
    139141  if( bUp) { accel = accel+(direction*acceleration); }
    140142  if( bDown) { accel = accel-(direction*acceleration); }
    141   if( bLeft ) { accel = accel + (orthDirection*acceleration); }
    142   if( bRight ) { accel = accel - (orthDirection*acceleration); }
     143  if( bLeft ) { accel = accel - (orthDirection*acceleration); }
     144  if( bRight ) { accel = accel + (orthDirection*acceleration); }
    143145  if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
    144146  if( bDescend) {/* FIXME */} /* \todo up and down player movement */
    145147
    146   Location* l = getLocation();
     148  //Location* l = getLocation();
    147149 
    148150  // r(t) = r(0) + v(0)*t + 1/2*a*t^2
     
    152154
    153155  /* this the base-speed of the player: determines how fast and how the player follows the track*/
    154   l->dist = l->dist + travelSpeed * time;
    155 
     156  //l->dist = l->dist + travelSpeed * time;
     157 
     158  Vector* shift = new Vector (this->travelSpeed * time, 0, 0);
     159  this->shiftCoor (shift);
     160 
    156161  /* this updates the player position on the track - user interaction */
    157   l->pos = l->pos + accel*time;
     162  //l->pos = l->pos + accel*time;
     163  Vector move = accel * time;
     164  this->shiftCoor (&move);
    158165}
Note: See TracChangeset for help on using the changeset viewer.