Changeset 1212
- Timestamp:
- May 1, 2008, 6:09:54 PM (17 years ago)
- Location:
- code/branches/network3
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/bin/levels/sample.oxw
r1190 r1212 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/network3/src/orxonox/CMakeLists.txt
r1153 r1212 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/network3/src/orxonox/objects/Camera.cc
r1067 r1212 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/network3/src/orxonox/objects/Camera.h
r1056 r1212 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/network3/src/orxonox/objects/SpaceShip.cc
r1184 r1212 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" … … 287 288 288 289 void SpaceShip::createCamera(){ 289 Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");290 290 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 291 camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 291 292 /* 292 293 // node->setInheritOrientation(false); … … 295 296 cam->roll(Degree(0)); 296 297 */ 297 298 cam->setPosition(Vector3(-200,0,35)); 298 cam_ = new Camera(this->camNode_); 299 cam_->setTargetNode(this->getNode()); 300 CameraHandler::getInstance()->requestFocus(cam_); 299 301 // cam->setPosition(Vector3(0,-350,0)); 300 cam->lookAt(Vector3(0,0,35)); 301 cam->roll(Degree(-90)); 302 303 this->camNode_->attachObject(cam); 304 GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam); 302 //cam->roll(Degree(-90)); 303 304 //this->camNode_->attachObject(cam); 305 305 306 306 } -
code/branches/network3/src/orxonox/objects/SpaceShip.h
r1184 r1212 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 … … 81 83 82 84 Ogre::SceneNode* camNode_; 85 Camera* cam_; 83 86 84 87 ParticleInterface* tt_;
Note: See TracChangeset
for help on using the changeset viewer.