Changeset 9656 in orxonox.OLD for trunk/src/world_entities/weapons/aiming_turret.cc
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aiming_turret.cc
r9406 r9656 38 38 */ 39 39 AimingTurret::AimingTurret () 40 : Weapon()40 : Weapon(), target(this) 41 41 { 42 42 this->init(); … … 46 46 47 47 AimingTurret::AimingTurret(const TiXmlElement* root) 48 : target(this) 48 49 { 49 50 this->init(); … … 58 59 { 59 60 // model will be deleted from WorldEntity-destructor 60 // delete this->target;61 // delete this->target; 61 62 } 62 63 … … 91 92 //this->getProjectileFactory()->prepare(100); 92 93 93 this->target = new Aim(this);94 this->target ->setVisibility(false);95 this->target ->setRange(400);96 this->target ->setAngle(M_PI_2);94 this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE); 95 this->target.setVisibility(false); 96 this->target.setRange(400); 97 this->target.setAngle(M_PI_2); 97 98 98 99 this->setActionSound(WA_SHOOT, "sound/explosions/explosion_3.wav"); … … 110 111 void AimingTurret::activate() 111 112 { 112 this->target ->setVisibility(true);113 this->target.setVisibility(true); 113 114 } 114 115 115 116 void AimingTurret::deactivate() 116 117 { 117 this->target ->setVisibility(false);118 this->target.setVisibility(false); 118 119 } 119 120 … … 123 124 return; 124 125 Quaternion quat; 125 Vector direction = this->target ->getAbsCoor() - this->getAbsCoor();126 Vector direction = this->target.getAbsCoor() - this->getAbsCoor(); 126 127 127 128 direction.normalize(); 128 129 129 130 if (likely (this->getParent() != NULL)) 130 quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 131 //quat = Quaternion(direction, this->getParent()->getAbsDirY()) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 132 quat = Quaternion ( M_PI_2, this->getParent()->getAbsDirY()) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), this->getParent()->getAbsDirY()); 131 133 else 132 quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 134 //quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 135 quat = Quaternion ( M_PI_2, Vector(0,1,0)) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), Vector(0,1,0)); 133 136 134 137 this->setAbsDirSoft(quat, 5); 135 138 136 this->target ->tick(dt);139 this->target.tick(dt); 137 140 } 138 141 … … 143 146 return; 144 147 145 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir ().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)146 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());148 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDirX()*250.0 + VECTOR_RAND(4) 149 /*target.getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 147 150 148 151 pj->setParent(PNode::getNullParent());
Note: See TracChangeset
for help on using the changeset viewer.