Index: trunk/src/world_entities/creatures/fps_player.cc
===================================================================
--- trunk/src/world_entities/creatures/fps_player.cc	(revision 8724)
+++ trunk/src/world_entities/creatures/fps_player.cc	(revision 8724)
@@ -0,0 +1,280 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Patrick Boenzli
+   co-programmer: ...
+
+*/
+
+#include "fps_player.h"
+
+#include "interactive_model.h"
+#include "md2/md2Model.h"
+
+#include "src/lib/util/loading/factory.h"
+
+#include "key_mapper.h"
+
+#include "debug.h"
+
+
+
+CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER);
+
+
+using namespace std;
+
+
+/**
+ *  destructs the FPSPlayer, deletes alocated memory
+ */
+FPSPlayer::~FPSPlayer ()
+{
+  this->setPlayer(NULL);
+}
+
+
+/**
+ *  creates a new FPSPlayer from Xml Data
+ * @param root the xml element containing FPSPlayer data
+ *
+ */
+FPSPlayer::FPSPlayer(const TiXmlElement* root)
+{
+  this->init();
+
+  if (root != NULL)
+    this->loadParams(root);
+
+}
+
+
+/**
+ * initializes a FPSPlayer
+ */
+void FPSPlayer::init()
+{
+  this->setClassID(CL_FPS_PLAYER, "FPSPlayer");
+
+  this->getWeaponManager().changeWeaponConfig(1);
+
+  this->bLeft = false;
+  this->bRight = false;
+  this->bForward = false;
+  this->bBackward = false;
+  this->bJump = false;
+  this->xMouse = 0.0f;
+  this->yMouse = 0.0f;
+
+  this->setHealthMax(100);
+  this->setHealth(80);
+
+  this->mouseDir = this->getAbsDir();
+
+  //add events to the eventlist
+  registerEvent(KeyMapper::PEV_FORWARD);
+  registerEvent(KeyMapper::PEV_BACKWARD);
+  registerEvent(KeyMapper::PEV_LEFT);
+  registerEvent(KeyMapper::PEV_RIGHT);
+  registerEvent(KeyMapper::PEV_FIRE1);
+  registerEvent(KeyMapper::PEV_JUMP);
+  registerEvent(EV_MOUSE_MOTION);
+
+  this->getWeaponManager().setSlotCount(0);
+
+  this->getWeaponManager().getFixedTarget()->setParent(this);
+  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
+
+  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
+
+  // network registration
+  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
+
+  // collision reaction registration
+  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
+}
+
+
+/**
+ * loads the Settings of a FPSPlayer from an XML-element.
+ * @param root the XML-element to load the Spaceship's properties from
+ */
+void FPSPlayer::loadParams(const TiXmlElement* root)
+{
+  Playable::loadParams(root);
+}
+
+void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed)
+{
+  this->mouseDir = quat;
+  this->angleY = quat.getHeading();
+  this->angleX = quat.getAttitude();
+}
+
+
+void FPSPlayer::reset()
+{
+  this->bLeft = false;
+  this->bRight = false;
+  this->bForward = false;
+  this->bBackward = false;
+  this->xMouse = 0.0f;
+  this->yMouse = 0.0f;
+
+  this->setHealth(80);
+}
+
+
+void FPSPlayer::enter()
+{
+  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false );
+  this->attachCamera();
+}
+
+void FPSPlayer::leave()
+{
+  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
+  this->detachCamera();
+}
+
+
+
+/**
+ *  the function called for each passing timeSnap
+ * @param time The timespan passed since last update
+ */
+void FPSPlayer::tick (float time)
+{
+  Playable::tick( time );
+
+  if( ( xMouse != 0 || yMouse != 0 ) /*&& this->getOwner() == this->getHostID() */)
+  {
+    xMouse *= time ;
+    yMouse *= time ;
+
+    angleX -= xMouse;
+    angleY -= yMouse;
+
+    if ( angleY > 2.05 )
+      angleY = 2.05;
+
+    if ( angleY < -1.15 )
+      angleY = -1.15;
+
+    this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) );
+
+    xMouse = yMouse = 0;
+  }
+
+  this->setAbsDir( this->mouseDir );
+
+  Vector velocity;
+
+  if ( this->bForward )
+  {
+    velocity += this->getAbsDirX();
+  }
+
+  if ( this->bBackward )
+  {
+    velocity -= this->getAbsDirX();
+  }
+
+  if ( this->bRight )
+  {
+    velocity += this->getAbsDirZ();
+  }
+
+  if ( this->bLeft )
+  {
+    velocity -= this->getAbsDirZ();
+  }
+
+  velocity *= 100;
+
+  this->shiftCoor( velocity*time );
+
+
+
+
+  if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(CL_INTERACTIVE_MODEL))
+  {
+    ((InteractiveModel*)this->getModel(0))->tick(time);
+//
+//     // handle animations differently
+//     if( this->bJump && likely(this->getModel(0) != NULL))
+//     {
+//       ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
+//     }
+//     else if( this->bFire && likely(this->getModel(0) != NULL))
+//     {
+//       if( ((InteractiveModel*)this->getModel(0))->getAnim() != ATTACK)
+//         ((InteractiveModel*)this->getModel(0))->setAnimation(ATTACK);
+//     }
+//     else if( fabs(move.len()) > 0.0f && likely(this->getModel(0) != NULL))
+//     {
+//       if( ((InteractiveModel*)this->getModel(0))->getAnim() != RUN)
+//         ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
+//     }
+//     else if (likely(this->getModel(0) != NULL))
+//     {
+//       if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
+//         ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
+//     }
+  }
+
+}
+
+
+
+/**
+ *  draws the MD2Creature after transforming it.
+ */
+void FPSPlayer::draw () const
+{
+  // only draw if this entity is not the player since the player nevers sees himself
+  if( this->getCurrentPlayer() == NULL)
+    WorldEntity::draw();
+}
+
+
+
+/**
+ * process
+ */
+void FPSPlayer::process(const Event &event)
+{
+  Playable::process(event);
+
+  if( event.type == KeyMapper::PEV_LEFT)
+    this->bLeft = event.bPressed;
+  else if( event.type == KeyMapper::PEV_RIGHT)
+    this->bRight = event.bPressed;
+  else if( event.type == KeyMapper::PEV_FORWARD)
+    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
+  else if( event.type == KeyMapper::PEV_BACKWARD)
+    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
+  else if( event.type == EV_MOUSE_MOTION)
+  {
+    this->xMouse += event.xRel;
+    this->yMouse += event.yRel;
+  }
+  else if( event.type == KeyMapper::PEV_JUMP)
+    this->getAbsCoor().debug();
+}
+
+
+
+
Index: trunk/src/world_entities/creatures/fps_player.h
===================================================================
--- trunk/src/world_entities/creatures/fps_player.h	(revision 8724)
+++ trunk/src/world_entities/creatures/fps_player.h	(revision 8724)
@@ -0,0 +1,54 @@
+/*!
+ * @file fps_player.h
+ * Implements a playable for fps games
+ */
+
+#ifndef _FPS_PLAYER_H
+#define _FPS_PLAYER_H
+
+
+#include "playable.h"
+
+
+class FPSPlayer : public Playable
+{
+
+  public:
+    FPSPlayer(const TiXmlElement* root = NULL);
+    virtual ~FPSPlayer();
+
+    virtual void loadParams(const TiXmlElement* root);
+
+    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
+
+    virtual void enter();
+    virtual void leave();
+
+    virtual void reset();
+
+
+    virtual void tick(float time);
+    virtual void draw() const;
+
+
+    virtual void process(const Event &event);
+
+  private:
+    void init();
+
+    bool                  bLeft;
+    bool                  bRight;
+    bool                  bForward;
+    bool                  bBackward;
+    bool                  bJump;              //!< jumping
+
+    float                 xMouse;             //!< mouse moved in x-Direction
+    float                 yMouse;             //!< mouse moved in y-Direction
+    Quaternion            mouseDir;           //!< the direction where the player wants to fly
+
+    float                 angleX;
+    float                 angleY;
+
+};
+
+#endif
Index: trunk/src/world_entities/creatures/md2_creature.cc
===================================================================
--- trunk/src/world_entities/creatures/md2_creature.cc	(revision 8490)
+++ trunk/src/world_entities/creatures/md2_creature.cc	(revision 8724)
@@ -63,5 +63,4 @@
 
   this->loadParams(doc.RootElement());
-  this->toList(OM_GROUP_01);
 }
 
@@ -77,4 +76,17 @@
   if (root != NULL)
     this->loadParams(root);
+}
+
+
+/**
+ * initializes a MD2Creature
+ */
+void MD2Creature::init()
+{
+  PRINTF(4)("MD2CREATURE INIT\n");
+  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
+  this->setClassID(CL_MD2_CREATURE, "MD2Creature");
+
+  this->toList(OM_GROUP_01);
 
   //weapons:
@@ -87,24 +99,21 @@
   cannon->setName("BFG");
 
-   this->getWeaponManager().addWeapon(wpLeft, 1, 0);
-   this->getWeaponManager().addWeapon(wpRight,1 ,1);
-//   this->getWeaponManager().addWeapon(cannon, 0, 6);
-
-  //this->getWeaponManager().addWeapon(turret, 3, 0);
-
+  this->addWeapon(wpLeft, 1, 0);
+  this->addWeapon(wpRight,1 ,1);
   this->getWeaponManager().changeWeaponConfig(0);
-}
-
-
-/**
- * initializes a MD2Creature
- */
-void MD2Creature::init()
-{
-//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
-  this->setClassID(CL_MD2_CREATURE, "MD2Creature");
-
-  PRINTF(4)("MD2CREATURE INIT\n");
-
+
+
+  // pnode camera issue
+  this->cameraConnNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+  this->cameraConnNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
+  this->cameraConnNode.setName("CameraConnectorNode");
+  this->addChild(&this->cameraConnNode);
+  this->cameraConnNode.addChild(State::getCameraTargetNode());
+  this->cameraConnNode.addChild(State::getCameraNode());
+  State::getCameraTargetNode()->setRelCoor(10,0,0);
+ 
+
+
+  // control initialisation
   this->mouseDirX *= Quaternion( M_PI * 0.75f, Vector(0,1,0));
 
@@ -116,31 +125,21 @@
   cycle = 0.0;
 
-  this->cameraConnNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
-  this->cameraConnNode.setName("CameraConnectorNode");
-  this->addChild(&this->cameraConnNode);
-  this->cameraConnNode.addChild(State::getCameraTargetNode());
-  this->cameraConnNode.addChild(State::getCameraNode());
-  State::getCameraTargetNode()->setRelCoor(10,0,0);
-
-  travelSpeed = 15.0;
+  travelSpeed =300.0;
   this->velocity = Vector(0.0,0.0,0.0);
 
-//   GLGuiButton* button = new GLGuiPushButton();
-//   button->show();
-//   button->setLabel("orxonox");
-//   button->setBindNode(this);
 
   //add events to the eventlist
-  this->registerEvent(SDLK_w);
-  this->registerEvent(SDLK_s);
-  this->registerEvent(SDLK_a);
-  this->registerEvent(SDLK_d);
+  //add events to the eventlist
+  registerEvent(KeyMapper::PEV_FORWARD);
+  registerEvent(KeyMapper::PEV_BACKWARD);
+  registerEvent(KeyMapper::PEV_LEFT);
+  registerEvent(KeyMapper::PEV_RIGHT);
+  registerEvent(KeyMapper::PEV_UP);
+  registerEvent(KeyMapper::PEV_DOWN);
+  registerEvent(KeyMapper::PEV_FIRE1);
+  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
+  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
+  registerEvent(EV_MOUSE_MOTION);
   this->registerEvent(SDLK_SPACE);
-  this->registerEvent(SDLK_q);
-  this->registerEvent(SDLK_e);
-  this->registerEvent(KeyMapper::PEV_FIRE1);
-  this->registerEvent(KeyMapper::PEV_NEXT_WEAPON);
-  this->registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
-  this->registerEvent(EV_MOUSE_MOTION);
 
 
@@ -165,30 +164,16 @@
   this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
   this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
-//
-   this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
-   this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
-   //
-
-   this->cameraConnNode.addChild(this->getWeaponManager().getFixedTarget());
+  //
+  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
+  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+  //
+
+  this->cameraConnNode.addChild(this->getWeaponManager().getFixedTarget());
   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
 
-  this->getWeaponManager().getFixedTarget()->setRelCoor(10,0,0);
-
-}
-
-
-void MD2Creature::enter()
-{
-  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
-  this->attachCamera();
-
-}
-
-void MD2Creature::leave()
-{
-  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
-
-
-}
+  this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0);
+
+}
+
 
 /**
@@ -202,11 +187,26 @@
 
 
+void MD2Creature::enter()
+{
+  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
+
+  State::getCameraNode()->setParent(&this->cameraConnNode);
+  State::getCameraNode()->setRelCoor(0, 0,0);
+  State::getCameraTargetNode()->setParentSoft(&this->cameraConnNode);
+
+}
+
+void MD2Creature::leave()
+{
+  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
+  this->detachCamera();
+}
+
+
 /**
  *  effect that occurs after the MD2Creature is spawned
 */
 void MD2Creature::postSpawn ()
-{
-  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
-}
+{}
 
 /**
@@ -234,5 +234,6 @@
   if (this->getCurrentPlayer() != NULL)
     WorldEntity::draw();
-//  this->cameraConnNode.debugDraw(0);
+
+  this->cameraConnNode.debugDraw(0);
 }
 
@@ -254,4 +255,6 @@
   this->shiftCoor (move);
 
+
+  // handle animations differently
   if( this->bJump && likely(this->getModel(0) != NULL))
   {
@@ -260,19 +263,25 @@
   else if( this->bFire && likely(this->getModel(0) != NULL))
   {
-    if( ((MD2Model*)this->getModel(0))->getAnim() != ATTACK) ((MD2Model*)this->getModel(0))->setAnimation(ATTACK);
+    if( ((MD2Model*)this->getModel(0))->getAnimation() != ATTACK)
+      ((MD2Model*)this->getModel(0))->setAnimation(ATTACK);
   }
   else if( fabs(move.len()) > 0.0f && likely(this->getModel(0) != NULL))
   {
-    if( ((MD2Model*)this->getModel(0))->getAnim() != RUN) ((MD2Model*)this->getModel(0))->setAnimation(RUN);
+    if( ((MD2Model*)this->getModel(0))->getAnimation() != RUN)
+      ((MD2Model*)this->getModel(0))->setAnimation(RUN);
   }
   else if (likely(this->getModel(0) != NULL))
   {
-    if( ((MD2Model*)this->getModel(0))->getAnim() != STAND) ((MD2Model*)this->getModel(0))->setAnimation(STAND);
+    if( ((MD2Model*)this->getModel(0))->getAnimation() != STAND)
+      ((MD2Model*)this->getModel(0))->setAnimation(STAND);
   }
 
 
   //orient the MD2Creature in direction of the mouse
-  this->setAbsDir(mouseDirX);
+//   this->setAbsDir(mouseDirX);
+//    this->cameraConnNode.setRelDir(mouseDirY);
+
   this->cameraConnNode.setRelDir(mouseDirY);
+  this->setAbsDir(this->mouseDirX);
 }
 
@@ -286,5 +295,5 @@
   Vector accel(0.0, 0.0, 0.0);
   /*
-  Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter
+  Vector rot(0.0, 0.0, 0.0); // wird ben�igt fr Helicopter
   */
   //float rotVal = 0.0;
@@ -292,13 +301,20 @@
   /* calculate the direction in which the craft is heading  */
 
+  if( bMouseMotion)
+  {
+    this->mouseDirX *= Quaternion(-M_PI / 4.0f * this->xMouse*mouseSensitivity, Vector(0,1,0));
+    this->mouseDirY *= Quaternion(-M_PI / 4.0f * this->yMouse*mouseSensitivity, Vector(0,0,1));
+    this->bMouseMotion = false;
+  }
+
   if( this->bUp )
-   {
-     accel += (this->getAbsDirX())*2;
-   }
+  {
+    accel += (this->getAbsDirX())*2;
+  }
 
   if( this->bDown )
-   {
-     accel -= (this->getAbsDirX())*2;
-   }
+  {
+    accel -= (this->getAbsDirX())*2;
+  }
 
   if( this->bLeft/* > -this->getRelCoor().z*2*/)
@@ -329,5 +345,5 @@
   }
 
-  velocity = accel * 20.0f;
+  velocity = accel * 40.0f;
   //rot.normalize();
   //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
@@ -335,5 +351,4 @@
 
 
-
 /**
  * @todo switch statement ??
@@ -342,22 +357,19 @@
 {
   Playable::process(event);
-  if( event.type == SDLK_a)
-      this->bStrafeL = event.bPressed;
-  else if( event.type == SDLK_d)
-      this->bStrafeR = event.bPressed;
-  else if( event.type == SDLK_w)
-    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
-  else if( event.type == SDLK_s)
-    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
+  if( event.type == KeyMapper::PEV_LEFT)
+    this->bStrafeL = event.bPressed;
+  else if( event.type == KeyMapper::PEV_RIGHT)
+    this->bStrafeR = event.bPressed;
+  else if( event.type == KeyMapper::PEV_FORWARD)
+    this->bUp = event.bPressed;
+  else if( event.type == KeyMapper::PEV_BACKWARD)
+    this->bDown = event.bPressed;
   else if( event.type == SDLK_SPACE)
     this->bJump = event.bPressed;
   else if( event.type == EV_MOUSE_MOTION)
   {
+    this->bMouseMotion = true;
     this->xMouse = event.xRel;
     this->yMouse = event.yRel;
-    this->mouseDirX *= Quaternion(-M_PI/4*this->xMouse*mouseSensitivity, Vector(0,1,0));
-    this->mouseDirY *= Quaternion(-M_PI/4*this->yMouse*mouseSensitivity, Vector(0,0,1));
-//     if( xMouse*xMouse < 0.9)
-//      this->setAbsDir(mouseDir);
-  }
-}
+  }
+}
Index: trunk/src/world_entities/creatures/md2_creature.h
===================================================================
--- trunk/src/world_entities/creatures/md2_creature.h	(revision 8490)
+++ trunk/src/world_entities/creatures/md2_creature.h	(revision 8724)
@@ -57,4 +57,5 @@
     bool                  bStrafeR;           //!< strafe to the rith side
     bool                  bJump;              //!< jump
+    bool                  bMouseMotion;       //!< mouse motion evet
 
     PNode                 cameraConnNode;     //!< The Node the camera is connected to.
