Changeset 10648 in orxonox.OLD for branches/vs-enhencements/src/world_entities/weapons/disruptor.cc
- Timestamp:
- May 4, 2007, 9:53:07 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/world_entities/weapons/disruptor.cc
r10645 r10648 15 15 */ 16 16 17 #include " heavy_blaster.h"17 #include "disruptor.h" 18 18 #include "world_entities/projectiles/projectile.h" 19 19 … … 29 29 #include "elements/glgui_energywidgetvertical.h" 30 30 31 CREATE_FACTORY( HeavyBlaster);32 // ObjectListDefinition( HeavyBlaster);31 CREATE_FACTORY(Disruptor); 32 // ObjectListDefinition(Disruptor); 33 33 34 34 … … 37 37 * Standard constructor 38 38 */ 39 HeavyBlaster::HeavyBlaster (int leftRight)39 Disruptor::Disruptor () 40 40 : Weapon() 41 41 { 42 // this->registerObject(this, HeavyBlaster::_objectList);43 44 this->init( leftRight);45 } 46 47 HeavyBlaster::HeavyBlaster (const TiXmlElement* root = NULL)42 // this->registerObject(this, Disruptor::_objectList); 43 44 this->init(); 45 } 46 47 Disruptor::Disruptor (const TiXmlElement* root = NULL) 48 48 : Weapon() 49 49 { 50 // this->registerObject(this, HeavyBlaster::_objectList);50 // this->registerObject(this, Disruptor::_objectList); 51 51 52 52 // TODO add leftRight to params 53 this->init( 0);53 this->init(); 54 54 if (root != NULL) 55 55 this->loadParams(root); … … 59 59 * Default destructor 60 60 */ 61 HeavyBlaster::~HeavyBlaster()61 Disruptor::~Disruptor() 62 62 { 63 63 for (int i = 0; i < this->getBarrels(); i++) … … 85 85 } 86 86 87 void HeavyBlaster::loadParams(const TiXmlElement* root)87 void Disruptor::loadParams(const TiXmlElement* root) 88 88 { 89 89 Weapon::loadParams(root); 90 90 } 91 91 92 void HeavyBlaster::init(int leftRight) 93 { 94 95 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 100 this->loadModel("models/guns/frag_cannon2.obj", .4); 101 102 103 this->setStateDuration(WS_SHOOTING, 0.5); // 2 Schuss pro Sekunde 92 void Disruptor::init() 93 { 94 95 this->setScaling(.5); 96 97 this->loadModel("models/guns/disruptor.obj", this->getScaling()); 98 99 100 this->setStateDuration(WS_SHOOTING, 0.3333); // 3 Shots per Second 104 101 this->setStateDuration(WS_RELOADING, 0); 105 102 this->setStateDuration(WS_ACTIVATING, .5); … … 118 115 this->prepareProjectiles(5); 119 116 120 this->setBarrels( 3);121 this->setSegs( 2);117 this->setBarrels(1); 118 this->setSegs(1); 122 119 this->activeBarrel = 0; 123 120 … … 131 128 this->objComp[i] = new PNode* [this->getSegs()]; 132 129 this->emissionPoint[i] = new PNode; 133 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 Projectiles130 this->emissionPoint[i]->setParent(this); //Parenting emissionPoint to Weapon 134 131 this->emissionPoint[i]->setName("EmissionPoint"); 135 132 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); … … 143 140 } 144 141 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)); 150 } 151 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)); 155 } 156 157 158 for (int i = 0; i < this->getBarrels(); i++){ 159 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, 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.55, ANIM_LINEAR, ANIM_NULL); 162 163 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, 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.25, ANIM_LINEAR, ANIM_NULL); 166 } 142 this->emissionPoint[0]->setRelCoor(Vector(1.672, 0.0, 0.0) * this->getScaling()); 143 167 144 168 145 Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); … … 180 157 181 158 182 void HeavyBlaster::fire()159 void Disruptor::fire() 183 160 { 184 161 Projectile* pj = this->getProjectile(); … … 197 174 198 175 // initiate animation 199 for (int i = 0; i < this->getSegs(); i++)200 this->shootAnim[this->activeBarrel][i]->replay();176 // for (int i = 0; i < this->getSegs(); i++) 177 // this->shootAnim[this->activeBarrel][i]->replay(); 201 178 202 179 // switch barrel 203 this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels();180 // this->activeBarrel = (this->activeBarrel + 1) % this->getBarrels(); 204 181 } 205 182 … … 207 184 * this activates the weapon 208 185 */ 209 void HeavyBlaster::activate()186 void Disruptor::activate() 210 187 { 211 188 } … … 214 191 * this deactivates the weapon 215 192 */ 216 void HeavyBlaster::deactivate()217 { 218 } 219 220 221 void HeavyBlaster::draw() const193 void Disruptor::deactivate() 194 { 195 } 196 197 198 void Disruptor::draw() const 222 199 { 223 200 glMatrixMode(GL_MODELVIEW); … … 229 206 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 230 207 231 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); 208 static_cast<StaticModel*>(this->getModel())->draw(); 209 239 210 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(); 265 266 glPopMatrix(); 267 } 268 269 void HeavyBlaster::tick(float dt) 211 } 212 213 void Disruptor::tick(float dt) 270 214 { 271 215 if (!Weapon::tickW(dt))
Note: See TracChangeset
for help on using the changeset viewer.