Changeset 6606 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities/weapons/aim.cc
- Timestamp:
- Jan 18, 2006, 7:32:59 PM (18 years ago)
- File:
-
- 1 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,
Note: See TracChangeset
for help on using the changeset viewer.