Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 4, 2006, 11:18:41 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Presentation back

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

Legend:

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

    r9003 r9110  
    2121
    2222#include "src/lib/util/loading/factory.h"
     23
     24#include "md2/md2Model.h"
    2325
    2426#include "weapons/weapon_manager.h"
     
    2830#include "weapons/fps_sniper_rifle.h"
    2931
     32#include "aabb.h"
     33
    3034#include "key_mapper.h"
    3135
    3236#include "debug.h"
    3337
     38#include "shared_network_data.h"
    3439
    3540
     
    9297
    9398  this->fallVelocity = 0.0f;
     99  this->jumpForce = 0.0f;
    94100
    95101  this->cameraNode.setParent(this);
     
    123129
    124130  this->getWeaponManager().setSlotCount(2);
    125   this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
    126131//   this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0)));
    127132  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     133  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     134  this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
    128135  this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0));
    129   this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     136
    130137
    131138  this->getWeaponManager().setParentNode(&this->cameraNode);
     
    141148  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
    142149  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
    143 //  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
    144 
    145 
    146   // collision reaction registration
    147   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     150  registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) );
     151  registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) );
    148152}
    149153
     
    189193
    190194
    191   State::getCameraNode()->setRelCoor(0,0,0);
    192   State::getCameraTargetNode()->setRelCoor(10,0,0);
     195  AABB* box = this->getModelAABB();
     196  if( box != NULL)
     197  {
     198    State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0);
     199    State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0);
     200
     201    this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1));
     202    this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0));
     203  }
    193204}
    194205
     
    207218void FPSPlayer::tick (float time)
    208219{
    209  
     220
    210221  if( this->bPosBut)
    211222  {
    212223    this->bPosBut = false;
    213     printf("prisoner:walkTo( %f, height, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
    214   }
    215  
     224    printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
     225  }
     226
    216227  Playable::tick( time );
    217228
    218   if( ( xMouse != 0 || yMouse != 0 ) /*&& this->getOwner() == this->getHostID() */)
     229  if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) )
    219230  {
    220231    xMouse *= time ;
     
    230241      attitude = -1.15;
    231242
    232     this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
    233     this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
    234 
    235243    xMouse = yMouse = 0;
    236244  }
    237245
    238  // this->setAbsDir( this->mouseDir );
     246  this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
     247  this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
    239248
    240249  Vector velocity;
     
    262271
    263272  velocity *= 100;
     273
     274  if( this->bJump && likely(this->getModel(0) != NULL))
     275  {
     276    if( this->jumpForce < 1.0f)
     277    {
     278      this->jumpForce = 300.0f;
     279
     280      if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
     281        ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
     282    }
     283  }
     284  else if(velocity.len() != 0.0f)
     285  {
     286    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
     287      ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
     288  }
     289  else
     290  {
     291    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
     292      ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
     293  }
     294
     295
     296  velocity.y += this->jumpForce;
     297  if( this->jumpForce > 1.0f)
     298    this->jumpForce *= 0.9f;
    264299
    265300
     
    287322  {
    288323    ((InteractiveModel*)this->getModel(0))->tick(time);
    289 //
    290 //     // handle animations differently
    291 //     if( this->bJump && likely(this->getModel(0) != NULL))
    292 //     {
    293 //       ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
    294 //     }
     324
     325    // handle animations differently
     326
     327
     328
     329
     330
    295331//     else if( this->bFire && likely(this->getModel(0) != NULL))
    296332//     {
     
    347383  }
    348384  else if( event.type == KeyMapper::PEV_JUMP)
     385    this->bJump = event.bPressed;
    349386    this->bPosBut = event.bPressed;
    350387}
  • trunk/src/world_entities/creatures/fps_player.h

    r9003 r9110  
    5454
    5555    float                 fallVelocity;        //!< velocity for falling down
     56    float                 jumpForce;           //!< the jump force
    5657};
    5758
Note: See TracChangeset for help on using the changeset viewer.