Changeset 9656 in orxonox.OLD for trunk/src/world_entities/weapons/aim.cc
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aim.cc
r9406 r9656 50 50 Aim::~Aim () 51 51 { 52 if (this->material)53 delete this->material;54 55 52 /* if (this->text != NULL) 56 53 delete this->text;*/ … … 70 67 71 68 this->setBindNode(this); 72 this->material = new Material;73 69 this->source = NULL; 74 70 75 this->range = 1000 0;71 this->range = 1000; 76 72 this->angle = M_PI_4; 77 this-> group = OM_GROUP_01;73 this->targetGroup = OM_GROUP_01; 78 74 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 79 75 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 103 99 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 104 100 .describe("the Speed with which the Aim should rotate"); 101 102 LoadParam(root, "target-group", this, Aim, setTargetGroupS); 105 103 } 106 104 … … 108 106 { 109 107 ObjectManager::EntityList::iterator entity; 110 111 for (entity = State::getObjectManager()->getObjectList( group).begin();112 entity != State::getObjectManager()->getObjectList( group).end();108 //printf("%d\n", this->targetGroup); 109 for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin(); 110 entity != State::getObjectManager()->getObjectList(this->targetGroup).end(); 113 111 entity ++) 114 112 { 115 113 diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() ); 116 114 117 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)115 if ( diffVec.len() < range )//&& acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 118 116 { 119 117 //if (this->getParent() != (*entity)) 120 118 { 119 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 121 120 this->anim->replay(); 122 121 this->setParentSoft(*entity, 5); … … 128 127 //if no target found: 129 128 this->setParent(PNode::getNullParent()); 130 131 132 133 } 134 129 } 130 131 void Aim::setTargetGroupS(const std::string& groupName) 132 { 133 OM_LIST id = ObjectManager::StringToOMList(groupName); 134 if (id != OM_NULL) 135 this->setTargetGroup(id); 136 else 137 PRINTF(2)("List %s not found for targetting\n", groupName.c_str()); 138 } 135 139 136 140 /** … … 149 153 void Aim::setTexture(const std::string& textureFile) 150 154 { 151 this->material ->setDiffuseMap(textureFile);155 this->material.setDiffuseMap(textureFile); 152 156 } 153 157 … … 170 174 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 171 175 if(this->getParent() == PNode::getNullParent() || 172 diffVec.len() > range ||173 ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))176 diffVec.len() > range )// || 177 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 174 178 { 175 179 this->setParentSoft(PNode::getNullParent(),5); … … 213 217 214 218 glRotatef(this->getAbsDir2D(), 0,0,1); 215 this->material ->select();219 this->material.select(); 216 220 glBegin(GL_TRIANGLE_STRIP); 217 221 glTexCoord2f(0, 0);
Note: See TracChangeset
for help on using the changeset viewer.