#include "heavy_blaster.h" #include "world_entities/projectiles/projectile.h" #include "world_entity.h" #include "static_model.h" #include "weapon_manager.h" #include "util/loading/factory.h" #include "animation3d.h" #include "loading/fast_factory.h" CREATE_FACTORY(HeavyBlaster); /** * Standard constructor */ HeavyBlaster::HeavyBlaster () : Weapon() { this->init(); } HeavyBlaster::HeavyBlaster (const TiXmlElement* root = NULL) : Weapon() { this->init(); if (root != NULL) this->loadParams(root); } /** * Default destructor */ HeavyBlaster::~HeavyBlaster() { // model will be deleted from WorldEntity-destructor } void HeavyBlaster::loadParams(const TiXmlElement* root) { Weapon::loadParams(root); } void HeavyBlaster::init() { //this->registerObject(this, HeavyBlaster::_objectList); // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); this->loadModel("models/guns/fragcannon.obj", .4); this->setStateDuration(WS_SHOOTING, 0.5); // 2 Schuss pro Sekunde this->setStateDuration(WS_RELOADING, 0); this->setStateDuration(WS_ACTIVATING, .5); this->setStateDuration(WS_DEACTIVATING, 1); this->setEnergyMax(500); this->increaseEnergy(500); //this->minCharge = 2; this->setActionSound(WA_SHOOT, "sound/laser.wav"); this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav"); this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav"); this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); this->setProjectileTypeC("HBolt"); // FIXME temp project type until the blaste class exist this->prepareProjectiles(5); this->setBarrels(3); this->setSegs(2); this->objComp1 = new PNode; this->objComp2 = new PNode; this->objComp3 = new PNode; this->objComp4 = new PNode; this->objComp5 = new PNode; this->objComp6 = new PNode; Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp1); // Animation3D* animB1Shoot = this->getAnimation(WS_SHOOTING1, this->objComp2); // Animation3D* animB2Shoot = this->getAnimation(WS_SHOOTING2, this->objComp3); // Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp4); // Animation3D* animT1Shoot = this->getAnimation(WS_SHOOTING4, this->objComp5); // Animation3D* animT2Shoot = this->getAnimation(WS_SHOOTING5, this->objComp6); animB0Shoot->setInfinity(ANIM_INF_CONSTANT); // animB1Shoot->setInfinity(ANIM_INF_CONSTANT); // animB2Shoot->setInfinity(ANIM_INF_CONSTANT); // animT0Shoot->setInfinity(ANIM_INF_CONSTANT); // animT1Shoot->setInfinity(ANIM_INF_CONSTANT); // animT2Shoot->setInfinity(ANIM_INF_CONSTANT); animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animB0Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); /* animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animT0Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);*/ /* animB1Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animB1Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animB1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); animT1Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animT1Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animT1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); animB2Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animB2Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animB2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); animT2Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); animT2Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animT2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);*/ Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); animation2->setInfinity(ANIM_INF_CONSTANT); animation3->setInfinity(ANIM_INF_CONSTANT); this->setEmissionPoint(3.8, 1.2, 0); animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); } void HeavyBlaster::fire() { Projectile* pj = this->getProjectile(); if (pj == NULL) return; // set the owner pj->setOwner(this->getOwner()); pj->setParent(PNode::getNullParent()); // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); pj->setAbsCoor(this->getEmissionPoint()); pj->setAbsDir(this->getAbsDir()); pj->toList(OM_GROUP_01_PROJ); pj->activate(); } /** * this activates the weapon */ void HeavyBlaster::activate() { } /** * this deactivates the weapon */ void HeavyBlaster::deactivate() { } void HeavyBlaster::draw() const { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); static_cast(this->getModel())->draw(6); glPushMatrix(); glTranslatef (this->objComp1->getAbsCoor().x, this->objComp1->getAbsCoor().y, this->objComp1->getAbsCoor().z); static_cast(this->getModel())->draw(1); static_cast(this->getModel())->draw(2); static_cast(this->getModel())->draw(0); glPushMatrix(); glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z); static_cast(this->getModel())->draw(4); static_cast(this->getModel())->draw(5); static_cast(this->getModel())->draw(3); glPopMatrix(); glPopMatrix(); /* glPushMatrix(); glTranslatef (this->objComp2->getAbsCoor().x, this->objComp2->getAbsCoor().y, this->objComp2->getAbsCoor().z); static_cast(this->getModel())->draw(2); glPopMatrix(); glPushMatrix(); glTranslatef (this->objComp3->getAbsCoor().x, this->objComp3->getAbsCoor().y, this->objComp3->getAbsCoor().z); static_cast(this->getModel())->draw(0); glPopMatrix();*/ // glPushMatrix(); // glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z); // static_cast(this->getModel())->draw(4); // static_cast(this->getModel())->draw(5); // static_cast(this->getModel())->draw(3); // glPopMatrix(); /* glPushMatrix(); glTranslatef (this->objComp5->getAbsCoor().x, this->objComp5->getAbsCoor().y, this->objComp5->getAbsCoor().z); static_cast(this->getModel())->draw(5); glPopMatrix(); glPushMatrix(); glTranslatef (this->objComp6->getAbsCoor().x, this->objComp6->getAbsCoor().y, this->objComp6->getAbsCoor().z); static_cast(this->getModel())->draw(3); glPopMatrix();*/ glPopMatrix(); }