Changeset 4834 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons/crosshair.cc
- Timestamp:
- Jul 11, 2005, 5:47:23 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/crosshair.cc
r4832 r4834 43 43 } 44 44 45 46 45 /** 47 46 * destroys a Crosshair … … 68 67 69 68 this->rotation = 0; 70 this-> rotationSpeed = 5;69 this->setRotationSpeed(5); 71 70 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); 72 71 … … 155 154 void Crosshair::tick(float dt) 156 155 { 156 // let the crosshair rotate 157 157 this->rotation += dt * rotationSpeed; 158 158 159 159 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; 209 163 210 164 GLdouble objX, objY, objZ; … … 221 175 this->setAbsCoor(objX, objY, objZ); 222 176 177 178 } 179 180 /** 181 * draws the crosshair 182 */ 183 void Crosshair::draw() 184 { 185 GraphicsEngine::storeMatrices(); 186 187 188 189 223 190 // glBegin(GL_TRIANGLES); 224 191 // glColor3f(1,0,0); … … 228 195 // glEnd(); 229 196 197 this->debugDraw(); 230 198 231 199 GraphicsEngine::enter2DMode(); … … 253 221 glVertex2f(size, size); 254 222 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 271 224 GraphicsEngine::leave2DMode(); 272 225 }
Note: See TracChangeset
for help on using the changeset viewer.