- Timestamp:
- Mar 23, 2005, 12:46:37 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/camera.cc
r3635 r3636 34 34 { 35 35 this->target = new CameraTarget(); 36 37 this->setFovy(60); 38 this->setAspectRatio(1.2f); 39 this->setClipRegion(.1, 2000); 36 40 } 37 41 … … 58 62 } 59 63 64 65 /** 66 \brief sets a new AspectRatio 67 \param aspectRatio the new aspect ratio to set (width / height) 68 */ 69 void Camera::setAspectRatio(float aspectRatio) 70 { 71 this->aspectRatio = aspectRatio; 72 } 73 74 /** 75 \brief sets the Field of View to fofy 76 \param fovy new field of view factor (in degrees) 77 */ 78 void Camera::setFovy(float fovy) 79 { 80 this->fovy = fovy; 81 } 82 83 /** 84 \brief Sets a new clipping region 85 \param nearClip The near clip plane 86 \param farClip The far clip plane 87 */ 88 void Camera::setClipRegion(float nearClip, float farClip) 89 { 90 this->nearClip = nearClip; 91 this->farClip = farClip; 92 } 93 94 95 96 60 97 /** 61 98 \brief initialize rendering perspective according to this camera … … 66 103 void Camera::apply () 67 104 { 105 // switching to Projection Matrix 68 106 glMatrixMode (GL_PROJECTION); 69 107 glLoadIdentity (); 70 108 71 gluPerspective(60, 1.2f, 0.1, 2000); 72 float matrix[4][4]; 109 // setting up the perspective 110 gluPerspective(this->fovy, 111 this->aspectRatio, 112 this->nearClip, 113 this->farClip); 73 114 115 // speed-up feature 74 116 Vector cameraPosition = this->getAbsCoor(); 75 117 Vector targetPosition = this->target->getAbsCoor(); 76 118 119 // Setting the Camera Eye, lookAt and up Vectors 77 120 gluLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z, 78 121 targetPosition.x, targetPosition.y, targetPosition.z, 79 122 0.0, 1.0, 0.0); 123 124 // switching back to Modeling Matrix 80 125 glMatrixMode (GL_MODELVIEW); 81 glLoadIdentity ();82 126 } 83 127 -
orxonox/trunk/src/camera.h
r3635 r3636 20 20 { 21 21 private: 22 CameraTarget* target; 22 CameraTarget* target; //!< The Target of the Camera (where this Camera Looks at) 23 24 float fovy; //!< The field of view Angle (in degrees). 25 float aspectRatio; //!< The aspect ratio (width / height). 26 float nearClip; //!< The near clipping plane. 27 float farClip; //!< The far clipping plane. 23 28 24 29 public: … … 27 32 28 33 void lookAt(PNode* target); 29 30 34 PNode* getTarget(); 31 void apply (); 35 36 void setAspectRatio(float aspectRatio); 37 void setFovy(float fovy); 38 void setClipRegion(float nearClip, float farClip); 39 40 void apply (void); 32 41 }; 33 42 … … 35 44 class CameraTarget : public PNode 36 45 { 37 friend class Camera; //!46 friend class Camera; //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. 38 47 39 48 private:
Note: See TracChangeset
for help on using the changeset viewer.