Changeset 8079 for code/trunk/src/orxonox/graphics
- Timestamp:
- Mar 15, 2011, 9:47:11 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/graphics/Camera.cc
r7163 r8079 69 69 this->bHasFocus_ = false; 70 70 this->bDrag_ = false; 71 this->nearClipDistance_ = 1;72 71 this->lastDtLagged_ = false; 73 72 … … 75 74 76 75 this->setConfigValues(); 76 77 this->configvaluecallback_changedFovAndAspectRatio(); 77 78 this->configvaluecallback_changedNearClipDistance(); 78 79 } … … 82 83 if (this->isInitialized()) 83 84 { 84 if (GUIManager::getInstance().getCamera() == this->camera_)85 GUIManager::getInstance().setCamera(NULL);86 85 this->releaseFocus(); 87 86 … … 99 98 void Camera::setConfigValues() 100 99 { 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); 102 123 } 103 124 … … 105 126 { 106 127 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(); 107 136 } 108 137 -
code/trunk/src/orxonox/graphics/Camera.h
r6417 r8079 33 33 34 34 #include "util/OgreForwardRefs.h" 35 #include "core/WindowEventListener.h" 35 36 #include "tools/interfaces/Tickable.h" 36 37 #include "tools/interfaces/TimeFactorListener.h" … … 39 40 namespace orxonox 40 41 { 41 class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener 42 class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener 42 43 { 43 44 friend class CameraManager; … … 66 67 void removeFocus(); 67 68 void setFocus(); 69 70 void configvaluecallback_changedFovAndAspectRatio(); 68 71 void configvaluecallback_changedNearClipDistance(); 72 73 void windowResized(unsigned int newWidth, unsigned int newHeight); 69 74 70 75 Ogre::Camera* camera_; … … 74 79 bool bDrag_; 75 80 bool lastDtLagged_; 81 float fov_; 82 float aspectRatio_; 76 83 }; 77 84 } -
code/trunk/src/orxonox/graphics/GlobalShader.cc
r5781 r8079 61 61 SUPER(GlobalShader, XMLPort, xmlelement, mode); 62 62 63 XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositor , getCompositor, xmlelement, mode);63 XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositorName, getCompositorName, xmlelement, mode); 64 64 } 65 65 … … 67 67 { 68 68 registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility)); 69 registerVariable(const_cast<std::string&>(this->shader_.getCompositor ()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));69 registerVariable(const_cast<std::string&>(this->shader_.getCompositorName()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositorName)); 70 70 } 71 71 -
code/trunk/src/orxonox/graphics/GlobalShader.h
r7163 r8079 53 53 private: 54 54 void registerVariables(); 55 void changedCompositor();56 55 57 56 Shader shader_; -
code/trunk/src/orxonox/graphics/Model.cc
r7183 r8079 60 60 void Model::setConfigValues() 61 61 { 62 SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableM odelLoD", true)62 SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableMeshLoD", true) 63 63 .description("Enable level of detail for models"); 64 64 }
Note: See TracChangeset
for help on using the changeset viewer.