Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3636 in orxonox.OLD for orxonox/trunk/src/camera.cc


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

orxonox/trunk: functions to set gluPerspective-options

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.