Changeset 4893 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons
- Timestamp:
- Jul 19, 2005, 5:16:07 PM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities/weapons
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4890 r4893 53 53 54 54 this->objectComponent1 = new PNode(); 55 this->animation1 = new Animation3D(this->objectComponent1);56 this->animation2 = new Animation3D(this);57 this->animation3 = new Animation3D(this);55 Animation3D* animation1 = this->createAnimation(WS_SHOOTING, this->objectComponent1); 56 Animation3D* animation2 = this->createAnimation(WS_ACTIVATING, this); 57 Animation3D* animation3 = this->createAnimation(WS_DEACTIVATING, this); 58 58 //parent->addChild(this->objectComponent1, PNODE_ALL); 59 59 this->addChild(this->objectComponent1, PNODE_ALL); 60 60 61 this->animation1->setInfinity(ANIM_INF_CONSTANT);62 this->animation2->setInfinity(ANIM_INF_CONSTANT);63 this->animation3->setInfinity(ANIM_INF_CONSTANT);61 animation1->setInfinity(ANIM_INF_CONSTANT); 62 animation2->setInfinity(ANIM_INF_CONSTANT); 63 animation3->setInfinity(ANIM_INF_CONSTANT); 64 64 if( this->leftRight == W_LEFT) 65 65 { 66 66 this->projectileOffset = Vector(1.0, 0.0, -0.35); 67 67 68 this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);69 this->animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);70 this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);71 72 this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);73 this->animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);74 75 this->animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);76 this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);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(-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); 77 77 } 78 78 else if( this->leftRight == W_RIGHT) … … 81 81 82 82 this->objectComponent1->setRelCoor(Vector(0,0,0.35)); 83 this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);84 this->animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);85 this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);86 87 this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);88 this->animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);89 90 this->animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);91 this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);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(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 88 animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 89 90 animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 91 animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 92 92 } 93 93 /* … … 128 128 void TestGun::activate() 129 129 { 130 this->animation2->replay();131 130 } 132 131 … … 141 140 void TestGun::deactivate() 142 141 { 143 this->animation3->replay();144 142 } 145 143 … … 153 151 void TestGun::fire() 154 152 { 155 this->energyLoaded -= this->minCharge;156 153 Projectile* pj = new TestBullet(this);//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS)); 157 154 // weaponSource->play(); … … 161 158 pj->setVelocity(this->getVelocity()); 162 159 State::getWorldEntityList()->add(pj); 163 164 this->animation1->replay();165 160 } 166 161 -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4885 r4893 49 49 50 50 private: 51 Animation3D* animation1;52 Animation3D* animation2;53 Animation3D* animation3;54 55 51 PNode* objectComponent1; //<! the gun is made of multiple parts, these PNodes represent their location and orientation 56 52 PNode* objectComponent2; -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4892 r4893 126 126 } 127 127 128 129 /** 130 * creates an Animation3D for a certain State. 131 * @param state what state should the Animation be created for 132 * @param node the node this Animation should apply to. 133 * @returns The created animation.Animation(), NULL on error. 134 * 135 * This function does only generate the Animation Object, and if set it will 136 * automatically be executed, when a certain State is reached. 137 * What this does not do, is set keyframes, you have to operate on the returned animation. 138 */ 139 Animation3D* Weapon::createAnimation(WeaponState state, PNode* node) 140 { 141 if (state >= WS_STATE_COUNT || node == NULL) 142 return NULL; 143 144 if (unlikely(this->animation[state] != NULL)) 145 { 146 delete this->animation[state]; 147 this->animation[state] = NULL; 148 } 149 return this->animation[state] = new Animation3D(node); 150 } 151 152 128 153 ///////////////// 129 154 // EXECUTION // … … 219 244 { 220 245 // play Sound 221 if ( this->soundBuffers[WA_ACTIVATE] != NULL)246 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL)) 222 247 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 248 if (likely(this->animation[WS_ACTIVATING] != NULL)) 249 this->animation[WS_ACTIVATING]->replay(); 223 250 // activate 224 251 PRINTF(5)("Activating the Weapon %s\n", this->getName()); … … 243 270 if (this->soundBuffers[WA_DEACTIVATE] != NULL) 244 271 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 272 if (likely(this->animation[WS_DEACTIVATING] != NULL)) 273 this->animation[WS_DEACTIVATING]->replay(); 245 274 // deactivate 246 275 this->deactivate(); … … 263 292 if (this->soundBuffers[WA_CHARGE] != NULL) 264 293 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 294 if (likely(this->animation[WS_CHARGING] != NULL)) 295 this->animation[WS_CHARGING]->replay(); 296 265 297 // charge 266 298 this->charge(); … … 289 321 if (this->soundBuffers[WA_SHOOT] != NULL) 290 322 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 323 if (likely(this->animation[WS_SHOOTING] != NULL)) 324 this->animation[WS_SHOOTING]->replay(); 291 325 // fire 292 326 this->fire(); … … 321 355 if (this->soundBuffers[WA_RELOAD] != NULL) 322 356 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 357 if (likely(this->animation[WS_RELOADING] != NULL)) 358 this->animation[WS_RELOADING]->replay(); 323 359 324 360 if (chargeSize > this->energy) -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4892 r4893 112 112 void setActionSound(const char* action, const char* soundFile) { this->setActionSound(charToAction(action), soundFile); }; 113 113 114 114 Animation3D* createAnimation(WeaponState state, PNode* node); 115 115 116 116 // FLOW
Note: See TracChangeset
for help on using the changeset viewer.