Changeset 10152 in orxonox.OLD for branches/playability/src/world_entities/weapons/weapon.cc
- Timestamp:
- Dec 27, 2006, 12:03:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/weapons/weapon.cc
r10140 r10152 124 124 this->segs = 1; 125 125 126 this->shootAnim = new Animation3D**[this->getBarrels()]; 127 for (int i = 0; i < this->getBarrels(); i++) 128 this->shootAnim[i] = new Animation3D* [this->getSegs()]; 129 126 130 this->emissionPoint = new PNode*[this->barrels]; 127 131 for(int i = 0; i < this->barrels; i++){ … … 150 154 // set this object to be synchronized over network 151 155 //this->setSynchronized(true); 156 } 157 158 /** 159 * needed, if there are more than one barrel or segments 160 */ 161 void Weapon::init2() 162 { 163 if (this->barrels == 1 && this->segs == 1) 164 return; 165 166 delete this->emissionPoint[0]; 167 delete this->emissionPoint; 168 delete this->shootAnim[0]; 169 delete this->shootAnim; 170 171 this->shootAnim = new Animation3D**[this->barrels]; 172 this->emissionPoint = new PNode*[this->barrels]; 173 for(int i = 0; i < this->barrels; i++){ 174 this->emissionPoint[i] = new PNode; 175 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles 176 this->emissionPoint[i]->setName("EmissionPoint"); 177 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 178 this->shootAnim[i] = new Animation3D* [this->segs]; 179 } 180 } 181 182 /** 183 * deconstructor for init2 184 */ 185 void Weapon::deconstr() 186 { 187 for(int i = 0; i < this->barrels; i++) { 188 delete this->emissionPoint[i]; 189 for (int j = 0; j < this->segs; j++) 190 delete this->shootAnim[i][j]; 191 delete this->shootAnim[i]; 192 } 193 194 delete this->emissionPoint; 195 delete this->shootAnim; 152 196 } 153 197 … … 327 371 } 328 372 329 Animation3D* Weapon::getAnimation( ShootingStates state, PNode* node)330 { 331 if ( state >= WS_SS_MAX) // if the state is not known373 Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node) 374 { 375 if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known 332 376 return NULL; 333 377 334 if (unlikely(this-> animation[state] == NULL)) // if the animation does not exist yet create it.378 if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it. 335 379 { 336 380 if (likely(node != NULL)) 337 return this-> animation[state] = new Animation3D(node);381 return this->shootAnim[barrel][seg] = new Animation3D(node); 338 382 else 339 383 { … … 343 387 } 344 388 else 345 return this-> animation[state];389 return this->shootAnim[barrel][seg]; 346 390 } 347 391
Note: See TracChangeset
for help on using the changeset viewer.