Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2008, 11:26:16 PM (16 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/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}
Note: See TracChangeset for help on using the changeset viewer.