Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4906 in orxonox.OLD


Ignore:
Timestamp:
Jul 20, 2005, 1:41:19 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: states are now flow'n through

Location:
orxonox/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/orxonox.kdevelop

    r4885 r4906  
    77    <projectmanagement>KDevCustomProject</projectmanagement>
    88    <primarylanguage>C++</primarylanguage>
    9     <ignoreparts/>
     9    <ignoreparts>
     10      <part>CvsService</part>
     11    </ignoreparts>
     12    <projectdirectory>.</projectdirectory>
     13    <absoluteprojectpath>false</absoluteprojectpath>
     14    <description></description>
     15    <secondaryLanguages>
     16      <language>C</language>
     17    </secondaryLanguages>
    1018  </general>
    1119  <kdevcustomproject>
    1220    <run>
    13       <mainprogram>orxonox</mainprogram>
    14       <directoryradio>executable</directoryradio>
     21      <mainprogram>src/orxonox</mainprogram>
     22      <directoryradio>build</directoryradio>
     23      <customdirectory>/</customdirectory>
     24      <programargs></programargs>
     25      <terminal>false</terminal>
     26      <autocompile>true</autocompile>
     27      <envvars/>
    1528    </run>
     29    <build>
     30      <buildtool>make</buildtool>
     31      <builddir></builddir>
     32    </build>
     33    <make>
     34      <abortonerror>false</abortonerror>
     35      <numberofjobs>1</numberofjobs>
     36      <prio>0</prio>
     37      <dontact>false</dontact>
     38      <makebin></makebin>
     39      <makeoptions></makeoptions>
     40      <selectedenvironment>default</selectedenvironment>
     41      <environments>
     42        <default/>
     43      </environments>
     44    </make>
    1645  </kdevcustomproject>
    1746  <kdevdebugger>
    1847    <general>
    19       <dbgshell/>
     48      <dbgshell></dbgshell>
     49      <programargs></programargs>
     50      <gdbpath></gdbpath>
     51      <configGdbScript></configGdbScript>
     52      <runShellScript></runShellScript>
     53      <runGdbScript></runGdbScript>
     54      <breakonloadinglibs>true</breakonloadinglibs>
     55      <separatetty>false</separatetty>
     56      <floatingtoolbar>false</floatingtoolbar>
    2057    </general>
     58    <display>
     59      <staticmembers>false</staticmembers>
     60      <demanglenames>true</demanglenames>
     61      <outputradix>10</outputradix>
     62    </display>
    2163  </kdevdebugger>
    2264  <kdevdoctreeview>
     
    80122      <includeTypes>true</includeTypes>
    81123      <includeEnums>true</includeEnums>
    82       <includeTypedefs>false</includeTypedefs>
     124      <includeTypedefs>true</includeTypedefs>
    83125      <automaticCodeCompletion>true</automaticCodeCompletion>
    84126      <automaticArgumentsHint>true</automaticArgumentsHint>
     
    90132  </kdevcppsupport>
    91133  <kdevfileview>
    92     <groups>
    93       <hidenonprojectfiles>false</hidenonprojectfiles>
    94       <hidenonlocation>false</hidenonlocation>
    95     </groups>
     134    <groups/>
    96135    <tree>
    97136      <hidepatterns>*.o,*.lo,*~,*in</hidepatterns>
     
    99138    </tree>
    100139  </kdevfileview>
     140  <cppsupportpart>
     141    <filetemplates>
     142      <interfacesuffix>.h</interfacesuffix>
     143      <implementationsuffix>.cpp</implementationsuffix>
     144    </filetemplates>
     145  </cppsupportpart>
     146  <kdevdocumentation>
     147    <projectdoc>
     148      <docsystem></docsystem>
     149      <docurl></docurl>
     150      <usermanualurl></usermanualurl>
     151    </projectdoc>
     152  </kdevdocumentation>
    101153</kdevelop>
  • orxonox/trunk/src/util/animation/animation3d.h

    r4746 r4906  
    99class PNode;
    1010
    11 #define DELTA_X_3D 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
     11#define DELTA_X_3D 0.05  //!< the percentag of the distance that doesn't have to be done by neg_exp (asymptotical) ~ maschinendelta
    1212
    1313//! KeyFrame3D Struct
     
    3636  virtual void rewind();
    3737
    38   void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION, ANIM_FUNCTION animFuncRot = ANIM_NULL);
     38  void addKeyFrame(Vector position, Quaternion direction,
     39                   float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION,
     40                   ANIM_FUNCTION animFuncRot = ANIM_NULL);
    3941  //  void addKeyFrame(KeyFrame3D* frame);
    4042
  • orxonox/trunk/src/world_entities/player.cc

    r4885 r4906  
    4949  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    5050
    51   this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    52   this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
    53   this->weaponMan->addWeapon(wpRight, W_CONFIG2);
    54   this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     51  this->weaponMan->addWeapon(wpRight, WM_CONFIG0, WM_SLOT0);
     52  this->weaponMan->addWeapon(wpLeft, WM_CONFIG1, WM_SLOT1);
     53  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
     54  this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);
    5555}
    5656
     
    8383  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    8484
    85   this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    86   this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
    87   this->weaponMan->addWeapon(wpRight, W_CONFIG2);
    88   this->weaponMan->addWeapon(wpLeft, W_CONFIG2);
     85  this->weaponMan->addWeapon(wpRight, WM_CONFIG0, WM_SLOT0);
     86  this->weaponMan->addWeapon(wpLeft, WM_CONFIG1, WM_SLOT1);
     87  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
     88  this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);
    8989}
    9090
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4895 r4906  
    7070      animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    7171
    72       animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    73       animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    74 
    75       animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    76       animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     72      animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     73      animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     74
     75      animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     76      animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    7777    }
    7878  else if( this->leftRight == W_RIGHT)
     
    100100  //ObjectManager::getInstance()->debug();
    101101
    102   this->setStateDuration(WS_SHOOTING, .2);
    103   this->setStateDuration(WS_RELOADING, .5);
     102  this->setStateDuration(WS_SHOOTING, .4);
     103  this->setStateDuration(WS_RELOADING, 1);
    104104  //this->setStateDuration(WS_ACTIVATING, .4);
    105105  //this->setStateDuration(WS_DEACTIVATING, .4);
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4895 r4906  
    8181  this->emissionPoint.setParent(this);
    8282
    83   this->active = true;
    8483  this->projectile = NULL;
     84
     85  this->hideInactive = true;
    8586
    8687  this->minCharge = 1.0;
     
    171172void Weapon::requestAction(WeaponAction action)
    172173{
    173   if (this->requestedAction != WA_NONE)
    174     return;
    175   else
    176   {
     174  if (likely(this->isActive()))
     175  {
     176    if (this->requestedAction != WA_NONE)
     177      return;
    177178    printf("next action will be %s in %f seconds\n", actionToChar(action), this->stateDuration);
    178179    this->requestedAction = action;
     180  }
     181  //else
     182  else if (unlikely(action == WA_ACTIVATE))
     183  {
     184    this->currentState = WS_ACTIVATING;
     185    this->requestAction(WA_ACTIVATE);
    179186  }
    180187}
     
    215222bool Weapon::execute()
    216223{
    217 
     224#if DEBUG > 4
    218225  PRINTF(4)("trying to execute action %s\n", actionToChar(this->requestedAction));
    219226  this->debug();
     227#endif
    220228
    221229  switch (this->requestedAction)
     
    246254bool Weapon::activateW()
    247255{
    248 //  if (this->currentState == WS_INACTIVE)
     256  if (this->currentState == WS_INACTIVE)
    249257  {
    250258        // play Sound
     
    256264    PRINTF(4)("Activating the Weapon %s\n", this->getName());
    257265    this->activate();
    258     this->active = true;
    259266    // setting up for next action
     267    this->currentState = WS_ACTIVATING;
    260268    this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration;
    261269  }
     
    280288        // deactivate
    281289    this->deactivate();
    282     this->active = false;
    283290        // setting up for next action
     291    this->currentState = WS_DEACTIVATING;
    284292    this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration;
    285293  }
     
    305313        // setting up for the next state
    306314    this->requestedAction = WA_NONE;
     315    this->currentState = WS_CHARGING;
    307316    this->stateDuration = this->times[WA_CHARGE] + this->stateDuration;
    308317  }
     
    334343          // setting up for the next state
    335344    this->stateDuration = this->times[WA_SHOOT] + this->stateDuration;
     345    this->currentState = WS_SHOOTING;
    336346    this->requestedAction = WA_NONE;
    337347  }
     
    379389
    380390  this->requestedAction = WA_NONE;
     391  this->currentState = WS_RELOADING;
    381392  this->stateDuration = this->times[WA_RELOAD] + this->stateDuration;
    382393
     
    387398 * tick signal for time dependent/driven stuff
    388399*/
    389 void Weapon::tick(float dt)
     400void Weapon::tickW(float dt)
    390401{
    391402  // setting up the timing properties
     
    394405  if (this->isActive())
    395406  {
    396     if (this->stateDuration <= 0.0 && this->requestedAction != WA_NONE)
    397     {
    398       this->stateDuration = -dt;
    399       this->execute();
    400     }
    401   }
    402   else
    403     if (this->requestedAction == WA_ACTIVATE)
    404       this->activate();
    405 
     407    if (this->stateDuration <= 0.0)
     408    {
     409      if (unlikely (this->currentState != WS_DEACTIVATING))
     410        this->currentState = WS_IDLE;
     411      else
     412        this->currentState = WS_INACTIVE;
     413
     414      if (this->requestedAction != WA_NONE)
     415      {
     416        this->stateDuration = -dt;
     417        this->execute();
     418      }
     419    }
     420  }
     421  tick(dt);
    406422}
    407423
     
    569585      return "idle";
    570586      break;
     587    case WS_INACTIVE:
     588      return "inactive";
     589      break;
    571590    default:
    572591      return "none";
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4895 r4906  
    8181    float increaseEnergy(float energyToAdd);
    8282
    83     /** @returns true if the Weapon is Active */
    84     inline bool isActive() const { return this->active; };
     83    /** @returns true if the Weapon is Active  (this is used to check if the weapon must be drawn)*/
     84    inline bool isActive() const { return (this->currentState == WS_INACTIVE)?false:true; };
     85    /** @returns true if the weapon must be drawn */
     86    inline bool isVisible() const { return (this->currentState != WS_INACTIVE || !this->hideInactive)?true:false; };
    8587
    8688    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
     
    113115
    114116    Animation3D* getAnimation(WeaponState state, PNode* node = NULL);
     117    Animation3D* copyAnimation(WeaponState from, WeaponState to);
    115118
    116119    // FLOW
    117     virtual void tick(float dt);
     120    void tickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within
     121    virtual void tick(float dt) {};
    118122    virtual void draw();
    119123
     
    175179    PNode                emissionPoint;                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
    176180
    177     bool                 active;                          //!< states wheter the weapon is enabled or not
    178181    bool                 hideInactive;                    //!< Hides the Weapon if it is inactive
    179182    bool                 chargeable;                      //!< if the Weapon is charcheable
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4895 r4906  
    7575      this->configs[i].slots[j] = NULL;
    7676  }
    77   this->currConfID = W_CONFIG0;
     77  this->currConfID = WM_CONFIG0;
    7878
    7979
     
    141141 *
    142142 * if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
    143  * replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free
     143 * replaced by the weapon specified. if you use the WM_FREE_SLOT, the manager will look for a free
    144144 * slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be
    145145 * a error message.
     
    147147void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    148148{
    149   if( slotID == W_FREE_SLOT)
     149  if( slotID == WM_FREE_SLOT)
    150150  {
    151151    int freeSlot = this->getNextFreeSlot( configID);
     
    187187  lastConfID = this->currConfID;
    188188  for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    189   if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0;
     189  if( i == W_MAX_CONFIGS) this->currConfID = WM_CONFIG0;
    190190  else this->currConfID = i;
    191191
     
    241241{
    242242  Weapon* w;
    243   for (int j = 0; j < 4; ++j )
    244     for(int i = 0; i < W_MAX_SLOTS; ++i)
    245   {
    246     w = this->configs[j].slots[i];
    247     if( w != NULL) w->tick(dt);
     243  for(int i = 0; i < W_MAX_SLOTS; ++i)
     244  {
     245    w = this->configs[this->currConfID].slots[i];
     246    if( w != NULL && w->isActive())
     247      w->tickW(dt);
    248248  }
    249249
     
    262262  {
    263263    w = this->configs[j].slots[i];
    264     if( w != NULL)
     264    if( w != NULL && w->isVisible())
    265265      w->draw();
    266266  }
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4837 r4906  
    3939
    4040//! this is an identifier for the weapon config
    41 #define    W_CONFIG0     0
    42 #define    W_CONFIG1     1
    43 #define    W_CONFIG2     2
    44 #define    W_CONFIG3     3
     41typedef enum
     42{
     43  WM_CONFIG0           = 0,
     44  WM_CONFIG1           = 1,
     45  WM_CONFIG2           = 2,
     46  WM_CONFIG3           = 3,
    4547
     48  WM_CONFIGCOUNT       = 4
     49} WM_CONFIG;
    4650
    4751//! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time
    48 #define    W_SLOT0       0
    49 #define    W_SLOT1       1
    50 #define    W_SLOT2       2
    51 #define    W_SLOT3       3
    52 #define    W_SLOT4       4
    53 #define    W_SLOT5       5
    54 #define    W_SLOT6       6
    55 #define    W_SLOT7       7
    56 #define    W_FREE_SLOT   99
     52typedef enum
     53{
     54  WM_SLOT0              = 0,
     55  WM_SLOT1              = 1,
     56  WM_SLOT2              = 2,
     57  WM_SLOT3              = 3,
     58  WM_SLOT4              = 4,
     59  WM_SLOT5              = 5,
     60  WM_SLOT6              = 6,
     61  WM_SLOT7              = 7,
    5762
     63  WM_SLOT_COUNT         = 8,
     64
     65  WM_FREE_SLOT          = -1
     66} WM_SLOT;
    5867
    5968//! this is a weapon Configuration: it has up to 8 slots
     
    7786    void setSlotCount(int nrOfSlots);
    7887
    79     void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
    80     void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
     88    void addWeapon(Weapon* weapon, int configID = WM_CONFIG0, int slotID = WM_FREE_SLOT);
     89    void removeWeapon(Weapon* weapon, int configID = WM_CONFIG0);
    8190    void nextWeaponConf();
    8291
Note: See TracChangeset for help on using the changeset viewer.