Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5498 in orxonox.OLD


Ignore:
Timestamp:
Nov 7, 2005, 10:43:22 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: redocumented the WorldEntity and Weapon classes

Location:
trunk/src/world_entities
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/test_entity.cc

    r5428 r5498  
    7272}
    7373
    74 void TestEntity::hit (WorldEntity* weapon, Vector* loc) {}
    75 
    76 
    7774void TestEntity::destroy () {}
    7875
  • trunk/src/world_entities/test_entity.h

    r5427 r5498  
    2222
    2323  virtual void tick (float time);
    24   virtual void hit (WorldEntity* weapon, Vector* loc);
    2524  virtual void destroy ();
    2625  virtual void collidesWith(WorldEntity* entity, const Vector& location);
  • trunk/src/world_entities/weapons/projectile.h

    r5447 r5498  
    11/*!
    22 * @file projectile.h
    3   *  a projectile, that is been shooted by a weapon
    4 
    5     You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the
    6     shooting funcions work, use the Projectile class. But if you want to implement your own shoots its
    7     different:<br>
    8     Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions
    9     - void tick()
    10     - void draw()
    11     - void hit() (only if you have working collision detection)
    12     When you have implemented these functions you have just to add the projectiles to your weapon. You ll want
    13     to make this by looking into the function
    14     - Weapon::fire()
    15     there you just change the line:
    16     Projectile* pj = new Projectile();    TO     Projectile* pj = new MyOwnProjectileClass();
    17     and schwups it works... :)
    18 */
     3 * a projectile, that is been shooted by a weapon
     4 *
     5 * You can use this class to make some Projectiles/Bullets/Lasers/Rockets/etc.
     6 *
     7 */
    198
    209#ifndef _PROJECTILE_H
     
    2211
    2312#include "world_entity.h"
    24 
    25 class FastFactory;
    2613
    2714class Projectile : public WorldEntity
     
    5744  protected:
    5845    // energy
    59     float                 energyMin;
    60     float                 energyMax;
     46    float                 energyMin;                 //!< The minimal Energy a Projectile needs to be emitted.
     47    float                 energyMax;                 //!< The maximal Energy a Projectile can take, before being emitted.
    6148    bool                  bChargeable;               //!< if the Projectile is Charegeable
    6249
  • trunk/src/world_entities/weapons/test_gun.cc

    r5462 r5498  
    192192}
    193193
    194 
    195 /**
    196  *  is called, when the weapon gets hit (=collide with something)
    197  * @param from which entity it is been hit
    198  * @param where it is been hit
    199 
    200    this may not be used, since it would make the game relay complicated when one
    201    can destroy the weapons of enemies or vice versa.
    202 */
    203 void TestGun::hit (WorldEntity* entity, Vector* position)
    204 {}
    205 
    206 
    207194/**
    208195 *  is called, when the weapon is destroyed
    209 
    210    this is in conjunction with the hit function, so when a weapon is able to get
    211    hit, it can also be destoryed.
     196 *
     197 * this is in conjunction with the hit function, so when a weapon is able to get
     198 * hit, it can also be destoryed.
    212199*/
    213200void TestGun::destroy ()
  • trunk/src/world_entities/weapons/test_gun.h

    r4972 r5498  
    4949
    5050    virtual void fire();
    51     virtual void hit (WorldEntity* weapon, Vector* loc);
    5251    virtual void destroy();
    5352
  • trunk/src/world_entities/weapons/weapon.cc

    r5441 r5498  
    6565/**
    6666 * initializes the Weapon with ALL default values
     67 *
     68 * This Sets the default values of the Weapon
    6769 */
    6870void Weapon::init()
    6971{
    70   this->currentState     = WS_INACTIVE;
    71   this->requestedAction  = WA_NONE;
    72   this->stateDuration    = 0.0;
    73   for (int i = 0; i < WS_STATE_COUNT; i++)
     72  this->currentState     = WS_INACTIVE;            //< Normaly the Weapon is Inactive
     73  this->requestedAction  = WA_NONE;                //< No action is requested by default
     74  this->stateDuration    = 0.0;                    //< All the States have zero duration
     75  for (int i = 0; i < WS_STATE_COUNT; i++)         //< Every State has:
    7476    {
    75       this->times[i] = 0.0;
    76       this->animation[i] = NULL;
     77      this->times[i] = 0.0;                        //< An infinitesimal duration
     78      this->animation[i] = NULL;                   //< No animation
    7779    }
    7880  for (int i = 0; i < WA_ACTION_COUNT; i++)
    79     this->soundBuffers[i] = NULL;
    80 
    81   this->soundSource = new SoundSource(this);
    82   this->emissionPoint.setParent(this);
    83 
    84   this->projectile = CL_NULL;
    85   this->projectileFactory = NULL;
    86 
    87   this->hideInactive = true;
    88 
    89   this->minCharge = 1.0;
    90   this->maxCharge = 1.0;
    91 
    92   this->energyLoaded = .0;
    93   this->energyLoadedMax = 5.0;
    94   this->energy = .0;
    95   this->energyMax = 10.0;
    96   this->capability = WTYPE_ALL;
    97 
    98   this->setWeaponManager(NULL);
    99 }
    100 
     81    this->soundBuffers[i] = NULL;                  //< No Sounds
     82
     83  this->soundSource = new SoundSource(this);       //< Every Weapon has exacty one SoundSource.
     84  this->emissionPoint.setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     85
     86  this->projectile = CL_NULL;                      //< No Projectile Class is Connected to this weapon
     87  this->projectileFactory = NULL;                  //< No Factory generating Projectiles is selected.
     88
     89  this->hideInactive = true;                       //< The Weapon will be hidden if it is inactive (by default)
     90
     91  this->minCharge = 1.0;                           //< The minimum charge the Weapon can hold is 1 unit.
     92  this->maxCharge = 1.0;                           //< The maximum charge is also one unit.
     93
     94  this->energyLoaded = .0;                         //< How much energy is loaded in the Gun. (Weapons must be charged befor usage)
     95  this->energyLoadedMax = 5.0;                     //< Each Weapon has a Maximum energy that can be charged onto it
     96  this->energy = .0;                               //< The secondary Buffer (before we have to reload)
     97  this->energyMax = 10.0;                          //< How much energy can be carried
     98  this->capability = WTYPE_ALL;                    //< The Weapon has all capabilities @see W_Capability.
     99
     100  this->setWeaponManager(NULL);                    //< By default the Weapon is free, and unhandled by a WeaponManager (this is good for small enemies).
     101}
     102
     103/**
     104 * loads the Parameters of a Weapon
     105 * @param root the XML-Element to load the Weapons settings from
     106 */
    101107void Weapon::loadParams(const TiXmlElement* root)
    102108{
     
    121127 * @returns true, if it was sucessfull, false on error
    122128 *
    123  * be aware, that this function does not create Factories, as this is job of Bullet-classes.
     129 * be aware, that this function does not create Factories, as this is job of Projecitle/Bullet-classes.
     130 * What it does, is telling the Weapon what Projectiles it can Emit.
    124131 */
    125132void Weapon::setProjectileType(ClassID projectile)
     
    166173/**
    167174 * prepares Projectiles of the Weapon
    168  * @param count how many Projectiles to create
     175 * @param count how many Projectiles to create (they will be stored in the ProjectileFactory)
    169176 */
    170177void Weapon::prepareProjectiles(unsigned int count)
     
    178185/**
    179186 * resurects and returns a Projectile
    180  * @returns a Projectile on success, NULL on error (ProjectileFastFactory not Found)
     187 * @returns a Projectile on success, NULL on error
     188 *
     189 * errors: 1. (ProjectileFastFactory not Found)
     190 *         2. No more Projectiles availiable.
    181191 */
    182192Projectile* Weapon::getProjectile()
     
    186196  else
    187197  {
    188     PRINTF(2)("No projectile defined for Weapon %s(%s) cant return any\n", this->getName(), this->getClassName());
     198    PRINTF(2)("No projectile defined for Weapon %s(%s) can't return any\n", this->getName(), this->getClassName());
    189199    return NULL;
    190200  }
     
    307317}
    308318
    309 //////////////////////
    310 // WEAPON INTERNALS //
    311 //////////////////////
     319////////////////////////////////////////////////////////////
     320// WEAPON INTERNALS                                       //
     321// These are functions, that no other Weapon should over- //
     322// write. No class has direct Access to them, as it is    //
     323// quite a complicated process, handling a Weapon from    //
     324// the outside                                            //
     325////////////////////////////////////////////////////////////
    312326/**
    313327 * executes an action, and with it starts a new State.
     
    531545/**
    532546 * checks wether all the Weapons functions are valid, and if it is possible to go to action with it.
    533  *
     547 * @todo IMPLEMENT the Weapons Check
    534548 */
    535549bool Weapon::check() const
     
    561575}
    562576
    563 
    564 // static
     577////////////////////////////////////////////////////////
     578// static Definitions (transormators for readability) //
     579////////////////////////////////////////////////////////
    565580/**
    566581 * Converts a String into an Action.
  • trunk/src/world_entities/world_entity.cc

    r5482 r5498  
    3535/**
    3636 *  Loads the WordEntity-specific Part of any derived Class
    37 */
     37 *
     38 * @param root: Normally NULL, as the Derived Entities define a loadParams Function themeselves,
     39 *              that can calls WorldEntities loadParams for itself.
     40 */
    3841WorldEntity::WorldEntity(const TiXmlElement* root)
    3942{
     
    5457WorldEntity::~WorldEntity ()
    5558{
    56   // if( collisioncluster != NULL) delete collisioncluster;
     59  // Delete the model (unregister it with the ResourceManager)
    5760  if (likely(this->model != NULL))
    5861    ResourceManager::getInstance()->unload(this->model);
     62  // Delete the obbTree
    5963  if( this->obbTree != NULL)
    6064    delete this->obbTree;
    6165}
    6266
     67/**
     68 * loads the WorldEntity Specific Parameters.
     69 * @param root: the XML-Element to load the Data From
     70 */
    6371void WorldEntity::loadParams(const TiXmlElement* root)
    6472{
     73  // Do the PNode loading stuff
    6574  static_cast<PNode*>(this)->loadParams(root);
     75
    6676  // Model Loading
    6777  LoadParam<WorldEntity>(root, "model", this, &WorldEntity::loadModel)
     
    7787 * @param fileName the name of the model to load
    7888 * @param scaling the Scaling of the model
     89 *
     90 * @todo fix this, so it only has one loadModel-Function.
    7991*/
    8092void WorldEntity::loadModelWithScale(const char* fileName, float scaling)
     
    126138 * these attributes don't have to be set, only use them, if you need them
    127139*/
    128 void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
    129 {}
    130 
    131 
    132 /**
    133  * gets the Character attributes of this worldentity
    134  * @returns character attributes
    135 */
    136 CharacterAttributes* WorldEntity::getCharacterAttributes()
    137 {}
     140//void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
     141//{}
    138142
    139143
     
    146150void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location)
    147151{
     152  /**
     153   * THIS IS A DEFAULT COLLISION-Effect.
     154   * IF YOU WANT TO CREATE A SPECIFIC COLLISION ON EACH OBJECT
     155   * USE::
     156   * if (entity->isA(CL_WHAT_YOU_ARE_LOOKING_FOR)) { printf "dothings"; };
     157   *
     158   * You can always define a default Action.... don't be affraid just test it :)
     159   */
    148160//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    149161}
    150162
    151 /**
    152  *  this function is called, when the ship is hit by a waepon
    153  * @param weapon: the laser/rocket/shoot that hits.
    154  * @param loc: place where it is hit
    155  *
    156  * calculate the damage depending
    157 */
    158 void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
    159 
    160 
    161 /**
    162  *  this is called immediately after the Entity has been constructed and initialized
    163  *
    164  * Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
    165  * DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
    166 */
     163
     164/**
     165 *  this is called immediately after the Entity has been constructed, initialized and then Spawned into the World
     166 *
     167 */
    167168void WorldEntity::postSpawn ()
    168169{
     
    175176 * For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    176177 * place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    177 */
     178 *
     179 * NOT YET IMPLEMENTED
     180 */
    178181void WorldEntity::leftWorld ()
    179182{
     
    190193{
    191194}
     195
    192196
    193197/**
     
    216220}
    217221
    218 
     222/**
     223 * DEBUG-DRAW OF THE BV-Tree.
     224 * @param depth What depth to draw
     225 * @param drawMode the mode to draw this entity under
     226 */
    219227void WorldEntity::drawBVTree(unsigned int depth, int drawMode)
    220228{
  • trunk/src/world_entities/world_entity.h

    r5431 r5498  
    1111
    1212// FORWARD DECLARATION
    13 class CharacterAttributes;
    14 class SoundEngine;
    1513class SoundBuffer;
    1614class SoundSource;
    1715class BVTree;
     16
     17//class CharacterAttributes;
    1818
    1919
     
    2828
    2929  /** @see loadModelWithScale(const char*, float) @param fileName the File to load */
    30   void loadModel(const char* fileName) { this->loadModelWithScale(fileName, 1.0); };
     30  void loadModel(const char* fileName) { this->loadModelWithScale(fileName, 1.0f); };
     31
    3132  void loadModelWithScale(const char* fileName, float scaling);
    3233
     
    4243  bool isVisible() const { return this->bVisible; };
    4344
    44   void setCharacterAttributes(CharacterAttributes* charAttr);
    45   CharacterAttributes* getCharacterAttributes();
     45//  void setCharacterAttributes(CharacterAttributes* charAttr);
     46//  CharacterAttributes* getCharacterAttributes();
    4647
    4748  /** @returns a reference to the obb tree of this worldentity */
     
    5152  virtual void leftWorld ();
    5253
    53   virtual void hit (WorldEntity* weapon, Vector* loc);
    5454  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    5555
     
    6363 protected:
    6464  Model*                  model;            //!< The model that should be loaded for this entity.
    65   CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    6665  BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
     66  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    6767
    6868 private:
Note: See TracChangeset for help on using the changeset viewer.