Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2478


Ignore:
Timestamp:
Dec 15, 2008, 11:26:16 PM (15 years ago)
Author:
landauf
Message:
  • Readded smooth camera movement (configurable through CameraPosition), works also with camera-position-changes
  • Added free mouse look (press left control key)
  • Made strength of boost-blur configurable
Location:
code/branches/objecthierarchy2
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/bin/def_keybindings.ini

    r2462 r2478  
    5454KeyLeftAlt=
    5555KeyLeftBracket=
    56 KeyLeftControl=
     56KeyLeftControl=mouseLook
    5757KeyLeftShift=
    5858KeyLeftWindows=
  • code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.cc

    r2462 r2478  
    5050    SetConsoleCommand(HumanController, use,           true);
    5151    SetConsoleCommand(HumanController, switchCamera,  true);
     52    SetConsoleCommand(HumanController, mouseLook,     true);
    5253    SetConsoleCommand(HumanController, suicide,       true);
    5354    SetConsoleCommand(HumanController, addBots,       true).defaultValues(1);
     
    142143    }
    143144
     145    void HumanController::mouseLook()
     146    {
     147        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     148            HumanController::localController_s->controllableEntity_->mouseLook();
     149    }
     150
    144151    void HumanController::suicide()
    145152    {
  • code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.h

    r2462 r2478  
    5858            static void use();
    5959            static void switchCamera();
     60            static void mouseLook();
    6061
    6162            static void suicide();
  • code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.cc

    r2361 r2478  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/ConfigValueIncludes.h"
    3334#include "core/XMLPort.h"
    3435#include "objects/Scene.h"
     
    6364        this->boostBlur_ = 0;
    6465
     66        this->setConfigValues();
    6567        this->registerVariables();
    6668    }
     
    9597    }
    9698
     99    void Engine::setConfigValues()
     100    {
     101        SetConfigValue(blurStrength_, 3.0f);
     102    }
     103
    97104    void Engine::registerVariables()
    98105    {
     
    197204
    198205        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));
    200207    }
    201208
  • code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.h

    r2350 r2478  
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4747            void registerVariables();
     48            void setConfigValues();
    4849
    4950            virtual void tick(float dt);
     
    127128
    128129            Shader* boostBlur_;
     130            float blurStrength_;
    129131    };
    130132}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc

    r2449 r2478  
    5151        RegisterObject(Camera);
    5252
    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.");
    5557
    5658        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_);
    5861
    5962        this->bHasFocus_ = false;
     
    7275        {
    7376            this->releaseFocus();
     77
     78            this->cameraNode_->detachAllObjects();
    7479            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());
    7586        }
    7687    }
     
    89100    {
    90101        SUPER(Camera, tick, dt);
    91 /*
    92         // this stuff here may need some adjustments
    93         float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
    94102
    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);
    97107
    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        }
    100114    }
    101115
     
    124138        CameraManager::getInstance().useCamera(this->camera_);
    125139    }
     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    }
    126161}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.h

    r2396 r2478  
    5555                { return this->bHasFocus_; }
    5656
    57             inline void setDrag(bool bDrag)
    58                 { this->bDrag_ = bDrag; }
     57            void setDrag(bool bDrag);
    5958            inline bool getDrag() const
    6059                { return this->bDrag_; }
     
    6564            void configvaluecallback_changedNearClipDistance();
    6665
    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_;
    7171    };
    7272}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/CameraPosition.cc

    r2449 r2478  
    4343
    4444        this->bDrag_ = false;
     45        this->bAllowMouseLook_ = false;
    4546
    4647        this->setObjectMode(0x0);
     
    5657
    5758        XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
     59        XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
    5860    }
    5961
    6062    void CameraPosition::attachCamera(Camera* camera)
    6163    {
    62         camera->setDrag(this->bDrag_);
     64        if (!this->bDrag_)
     65            camera->setDrag(false);
     66
    6367        this->attach(camera);
     68
     69        if (this->bDrag_)
     70            camera->setDrag(true);
    6471    }
    6572}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/CameraPosition.h

    r2087 r2478  
    4949                { return this->bDrag_; }
    5050
     51            inline void setAllowMouseLook(bool bAllow)
     52                { this->bAllowMouseLook_ = bAllow; }
     53            inline bool getAllowMouseLook() const
     54                { return this->bAllowMouseLook_; }
     55
    5156            void attachCamera(Camera* camera);
    5257
    5358        private:
    5459            bool bDrag_;
     60            bool bAllowMouseLook_;
    5561    };
    5662}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2461 r2478  
    3030#include "ControllableEntity.h"
    3131
     32#include <OgreSceneManager.h>
     33
    3234#include "core/CoreIncludes.h"
     35#include "core/ConfigValueIncludes.h"
    3336#include "core/Core.h"
    3437#include "core/XMLPort.h"
    3538#include "core/Template.h"
    3639
     40#include "objects/Scene.h"
    3741#include "objects/infos/PlayerInfo.h"
    3842#include "objects/worldentities/Camera.h"
     
    5963        this->camera_ = 0;
    6064        this->bDestroyWhenPlayerLeft_ = false;
     65        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     66        this->bMouseLook_ = false;
     67        this->mouseLookSpeed_ = 200;
    6168
    6269        this->gtinfo_ = 0;
     
    7481        this->client_orientation_ = Quaternion::IDENTITY;
    7582
     83        this->setConfigValues();
    7684        this->registerVariables();
    7785    }
     
    94102            if (this->camera_)
    95103                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());
    96110        }
    97111    }
     
    107121    }
    108122
     123    void ControllableEntity::setConfigValues()
     124    {
     125        SetConfigValue(mouseLookSpeed_, 3.0f);
     126    }
     127
    109128    void ControllableEntity::changedGametype()
    110129    {
     
    124143    void ControllableEntity::addCameraPosition(CameraPosition* position)
    125144    {
    126         this->attach(position);
     145        if (position->getAllowMouseLook())
     146            position->attachToNode(this->cameraPositionRootNode_);
     147        else
     148            this->attach(position);
    127149        this->cameraPositions_.push_back(position);
    128150    }
     
    165187            else
    166188            {
    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);
    170218    }
    171219
     
    243291                this->cameraPositions_.front()->attachCamera(this->camera_);
    244292            else
    245                 this->attach(this->camera_);
     293                this->camera_->attachToNode(this->cameraPositionRootNode_);
    246294        }
    247295
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h

    r2428 r2478  
    4646            virtual void tick(float dt);
    4747            void registerVariables();
     48            void setConfigValues();
    4849
    4950            virtual void changedGametype();
     
    6364            virtual void moveUpDown(const Vector2& value) {}
    6465
    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);
    6869
    6970            inline void moveFrontBack(float value)
     
    8889            virtual void use() {}
    8990            virtual void switchCamera();
     91            virtual void mouseLook();
    9092
    9193            inline const Vector3& getVelocity() const
     
    148150                { return this->gtinfo_; }
    149151
     152            inline bool isInMouseLook() const
     153                { return this->bMouseLook_; }
     154            inline float getMouseLookSpeed() const
     155                { return this->mouseLookSpeed_; }
     156
    150157        protected:
    151158            virtual void startLocalHumanControl();
     
    179186            bool bHasLocalController_;
    180187            bool bHasHumanController_;
     188            bool bDestroyWhenPlayerLeft_;
    181189
    182190            Vector3 server_position_;
     
    189197            PlayerInfo* player_;
    190198            unsigned int playerID_;
     199
    191200            std::string hudtemplate_;
    192201            OverlayGroup* hud_;
     202
    193203            Camera* camera_;
    194             bool bDestroyWhenPlayerLeft_;
    195 
     204            bool bMouseLook_;
     205            float mouseLookSpeed_;
     206            Ogre::SceneNode* cameraPositionRootNode_;
    196207            std::list<CameraPosition*> cameraPositions_;
    197208            std::string cameraPositionTemplate_;
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.cc

    r2365 r2478  
    7979                this->detachFromParent();
    8080
     81            this->node_->removeAllChildren();
     82
    8183            if (this->getScene()->getSceneManager())
    8284                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     
    125127    }
    126128
     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
    127157    void WorldEntity::attach(WorldEntity* object)
    128158    {
     
    135165        if (object->getParent())
    136166            object->detachFromParent();
    137         else
    138         {
    139             Ogre::Node* parent = object->node_->getParent();
    140             if (parent)
    141                 parent->removeChild(object->node_);
    142         }
    143167
    144         this->node_->addChild(object->node_);
     168        this->attachNode(object->node_);
     169
    145170        this->children_.insert(object);
    146171        object->parent_ = this;
     
    150175    void WorldEntity::detach(WorldEntity* object)
    151176    {
    152         this->node_->removeChild(object->node_);
     177        this->detachNode(object->node_);
    153178        this->children_.erase(object);
    154179        object->parent_ = 0;
    155180        object->parentID_ = OBJECTID_UNKNOWN;
    156 
    157 //        this->getScene()->getRootSceneNode()->addChild(object->node_);
    158181    }
    159182
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.h

    r2256 r2478  
    147147                { return this->parent_; }
    148148
     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
    149154        protected:
    150155            Ogre::SceneNode* node_;
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2256 r2478  
    134134        if (this->hasLocalController())
    135135        {
    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            }
    142145
    143146            this->yawRotation_   = this->zeroDegree_;
     
    170173            temp = -this->maxRotation_;
    171174        this->yawRotation_ = Degree(temp);
     175
     176        Pawn::rotateYaw(value);
    172177    }
    173178
     
    180185            temp = -this->maxRotation_;
    181186        this->pitchRotation_ = Degree(temp);
     187
     188        Pawn::rotatePitch(value);
    182189    }
    183190
     
    190197            temp = -this->maxRotation_;
    191198        this->rollRotation_ = Degree(temp);
     199
     200        Pawn::rotateRoll(value);
    192201    }
    193202
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2428 r2478  
    5151
    5252        this->speed_ = 200;
    53         this->rotationSpeed_ = 3;
    5453
    5554        this->yaw_ = 0;
     
    8887    {
    8988        SetConfigValue(speed_, 200.0f);
    90         SetConfigValue(rotationSpeed_, 3.0f);
    9189    }
    9290
     
    116114            this->setVelocity(velocity * this->speed_);
    117115
    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            }
    121122
    122123            this->yaw_ = this->pitch_ = this->roll_ = 0;
     
    161162    {
    162163        this->yaw_ = value.y;
     164
     165        ControllableEntity::rotateYaw(value);
    163166    }
    164167
     
    166169    {
    167170        this->pitch_ = value.y;
     171
     172        ControllableEntity::rotatePitch(value);
    168173    }
    169174
     
    171176    {
    172177        this->roll_ = value.y;
     178
     179        ControllableEntity::rotateRoll(value);
    173180    }
    174181
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2428 r2478  
    6969
    7070            float speed_;
    71             float rotationSpeed_;
    7271
    7372            float yaw_;
Note: See TracChangeset for help on using the changeset viewer.