Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 11, 2005, 5:47:23 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: crosshair in WeaponManager (instead of World) and implemented easy Cyling for LoadParam

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4832 r4834  
    4343}
    4444
    45 
    4645/**
    4746 * destroys a Crosshair
     
    6867
    6968  this->rotation = 0;
    70   this->rotationSpeed = 5;
     69  this->setRotationSpeed(5);
    7170  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    7271
     
    155154void Crosshair::tick(float dt)
    156155{
     156  // let the crosshair rotate
    157157  this->rotation += dt * rotationSpeed;
    158158
    159159
    160 
    161 }
    162 
    163 /**
    164  * draws the crosshair
    165  */
    166 void Crosshair::draw()
    167 {
    168   /*
    169   const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
    170   Vector cameraPos = camera->getAbsCoor();
    171   Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
    172   Vector view = cameraTargetPos - cameraPos;
    173   Vector up = Vector(0, 1, 0);
    174   up = camera->getAbsDir().apply(up);
    175   Vector h = up.cross(view);
    176   Vector v = h.cross(view);
    177   h.normalize();
    178   v.normalize();
    179 
    180   float px = (position2D[0]-GraphicsEngine::getInstance()->getResolutionX()/2)*.05;
    181   float py = -(position2D[1]-GraphicsEngine::getInstance()->getResolutionY()/2)*.05;
    182 
    183   glBegin(GL_TRIANGLES);
    184   glVertex3f(cameraTargetPos.x - h.x*px - v.x*py,
    185   cameraTargetPos.y - h.y*px - v.y*py,
    186   cameraTargetPos.z - h.z*px - v.z*py);
    187 
    188   glVertex3f(cameraTargetPos.x - h.x*(px+1) - v.x*py,
    189   cameraTargetPos.y - h.y*(px+1) - v.y*py,
    190   cameraTargetPos.z - h.z*(px+1) - v.z*py);
    191 
    192   glVertex3f(cameraTargetPos.x - h.x*px - v.x*(py+1),
    193   cameraTargetPos.y - h.y*px - v.y*(py+1),
    194   cameraTargetPos.z - h.z*px - v.z*(py+1));
    195 
    196   glEnd();
    197 
    198   */
    199 
    200 
    201   GraphicsEngine::storeMatrices();
    202 
    203 ///  float z;
    204 //   glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    205 
    206 
    207   //cout << z <<"  "<< scale << "  "  << bias<< endl;
    208 
     160  float z;
     161  glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
     162  //cout << z << endl;
    209163
    210164  GLdouble objX, objY, objZ;
     
    221175  this->setAbsCoor(objX, objY, objZ);
    222176
     177
     178}
     179
     180/**
     181 * draws the crosshair
     182 */
     183void Crosshair::draw()
     184{
     185  GraphicsEngine::storeMatrices();
     186
     187
     188
     189
    223190//   glBegin(GL_TRIANGLES);
    224191//   glColor3f(1,0,0);
     
    228195//   glEnd();
    229196
     197  this->debugDraw();
    230198
    231199  GraphicsEngine::enter2DMode();
     
    253221  glVertex2f(size, size);
    254222  glEnd();
    255   /*
    256   glBegin(GL_QUADS);
    257   {
    258     glColor4f(1,0,0,1);
    259     glVertex2f(position2D[0]-10, position2D[1]-10);
    260     glVertex2f(position2D[0]+10, position2D[1]-10);
    261     glVertex2f(position2D[0]+10, position2D[1]+10);
    262     glVertex2f(position2D[0]-10, position2D[1]+10);
    263 
    264     //     glVertex2f(pos[0]-10, pos[1]-10);
    265     //     glVertex2f(pos[0]-10, pos[1]+10);
    266     //     glVertex2f(pos[0]+10, pos[1]+10);
    267     //     glVertex2f(pos[0]+10, pos[1]-10);
    268   }
    269   glEnd();
    270   */
     223
    271224  GraphicsEngine::leave2DMode();
    272225}
Note: See TracChangeset for help on using the changeset viewer.