Changeset 2478 for code/branches/objecthierarchy2/src/orxonox
- Timestamp:
- Dec 15, 2008, 11:26:16 PM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.cc
r2462 r2478 50 50 SetConsoleCommand(HumanController, use, true); 51 51 SetConsoleCommand(HumanController, switchCamera, true); 52 SetConsoleCommand(HumanController, mouseLook, true); 52 53 SetConsoleCommand(HumanController, suicide, true); 53 54 SetConsoleCommand(HumanController, addBots, true).defaultValues(1); … … 142 143 } 143 144 145 void HumanController::mouseLook() 146 { 147 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 148 HumanController::localController_s->controllableEntity_->mouseLook(); 149 } 150 144 151 void HumanController::suicide() 145 152 { -
code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.h
r2462 r2478 58 58 static void use(); 59 59 static void switchCamera(); 60 static void mouseLook(); 60 61 61 62 static void suicide(); -
code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.cc
r2361 r2478 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "core/ConfigValueIncludes.h" 33 34 #include "core/XMLPort.h" 34 35 #include "objects/Scene.h" … … 63 64 this->boostBlur_ = 0; 64 65 66 this->setConfigValues(); 65 67 this->registerVariables(); 66 68 } … … 95 97 } 96 98 99 void Engine::setConfigValues() 100 { 101 SetConfigValue(blurStrength_, 3.0f); 102 } 103 97 104 void Engine::registerVariables() 98 105 { … … 197 204 198 205 if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 199 this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", 5.0f* clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f));206 this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f)); 200 207 } 201 208 -
code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.h
r2350 r2478 46 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 void registerVariables(); 48 void setConfigValues(); 48 49 49 50 virtual void tick(float dt); … … 127 128 128 129 Shader* boostBlur_; 130 float blurStrength_; 129 131 }; 130 132 } -
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 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.h
r2396 r2478 55 55 { return this->bHasFocus_; } 56 56 57 inline void setDrag(bool bDrag) 58 { this->bDrag_ = bDrag; } 57 void setDrag(bool bDrag); 59 58 inline bool getDrag() const 60 59 { return this->bDrag_; } … … 65 64 void configvaluecallback_changedNearClipDistance(); 66 65 67 Ogre::Camera* camera_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 66 Ogre::Camera* camera_; 67 Ogre::SceneNode* cameraNode_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 71 71 }; 72 72 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/CameraPosition.cc
r2449 r2478 43 43 44 44 this->bDrag_ = false; 45 this->bAllowMouseLook_ = false; 45 46 46 47 this->setObjectMode(0x0); … … 56 57 57 58 XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false); 59 XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false); 58 60 } 59 61 60 62 void CameraPosition::attachCamera(Camera* camera) 61 63 { 62 camera->setDrag(this->bDrag_); 64 if (!this->bDrag_) 65 camera->setDrag(false); 66 63 67 this->attach(camera); 68 69 if (this->bDrag_) 70 camera->setDrag(true); 64 71 } 65 72 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/CameraPosition.h
r2087 r2478 49 49 { return this->bDrag_; } 50 50 51 inline void setAllowMouseLook(bool bAllow) 52 { this->bAllowMouseLook_ = bAllow; } 53 inline bool getAllowMouseLook() const 54 { return this->bAllowMouseLook_; } 55 51 56 void attachCamera(Camera* camera); 52 57 53 58 private: 54 59 bool bDrag_; 60 bool bAllowMouseLook_; 55 61 }; 56 62 } -
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 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h
r2428 r2478 46 46 virtual void tick(float dt); 47 47 void registerVariables(); 48 void setConfigValues(); 48 49 49 50 virtual void changedGametype(); … … 63 64 virtual void moveUpDown(const Vector2& value) {} 64 65 65 virtual void rotateYaw(const Vector2& value) {}66 virtual void rotatePitch(const Vector2& value) {}67 virtual void rotateRoll(const Vector2& value) {}66 virtual void rotateYaw(const Vector2& value); 67 virtual void rotatePitch(const Vector2& value); 68 virtual void rotateRoll(const Vector2& value); 68 69 69 70 inline void moveFrontBack(float value) … … 88 89 virtual void use() {} 89 90 virtual void switchCamera(); 91 virtual void mouseLook(); 90 92 91 93 inline const Vector3& getVelocity() const … … 148 150 { return this->gtinfo_; } 149 151 152 inline bool isInMouseLook() const 153 { return this->bMouseLook_; } 154 inline float getMouseLookSpeed() const 155 { return this->mouseLookSpeed_; } 156 150 157 protected: 151 158 virtual void startLocalHumanControl(); … … 179 186 bool bHasLocalController_; 180 187 bool bHasHumanController_; 188 bool bDestroyWhenPlayerLeft_; 181 189 182 190 Vector3 server_position_; … … 189 197 PlayerInfo* player_; 190 198 unsigned int playerID_; 199 191 200 std::string hudtemplate_; 192 201 OverlayGroup* hud_; 202 193 203 Camera* camera_; 194 bool bDestroyWhenPlayerLeft_; 195 204 bool bMouseLook_; 205 float mouseLookSpeed_; 206 Ogre::SceneNode* cameraPositionRootNode_; 196 207 std::list<CameraPosition*> cameraPositions_; 197 208 std::string cameraPositionTemplate_; -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.cc
r2365 r2478 79 79 this->detachFromParent(); 80 80 81 this->node_->removeAllChildren(); 82 81 83 if (this->getScene()->getSceneManager()) 82 84 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); … … 125 127 } 126 128 129 void WorldEntity::attachNode(Ogre::SceneNode* node) 130 { 131 Ogre::Node* parent = node->getParent(); 132 if (parent) 133 parent->removeChild(node); 134 this->node_->addChild(node); 135 } 136 137 void WorldEntity::detachNode(Ogre::SceneNode* node) 138 { 139 this->node_->removeChild(node); 140 // this->getScene()->getRootSceneNode()->addChild(node); 141 } 142 143 void WorldEntity::attachToNode(Ogre::SceneNode* node) 144 { 145 Ogre::Node* parent = this->node_->getParent(); 146 if (parent) 147 parent->removeChild(this->node_); 148 node->addChild(this->node_); 149 } 150 151 void WorldEntity::detachFromNode(Ogre::SceneNode* node) 152 { 153 node->removeChild(this->node_); 154 // this->getScene()->getRootSceneNode()->addChild(this->node_); 155 } 156 127 157 void WorldEntity::attach(WorldEntity* object) 128 158 { … … 135 165 if (object->getParent()) 136 166 object->detachFromParent(); 137 else138 {139 Ogre::Node* parent = object->node_->getParent();140 if (parent)141 parent->removeChild(object->node_);142 }143 167 144 this->node_->addChild(object->node_); 168 this->attachNode(object->node_); 169 145 170 this->children_.insert(object); 146 171 object->parent_ = this; … … 150 175 void WorldEntity::detach(WorldEntity* object) 151 176 { 152 this-> node_->removeChild(object->node_);177 this->detachNode(object->node_); 153 178 this->children_.erase(object); 154 179 object->parent_ = 0; 155 180 object->parentID_ = OBJECTID_UNKNOWN; 156 157 // this->getScene()->getRootSceneNode()->addChild(object->node_);158 181 } 159 182 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.h
r2256 r2478 147 147 { return this->parent_; } 148 148 149 void attachNode(Ogre::SceneNode* node); 150 void detachNode(Ogre::SceneNode* node); 151 void attachToNode(Ogre::SceneNode* node); 152 void detachFromNode(Ogre::SceneNode* node); 153 149 154 protected: 150 155 Ogre::SceneNode* node_; -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2256 r2478 134 134 if (this->hasLocalController()) 135 135 { 136 this->yaw(this->yawRotation_ * dt); 137 if (this->bInvertYAxis_) 138 this->pitch(Degree(-this->pitchRotation_ * dt)); 139 else 140 this->pitch(Degree( this->pitchRotation_ * dt)); 141 this->roll(this->rollRotation_ * dt); 136 if (!this->isInMouseLook()) 137 { 138 this->yaw(this->yawRotation_ * dt); 139 if (this->bInvertYAxis_) 140 this->pitch(Degree(-this->pitchRotation_ * dt)); 141 else 142 this->pitch(Degree( this->pitchRotation_ * dt)); 143 this->roll(this->rollRotation_ * dt); 144 } 142 145 143 146 this->yawRotation_ = this->zeroDegree_; … … 170 173 temp = -this->maxRotation_; 171 174 this->yawRotation_ = Degree(temp); 175 176 Pawn::rotateYaw(value); 172 177 } 173 178 … … 180 185 temp = -this->maxRotation_; 181 186 this->pitchRotation_ = Degree(temp); 187 188 Pawn::rotatePitch(value); 182 189 } 183 190 … … 190 197 temp = -this->maxRotation_; 191 198 this->rollRotation_ = Degree(temp); 199 200 Pawn::rotateRoll(value); 192 201 } 193 202 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2428 r2478 51 51 52 52 this->speed_ = 200; 53 this->rotationSpeed_ = 3;54 53 55 54 this->yaw_ = 0; … … 88 87 { 89 88 SetConfigValue(speed_, 200.0f); 90 SetConfigValue(rotationSpeed_, 3.0f);91 89 } 92 90 … … 116 114 this->setVelocity(velocity * this->speed_); 117 115 118 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 119 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 120 this->roll(Radian(this->roll_ * this->rotationSpeed_)); 116 if (!this->isInMouseLook()) 117 { 118 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed())); 119 this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 120 this->roll(Radian(this->roll_ * this->getMouseLookSpeed())); 121 } 121 122 122 123 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 161 162 { 162 163 this->yaw_ = value.y; 164 165 ControllableEntity::rotateYaw(value); 163 166 } 164 167 … … 166 169 { 167 170 this->pitch_ = value.y; 171 172 ControllableEntity::rotatePitch(value); 168 173 } 169 174 … … 171 176 { 172 177 this->roll_ = value.y; 178 179 ControllableEntity::rotateRoll(value); 173 180 } 174 181 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.h
r2428 r2478 69 69 70 70 float speed_; 71 float rotationSpeed_;72 71 73 72 float yaw_;
Note: See TracChangeset
for help on using the changeset viewer.