Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8731 in orxonox.OLD for trunk


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

new player

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/math/quaternion.cc

    r8724 r8731  
    216216
    217217/**
    218  * @returns the heading
     218 * @returns the Heading
    219219 */
    220220float Quaternion::getHeading() const
     
    230230
    231231/**
     232 * @returns the Heading-Quaternion
     233 */
     234Quaternion Quaternion::getHeadingQuat() const
     235{
     236  return Quaternion(this->getHeading(), Vector(0,1,0));
     237}
     238
     239/**
    232240 * @returns the Attitude
    233241 */
     
    236244  return asin(2.0 * (v.x*v.y + v.z*w));
    237245}
     246
     247/**
     248 * @returns the Attitude-Quaternion
     249 */
     250Quaternion Quaternion::getAttitudeQuat() const
     251{
     252  return Quaternion(this->getAttitude(), Vector(0,0,1));
     253}
     254
    238255
    239256/**
     
    247264    return 0.0f;
    248265}
     266
     267/**
     268 * @returns the Bank-Quaternion
     269 */
     270Quaternion Quaternion::getBankQuat() const
     271{
     272  return Quaternion(this->getBank(), Vector(1,0,0));
     273}
     274
    249275
    250276
  • trunk/src/lib/math/quaternion.h

    r8724 r8731  
    9898
    9999  float getHeading() const;
     100  Quaternion getHeadingQuat() const;
    100101  float getAttitude() const;
     102  Quaternion getAttitudeQuat() const;
    101103  float getBank() const;
     104  Quaternion getBankQuat() const;
    102105  /** @returns the rotational axis of this Quaternion */
    103106  inline Vector getSpacialAxis() const { return this->v / sin(acos(w));/*sqrt(v.x*v.x + v.y*v.y + v.z+v.z);*/ };
  • 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.