Changeset 9869 in orxonox.OLD for trunk/src/world_entities/weapons/aim.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aim.cc
r9656 r9869 29 29 30 30 31 ObjectListDefinition(Aim); 31 32 32 33 /** … … 50 51 Aim::~Aim () 51 52 { 52 /* if (this->text != NULL)53 delete this->text;*/53 /* if (this->text != NULL) 54 delete this->text;*/ 54 55 } 55 56 … … 59 60 void Aim::init() 60 61 { 61 this-> setClassID(CL_CROSSHAIR, "Aim");62 this->registerObject(this, Aim::_objectList); 62 63 this->setName("Aim"); 63 64 … … 79 80 80 81 81 /* this->text = new Text();82 this->text->setLayer(this->getLayer());83 this->text->setParent2D(this);84 this->text->setRelCoor2D(10, -50);85 this->text->setParentMode2D(E2D_PARENT_MOVEMENT);86 this->text->setText("Testing");*/82 /* this->text = new Text(); 83 this->text->setLayer(this->getLayer()); 84 this->text->setParent2D(this); 85 this->text->setRelCoor2D(10, -50); 86 this->text->setParentMode2D(E2D_PARENT_MOVEMENT); 87 this->text->setText("Testing");*/ 87 88 } 88 89 … … 92 93 93 94 LoadParam(root, "texture", this, Aim, setTexture) 94 95 .describe("the texture-file to load onto the Aim"); 95 96 96 97 LoadParam(root, "size", this, Aim, setSize) 97 98 .describe("the size of the Aim in Pixels"); 98 99 99 100 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 100 101 .describe("the Speed with which the Aim should rotate"); 101 102 102 103 LoadParam(root, "target-group", this, Aim, setTargetGroupS); … … 107 108 ObjectManager::EntityList::iterator entity; 108 109 //printf("%d\n", this->targetGroup); 109 for (entity = State::getObjectManager()->get ObjectList(this->targetGroup).begin();110 entity != State::getObjectManager()->get ObjectList(this->targetGroup).end();110 for (entity = State::getObjectManager()->getEntityList(this->targetGroup).begin(); 111 entity != State::getObjectManager()->getEntityList(this->targetGroup).end(); 111 112 entity ++) 112 113 { … … 117 118 //if (this->getParent() != (*entity)) 118 119 { 119 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());120 // printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 120 121 this->anim->replay(); 121 122 this->setParentSoft(*entity, 5); … … 125 126 } 126 127 127 128 128 //if no target found: 129 this->setParent(PNode::getNullParent()); 129 130 } 130 131 … … 165 166 this->shiftDir2D(dt * rotationSpeed); 166 167 167 // char outputText[100];168 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len());169 // this->text->setText(outputText);170 171 172 // if (this->source->getAbsCoor().x > this->getAbsCoor().x )168 // char outputText[100]; 169 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len()); 170 // this->text->setText(outputText); 171 172 173 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 173 174 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 174 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range175 175 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 176 if(this->getParent() == PNode::getNullParent() || 176 177 diffVec.len() > range )// || 177 178 179 180 181 182 183 // float z = 0.0f;184 // glReadPixels ((int)this->getAbsCoor2D().x,185 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,186 // 1,187 // 1,188 // GL_DEPTH_COMPONENT,189 // GL_FLOAT,190 // &z);191 //192 //193 // GLdouble objX=.0, objY=.0, objZ=.0;194 // gluUnProject(this->getAbsCoor2D().x,195 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,196 // .99, // z197 // GraphicsEngine::modMat,198 // GraphicsEngine::projMat,199 // GraphicsEngine::viewPort,200 // &objX,201 // &objY,202 // &objZ );203 //aa204 // this->setAbsCoor(objX, objY, objZ);178 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 179 { 180 this->setParentSoft(PNode::getNullParent(),5); 181 this->searchTarget(); 182 } 183 184 // float z = 0.0f; 185 // glReadPixels ((int)this->getAbsCoor2D().x, 186 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 187 // 1, 188 // 1, 189 // GL_DEPTH_COMPONENT, 190 // GL_FLOAT, 191 // &z); 192 // 193 // 194 // GLdouble objX=.0, objY=.0, objZ=.0; 195 // gluUnProject(this->getAbsCoor2D().x, 196 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 197 // .99, // z 198 // GraphicsEngine::modMat, 199 // GraphicsEngine::projMat, 200 // GraphicsEngine::viewPort, 201 // &objX, 202 // &objY, 203 // &objZ ); 204 //aa 205 // this->setAbsCoor(objX, objY, objZ); 205 206 } 206 207 … … 211 212 { 212 213 213 if( this->getParent() != PNode::getNullParent() )214 if( this->getParent() != PNode::getNullParent() ) 214 215 { 215 glPushMatrix();216 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);217 218 glRotatef(this->getAbsDir2D(), 0,0,1);219 this->material.select();220 glBegin(GL_TRIANGLE_STRIP);221 glTexCoord2f(0, 0);222 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());223 glTexCoord2f(1, 0);224 glVertex2f(this->getSizeX2D(), -this->getSizeY2D());225 glTexCoord2f(0, 1);226 glVertex2f(-this->getSizeX2D(), this->getSizeY2D());227 glTexCoord2f(1, 1);228 glVertex2f(this->getSizeX2D(), this->getSizeY2D());229 glEnd();230 glPopMatrix();216 glPushMatrix(); 217 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 218 219 glRotatef(this->getAbsDir2D(), 0,0,1); 220 this->material.select(); 221 glBegin(GL_TRIANGLE_STRIP); 222 glTexCoord2f(0, 0); 223 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D()); 224 glTexCoord2f(1, 0); 225 glVertex2f(this->getSizeX2D(), -this->getSizeY2D()); 226 glTexCoord2f(0, 1); 227 glVertex2f(-this->getSizeX2D(), this->getSizeY2D()); 228 glTexCoord2f(1, 1); 229 glVertex2f(this->getSizeX2D(), this->getSizeY2D()); 230 glEnd(); 231 glPopMatrix(); 231 232 } 232 233
Note: See TracChangeset
for help on using the changeset viewer.