Changeset 3365 in orxonox.OLD for orxonox/trunk/src/player.cc
- Timestamp:
- Jan 7, 2005, 1:14:33 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/player.cc
r3233 r3365 19 19 #include "stdincl.h" 20 20 #include "collision.h" 21 #include "importer/model.h" 21 22 22 23 using namespace std; … … 26 27 { 27 28 28 this-> obj = new Object("reaplow.obj");29 this->model = new Model("reaplow.obj"); 29 30 /* 30 31 objectList = glGenLists(1); … … 54 55 } 55 56 56 Player::~Player ()57 Player::~Player () 57 58 { 58 delete this-> obj;59 delete this->model; 59 60 } 60 61 61 void Player::postSpawn ()62 void Player::postSpawn () 62 63 { 63 64 travelSpeed = 15.0; … … 69 70 } 70 71 71 void Player::tick (float time)72 void Player::tick (float time) 72 73 { 73 74 // movement 74 move (time);75 this->move (time); 75 76 } 76 77 77 void Player::hit (WorldEntity* weapon, Vector loc)78 void Player::hit (WorldEntity* weapon, Vector loc) 78 79 { 79 80 } 80 81 81 void Player::destroy ()82 void Player::destroy () 82 83 { 83 84 } 84 85 85 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)86 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) 86 87 { 87 88 } 88 89 89 void Player::command (Command* cmd)90 void Player::command (Command* cmd) 90 91 { 91 92 //printf("Player|recieved command [%s]\n", cmd->cmd); … … 97 98 } 98 99 99 void Player::draw ()100 void Player::draw () 100 101 { 101 102 glMatrixMode(GL_MODELVIEW); … … 103 104 float matrix[4][4]; 104 105 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); 107 109 glMultMatrixf((float*)matrix); 108 110 109 111 glMatrixMode(GL_MODELVIEW); 110 glRotatef(-90, 0,1,0); 111 obj->draw(); 112 this->model->draw(); 112 113 // glCallList(objectList); 113 114 115 116 114 } 117 115 116 117 /*PN 118 118 void Player::getLookat(Location* locbuf) 119 119 { … … 121 121 //locbuf->dist += 5.0; 122 122 } 123 */ 123 124 124 void Player::leftWorld ()125 void Player::leftWorld () 125 126 { 126 127 } 127 128 128 void Player::move (float time)129 void Player::move (float time) 129 130 { 130 131 Vector accel(0.0, 0.0, 0.0); 131 132 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 132 Placement *pos = getPlacement(); 133 //Placement *pos = getPlacement(); 134 133 135 /* 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); 138 140 139 141 if( bUp) { accel = accel+(direction*acceleration); } 140 142 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); } 143 145 if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */} 144 146 if( bDescend) {/* FIXME */} /* \todo up and down player movement */ 145 147 146 Location* l = getLocation();148 //Location* l = getLocation(); 147 149 148 150 // r(t) = r(0) + v(0)*t + 1/2*a*t^2 … … 152 154 153 155 /* 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 156 161 /* 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); 158 165 }
Note: See TracChangeset
for help on using the changeset viewer.