Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4781 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jul 2, 2005, 11:35:29 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: the mighty useless crosshair…

Location:
orxonox/trunk/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/player.cc

    r4780 r4781  
    3535#include "crosshair.h"
    3636
     37Crosshair* test;
     38
    3739using namespace std;
    3840
     
    100102
    101103
    102   new Crosshair();
     104  test = new Crosshair();
    103105}
    104106
     
    196198void Player::draw ()
    197199{
     200  test->draw();
    198201  glMatrixMode(GL_MODELVIEW);
    199202  glPushMatrix();
     
    212215
    213216  this->weaponMan->draw();
     217
    214218}
    215219
     
    299303}
    300304
    301 
     305/**
     306 * @todo switch statement ??
     307 */
    302308void Player::process(const Event &event)
    303309{
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4780 r4781  
    1818#include "crosshair.h"
    1919#include "event_handler.h"
     20
     21#include "graphics_engine.h"
     22#include "glincl.h"
     23#include "p_node.h"
     24#include "state.h"
     25
    2026using namespace std;
    2127
     
    4450void Crosshair::process(const Event &event)
    4551{
    46   printf("wow\n");
     52  if  (event.type == EV_MOUSE_MOTION)
     53  {
     54    this->position2D[0] = event.x;
     55    this->position2D[1] = event.y;
     56  }
    4757
    4858}
     59
     60
     61void Crosshair::draw() const
     62{
     63  const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
     64  Vector cameraPos = camera->getAbsCoor();
     65  Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
     66  Vector view = cameraTargetPos - cameraPos;
     67  Vector up = Vector(0, 1, 0);
     68  up = camera->getAbsDir().apply(up);
     69  Vector h = up.cross(view);
     70  Vector v = h.cross(view);
     71  h.normalize();
     72  v.normalize();
     73
     74  float px = (position2D[0]-GraphicsEngine::getInstance()->getResolutionX()/2)*.05;
     75  float py = -(position2D[1]-GraphicsEngine::getInstance()->getResolutionY()/2)*.05;
     76
     77
     78
     79  glBegin(GL_TRIANGLES);
     80  glVertex3f(cameraTargetPos.x - h.x*px - v.x*py,
     81             cameraTargetPos.y - h.y*px - v.y*py,
     82             cameraTargetPos.z - h.z*px - v.z*py);
     83
     84  glVertex3f(cameraTargetPos.x - h.x*(px+1) - v.x*py,
     85             cameraTargetPos.y - h.y*(px+1) - v.y*py,
     86             cameraTargetPos.z - h.z*(px+1) - v.z*py);
     87
     88  glVertex3f(cameraTargetPos.x - h.x*px - v.x*(py+1),
     89             cameraTargetPos.y - h.y*px - v.y*(py+1),
     90             cameraTargetPos.z - h.z*px - v.z*(py+1));
     91
     92  glEnd();
     93
     94}
  • orxonox/trunk/src/world_entities/weapons/crosshair.h

    r4779 r4781  
    2929
    3030  void tick(float dt);
    31   void draw();
     31  void draw() const;
    3232
    3333 private:
    3434   Vector           position;             //!< The current position of the Crosshair
     35   float            position2D[2];        //!< The 2D-position on the screen
    3536
    3637};
Note: See TracChangeset for help on using the changeset viewer.