Changeset 4972 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons
- Timestamp:
- Aug 7, 2005, 10:32:23 AM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities/weapons
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/projectile.h
r4948 r4972 66 66 Vector velocity; //!< velocity of the projectile. 67 67 68 ParticleEmitter* emitter; //!< For special effects each Projectile consists ofan emitter.68 ParticleEmitter* emitter; //!< For special effects each Projectile has an emitter. 69 69 }; 70 70 -
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4966 r4972 39 39 using namespace std; 40 40 41 CREATE_FACTORY(TestGun); 41 42 42 43 /** … … 48 49 : Weapon(weaponManager) 49 50 { 50 this->setClassID(CL_TEST_GUN, "TestGun");51 52 this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);53 51 this->leftRight = leftRight; 54 52 … … 63 61 animation2->setInfinity(ANIM_INF_CONSTANT); 64 62 animation3->setInfinity(ANIM_INF_CONSTANT); 63 65 64 if( this->leftRight == W_LEFT) 66 67 68 69 70 71 72 73 74 75 76 77 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 } 79 78 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 96 TestGun::TestGun(const TiXmlElement* root) 97 { 98 this->init(); 99 this->loadParams(root); 100 } 101 102 /** 103 * standard deconstructor 104 */ 105 TestGun::~TestGun () 106 { 107 // model will be deleted from WorldEntity-destructor 108 } 109 110 111 void 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); 102 116 103 117 this->setStateDuration(WS_SHOOTING, .4); … … 117 131 118 132 119 /** 120 * standard deconstructor 121 */ 122 TestGun::~TestGun () 123 { 124 // model will be deleted from WorldEntity-destructor 133 void TestGun::loadParams(const TiXmlElement* root) 134 { 135 136 125 137 } 126 138 -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4959 r4972 39 39 public: 40 40 TestGun (WeaponManager* weaponManager, int leftRight); 41 TestGun (const TiXmlElement* root); 41 42 virtual ~TestGun (); 43 44 void init(); 45 void loadParams(const TiXmlElement* root); 42 46 43 47 virtual void activate(); -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4967 r4972 96 96 } 97 97 98 void 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 98 115 /** 99 116 * sets the Projectile to use for this weapon. … … 103 120 * be aware, that this function does not create Factories, as this is job of Bullet-classes. 104 121 */ 105 boolWeapon::setProjectile(ClassID projectile)122 void Weapon::setProjectile(ClassID projectile) 106 123 { 107 124 if (projectile == CL_NULL) 108 return false;125 return; 109 126 this->projectile = projectile; 110 127 this->projectileFactory = FastFactory::searchFastFactory(projectile); 111 128 if (this->projectileFactory == NULL) 112 return false;129 return; 113 130 else 114 131 { … … 125 142 * @see bool Weapon::setProjectile(ClassID projectile) 126 143 * @param projectile the Name of the Projectile. 127 * @return true if 128 */ 129 bool Weapon::setProjectile(const char* projectile) 144 */ 145 void Weapon::setProjectile(const char* projectile) 130 146 { 131 147 if (projectile == NULL) 132 return false;148 return; 133 149 FastFactory* tmpFac = FastFactory::searchFastFactory(projectile); 134 150 if (tmpFac != NULL) 135 151 { 136 152 this->setProjectile(tmpFac->getStoredID()); 153 } 154 else 155 { 156 PRINTF(2)("Projectile %s does not exist for weapon %s\n", projectile, this->getName()); 137 157 } 138 158 } -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4959 r4972 77 77 // INITIALISATION // 78 78 Weapon (WeaponManager* weaponManager = NULL); 79 Weapon(const TiXmlElement* root);80 79 virtual ~Weapon (); 81 80 … … 89 88 /////////////////// 90 89 91 /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free)) */90 /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free)) */ 92 91 inline void setWeaponManager(WeaponManager* weaponManager) { this->weaponManager = weaponManager; }; 93 92 /** @returns the WeaponManager of this Weapon (or NULL if it is free) */ … … 102 101 103 102 // FUNCTIONS TO SET THE WEAPONS PROPERTIES. 104 boolsetProjectile(ClassID projectile);105 boolsetProjectile(const char* projectile);103 void setProjectile(ClassID projectile); 104 void setProjectile(const char* projectile); 106 105 /** @returns The projectile's classID */ 107 106 inline ClassID getProjectile() { return this->projectile; }; … … 112 111 void setEmissionPoint(const Vector& point); 113 112 /** @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)); }; 115 114 /** @returns the absolute Position of the EmissionPoint */ 116 115 inline const Vector& getEmissionPoint() const { return this->emissionPoint.getAbsCoor(); }; -
orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
r4969 r4972 103 103 { 104 104 static_cast<BaseObject*>(this)->loadParams(root); 105 /* 105 106 106 LoadParam<WeaponManager>(root, "slot-count", this, &WeaponManager::setSlotCount) 107 107 .describe("how many slots(cannons) the WeaponManager can handle"); … … 109 109 LOAD_PARAM_START_CYCLE; 110 110 111 LoadParam<WeaponManager>( root, "Weapons", this, &WeaponManager::loadWeapons)111 LoadParam<WeaponManager>(element, "weapons", this, &WeaponManager::loadWeapons) 112 112 .describe("loads Weapons"); 113 113 // LoadParam<WeaponManager>(root, "Weapon", this, &WeaponManager::addWeapon); 114 114 115 LOAD_PARAM_END_CYCLE; */115 LOAD_PARAM_END_CYCLE; 116 116 } 117 117 … … 141 141 this->parent->addChild(&this->currentSlotConfig[i].position); 142 142 } 143 144 143 } 145 144 … … 156 155 } 157 156 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 */ 158 163 void WeaponManager::setSlotPosition(int slot, const Vector& position) 159 164 { … … 162 167 } 163 168 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 */ 164 175 void WeaponManager::setSlotDirection(int slot, const Quaternion& rotation) 165 176 { … … 171 182 /** 172 183 * adds a weapon to the selected weaponconfiguration into the selected slot 173 * @param the weapon to add174 * @param an identifier for the slot: number between 0..7 if not specified: slotID=next free slot175 * @param an identifier for the weapon configuration, number between 0..3184 * @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 176 187 * 177 188 * 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 41 41 * How to configure 42 42 * 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) 44 44 * 3. go on and run :).... 45 45 */ … … 78 78 79 79 /** @returns a fixed target namely the Crosshair's 3D position */ 80 inline PNode* getFixedTarget() { return this->crosshair; } 80 inline PNode* getFixedTarget() { return this->crosshair; }; 81 81 void fire(); 82 82
Note: See TracChangeset
for help on using the changeset viewer.