Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 21, 2008, 4:56:41 PM (16 years ago)
Author:
landauf
Message:
  • added ControllableEntity, the baseclass of all players, vehicles and ships.
  • moved Template to core
  • some changes in Camera
  • added 6 constants to WorldEntity to identify relative directions
  • changed vom Radian to Degree as default angle unit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/Camera.cc

    r1911 r1989  
    4747namespace orxonox
    4848{
     49  Camera::Camera()
     50  {
     51    RegisterObject(Camera);
    4952
    50   Camera::Camera(Ogre::SceneNode* node)
    51   {
    5253    this->bHasFocus_ = false;
    53     this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
    54     if( node != NULL )
    55       this->setPositionNode(node);
     54    this->bDrag_ = false;
     55    this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode();
     56    this->setObjectMode(0x0);
    5657  }
    5758
    5859  Camera::~Camera()
    5960  {
    60     CameraHandler::getInstance()->releaseFocus(this);
    61     GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
    62   }
    63 
    64   void Camera::setPositionNode(Ogre::SceneNode* node)
    65   {
    66     this->positionNode_ = node;
    67     // set camera to node values according to camera mode
    68   }
    69 
    70   void Camera::setTargetNode(Ogre::SceneNode* obj)
    71   {
    72     this->targetNode_ = obj;
     61    if (this->isInitialized())
     62    {
     63      CameraHandler::getInstance()->releaseFocus(this);
     64      GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(this->cameraNode_->getName());
     65    }
    7366  }
    7467
    7568  void Camera::tick(float dt)
    7669  {
    77     if (this->positionNode_ != NULL)
    78     {
    7970      // this stuff here may need some adjustments
    80       Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getWorldPosition();
    81       float coeff = 15.0f * dt;
    82       if (coeff > 1.0f)
    83         coeff = 1.0f;
     71      float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
    8472
     73      Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
    8574      this->cameraNode_->translate(coeff * offset);
    8675
    87       this->cameraNode_->setOrientation(Quaternion::Slerp(1-coeff, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
    88     }
     76      this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
    8977  }
    9078
     
    9583  void Camera::update()
    9684  {
    97     if(this->positionNode_ != NULL)
    98     {
    99       this->cameraNode_->setPosition(this->positionNode_->getWorldPosition());
    100       this->cameraNode_->setOrientation(this->positionNode_->getWorldOrientation());
    101     }
     85      this->cameraNode_->setPosition(this->getWorldPosition());
     86      this->cameraNode_->setOrientation(this->getWorldOrientation());
    10287  }
    10388
     
    119104    this->cameraNode_->attachObject(this->cam_);
    120105  }
     106
     107  void Camera::requestFocus()
     108  {
     109    CameraHandler::getInstance()->requestFocus(this);
     110  }
    121111}
Note: See TracChangeset for help on using the changeset viewer.