Changeset 6606 in orxonox.OLD for branches/spaceshipcontrol/src
- Timestamp:
- Jan 18, 2006, 7:32:59 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src/world_entities/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/weapons/aim.cc
r6305 r6606 101 101 } 102 102 103 void Aim::searchTarget(float range )103 void Aim::searchTarget(float range, float angle) 104 104 { 105 105 std::list<WorldEntity*>::iterator entity; 106 106 Vector diffVec(0.0, 0.0, 0.0); 107 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 108 109 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 110 if( this == PNode::getNullParent() || diffVec.len() > range || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle && (this->source->getAbsDirX()).dot(diffVec) > 0)) 107 111 for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin(); 108 112 entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end(); 109 113 entity ++) 110 114 { 111 if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range) 115 diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() ); 116 117 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle && (this->source->getAbsDirX()).dot(diffVec) > 0) 112 118 { 113 119 if (this->getParent() != (*entity)) … … 119 125 } 120 126 } 127 //if no target found: 128 this->setParent(PNode::getNullParent()); 121 129 } 122 130 … … 155 163 156 164 157 if (this->source->getAbsCoor().x > this->getAbsCoor().x )158 this->searchTarget(1000);165 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 166 // this->searchTarget(1000,M_PI_2); 159 167 // float z = 0.0f; 160 168 // glReadPixels ((int)this->getAbsCoor2D().x, -
branches/spaceshipcontrol/src/world_entities/weapons/aim.h
r5750 r6606 38 38 inline PNode* getTarget(PNode* target) { return this->getParent(); }; 39 39 40 void searchTarget(float range );40 void searchTarget(float range, float angle); 41 41 42 42 void setSize(float size); -
branches/spaceshipcontrol/src/world_entities/weapons/aiming_turret.cc
r6439 r6606 130 130 this->setAbsDirSoft(quat, 5); 131 131 132 this->target-> tick(dt);132 this->target->searchTarget(100,M_PI_2); 133 133 } 134 134 … … 146 146 pj->setAbsDir(this->getAbsDir()); 147 147 pj->activate(); 148 this->target->searchTarget(100 );148 this->target->searchTarget(100,M_PI_2); 149 149 } 150 150 -
branches/spaceshipcontrol/src/world_entities/weapons/targeting_turret.cc
r6439 r6606 92 92 this->target = new Aim(this); 93 93 this->target->setVisibility(false); 94 94 this->lockedTime = 0; 95 this->neededLockTime = 2; 96 this->lockedTarget->setParent(PNode::getNullParent()); 95 97 this->loadModel("models/guns/turret2.obj"); 96 98 … … 119 121 void TargetingTurret::tick(float dt) 120 122 { 123 if( lockedTime >= neededLockTime ) 124 { 125 lockedTarget = this->target->getParent(); 126 lockedTime = 0; 127 } 121 128 122 129 this->target->tick(dt); 130 131 if(this->target->getParent() == PNode::getNullParent()) 132 lockedTime = 0; 133 else 134 lockedTime += dt; 135 123 136 } 124 137 … … 137 150 pj->setAbsDir(this->getAbsDir()); 138 151 pj->activate(); 139 this->target->searchTarget(100 );152 this->target->searchTarget(100,M_PI_2); 140 153 } 141 154 -
branches/spaceshipcontrol/src/world_entities/weapons/targeting_turret.h
r6426 r6606 32 32 33 33 private: 34 Aim* target; 35 }; 34 Aim* target; 35 PNode* lockedTarget; 36 float lockedTime; 37 float neededLockTime; 38 }; 36 39 37 40 #endif /* _TARGETING_TURRET_H */
Note: See TracChangeset
for help on using the changeset viewer.