Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4972 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons


Ignore:
Timestamp:
Aug 7, 2005, 10:32:23 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: many loadParams

Location:
orxonox/trunk/src/world_entities/weapons
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/projectile.h

    r4948 r4972  
    6666    Vector                velocity;                  //!< velocity of the projectile.
    6767
    68     ParticleEmitter*      emitter;                   //!< For special effects each Projectile consists of an emitter.
     68    ParticleEmitter*      emitter;                   //!< For special effects each Projectile has an emitter.
    6969};
    7070
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4966 r4972  
    3939using namespace std;
    4040
     41CREATE_FACTORY(TestGun);
    4142
    4243/**
     
    4849  : Weapon(weaponManager)
    4950{
    50   this->setClassID(CL_TEST_GUN, "TestGun");
    51 
    52   this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    5351  this->leftRight = leftRight;
    5452
     
    6361  animation2->setInfinity(ANIM_INF_CONSTANT);
    6462  animation3->setInfinity(ANIM_INF_CONSTANT);
     63
    6564  if( this->leftRight == W_LEFT)
    66     {
    67       this->setEmissionPoint(1.0, 0.0, -0.35);
    68 
    69       animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    70       animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    71       animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    72 
    73       animation2->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    74       animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    75 
    76       animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    77       animation3->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    78     }
     65  {
     66    this->setEmissionPoint(1.0, 0.0, -0.35);
     67
     68    animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     69    animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     70    animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
     71
     72    animation2->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     73    animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     74
     75    animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     76    animation3->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     77  }
    7978  else if( this->leftRight == W_RIGHT)
    80     {
    81       this->setEmissionPoint(1.0, 0.0, 0.5);
    82 
    83       this->objectComponent1->setRelCoor(Vector(0,0,0.35));
    84       animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    85       animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    86       animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    87 
    88       animation2->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    89       animation2->addKeyFrame(Vector(.0, .0, .0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    90 
    91       animation3->addKeyFrame(Vector(.0, .0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    92       animation3->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
    93     }
    94 /*
    95   this->fireSound = (SoundBuffer*)ResourceManager::getInstance()->load("sound/shot1.wav", WAV);
    96   this->weaponSource = new SoundSource(this->fireSound, this);
    97   this->weaponSource->setRolloffFactor(.1);*/
    98   Projectile* p = new TestBullet();
    99 
    100   //  ObjectManager::getInstance()->cache(CL_TEST_BULLET, 100, p);
    101   //ObjectManager::getInstance()->debug();
     79  {
     80    this->setEmissionPoint(1.0, 0.0, 0.5);
     81
     82    this->objectComponent1->setRelCoor(Vector(0,0,0.35));
     83    animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     84    animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
     85    animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
     86
     87    animation2->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     88    animation2->addKeyFrame(Vector(.0, .0, .0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     89
     90    animation3->addKeyFrame(Vector(.0, .0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     91    animation3->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
     92  }
     93}
     94
     95
     96TestGun::TestGun(const TiXmlElement* root)
     97{
     98  this->init();
     99  this->loadParams(root);
     100}
     101
     102/**
     103 *  standard deconstructor
     104*/
     105TestGun::~TestGun ()
     106{
     107  // model will be deleted from WorldEntity-destructor
     108}
     109
     110
     111void TestGun::init()
     112{
     113  this->setClassID(CL_TEST_GUN, "TestGun");
     114
     115  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    102116
    103117  this->setStateDuration(WS_SHOOTING, .4);
     
    117131
    118132
    119 /**
    120  *  standard deconstructor
    121 */
    122 TestGun::~TestGun ()
    123 {
    124   // model will be deleted from WorldEntity-destructor
     133void TestGun::loadParams(const TiXmlElement* root)
     134{
     135
     136
    125137}
    126138
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4959 r4972  
    3939  public:
    4040    TestGun (WeaponManager* weaponManager, int leftRight);
     41    TestGun (const TiXmlElement* root);
    4142    virtual ~TestGun ();
     43
     44    void init();
     45    void loadParams(const TiXmlElement* root);
    4246
    4347    virtual void activate();
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4967 r4972  
    9696}
    9797
     98void Weapon::loadParams(const TiXmlElement* root)
     99{
     100  static_cast<WorldEntity*>(this)->loadParams(root);
     101
     102  LoadParam<Weapon>(root, "projectile", this, &Weapon::setProjectile)
     103      .describe("Sets the name of the Projectile to load onto the Entity");
     104
     105  LoadParam<Weapon>(root, "emission-point", this, &Weapon::setEmissionPoint)
     106      .describe("Sets the Point of emission of this weapon");
     107
     108  LoadParam<Weapon>(root, "state-duration", this, &Weapon::setStateDuration)
     109      .describe("Sets the duration of a given state (1: state-Name; 2: duration in seconds)");
     110
     111  LoadParam<Weapon>(root, "action-sound", this, &Weapon::setActionSound)
     112      .describe("Sets a given sound to an action (1: action-Name; 2: name of the sound (relative to the Data-Path))");
     113}
     114
    98115/**
    99116 * sets the Projectile to use for this weapon.
     
    103120 * be aware, that this function does not create Factories, as this is job of Bullet-classes.
    104121 */
    105 bool Weapon::setProjectile(ClassID projectile)
     122void Weapon::setProjectile(ClassID projectile)
    106123{
    107124  if (projectile == CL_NULL)
    108     return false;
     125    return;
    109126  this->projectile = projectile;
    110127  this->projectileFactory = FastFactory::searchFastFactory(projectile);
    111128  if (this->projectileFactory == NULL)
    112     return false;
     129    return;
    113130  else
    114131  {
     
    125142 * @see bool Weapon::setProjectile(ClassID projectile)
    126143 * @param projectile the Name of the Projectile.
    127  * @return true if
    128  */
    129 bool Weapon::setProjectile(const char* projectile)
     144 */
     145void Weapon::setProjectile(const char* projectile)
    130146{
    131147  if (projectile == NULL)
    132     return false;
     148    return;
    133149  FastFactory* tmpFac = FastFactory::searchFastFactory(projectile);
    134150  if (tmpFac != NULL)
    135151  {
    136152    this->setProjectile(tmpFac->getStoredID());
     153  }
     154  else
     155  {
     156    PRINTF(2)("Projectile %s does not exist for weapon %s\n", projectile, this->getName());
    137157  }
    138158}
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4959 r4972  
    7777    // INITIALISATION //
    7878    Weapon (WeaponManager* weaponManager = NULL);
    79     Weapon(const TiXmlElement* root);
    8079    virtual ~Weapon ();
    8180
     
    8988    ///////////////////
    9089
    91     /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free))*/
     90    /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free)) */
    9291    inline void setWeaponManager(WeaponManager* weaponManager) { this->weaponManager = weaponManager; };
    9392    /** @returns the WeaponManager of this Weapon (or NULL if it is free) */
     
    102101
    103102    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
    104     bool setProjectile(ClassID projectile);
    105     bool setProjectile(const char* projectile);
     103    void setProjectile(ClassID projectile);
     104    void setProjectile(const char* projectile);
    106105    /** @returns The projectile's classID */
    107106    inline ClassID getProjectile() { return this->projectile; };
     
    112111    void setEmissionPoint(const Vector& point);
    113112    /** @see void setEmissionPoint(const Vector& point); */
    114     inline void setEmissionPoint(float x, float y, float z) { this->setEmissionPoint(Vector(x,y,z)); };
     113    inline void setEmissionPoint(float x, float y, float z) { this->setEmissionPoint(Vector(x, y, z)); };
    115114    /** @returns the absolute Position of the EmissionPoint */
    116115    inline const Vector& getEmissionPoint() const { return this->emissionPoint.getAbsCoor(); };
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4969 r4972  
    103103{
    104104  static_cast<BaseObject*>(this)->loadParams(root);
    105 /*
     105
    106106  LoadParam<WeaponManager>(root, "slot-count", this, &WeaponManager::setSlotCount)
    107107      .describe("how many slots(cannons) the WeaponManager can handle");
     
    109109  LOAD_PARAM_START_CYCLE;
    110110
    111   LoadParam<WeaponManager>(root, "Weapons", this, &WeaponManager::loadWeapons)
     111  LoadParam<WeaponManager>(element, "weapons", this, &WeaponManager::loadWeapons)
    112112      .describe("loads Weapons");
    113113      // LoadParam<WeaponManager>(root, "Weapon", this, &WeaponManager::addWeapon);
    114114
    115   LOAD_PARAM_END_CYCLE;*/
     115  LOAD_PARAM_END_CYCLE;
    116116}
    117117
     
    141141      this->parent->addChild(&this->currentSlotConfig[i].position);
    142142  }
    143 
    144143}
    145144
     
    156155}
    157156
     157
     158/**
     159 * sets the position of the Slot relative to the parent
     160 * @param slot the slot to set-up
     161 * @param position the position of the given slot
     162 */
    158163void WeaponManager::setSlotPosition(int slot, const Vector& position)
    159164{
     
    162167}
    163168
     169
     170/**
     171 * sets the relative rotation of the slot to its parent
     172 * @param slot the slot to set-up
     173 * @param rotation the relative rotation of the given slot
     174 */
    164175void WeaponManager::setSlotDirection(int slot, const Quaternion& rotation)
    165176{
     
    171182/**
    172183 * adds a weapon to the selected weaponconfiguration into the selected slot
    173  * @param the weapon to add
    174  * @param an identifier for the slot: number between 0..7 if not specified: slotID=next free slot
    175  * @param an identifier for the weapon configuration, number between 0..3
     184 * @param weapon the weapon to add
     185 * @param configID an identifier for the slot: number between 0..7 if not specified: slotID=next free slot
     186 * @param slotID an identifier for the weapon configuration, number between 0..3
    176187 *
    177188 * if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4969 r4972  
    4141 * How to configure
    4242 * 1. set the default values.
    43  * 2. define weapons. connect them to the WeaponManager's configurations
     43 * 2. define weapons. connect them to the WeaponManager's configurations (have a look at "player.cc", to see how it works)
    4444 * 3. go on and run :)....
    4545 */
     
    7878
    7979    /** @returns a fixed target namely the Crosshair's 3D position */
    80     inline PNode* getFixedTarget() { return this->crosshair; }
     80    inline PNode* getFixedTarget() { return this->crosshair; };
    8181    void fire();
    8282
Note: See TracChangeset for help on using the changeset viewer.