Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4823 in orxonox.OLD


Ignore:
Timestamp:
Jul 8, 2005, 12:30:31 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: better algorithm to get the position of the crosshair

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r4822 r4823  
    880880    }
    881881  delete iterator;
     882  crosshair->draw();
    882883
    883884  glCallList (objectList);
     
    885886  ParticleEngine::getInstance()->draw(); //!< \todo should be dts like in the Trunk;
    886887
    887   crosshair->draw();
    888888  TextEngine::getInstance()->draw();
    889889  LightManager::getInstance()->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4818 r4823  
    5757  }
    5858
     59  /*
     60  GLdouble z;
     61  GLdouble objX, objY, objZ;
     62  glReadPixels (event.x, event.y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);
     63
     64
     65  if (gluUnProject(event.x,
     66      event.y,
     67      10,
     68      GraphicsEngine::modMat,
     69      GraphicsEngine::projMat,
     70      GraphicsEngine::viewPort,
     71      &objX,
     72      &objY,
     73      &objZ ))
     74    PRINT(0)("screen %d %d -> obj(%f/%f/%f)\n", event.x, event.y, objX, objY, objZ);
     75  else
     76    PRINT(0)("shit\n");
     77*/
    5978}
    6079
     
    6281void Crosshair::draw() const
    6382{
     83  /*
    6484  const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
    6585  Vector cameraPos = camera->getAbsCoor();
     
    7696  float py = -(position2D[1]-GraphicsEngine::getInstance()->getResolutionY()/2)*.05;
    7797
    78 
    79 
    8098  glBegin(GL_TRIANGLES);
    8199  glVertex3f(cameraTargetPos.x - h.x*px - v.x*py,
    82              cameraTargetPos.y - h.y*px - v.y*py,
    83              cameraTargetPos.z - h.z*px - v.z*py);
     100  cameraTargetPos.y - h.y*px - v.y*py,
     101  cameraTargetPos.z - h.z*px - v.z*py);
    84102
    85103  glVertex3f(cameraTargetPos.x - h.x*(px+1) - v.x*py,
    86              cameraTargetPos.y - h.y*(px+1) - v.y*py,
    87              cameraTargetPos.z - h.z*(px+1) - v.z*py);
     104  cameraTargetPos.y - h.y*(px+1) - v.y*py,
     105  cameraTargetPos.z - h.z*(px+1) - v.z*py);
    88106
    89107  glVertex3f(cameraTargetPos.x - h.x*px - v.x*(py+1),
    90              cameraTargetPos.y - h.y*px - v.y*(py+1),
    91              cameraTargetPos.z - h.z*px - v.z*(py+1));
     108  cameraTargetPos.y - h.y*px - v.y*(py+1),
     109  cameraTargetPos.z - h.z*px - v.z*(py+1));
    92110
    93111  glEnd();
    94112
     113  */
     114
     115  GraphicsEngine::storeMatrices();
     116
     117  GLdouble z;
     118  GLdouble objX, objY, objZ;
     119  if (gluUnProject(position2D[0],
     120      GraphicsEngine::getInstance()->getResolutionY()-position2D[1],
     121      .8,
     122      GraphicsEngine::modMat,
     123      GraphicsEngine::projMat,
     124      GraphicsEngine::viewPort,
     125      &objX,
     126      &objY,
     127      &objZ ));
     128
     129  glBegin(GL_TRIANGLES);
     130  glColor3f(1,0,0);
     131  glVertex3f(objX, objY, objZ);
     132  glVertex3f(objX, objY+1, objZ);
     133  glVertex3f(objX, objY, objZ+1);
     134  glEnd();
    95135}
Note: See TracChangeset for help on using the changeset viewer.