Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.