Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/world_entities/weapons/aim.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/aim.cc

    r9656 r9869  
    2929
    3030
     31ObjectListDefinition(Aim);
    3132
    3233/**
     
    5051Aim::~Aim ()
    5152{
    52 /*  if (this->text != NULL)
    53     delete this->text;*/
     53  /*  if (this->text != NULL)
     54      delete this->text;*/
    5455}
    5556
     
    5960void Aim::init()
    6061{
    61   this->setClassID(CL_CROSSHAIR, "Aim");
     62  this->registerObject(this, Aim::_objectList);
    6263  this->setName("Aim");
    6364
     
    7980
    8081
    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");*/
    8788}
    8889
     
    9293
    9394  LoadParam(root, "texture", this, Aim, setTexture)
    94       .describe("the texture-file to load onto the Aim");
     95  .describe("the texture-file to load onto the Aim");
    9596
    9697  LoadParam(root, "size", this, Aim, setSize)
    97       .describe("the size of the Aim in Pixels");
     98  .describe("the size of the Aim in Pixels");
    9899
    99100  LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed)
    100       .describe("the Speed with which the Aim should rotate");
     101  .describe("the Speed with which the Aim should rotate");
    101102
    102103  LoadParam(root, "target-group", this, Aim, setTargetGroupS);
     
    107108  ObjectManager::EntityList::iterator entity;
    108109  //printf("%d\n", this->targetGroup);
    109   for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin();
    110        entity != State::getObjectManager()->getObjectList(this->targetGroup).end();
     110  for (entity = State::getObjectManager()->getEntityList(this->targetGroup).begin();
     111       entity != State::getObjectManager()->getEntityList(this->targetGroup).end();
    111112       entity ++)
    112113  {
     
    117118      //if (this->getParent() != (*entity))
    118119      {
    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());
    120121        this->anim->replay();
    121122        this->setParentSoft(*entity, 5);
     
    125126  }
    126127
    127    //if no target found:
    128    this->setParent(PNode::getNullParent());
     128  //if no target found:
     129  this->setParent(PNode::getNullParent());
    129130}
    130131
     
    165166  this->shiftDir2D(dt * rotationSpeed);
    166167
    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 )
    173174  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 range
    175    if(this->getParent() == PNode::getNullParent() ||
     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() ||
    176177      diffVec.len() > range )// ||
    177      //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    178     {
    179      this->setParentSoft(PNode::getNullParent(),5);
    180      this->searchTarget();
    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,  // z
    197 //                GraphicsEngine::modMat,
    198 //                GraphicsEngine::projMat,
    199 //                GraphicsEngine::viewPort,
    200 //                &objX,
    201 //                &objY,
    202 //                &objZ );
    203 //aa
    204 //   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);
    205206}
    206207
     
    211212{
    212213
    213  if( this->getParent() != PNode::getNullParent() )
     214  if( this->getParent() != PNode::getNullParent() )
    214215  {
    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();
    231232  }
    232233
Note: See TracChangeset for help on using the changeset viewer.