Changeset 2478 for code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc
- 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/ControllableEntity.cc
r2461 r2478 30 30 #include "ControllableEntity.h" 31 31 32 #include <OgreSceneManager.h> 33 32 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 33 36 #include "core/Core.h" 34 37 #include "core/XMLPort.h" 35 38 #include "core/Template.h" 36 39 40 #include "objects/Scene.h" 37 41 #include "objects/infos/PlayerInfo.h" 38 42 #include "objects/worldentities/Camera.h" … … 59 63 this->camera_ = 0; 60 64 this->bDestroyWhenPlayerLeft_ = false; 65 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 66 this->bMouseLook_ = false; 67 this->mouseLookSpeed_ = 200; 61 68 62 69 this->gtinfo_ = 0; … … 74 81 this->client_orientation_ = Quaternion::IDENTITY; 75 82 83 this->setConfigValues(); 76 84 this->registerVariables(); 77 85 } … … 94 102 if (this->camera_) 95 103 delete this->camera_; 104 105 for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 106 delete (*it); 107 108 if (this->getScene()->getSceneManager()) 109 this->getScene()->getSceneManager()->destroySceneNode(this->cameraPositionRootNode_->getName()); 96 110 } 97 111 } … … 107 121 } 108 122 123 void ControllableEntity::setConfigValues() 124 { 125 SetConfigValue(mouseLookSpeed_, 3.0f); 126 } 127 109 128 void ControllableEntity::changedGametype() 110 129 { … … 124 143 void ControllableEntity::addCameraPosition(CameraPosition* position) 125 144 { 126 this->attach(position); 145 if (position->getAllowMouseLook()) 146 position->attachToNode(this->cameraPositionRootNode_); 147 else 148 this->attach(position); 127 149 this->cameraPositions_.push_back(position); 128 150 } … … 165 187 else 166 188 { 167 this->attach(this->camera_); 168 } 169 } 189 this->camera_->attachToNode(this->cameraPositionRootNode_); 190 } 191 } 192 } 193 194 void ControllableEntity::mouseLook() 195 { 196 this->bMouseLook_ = !this->bMouseLook_; 197 198 if (!this->bMouseLook_) 199 this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY); 200 } 201 202 void ControllableEntity::rotateYaw(const Vector2& value) 203 { 204 if (this->bMouseLook_) 205 this->cameraPositionRootNode_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 206 } 207 208 void ControllableEntity::rotatePitch(const Vector2& value) 209 { 210 if (this->bMouseLook_) 211 this->cameraPositionRootNode_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 212 } 213 214 void ControllableEntity::rotateRoll(const Vector2& value) 215 { 216 if (this->bMouseLook_) 217 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 170 218 } 171 219 … … 243 291 this->cameraPositions_.front()->attachCamera(this->camera_); 244 292 else 245 this-> attach(this->camera_);293 this->camera_->attachToNode(this->cameraPositionRootNode_); 246 294 } 247 295
Note: See TracChangeset
for help on using the changeset viewer.