Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8731 in orxonox.OLD for trunk/src/world_entities/creatures


Ignore:
Timestamp:
Jun 22, 2006, 4:28:18 PM (19 years ago)
Author:
bensch
Message:

new player

Location:
trunk/src/world_entities/creatures
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/creatures/fps_player.cc

    r8724 r8731  
    1818
    1919#include "interactive_model.h"
    20 #include "md2/md2Model.h"
     20#include "state.h"
    2121
    2222#include "src/lib/util/loading/factory.h"
     
    2828
    2929
     30
    3031CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER);
    31 
    32 
    33 using namespace std;
    3432
    3533
     
    7270  this->bBackward = false;
    7371  this->bJump = false;
     72
    7473  this->xMouse = 0.0f;
    7574  this->yMouse = 0.0f;
     
    7877  this->setHealth(80);
    7978
    80   this->mouseDir = this->getAbsDir();
     79
     80  this->cameraNode.setParent(this);
     81
     82  this->attitude = this->getAbsDir().getAttitude();
     83  this->heading = this->getAbsDir().getHeading();
    8184
    8285  //add events to the eventlist
     
    9194  this->getWeaponManager().setSlotCount(0);
    9295
    93   this->getWeaponManager().getFixedTarget()->setParent(this);
    94   this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
    9596
    9697  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
     
    101102  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
    102103  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
    103   registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
     104//  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
    104105
    105106  // collision reaction registration
     
    119120void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed)
    120121{
    121   this->mouseDir = quat;
    122   this->angleY = quat.getHeading();
    123   this->angleX = quat.getAttitude();
     122  this->attitude = this->getAbsDir().getAttitude();
     123  this->heading = this->getAbsDir().getHeading();
    124124}
    125125
     
    140140void FPSPlayer::enter()
    141141{
    142   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false );
    143   this->attachCamera();
     142  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true );
     143
     144  State::getCameraNode()->setParentSoft(&this->cameraNode);
     145  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
     146
     147  this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode());
     148  this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0);
     149
     150
     151  State::getCameraNode()->setRelCoor(0,0,0);
     152  State::getCameraTargetNode()->setRelCoor(10,0,0);
    144153}
    145154
     
    165174    yMouse *= time ;
    166175
    167     angleX -= xMouse;
    168     angleY -= yMouse;
    169 
    170     if ( angleY > 2.05 )
    171       angleY = 2.05;
    172 
    173     if ( angleY < -1.15 )
    174       angleY = -1.15;
    175 
    176     this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) );
     176    heading -= xMouse;
     177    attitude-= yMouse;
     178
     179    if ( attitude > 2.05 )
     180      attitude = 2.05;
     181
     182    else if ( attitude < -1.15 )
     183      attitude = -1.15;
     184
     185    this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
     186    this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
    177187
    178188    xMouse = yMouse = 0;
    179189  }
    180190
    181   this->setAbsDir( this->mouseDir );
     191 // this->setAbsDir( this->mouseDir );
    182192
    183193  Vector velocity;
  • trunk/src/world_entities/creatures/fps_player.h

    r8724 r8731  
    4545    float                 xMouse;             //!< mouse moved in x-Direction
    4646    float                 yMouse;             //!< mouse moved in y-Direction
    47     Quaternion            mouseDir;           //!< the direction where the player wants to fly
    4847
    49     float                 angleX;
    50     float                 angleY;
    5148
     49    float                 heading;
     50    float                 attitude;
     51
     52    PNode                 cameraNode;
    5253};
    5354
Note: See TracChangeset for help on using the changeset viewer.