Changeset 6412 for code/branches/pickup2/src/orxonox/graphics/Camera.cc
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/graphics/Camera.cc
r5929 r6412 42 42 #include "Scene.h" 43 43 #include "CameraManager.h" 44 #include "sound/SoundManager.h" 44 45 45 46 namespace orxonox … … 61 62 62 63 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 64 this->camera_->setUserObject(this); 63 65 this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 64 66 this->attachNode(this->cameraNode_); … … 68 70 this->bDrag_ = false; 69 71 this->nearClipDistance_ = 1; 72 this->lastDtLagged_ = false; 70 73 71 74 this->setSyncMode(0x0); … … 111 114 { 112 115 // this stuff here may need some adjustments 113 float coeff = std::min(1.0f, 15.0f * dt); 116 float poscoeff = 15.0f * dt / this->getTimeFactor(); 117 float anglecoeff = 7.0f * dt / this->getTimeFactor(); 118 // Only clamp if fps rate is actually falling. Occasional high dts should 119 // not be clamped to reducing lagging effects. 120 if (poscoeff > 1.0f) 121 { 122 if (this->lastDtLagged_) 123 poscoeff = 1.0f; 124 else 125 this->lastDtLagged_ = true; 126 } 127 else 128 this->lastDtLagged_ = false; 129 130 if (anglecoeff > 1.0f) 131 { 132 if (this->lastDtLagged_) 133 anglecoeff = 1.0f; 134 else 135 this->lastDtLagged_ = true; 136 } 137 else 138 this->lastDtLagged_ = false; 114 139 115 140 Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition(); 116 this->cameraNode_->translate( coeff * offset);141 this->cameraNode_->translate(poscoeff * offset); 117 142 118 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true)); 119 //this->cameraNode_->setOrientation(this->getWorldOrientation()); 143 this->cameraNode_->setOrientation(Quaternion::Slerp(anglecoeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true)); 144 } 145 146 // Update sound listener transformation 147 if (GameMode::playsSound() && this->bHasFocus_) 148 { 149 SoundManager::getInstance().setListenerPosition(this->getWorldPosition()); 150 SoundManager::getInstance().setListenerOrientation(this->getWorldOrientation()); 120 151 } 121 152 }
Note: See TracChangeset
for help on using the changeset viewer.