Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/graphics/Camera.cc

    r7163 r8079  
    6969        this->bHasFocus_ = false;
    7070        this->bDrag_ = false;
    71         this->nearClipDistance_ = 1;
    7271        this->lastDtLagged_ = false;
    7372
     
    7574
    7675        this->setConfigValues();
     76
     77        this->configvaluecallback_changedFovAndAspectRatio();
    7778        this->configvaluecallback_changedNearClipDistance();
    7879    }
     
    8283        if (this->isInitialized())
    8384        {
    84             if (GUIManager::getInstance().getCamera() == this->camera_)
    85                 GUIManager::getInstance().setCamera(NULL);
    8685            this->releaseFocus();
    8786
     
    9998    void Camera::setConfigValues()
    10099    {
    101         SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     100        SetConfigValue(fov_, 80.0f)
     101            .description("Horizontal field of view in degrees")
     102            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     103        SetConfigValue(aspectRatio_, 1.0f)
     104            .description("Aspect ratio of pixels (width / height)")
     105            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     106        SetConfigValue(nearClipDistance_, 1.0f)
     107            .description("Distance from the camera where close objects will be clipped")
     108            .callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     109    }
     110
     111    /**
     112        @brief Update FOV and the aspect ratio of the camera after the config values or the window's size have changed.
     113    */
     114    void Camera::configvaluecallback_changedFovAndAspectRatio()
     115    {
     116        // the aspect ratio of the window (width / height) has to be multiplied with the pixels aspect ratio (this->aspectRatio_)
     117        float aspectRatio = this->aspectRatio_ * this->getWindowWidth() / this->getWindowHeight();
     118        this->camera_->setAspectRatio(aspectRatio);
     119
     120        // Since we use horizontal FOV, we have to calculate FOVy by dividing by the aspect ratio and using some tangents
     121        Radian fovy(2 * atan(tan(Degree(this->fov_).valueRadians() / 2) / aspectRatio));
     122        this->camera_->setFOVy(fovy);
    102123    }
    103124
     
    105126    {
    106127        this->camera_->setNearClipDistance(this->nearClipDistance_);
     128    }
     129
     130    /**
     131        @brief Inherited from WindowEventListener.
     132    */
     133    void Camera::windowResized(unsigned int newWidth, unsigned int newHeight)
     134    {
     135        this->configvaluecallback_changedFovAndAspectRatio();
    107136    }
    108137
Note: See TracChangeset for help on using the changeset viewer.