Changeset 1201 for code/branches
- Timestamp:
- Apr 29, 2008, 5:15:44 PM (17 years ago)
- Location:
- code/branches
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/camera/bin/levels/sample.oxw
r1102 r1201 11 11 <Ambient colourvalue="1,1,1" /> 12 12 <Skybox src="Orxonox/StarSkyBox" /> 13 14 13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> 15 14 -
code/branches/camera/src/core/Script.h
r1102 r1201 57 57 public: 58 58 inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export 59 inline ~Script() { Script::singletonRef = NULL; } ;59 inline ~Script() { Script::singletonRef = NULL; } 60 60 61 61 void loadFile(std::string filename, bool luaTags); -
code/branches/camera/src/orxonox/CMakeLists.txt
r1070 r1201 12 12 objects/Ambient.cc 13 13 objects/Camera.cc 14 objects/CameraHandler.cc 14 15 objects/Explosion.cc 15 16 # objects/Fighter.cc -
code/branches/camera/src/orxonox/objects/Camera.cc
r1067 r1201 47 47 namespace orxonox 48 48 { 49 49 //CreateFactory(Camera); 50 50 51 Camera::Camera() 51 Camera::Camera(Ogre::SceneNode* node) 52 { 53 //RegisterObject(Camera); 54 this->bHasFocus_ = false; 55 if( node != NULL ) 56 this->setCameraNode(node); 57 58 } 59 60 Camera::~Camera() 61 { 62 } 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")) 52 69 { 53 RegisterObject(Camera); 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; 54 106 } 107 }*/ 55 108 56 Camera::~Camera() 57 { 58 } 109 void Camera::setCameraNode(Ogre::SceneNode* node) 110 { 111 this->positionNode_ = node; 112 // set camera to node values according to camera mode 113 } 59 114 60 void Camera::loadParams(TiXmlElement* xmlElem) 61 { 62 Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager(); 115 void Camera::setTargetNode(Ogre::SceneNode* obj) 116 { 117 this->targetNode_ = obj; 118 } 63 119 64 if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node")) 65 { 66 // <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" /> 120 /** 121 don't move anything before here! here the Ogre camera is set to values of this camera 122 always call update after changes 123 */ 124 void Camera::update() 125 { 126 COUT(0) << "p " << this->positionNode_->getPosition() << std::endl; 127 COUT(0) << "t " << this->targetNode_->getPosition() << std::endl; 128 if(this->positionNode_ != NULL) 129 //this->cam_->setPosition(this->positionNode_->getPosition()); 130 if(this->targetNode_ != NULL) 131 this->cam_->lookAt(this->targetNode_->getPosition()); 132 } 67 133 68 std::string name = xmlElem->Attribute("name"); 69 std::string pos = xmlElem->Attribute("pos"); 70 std::string lookat = xmlElem->Attribute("lookat"); 134 /** 135 what to do when camera loses focus (do not request focus in this function!!) 136 this is called by the CameraHandler singleton class to notify the camera 137 */ 138 void Camera::removeFocus() 139 { 140 this->bHasFocus_ = false; 141 } 71 142 72 Ogre::Camera *cam = mgr->createCamera(name); 73 74 float x, y, z; 75 SubString posVec(xmlElem->Attribute("pos"), ','); 76 convertValue<std::string, float>(&x, posVec[0]); 77 convertValue<std::string, float>(&y, posVec[1]); 78 convertValue<std::string, float>(&z, posVec[2]); 79 80 cam->setPosition(Vector3(x,y,z)); 81 82 posVec = SubString(xmlElem->Attribute("lookat"), ','); 83 convertValue<std::string, float>(&x, posVec[0]); 84 convertValue<std::string, float>(&y, posVec[1]); 85 convertValue<std::string, float>(&z, posVec[2]); 86 87 cam->lookAt(Vector3(x,y,z)); 88 89 std::string node = xmlElem->Attribute("node"); 90 91 Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node); 92 sceneNode->attachObject((Ogre::MovableObject*)cam); 93 94 // FIXME: unused var 95 //Ogre::Viewport* vp = 96 GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam); 97 98 99 COUT(4) << "Loader: Created camera "<< name << std::endl << std::endl; 100 } 101 } 143 void Camera::setFocus(Ogre::Camera* ogreCam) 144 { 145 this->bHasFocus_ = true; 146 this->cam_ = ogreCam; 147 this->positionNode_->attachObject(cam_); 148 } 102 149 } -
code/branches/camera/src/orxonox/objects/Camera.h
r1056 r1201 30 30 #define _Camera_H__ 31 31 32 #include <OgrePrerequisites.h> 33 #include <OgreSceneNode.h> 34 #include <OgreCamera.h> 35 32 36 #include "OrxonoxPrereqs.h" 33 34 #include "core/BaseObject.h"35 37 36 38 namespace orxonox 37 39 { 38 class _OrxonoxExport Camera : public BaseObject40 class _OrxonoxExport Camera 39 41 { 40 public: 41 Camera(); 42 virtual ~Camera(); 42 friend class CameraHandler; 43 public: 44 Camera(Ogre::SceneNode* node = NULL); 45 virtual ~Camera(); 46 47 //inline void setPosition(Ogre::Vector3 pos) { position_->setPosition(pos); cam_->setPosition(pos); } 48 void setCameraNode(Ogre::SceneNode* node); 49 inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; } 50 // maybe also BaseObject 51 void setTargetNode(Ogre::SceneNode* obj); 43 52 44 53 45 void loadParams(TiXmlElement* xmlElem); 54 void update(); 55 inline bool hasFocus() { return this->bHasFocus_; } 46 56 47 private: 57 private: 58 void removeFocus(); 59 void setFocus(Ogre::Camera* ogreCam); 48 60 49 61 private: 62 Ogre::SceneNode* targetNode_; 63 Ogre::SceneNode* positionNode_; 64 Ogre::Camera* cam_; 65 bool bHasFocus_; 50 66 }; 51 67 } -
code/branches/camera/src/orxonox/objects/SpaceShip.cc
r1064 r1201 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 38 38 #include <OgreSceneNode.h> 39 39 40 #include "CameraHandler.h" 40 41 #include "util/tinyxml/tinyxml.h" 41 42 #include "util/Convert.h" … … 282 283 void SpaceShip::setCamera(const std::string& camera) 283 284 { 284 Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");285 285 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 286 camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 286 287 /* 287 288 // node->setInheritOrientation(false); … … 290 291 cam->roll(Degree(0)); 291 292 */ 292 293 cam->setPosition(Vector3(-200,0,35)); 293 cam_ = new Camera(this->camNode_); 294 cam_->setTargetNode(this->getNode()); 295 CameraHandler::getInstance()->requestFocus(cam_); 294 296 // cam->setPosition(Vector3(0,-350,0)); 295 cam->lookAt(Vector3(0,0,35)); 296 cam->roll(Degree(-90)); 297 298 this->camNode_->attachObject(cam); 299 GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam); 297 //cam->roll(Degree(-90)); 298 299 //this->camNode_->attachObject(cam); 300 300 } 301 301 -
code/branches/camera/src/orxonox/objects/SpaceShip.h
r1056 r1201 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 35 35 #include <OIS/OISMouse.h> 36 36 37 #include "Camera.h" 37 38 #include "Model.h" 38 39 #include "../tools/BillboardSet.h" 40 39 41 40 42 namespace orxonox … … 80 82 81 83 Ogre::SceneNode* camNode_; 84 Camera* cam_; 82 85 83 86 ParticleInterface* tt_;
Note: See TracChangeset
for help on using the changeset viewer.