Changeset 1287
- Timestamp:
- May 15, 2008, 3:54:30 PM (17 years ago)
- Location:
- code/branches/camera
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/camera/bin/ogre.cfg-init
r790 r1287 4 4 FSAA=0 5 5 Full Screen=No 6 RTT Preferred Mode= PBuffer6 RTT Preferred Mode=FBO 7 7 Video Mode=1024 x 768 -
code/branches/camera/src/orxonox/objects/Camera.cc
r1231 r1287 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "Camera.h" 31 #include "CameraHandler.h" 31 32 32 33 #include <string> … … 47 48 namespace orxonox 48 49 { 49 //CreateFactory(Camera);50 50 51 51 Camera::Camera(Ogre::SceneNode* node) 52 52 { 53 //RegisterObject(Camera);54 53 this->bHasFocus_ = false; 54 this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera"); 55 55 if( node != NULL ) 56 this->setCameraNode(node); 57 56 this->setPositionNode(node); 58 57 } 59 58 60 59 Camera::~Camera() 61 60 { 61 CameraHandler::getInstance()->releaseFocus(this); 62 62 } 63 63 64 /*void Camera::loadParams(TiXmlElement* xmlElem) 65 { 66 Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager(); 67 68 if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node")) 69 { 70 // <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" /> 71 72 std::string name = xmlElem->Attribute("name"); 73 std::string pos = xmlElem->Attribute("pos"); 74 std::string lookat = xmlElem->Attribute("lookat"); 75 76 this->cam_ = mgr->createCamera(name); 77 78 float x, y, z; 79 SubString posVec(xmlElem->Attribute("pos"), ','); 80 convertValue<std::string, float>(&x, posVec[0]); 81 convertValue<std::string, float>(&y, posVec[1]); 82 convertValue<std::string, float>(&z, posVec[2]); 83 84 setPosition(Vector3(x,y,z)); 85 86 //std::string target = xmlElem->Attribute("lookat"); 87 posVec.split(xmlElem->Attribute("lookat"), ','); 88 convertValue<std::string, float>(&x, posVec[0]); 89 convertValue<std::string, float>(&y, posVec[1]); 90 convertValue<std::string, float>(&z, posVec[2]); 91 92 cam_->lookAt(Vector3(x,y,z)); 93 94 /*std::string node = xmlElem->Attribute("node"); 95 96 Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node); 97 sceneNode->attachObject((Ogre::MovableObject*)cam_); 98 */ 99 100 // FIXME: unused var 101 //Ogre::Viewport* vp = 102 //GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam_); 103 /* 104 105 COUT(4) << "Loader: Created camera "<< name << std::endl << std::endl; 106 } 107 }*/ 108 109 void Camera::setCameraNode(Ogre::SceneNode* node) 64 void Camera::setPositionNode(Ogre::SceneNode* node) 110 65 { 111 66 this->positionNode_ = node; … … 118 73 } 119 74 75 void Camera::tick(float dt) 76 { 77 if(this->positionNode_ != NULL) { 78 // this stuff here may need some adjustments 79 Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getPosition(); 80 this->cameraNode_->translate(15*dt*offset); 81 82 this->cameraNode_->setOrientation(Quaternion::Slerp(0.7, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false)); 83 } 84 } 85 120 86 /** 121 87 don't move anything before here! here the Ogre camera is set to values of this camera … … 124 90 void Camera::update() 125 91 { 126 COUT(0) << "p " << this->positionNode_->getPosition() << std::endl;127 COUT(0) << "t " << this->targetNode_->getPosition() << std::endl;128 92 if(this->positionNode_ != NULL) 129 //this->cam_->setPosition(this->positionNode_->getPosition()); 130 if(this->targetNode_ != NULL) 131 this->cam_->lookAt(this->targetNode_->getPosition()); 93 { 94 this->cameraNode_->setPosition(this->positionNode_->getWorldPosition()); 95 this->cameraNode_->setOrientation(this->positionNode_->getWorldOrientation()); 96 } 132 97 } 133 98 … … 138 103 void Camera::removeFocus() 139 104 { 140 this->positionNode_->detachObject(cam_);141 105 this->bHasFocus_ = false; 106 this->cameraNode_->detachObject(this->cam_); 142 107 } 143 108 … … 146 111 this->bHasFocus_ = true; 147 112 this->cam_ = ogreCam; 148 this->positionNode_->attachObject(cam_); 113 this->cam_->setOrientation(this->cameraNode_->getWorldOrientation()); 114 this->cameraNode_->attachObject(this->cam_); 149 115 } 150 116 } -
code/branches/camera/src/orxonox/objects/Camera.h
r1201 r1287 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 45 45 virtual ~Camera(); 46 46 47 //inline void setPosition(Ogre::Vector3 pos) { position_->setPosition(pos); cam_->setPosition(pos); } 48 void setCameraNode(Ogre::SceneNode* node); 47 void setPositionNode(Ogre::SceneNode* node); 49 48 inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; } 50 49 // maybe also BaseObject 51 50 void setTargetNode(Ogre::SceneNode* obj); 52 51 53 52 void tick(float dt); 54 53 void update(); 55 54 inline bool hasFocus() { return this->bHasFocus_; } … … 62 61 Ogre::SceneNode* targetNode_; 63 62 Ogre::SceneNode* positionNode_; 63 Ogre::SceneNode* cameraNode_; 64 Ogre::Vector3 oldPos; 64 65 Ogre::Camera* cam_; 65 66 bool bHasFocus_; -
code/branches/camera/src/orxonox/objects/CameraHandler.cc
r1202 r1287 73 73 focusList_.remove(cam); 74 74 // set new focus if necessary 75 if( !(focusList_.back()->hasFocus()))75 if(focusList_.size() > 0 && !(focusList_.back()->hasFocus())) 76 76 focusList_.back()->setFocus(this->cam_); 77 77 } -
code/branches/camera/src/orxonox/objects/SpaceShip.cc
r1235 r1287 79 79 80 80 this->camNode_ = 0; 81 this->cam_ = NULL; 81 82 82 83 this->tt_ = 0; … … 148 149 if (this->tt_) 149 150 delete this->tt_; 151 if (this->cam_) 152 delete this->cam_; 150 153 } 151 154 … … 284 287 { 285 288 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 286 camNode_->setPosition(Vector3(-50,0,10)); 289 camNode_->setPosition(Vector3(-30,0,10)); 290 Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0)); 291 Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1)); 292 camNode_->setOrientation(q1*q2); 293 //this->camNode_->showBoundingBox(true); 294 287 295 /* 288 296 // node->setInheritOrientation(false); … … 292 300 */ 293 301 cam_ = new Camera(this->camNode_); 294 cam_->setTargetNode(this-> getNode());302 cam_->setTargetNode(this->chFarNode_); 295 303 CameraHandler::getInstance()->requestFocus(cam_); 296 304 // cam->setPosition(Vector3(0,-350,0)); … … 427 435 428 436 void SpaceShip::tick(float dt) 429 { 437 {/* 438 if (this->cam_) 439 this->cam_->update(); 440 */ 441 if (this->cam_) 442 this->cam_->tick(dt); 443 430 444 if (InputManager::getSingleton().getMouse()->getEventCallback() != this) 431 445 {
Note: See TracChangeset
for help on using the changeset viewer.