Changeset 5527 in orxonox.OLD for branches/world_entities/src/world_entities/weapons/aiming_turret.cc
- Timestamp:
- Nov 10, 2005, 12:33:31 AM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/world_entities/weapons/aiming_turret.cc
r5526 r5527 15 15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 16 16 17 #include " turret.h"17 #include "aiming_turret.h" 18 18 19 19 #include "weapon_manager.h" … … 30 30 #include "factory.h" 31 31 32 CREATE_FACTORY( Turret);32 CREATE_FACTORY(AimingTurret); 33 33 34 34 using namespace std; … … 40 40 creates a new weapon 41 41 */ 42 Turret::Turret (WeaponManager* weaponManager)42 AimingTurret::AimingTurret (WeaponManager* weaponManager) 43 43 : Weapon(weaponManager) 44 44 { … … 54 54 55 55 56 Turret::Turret(const TiXmlElement* root)56 AimingTurret::AimingTurret(const TiXmlElement* root) 57 57 { 58 58 this->init(); … … 63 63 * standard deconstructor 64 64 */ 65 Turret::~Turret ()65 AimingTurret::~AimingTurret () 66 66 { 67 67 // model will be deleted from WorldEntity-destructor 68 68 } 69 69 70 void Turret::init()70 void AimingTurret::init() 71 71 { 72 this->setClassID(CL_ TURRET, "Turret");72 this->setClassID(CL_AIMING_TURRET, "AimingTurret"); 73 73 74 74 Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this); … … 98 98 this->setEmissionPoint(1.684, 0.472, 0); 99 99 //this->getProjectileFactory()->prepare(100); 100 101 this->target = NULL; 100 102 } 101 103 102 void Turret::loadParams(const TiXmlElement* root)104 void AimingTurret::loadParams(const TiXmlElement* root) 103 105 { 104 106 static_cast<Weapon*>(this)->loadParams(root); … … 106 108 } 107 109 108 void Turret::activate()110 void AimingTurret::activate() 109 111 { 110 112 } 111 113 112 void Turret::deactivate()114 void AimingTurret::deactivate() 113 115 { 114 116 } 115 117 116 void Turret::tick(float dt)118 void AimingTurret::tick(float dt) 117 119 { 118 120 Quaternion quat; 119 Vector direction = this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor(); 121 if (this->target == NULL) 122 this->target = this->getWeaponManager()->getDistanceTarget(this, 50); 123 Vector direction = this->target->getAbsCoor() - this->getAbsCoor(); 120 124 121 125 direction.normalize(); … … 126 130 quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 127 131 128 this->setAbsDirSoft(quat, 5);132 this->setAbsDirSoft(quat, 20); 129 133 } 130 134 131 void Turret::fire()135 void AimingTurret::fire() 132 136 { 133 137 Projectile* pj = this->getProjectile(); … … 139 143 if (target != NULL) 140 144 { 141 pj->setVelocity( this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13)145 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13) 142 146 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 143 147 } … … 149 153 pj->setAbsDir(this->getAbsDir()); 150 154 pj->activate(); 155 this->target = this->getWeaponManager()->getDistanceTarget(this, 50); 151 156 } 152 157 153 void Turret::destroy ()158 void AimingTurret::destroy () 154 159 {} 155 160 156 161 /** 157 * draws the Turret162 * draws the AimingTurret 158 163 */ 159 void Turret::draw () const164 void AimingTurret::draw () const 160 165 { 161 166 this->getWeaponManager()->getFixedTarget()->debugDraw(10);
Note: See TracChangeset
for help on using the changeset viewer.