Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3636 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Mar 23, 2005, 12:46:37 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: functions to set gluPerspective-options

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/camera.cc

    r3635 r3636  
    3434{
    3535  this->target = new CameraTarget();
     36
     37  this->setFovy(60);
     38  this->setAspectRatio(1.2f);
     39  this->setClipRegion(.1, 2000);
    3640}
    3741
     
    5862}
    5963
     64
     65/**
     66   \brief sets a new AspectRatio
     67   \param aspectRatio the new aspect ratio to set (width / height)
     68*/
     69void 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*/
     78void 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*/
     88void Camera::setClipRegion(float nearClip, float farClip)
     89{
     90  this->nearClip = nearClip;
     91  this->farClip = farClip;
     92}
     93
     94
     95
     96
    6097/**
    6198   \brief initialize rendering perspective according to this camera
     
    66103void Camera::apply ()
    67104{
     105  // switching to Projection Matrix
    68106  glMatrixMode (GL_PROJECTION);
    69107  glLoadIdentity ();
    70108
    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);
    73114
     115  // speed-up feature
    74116  Vector cameraPosition = this->getAbsCoor();
    75117  Vector targetPosition = this->target->getAbsCoor();
    76118
     119  // Setting the Camera Eye, lookAt and up Vectors
    77120  gluLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,
    78121            targetPosition.x, targetPosition.y, targetPosition.z,
    79122            0.0, 1.0, 0.0);
     123
     124  // switching back to Modeling Matrix
    80125  glMatrixMode (GL_MODELVIEW);
    81   glLoadIdentity ();
    82126}
    83127
  • orxonox/trunk/src/camera.h

    r3635 r3636  
    2020{
    2121 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.
    2328 
    2429 public:
     
    2732
    2833  void lookAt(PNode* target);
    29  
    3034  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);
    3241};
    3342
     
    3544class CameraTarget : public PNode
    3645{
    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.
    3847 
    3948 private:
Note: See TracChangeset for help on using the changeset viewer.