- Timestamp:
- Dec 15, 2008, 11:26:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc
r2449 r2478 51 51 RegisterObject(Camera); 52 52 53 if (!this->getScene() || !this->getScene()->getSceneManager()) 54 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); 53 if (!this->getScene()) 54 ThrowException(AbortLoading, "Can't create Camera, no scene."); 55 if (!this->getScene()->getSceneManager()) 56 ThrowException(AbortLoading, "Can't create Camera, no scene-manager given."); 55 57 56 58 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 57 this->getNode()->attachObject(this->camera_); 59 this->cameraNode_ = this->getNode()->createChildSceneNode(); 60 this->cameraNode_->attachObject(this->camera_); 58 61 59 62 this->bHasFocus_ = false; … … 72 75 { 73 76 this->releaseFocus(); 77 78 this->cameraNode_->detachAllObjects(); 74 79 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 80 81 if (this->bDrag_) 82 this->detachNode(this->cameraNode_); 83 84 if (this->getScene()->getSceneManager()) 85 this->getScene()->getSceneManager()->destroySceneNode(this->cameraNode_->getName()); 75 86 } 76 87 } … … 89 100 { 90 101 SUPER(Camera, tick, dt); 91 /*92 // this stuff here may need some adjustments93 float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);94 102 95 Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 96 this->cameraNode_->translate(coeff * offset); 103 if (this->bDrag_) 104 { 105 // this stuff here may need some adjustments 106 float coeff = min(1.0f, 15.0f * dt); 97 107 98 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 99 */ 108 Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 109 this->cameraNode_->translate(coeff * offset); 110 111 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 112 //this->cameraNode_->setOrientation(this->getWorldOrientation()); 113 } 100 114 } 101 115 … … 124 138 CameraManager::getInstance().useCamera(this->camera_); 125 139 } 140 141 void Camera::setDrag(bool bDrag) 142 { 143 if (bDrag != this->bDrag_) 144 { 145 this->bDrag_ = bDrag; 146 147 if (!bDrag) 148 { 149 this->attachNode(this->cameraNode_); 150 this->cameraNode_->setPosition(Vector3::ZERO); 151 this->cameraNode_->setOrientation(Quaternion::IDENTITY); 152 } 153 else 154 { 155 this->detachNode(this->cameraNode_); 156 this->cameraNode_->setPosition(this->getWorldPosition()); 157 this->cameraNode_->setOrientation(this->getWorldOrientation()); 158 } 159 } 160 } 126 161 }
Note: See TracChangeset
for help on using the changeset viewer.