Changeset 4781 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jul 2, 2005, 11:35:29 PM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r4780 r4781 35 35 #include "crosshair.h" 36 36 37 Crosshair* test; 38 37 39 using namespace std; 38 40 … … 100 102 101 103 102 new Crosshair();104 test = new Crosshair(); 103 105 } 104 106 … … 196 198 void Player::draw () 197 199 { 200 test->draw(); 198 201 glMatrixMode(GL_MODELVIEW); 199 202 glPushMatrix(); … … 212 215 213 216 this->weaponMan->draw(); 217 214 218 } 215 219 … … 299 303 } 300 304 301 305 /** 306 * @todo switch statement ?? 307 */ 302 308 void Player::process(const Event &event) 303 309 { -
orxonox/trunk/src/world_entities/weapons/crosshair.cc
r4780 r4781 18 18 #include "crosshair.h" 19 19 #include "event_handler.h" 20 21 #include "graphics_engine.h" 22 #include "glincl.h" 23 #include "p_node.h" 24 #include "state.h" 25 20 26 using namespace std; 21 27 … … 44 50 void Crosshair::process(const Event &event) 45 51 { 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 } 47 57 48 58 } 59 60 61 void 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 29 29 30 30 void tick(float dt); 31 void draw() ;31 void draw() const; 32 32 33 33 private: 34 34 Vector position; //!< The current position of the Crosshair 35 float position2D[2]; //!< The 2D-position on the screen 35 36 36 37 };
Note: See TracChangeset
for help on using the changeset viewer.