Changeset 6723 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities/weapons/aim.cc
- Timestamp:
- Jan 25, 2006, 5:25:15 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/weapons/aim.cc
r6637 r6723 73 73 this->source = NULL; 74 74 75 this->range = 0; 76 this->angle = 0; 75 this->range = 10000; 76 this->angle = M_PI_4; 77 this->group = OM_GROUP_01; 77 78 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 78 79 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 106 107 { 107 108 std::list<WorldEntity*>::iterator entity; 108 Vector diffVec(0.0, 0.0, 0.0); 109 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 110 111 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 112 if( this == PNode::getNullParent() || diffVec.len() > range || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 113 for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin(); 114 entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end(); 109 110 for (entity = State::getObjectManager()->getObjectList(group).begin(); 111 entity != State::getObjectManager()->getObjectList(group).end(); 115 112 entity ++) 116 113 { … … 119 116 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 120 117 { 121 if (this->getParent() != (*entity))118 //if (this->getParent() != (*entity)) 122 119 { 123 120 this->anim->replay(); … … 127 124 } 128 125 } 129 //if no target found: 130 this->setParent(PNode::getNullParent()); 126 127 //if no target found: 128 this->setParent(PNode::getNullParent()); 129 130 131 131 132 } 132 133 … … 165 166 166 167 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 168 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 169 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 170 if(this->getParent() == PNode::getNullParent() || 171 diffVec.len() > range || 172 ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 173 { 167 174 this->searchTarget(); 175 } 176 168 177 // float z = 0.0f; 169 178 // glReadPixels ((int)this->getAbsCoor2D().x, … … 196 205 { 197 206 207 if( this->getParent() != PNode::getNullParent() ) 208 { 198 209 glPushMatrix(); 199 210 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); … … 212 223 glEnd(); 213 224 glPopMatrix(); 214 215 } 225 } 226 227 }
Note: See TracChangeset
for help on using the changeset viewer.