Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
13 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
  • trunk/src/world_entities/environments/mapped_water.cc

    r9021 r9110  
    2020#include "state.h"
    2121#include "t_animation.h"
    22 #include "math.h"
     22#include <cmath>
    2323#include "glgui.h"
    2424#include "shell_command.h"
  • trunk/src/world_entities/npcs/door.cc

    r9003 r9110  
    4545
    4646
    47 Door::Door ()
    48 {
    49   this->init();
    50 }
    51 
    52 
    5347Door::Door(const TiXmlElement* root)
    5448{
     
    5650  this->setClassID(CL_DOOR, "Door");
    5751  this->scale = 1.0f;
     52  this->actionRadius = 1.0;
    5853
    5954  if( root != NULL)
     
    6257  this->toList(OM_COMMON);
    6358  this->bLocked = false;
     59  this->bOpen = false;
    6460
    6561  this->loadMD2Texture("maps/doors.jpg");
  • trunk/src/world_entities/npcs/door.h

    r9003 r9110  
    2222{
    2323  public:
    24     Door ();
    25     Door(const TiXmlElement* root);
     24    Door(const TiXmlElement* root = NULL);
    2625    virtual ~Door ();
    2726
     
    4342
    4443  private:
     44    void init();
    4545    bool checkOpen();
    4646    void setAnimation(int animNum, int playbackMode = 0);
  • trunk/src/world_entities/npcs/generic_npc.cc

    r9061 r9110  
    8484  this->toList(OM_GROUP_00);
    8585
    86   if (this->soundBuffer != NULL)
    87     ResourceManager::getInstance()->unload(this->soundBuffer);
    8886  this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    8987
     
    9391
    9492  // collision reaction registration
    95 //   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     93   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    9694}
    9795
     
    186184  this->animationStack.push(this->behaviourList);
    187185  this->behaviourList = new std::list<GenericNPC::Anim>;
     186
     187  if( this->getAnimation() != STAND)
     188    this->setAnimation(STAND, MD2_ANIM_LOOP);
    188189}
    189190
     
    194195void GenericNPC::resume()
    195196{
    196   //if()
     197  if( this->animationStack.size() == 0)
     198    return;
     199
    197200  delete this->behaviourList;
    198201  this->behaviourList = this->animationStack.top();
     
    219222        Vector dir = (currentAnimation.v - this->getAbsCoor());
    220223        dir.y = 0.0f;
    221         dir.getNormalized();
     224        dir.normalize();
    222225        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    223226
     
    518521      {
    519522        Vector dest = currentAnimation.v - this->getAbsCoor();
     523        dest.y = 0.0f;
    520524        if (dest.len() < .5)
    521525          this->nextStep();
     
    530534      {
    531535        Vector dest = currentAnimation.v - this->getAbsCoor();
     536        dest.y = 0.0f;
    532537        if (dest.len() < .5)
    533538          this->nextStep();
  • trunk/src/world_entities/playable.cc

    r9061 r9110  
    6767  this->bDead = false;
    6868
     69  //subscribe to collision reaction
    6970  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    7071
  • trunk/src/world_entities/script_trigger.cc

    r9061 r9110  
    115115  LoadParam(root, "invert", this, ScriptTrigger, setInvert)
    116116      .describe("")
    117       .defaultValues("false");
     117      .defaultValues(false);
    118118  LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
    119119      .describe("")
    120       .defaultValues("true");
     120      .defaultValues(true);
    121121  LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    122122      .describe("")
    123       .defaultValues("false");
     123      .defaultValues(false);
    124124  LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
    125125      .describe("True if this scripttrigger should be aviable in the script")
    126       .defaultValues("false");
     126      .defaultValues(false);
    127127}
    128128
  • trunk/src/world_entities/space_ships/space_ship.cc

    r9061 r9110  
    5858CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,
    5959                        addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
     60                       //Coordinates
     61                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     62                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     63                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     64                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    6065                       );
    6166
  • trunk/src/world_entities/space_ships/spacecraft_2d.cc

    r9061 r9110  
    2525
    2626#include "util/loading/factory.h"
     27#include "util/loading/load_param.h"
    2728#include "key_mapper.h"
    2829#include "state.h"
     
    3637CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
    3738
     39/**
     40 *  destructs the spacecraft_2d, deletes alocated memory
     41 */
     42Spacecraft2D::~Spacecraft2D ()
     43{
     44  this->setPlayer(NULL);
     45  delete this->toTravelHeight;
     46}
    3847
    3948/**
     
    8695
    8796/**
    88  *  destructs the spacecraft_2d, deletes alocated memory
    89  */
    90 Spacecraft2D::~Spacecraft2D ()
    91 {
    92   this->setPlayer(NULL);
    93 }
    94 
    95 /**
    9697 * @brief initializes a Spacecraft2D
    9798 */
     
    101102  this->setClassID(CL_SPACECRAFT_2D, "Spacecraft2D");
    102103
    103   this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
    104 
     104  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal );
    105105
    106106  bForward = bBackward = bLeft = bRight = false;
     
    110110  this->rotation = 0.0f;
    111111  this->acceleration = 10.0f;
    112   this->altitude = 0.0f;
     112  this->airFriction = 2.0f;
     113
    113114
    114115  this->setHealthMax(100);
     
    116117
    117118
     119  /// 2D-MODE
     120  this->toTravelHeight = NULL;
     121  this->travelSpeed = 0.0f;
     122  this->travelNode = new PNode();
     123
     124
    118125  // camera - issue
    119   this->travelNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
     126  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     127  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    120128  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
    121129  //this->cameraNode.setParent(this);
    122130
    123   // rotors
    124131  // PARTICLES
    125132  this->burstEmitter = new DotEmitter(200, 5.0, .01);
    126133  this->burstEmitter->setParent(this);
    127134  this->burstEmitter->setRelCoor(0, -0.7, 0);
    128   this->burstEmitter->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
     135  this->burstEmitter->setRelDir(Quaternion(-M_PI, Vector(0,0,1)));
    129136  this->burstEmitter->setName("Spacecraft2D_Burst_emitter_Left");
    130 
    131137
    132138  this->burstSystem = new SpriteParticles(1000);
     
    150156  this->registerEvent(KeyMapper::PEV_LEFT);
    151157  this->registerEvent(KeyMapper::PEV_RIGHT);
    152   this->registerEvent(KeyMapper::PEV_UP);
    153   this->registerEvent(KeyMapper::PEV_DOWN);
    154158  this->registerEvent(KeyMapper::PEV_FIRE1);
    155159  this->registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    178182  this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
    179183
    180   this->travelNode.setRelCoor(0,0,0);
    181   //this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    182   //this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     184  this->cameraNode.setRelCoor(1,5,0);
     185  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     186  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
    183187
    184188  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    198202{
    199203  Playable::loadParams(root);
     204
     205  LoadParam(root, "travel-speed", this, Spacecraft2D, setTravelSpeed);
     206  LoadParam(root, "travel-height", this, Spacecraft2D, setTravelHeight);
     207  LoadParam(root, "travel-distance", this, Spacecraft2D, setTravelDistance);
    200208}
    201209
     
    205213}
    206214
    207 void Spacecraft2D::setTravelDirecton(const Quaternion& rot, float speed)
    208 {
    209   this->setPlayDirection(rot, speed);
    210 }
    211 
    212215void Spacecraft2D::setTravelSpeed(float travelSpeed)
    213216{
     
    216219
    217220
     221void Spacecraft2D::setTravelHeight(float travelHeight)
     222{
     223  if (this->toTravelHeight == NULL)
     224    this->toTravelHeight = new float;
     225  *this->toTravelHeight = travelHeight;
     226}
     227
     228
     229void Spacecraft2D::setTravelDistance(const Vector2D& distance)
     230{
     231  this->travelDistance = distance;
     232}
     233
     234void Spacecraft2D::setTravelDistance(float x, float y)
     235{
     236  this->setTravelDistance(Vector2D(x, y));
     237}
     238
     239
    218240
    219241void Spacecraft2D::enter()
    220242{
    221243  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
    222 
    223   if (State::getCameraNode != NULL)
    224   {
    225     State::getCameraNode()->setParentSoft(&this->travelNode);
    226     State::getCameraNode()->setRelCoorSoft(-10, 50,0);
    227     State::getCameraTargetNode()->setParentSoft(&this->travelNode);
    228   }
     244  this->setPlaymode(this->getPlaymode());
    229245}
    230246
     
    235251
    236252}
     253
     254
     255void Spacecraft2D::enterPlaymode(Playable::Playmode playmode)
     256{
     257  switch(playmode)
     258  {
     259    case Playable::Full3D:
     260      if (State::getCameraNode != NULL)
     261      {
     262        Vector absCoor = this->getAbsCoor();
     263        this->setParent(PNode::getNullParent());
     264        this->setAbsCoor(absCoor);
     265        State::getCameraNode()->setParentSoft(&this->cameraNode);
     266        State::getCameraNode()->setRelCoorSoft(-10, 0,0);
     267        State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
     268        State::getCameraTargetNode()->setRelCoorSoft(100, 0,0);
     269
     270      }
     271      break;
     272
     273
     274    case Playable::Horizontal:
     275      if (State::getCameraNode != NULL)
     276      {
     277        this->debugNode(1);
     278        this->travelNode->debugNode(1);
     279
     280        this->travelNode->setAbsCoor(this->getAbsCoor());
     281        this->travelNode->updateNode(0.01f);
     282
     283        this->setParent(this->travelNode);
     284        this->setRelCoor(0,0,0);
     285
     286        State::getCameraNode()->setParentSoft(this->travelNode);
     287        State::getCameraNode()->setRelCoorSoft(-3, 50,0);
     288        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     289        State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     290
     291
     292        this->debugNode(1);
     293        this->travelNode->debugNode(1);
     294      }
     295      break;
     296
     297    default:
     298      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
     299  }
     300}
     301
    237302
    238303
     
    277342
    278343  // TRYING TO FIX PNode.
    279   //this->travelNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
    280   //this->travelNode.setRelDirSoft(this->getAbsDir(), 30.0f);
     344  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
     345  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    281346}
    282347
     
    307372    accel += Vector(0, 0, this->acceleration);
    308373  }
    309 
    310374
    311375  switch(this->getPlaymode())
     
    316380
    317381        // this is the air friction (necessary for a smooth control)
    318 
    319         this->velocity += (accelerationDir)* dt;
     382        Vector damping = (this->velocity * this->airFriction);
     383
     384
     385        this->velocity += (accelerationDir - damping)* dt;
    320386        this->shiftCoor (this->velocity * dt);
    321387
     
    332398
    333399        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    334 
    335400      }
    336401      break;
     
    338403    case Playable::Horizontal:
    339404      {
     405
     406        if (this->toTravelHeight != NULL)
     407        {
     408          this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt, 0));
     409          if (fabsf(this->travelNode->getAbsCoor().y - *this->toTravelHeight) < .1)
     410          {
     411            delete this->toTravelHeight;
     412            this->toTravelHeight = NULL;
     413          }
     414        }
     415        this->travelNode->shiftCoor(Vector(this->travelSpeed * dt, 0, 0));
     416
    340417        accel.y = 0.0;
    341418        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
     
    343420
    344421        // this is the air friction (necessary for a smooth control)
    345 
    346 
    347         this->velocity += (accelerationDir )* dt;
     422        Vector damping = (this->velocity * this->airFriction);
     423
     424
     425        this->velocity += (accelerationDir - damping)* dt;
    348426        this->shiftCoor (this->velocity * dt);
    349 
    350         // limit the maximum rotation speed.
    351         if (this->rotation != 0.0f)
    352         {
    353           float maxRot = 10.0 * dt;
    354           if (unlikely(this->rotation > 0.01 || this->rotation < 0.01)) this->rotation /=1.5;
    355           this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
    356 
    357           this->rotation = 0.0f;
    358         }
    359 
    360         this->setRelDirSoft(this->direction, 5);
     427        this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 1.0f);
    361428      }
    362429      break;
    363430
    364431    default:
    365       PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
     432      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
    366433  }
    367434}
     
    390457  else if( event.type == EV_MOUSE_MOTION)
    391458  {
    392     float xMouse, yMouse;
    393     xMouse = event.xRel*mouseSensitivity;
    394     yMouse = event.yRel*mouseSensitivity;
    395 
    396     // rotate the Player around the y-axis
     459
     460
     461
    397462    if (this->getPlaymode() == Playable::Full3D)
     463    {
     464      float xMouse, yMouse;
     465      xMouse = event.xRel*mouseSensitivity;
     466      yMouse = event.yRel*mouseSensitivity;
     467
     468      // rotate the Player around the y-axis
    398469      this->rotation += xMouse;
    399470
    400     this->cameraLook += yMouse;
    401     // rotate the Camera around the z-axis
    402     if (cameraLook > M_PI_4)
    403       cameraLook = M_PI_4;
    404     else if (cameraLook < -M_PI_4)
    405       cameraLook = -M_PI_4;
    406     //this->cameraNode.setRelDirSoft(this->direction,10);
    407   }
    408 }
     471      this->cameraLook += yMouse;
     472      // rotate the Camera around the z-axis
     473      if (cameraLook > M_PI_4)
     474        cameraLook = M_PI_4;
     475      else if (cameraLook < -M_PI_4)
     476        cameraLook = -M_PI_4;
     477      //this->cameraNode.setRelDirSoft(this->direction,10);
     478    }
     479  }
     480}
  • trunk/src/world_entities/space_ships/spacecraft_2d.h

    r9061 r9110  
    2222
    2323    virtual void loadParams(const TiXmlElement* root);
     24
     25    void setTravelSpeed(float travelSpeed);
     26    void setTravelHeight(float travelHeight);
     27    void setTravelDistance(const Vector2D& distance);
     28    void setTravelDistance(float x, float y);
     29
     30
    2431    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
    25     void setTravelDirecton(const Quaternion& rot, float speed = 0.0);
    26     void setTravelSpeed(float travelSpeed);
    27 
    2832    virtual void enter();
    2933    virtual void leave();
    30 
    3134
    3235
     
    3942
    4043    virtual void process(const Event &event);
     44
     45  protected:
     46    virtual void enterPlaymode(Playable::Playmode playmode);
    4147
    4248  private:
     
    5359    float                 mouseSensitivity;   //!< the mouse sensitivity
    5460
     61    /// Normal Movement.
     62    Quaternion            direction;          //!< the direction of the Spacecraft2D.
     63    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
     64    float                 airFriction;        //!< AirFriction.
     65
     66    float                 airViscosity;
    5567
    5668
    57     PNode                 travelNode;
    58     float                 travelSpeed;
     69    /// 2D-traveling
     70    PNode*                travelNode;
     71    float*                toTravelHeight;
     72    float                 travelSpeed;        //!< the current speed of the Hove (to make soft movement)
    5973
     74    Vector2D              travelDistance;     //!< Travel-Distance away from the TravelNode.
     75
     76    /// Camera
     77    PNode                 cameraNode;
    6078    float                 cameraLook;
    6179    float                 rotation;
    6280
    63    // Vector                velocity;           //!< the velocity of the Spacecraft2D.
    64     Quaternion            direction;          //!< the direction of the Spacecraft2D.
    65     float                 acceleration;       //!< the acceleration of the Spacecraft2D.
    66     float                 maxSpeed;           //!< The Maximal speed of the Spacecraft2D.
    67 
    68     float                 altitude;           //!< The height in the Entity.
    6981
    7082    ParticleEmitter*      burstEmitter;
  • trunk/src/world_entities/world_entity.cc

    r9061 r9110  
    8585
    8686  this->toList(OM_NULL);
    87 
     87 
     88  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );
    8889  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    8990  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
    9091  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
     92 
     93  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );
     94  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );
    9195}
    9296
     
    837841    this->toList( (OM_LIST)list_write );
    838842  }
     843 
     844  if ( std::find( id.begin(), id.end(), health_handle ) != id.end() )
     845  {
     846    this->setHealth( health_write );
     847  }
     848 
     849  if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() )
     850  {
     851    this->setHealthMax( healthMax_write );
     852  }
    839853
    840854  PNode::varChangeHandler( id );
  • trunk/src/world_entities/world_entity.h

    r9008 r9110  
    198198  int                     list_write;                      //!< entity's list
    199199  int                     list_handle;                     //!< handle for list changes
     200 
     201  float                   health_write;
     202  int                     health_handle;
     203 
     204  float                   healthMax_write;
     205  int                     healthMax_handle;
    200206
    201207  CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
Note: See TracChangeset for help on using the changeset viewer.