Changeset 10771 in orxonox.OLD for branches/presentation/src/world_entities/weapons/heavy_blaster.cc
- Timestamp:
- Jun 27, 2007, 7:01:08 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/weapons/heavy_blaster.cc
r10698 r10771 30 30 31 31 CREATE_FACTORY(HeavyBlaster); 32 // ObjectListDefinition(HeavyBlaster);33 34 32 35 33 … … 37 35 * Standard constructor 38 36 */ 39 HeavyBlaster::HeavyBlaster (int leftRight )37 HeavyBlaster::HeavyBlaster (int leftRight = W_RIGHT) 40 38 : Weapon() 41 39 { 42 // this->registerObject(this, HeavyBlaster::_objectList);43 40 44 41 this->init(leftRight); … … 61 58 HeavyBlaster::~HeavyBlaster() 62 59 { 63 for (int i = 0; i < this->getBarrels(); i++)64 {65 delete [] this->shootAnim[i];66 delete [] this->objComp[i];67 }68 delete [] this->emissionPoint;69 70 delete [] this->shootAnim;71 delete [] this->objComp;72 /*73 for(int j = 0; j < this->getSegs(); j++)74 {75 delete this->shootAnim[i][j];76 delete this->objComp[i][j];77 }78 delete this->shootAnim[i];79 delete this->objComp[i];80 delete this->emissionPoint[i];81 }*/82 83 // this->deconstr();84 // model will be deleted from WorldEntity-destructor85 60 } 86 61 … … 94 69 95 70 this->leftRight = leftRight; 96 //this->registerObject(this, HeavyBlaster::_objectList);97 98 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);99 71 100 72 this->loadModel("models/guns/frag_cannon2.obj", .4); … … 108 80 this->setEnergyMax(500); 109 81 this->increaseEnergy(500); 110 //this->minCharge = 2;111 82 112 83 this->setActionSound(WA_SHOOT, "sounds/guns/laser.wav"); … … 120 91 this->setBarrels(3); 121 92 this->setSegs(2); 122 this->activeBarrel = 0; 123 124 125 126 this->objComp = new PNode**[this->getBarrels()]; 127 this->emissionPoint = new PNode*[this->getBarrels()]; 128 this->shootAnim = new Animation3D**[this->getBarrels()]; 129 for (int i = 0; i < this->getBarrels(); i++) 93 94 95 if (this->leftRight == W_LEFT) 130 96 { 131 this->objComp[i] = new PNode* [this->getSegs()]; 132 this->emissionPoint[i] = new PNode; 133 this->emissionPoint[i]->setParent(this); //Parenting emissionPoint to Weapons 134 this->emissionPoint[i]->setName("EmissionPoint"); 135 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 136 this->shootAnim[i] = new Animation3D* [this->getSegs()]; 137 for(int j = 0; j < this->getSegs(); j++) 138 { 139 this->objComp[i][j] = new PNode; 140 this->shootAnim[i][j] = new Animation3D(this->objComp[i][j]); 141 this->shootAnim[i][j]->setInfinity(ANIM_INF_CONSTANT); 142 } 143 } 144 145 if (this->leftRight == W_RIGHT) 146 { 147 this->emissionPoint[0]->setRelCoor(Vector(1.1, 0.14, 0.06)); 148 this->emissionPoint[1]->setRelCoor(Vector(1.1, -.06, 0.14)); 149 this->emissionPoint[2]->setRelCoor(Vector(1.1, 0.06, -.14)); 97 this->setEmissionPoint(Vector(1.1, 0.14, -.06), 0); 98 this->setEmissionPoint(Vector(1.1, -.06, -.14), 1); 99 this->setEmissionPoint(Vector(1.1, 0.06, 0.14), 2); 150 100 } 151 101 else { 152 this-> emissionPoint[0]->setRelCoor(Vector(1.1, 0.14, -.06));153 this-> emissionPoint[1]->setRelCoor(Vector(1.1, -.06, -.14));154 this-> emissionPoint[2]->setRelCoor(Vector(1.1, 0.06, 0.14));102 this->setEmissionPoint(Vector(1.1, 0.14, 0.06), 0); 103 this->setEmissionPoint(Vector(1.1, -.06, 0.14), 1); 104 this->setEmissionPoint(Vector(1.1, 0.06, -.14), 2); 155 105 } 156 106 157 107 158 108 for (int i = 0; i < this->getBarrels(); i++){ 159 this-> shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);160 this-> shootAnim[i][0]->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL);161 this-> shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);162 163 this-> shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);164 this-> shootAnim[i][1]->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL);165 this-> shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);109 this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL); 110 this->getShootAnim(i, 0)->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL); 111 this->getShootAnim(i, 0)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); 112 113 this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); 114 this->getShootAnim(i, 1)->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL); 115 this->getShootAnim(i, 1)->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL); 166 116 } 167 117 … … 192 142 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); 193 143 194 pj->setAbsCoor(this-> emissionPoint[this->activeBarrel]->getAbsCoor());144 pj->setAbsCoor(this->getEmissionPoint()); 195 145 pj->setAbsDir(this->getAbsDir()); 196 146 pj->activate(); … … 198 148 // initiate animation 199 149 for (int i = 0; i < this->getSegs(); i++) 200 this->shootAnim[this->activeBarrel][i]->replay(); 201 202 // switch barrel 203 this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels(); 150 this->getShootAnim(this->getActiveBarrel(), i)->replay(); // FIXME needs clean up 151 152 this->cycleBarrel(); 204 153 } 205 154 … … 230 179 231 180 if (this->leftRight == W_LEFT) 232 glScalef(1.0, 1.0, -1.0); 233 234 static_cast<StaticModel*>(this->getModel())->draw(6);235 236 glPushMatrix();237 glTranslatef (this->objComp[0][0]->getAbsCoor().x, this->objComp[0][0]->getAbsCoor().y, this->objComp[0][0]->getAbsCoor().z);238 static_cast<StaticModel*>(this->getModel())->draw(2);239 glPopMatrix();240 241 glPushMatrix();242 glTranslatef (this->objComp[1][0]->getAbsCoor().x, this->objComp[1][0]->getAbsCoor().y, this->objComp[1][0]->getAbsCoor().z);243 static_cast<StaticModel*>(this->getModel())->draw(3);244 glPopMatrix();245 246 glPushMatrix();247 glTranslatef (this->objComp[2][0]->getAbsCoor().x, this->objComp[2][0]->getAbsCoor().y, this->objComp[2][0]->getAbsCoor().z);248 static_cast<StaticModel*>(this->getModel())->draw(1);249 glPopMatrix();250 251 glPushMatrix();252 glTranslatef (this->objComp[0][1]->getAbsCoor().x, this->objComp[0][1]->getAbsCoor().y, this->objComp[0][1]->getAbsCoor().z);253 static_cast<StaticModel*>(this->getModel())->draw(4);254 glPopMatrix();255 256 glPushMatrix();257 glTranslatef (this->objComp[1][1]->getAbsCoor().x, this->objComp[1][1]->getAbsCoor().y, this->objComp[1][1]->getAbsCoor().z);258 static_cast<StaticModel*>(this->getModel())->draw(5);259 glPopMatrix();260 261 glPushMatrix();262 glTranslatef (this->objComp[2][1]->getAbsCoor().x, this->objComp[2][1]->getAbsCoor().y, this->objComp[2][1]->getAbsCoor().z);263 static_cast<StaticModel*>(this->getModel())->draw(0);264 glPopMatrix();181 glScalef(1.0, 1.0, -1.0); //FIXME check weather this causes a slowdown... 182 183 static_cast<StaticModel*>(this->getModel())->draw(6); 184 185 glPushMatrix(); 186 glTranslatef (this->getObjCompx(0,0), this->getObjCompy(0,0), this->getObjCompz(0,0)); 187 static_cast<StaticModel*>(this->getModel())->draw(2); 188 glPopMatrix(); 189 190 glPushMatrix(); 191 glTranslatef (this->getObjCompx(1,0), this->getObjCompy(1,0), this->getObjCompz(1,0)); 192 static_cast<StaticModel*>(this->getModel())->draw(3); 193 glPopMatrix(); 194 195 glPushMatrix(); 196 glTranslatef (this->getObjCompx(2,0), this->getObjCompy(2,0), this->getObjCompz(2,0)); 197 static_cast<StaticModel*>(this->getModel())->draw(1); 198 glPopMatrix(); 199 200 glPushMatrix(); 201 glTranslatef (this->getObjCompx(0,1), this->getObjCompy(0,1), this->getObjCompz(0,1)); 202 static_cast<StaticModel*>(this->getModel())->draw(4); 203 glPopMatrix(); 204 205 glPushMatrix(); 206 glTranslatef (this->getObjCompx(1,1), this->getObjCompy(1,1), this->getObjCompz(1,1)); 207 static_cast<StaticModel*>(this->getModel())->draw(5); 208 glPopMatrix(); 209 210 glPushMatrix(); 211 glTranslatef (this->getObjCompx(2,1), this->getObjCompy(2,1), this->getObjCompz(2,1)); 212 static_cast<StaticModel*>(this->getModel())->draw(0); 213 glPopMatrix(); 265 214 266 215 glPopMatrix();
Note: See TracChangeset
for help on using the changeset viewer.