Index: orxonox/trunk/src/player.cc
===================================================================
--- orxonox/trunk/src/player.cc	(revision 2036)
+++ orxonox/trunk/src/player.cc	(revision 2190)
@@ -13,118 +13,117 @@
    ### File Specific:
    main-programmer: Patrick Boenzli
-   co-programmer:
+   co-programmer: Christian Meyer
 */
 
-#include <iostream>
-#include <stdlib.h>
-#include <GL/glut.h>
-
-#include "shoot_laser.h"
-#include "shoot_rocket.h"
-#include "data_tank.h"
-
 #include "player.h"
+#include "stdincl.h"
+#include "collision.h"
 
 using namespace std;
 
 
-Player::Player() 
-   : WorldEntity() {
-  //cout << "Player::Player" << endl;
-  xCor = yCor = zCor = 0;
-  shootLaser = new ShootLaser;
-  shootRocket = new ShootRocket;
+Player::Player(bool isFree) : WorldEntity(isFree)
+{
 }
 
 Player::~Player () 
 {
-  //delete shootLaser;
 }
 
-
-void Player::setPosition( float x, float y, float z)
+void Player::post_spawn ()
 {
-  xCor = x; yCor = y; zCor = z;
+	travel_speed = 10.0;
+	velocity = Vector();
+	bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
+	bFire = false;
+	acceleration = 10.0;
+	set_collision (new CollisionCluster (1.0, Vector(0,0,0)));
 }
 
-
-void Player::getPosition(float* x, float* y, float* z)
+void Player::tick (float time)
 {
-  *x = xCor; *y = yCor; *z = zCor;
+	// movement
+	move (time);
 }
 
-
-void Player::setCollisionRadius(float radius) 
+void Player::hit (WorldEntity* weapon, Vector loc)
 {
-  collisionRadius = radius;
 }
 
-
-void Player::goX(float x) 
+void Player::destroy ()
 {
-  xCor += x;
 }
 
-
-void Player::goY(float y)
+void Player::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags)
 {
-  yCor += y;
 }
 
-void Player::goZ(float z)
+void Player::command (Command* cmd)
 {
-  zCor += z;
+	printf("Player|recieved command [%s]\n", cmd->cmd);
+	if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
+	else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
+	else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
+	else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
+	else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
 }
 
+void Player::draw ()
+{
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	float matrix[4][4];
 
-
-void Player::shoot(int n) 
-{
-
-  //  if (shootLaser->inhibitor++ <= 100)
-  shootLaser->addShoot(xCor, yCor, zCor);
-  // else if (shootLaser->inhibitor++ <= 200)
-  shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
-  //  else if (shootLaser->inhibitor++ <= 300)
-  shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
-  //  else
-  shootLaser->inhibitor =0;
-  
-  //  if (shootRocket->inhibitor++ >=80)
-  {
-    shootRocket->addBackParable(xCor, yCor, zCor);
-    shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);
-    shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);
-    shootRocket->addRotater(xCor, yCor, zCor);
-    //  if (shootRocket->inhibitor >=90)
-    //        shootRocket->inhibitor =0;
-  }
-  //cout << "Player::shoot" << endl;
-  
-  /*
-  shootLaser->addShoot(xCor, yCor, zCor);
-  shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
-  shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
-  //shootRocket->addShoot(xCor, yCor, zCor);
-  //cout << "Player::shoot" << endl;
-  */
+	glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
+  get_placement()->w.matrix (matrix);
+  glMultMatrixf ((float*)matrix);
+	
+	glBegin(GL_TRIANGLES);
+	glColor3f(1,0,0);
+	glVertex3f(0,0,0.5);
+	glColor3f(0,1,0);
+	glVertex3f(-0.5,0,-1);
+	glColor3f(0,0,1);
+	glVertex3f(0.5,0,-1);
+	glEnd();
+	
+	printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z);
 }
 
+void Player::get_lookat (Location* locbuf)
+{
+	*locbuf = *get_location();
+	//locbuf->dist += 5.0;
+}
 
-//void Player::addIO(InputOutput *io) {}
+void Player::left_world ()
+{
+}
 
-
-void Player::paint() 
+void Player::move (float time)
 {
-  //cout << "Player::drawPlayer" << endl;
-  glPushMatrix();
-  glTranslatef(xCor, yCor, 3.0);
-  glScalef(1.0, 3.0, 1.0);
-  glutWireCube(1.0);
-  glPopMatrix();
-  /* draw all the shoots additionaly */
-  shootLaser->drawShoot();
-  shootRocket->drawShoot();
-  //cout << "Player::drawPlayer, end" << endl;
+	float xAccel, yAccel, zAccel;
+	xAccel = yAccel = zAccel = 0;
+	if( bUp) xAccel += acceleration;
+	if( bDown) xAccel -= acceleration;
+	if( bLeft) yAccel += acceleration;
+	if( bRight) yAccel -= acceleration;
+	if( bAscend) zAccel += acceleration;
+	if( bDescend) zAccel -= acceleration;
+	
+	Vector accel( xAccel, yAccel, zAccel);
+	
+	Location* l = get_location();
+	
+	// r(t) = r(0) + v(0)*t + 1/2*a*t^2
+	// r = position
+	// v = velocity
+	// a = acceleration
+	
+	l->pos = l->pos + velocity*time + (accel*(0.5*time*time));
+	l->dist += travel_speed * time;
+	
+	velocity = velocity + (accel * time);
+	printf("Player|velocity %f/%f/%f\n", velocity.x, velocity.y, velocity.z);
 }
 
@@ -146,10 +145,2 @@
 
 
-
-
-
-
-
-
-
-
