Changeset 2942 for code/branches/map/src/orxonox/overlays
- Timestamp:
- Apr 30, 2009, 2:12:57 PM (16 years ago)
- Location:
- code/branches/map/src/orxonox/overlays/map
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/map/src/orxonox/overlays/map/Map.cc
r2913 r2942 28 28 29 29 #include <string> 30 #include "util/String.h" 30 31 #include <OgreSceneManager.h> 31 32 #include <OgreSceneNode.h> … … 33 34 #include <OgreNode.h> 34 35 36 35 37 #include <OgreRenderWindow.h> 36 38 #include <OgreRenderTexture.h> 37 39 #include <OgreTexture.h> 38 40 #include <OgreViewport.h> 39 #include <OgreMaterial.h> 41 40 42 #include <OgreMaterialManager.h> 41 43 #include <OgreRoot.h> … … 53 55 #include "objects/Scene.h" 54 56 #include "objects/RadarViewable.h" 57 #include "objects/controllers/HumanController.h" 55 58 56 59 namespace orxonox 57 60 { 58 61 CreateFactory(Map); 59 SetConsoleCommand(Map, openMap, true); 62 SetConsoleCommand(Map, openMap, true); 63 SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand(); 64 SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand(); 65 66 Map* Map::singletonMap_s = 0; 60 67 61 68 Map::Map(BaseObject* creator) : OrxonoxOverlay(creator) 62 69 { 63 70 RegisterObject(Map); 64 71 Map::singletonMap_s=this; 65 72 //Getting Scene Manager (Hack) 66 73 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); … … 88 95 */ 89 96 90 97 this->mouseLookSpeed_ = 200; 91 98 92 99 … … 99 106 mReflectCam_->setAspectRatio(1); 100 107 108 //Create overlay material 101 109 std::string camMat_id = "RttMat"; 102 110 Ogre::MaterialPtr material = this->createRenderCamera(mReflectCam_, camMat_id); … … 145 153 overlay_->hide(); 146 154 147 } 148 155 //Create plane in map 156 Ogre::Entity* plane_ent = this->mapSceneM_->createEntity( "MapPlane", "plane.mesh"); 157 Ogre::SceneNode* plane_node = this->mapSceneM_->getRootSceneNode()->createChildSceneNode(); 158 159 //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General"); 160 //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga"); 161 //plane_ent->setMaterialName("mapgrid"); 162 plane_ent->setMaterialName("Map/Grid"); 163 plane_node->attachObject(plane_ent); 164 plane_node->scale(10,1,10); 165 //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock"); 166 167 168 //ToDo create material script 169 Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General"); 170 myManualObjectMaterial->setReceiveShadows(false); 171 myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true); 172 myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0); 173 myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0); 174 myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0); 175 176 } 177 178 Map::~Map() 179 { 180 singletonMap_s = 0; 181 //delete sManager_; 182 //delete rootNode_; 183 //delete oManager_; 184 //delete mReflectCam_; 185 //delete mapSceneM_; 186 } 187 149 188 Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName) 150 189 { … … 168 207 void Map::updatePositions() 169 208 { 209 170 210 //Ogre::Entity * ent;// = mapSceneM_->createEntity("ent1", "drone.mesh"); 171 int i=0;172 211 for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); 173 212 it!=ObjectList<orxonox::RadarViewable>::end(); 174 213 it++) 175 214 { 176 i++;177 215 //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl; 178 216 //Ogre::SceneNode node = it->getMapNode(); … … 182 220 it->MapNode_ = rootNode_->createChildSceneNode( it->getRVWorldPosition() ); 183 221 //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD ); 222 /*if(it->getRadarObjectShape() == RadarViewable::Dot) 223 { 224 //if( !(it->MapEntity_) )//check wether the entity is already attached 225 //{ 226 //it->MapEntity_ = this->mapSceneM_->createEntity( getUniqueNumberString(), "drone.mesh"); 227 //it->addEntity(); 228 //it->MapNode_->attachObject( it->MapEntity_ ); 229 //it->MapNode_->attachObject( it->line_ ); 230 // } 231 }*/ 232 it->addMapEntity(); 184 233 } 185 it->MapNode_->setPosition( it->getRVWorldPosition() ); 186 it->MapNode_->translate( it->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 ); 187 if( !(it->MapEntity_) ) 188 { 189 it->MapEntity_ = mapSceneM_->createEntity( "MapEnt"+i, "drone.mesh"); 190 it->MapNode_->attachObject( it->MapEntity_ ); 191 } 234 235 it->updateMapPosition(); 236 237 238 192 239 193 240 … … 218 265 this->overlay_->show(); 219 266 this->isVisible_=1; 220 //updatePositions(); 267 //set mouselook when showing map 268 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook()) 269 HumanController::localController_s->controllableEntity_->mouseLook(); 221 270 } 222 271 else … … 224 273 this->overlay_->hide(); 225 274 this->isVisible_=0; 275 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook()) 276 HumanController::localController_s->controllableEntity_->mouseLook(); 226 277 } 227 278 } … … 235 286 { 236 287 //Map * m = it->getMap(); 237 COUT(0) << it->isVisible_ << std::endl;288 //COUT(0) << it->isVisible_ << std::endl; 238 289 it->toggleVisibility(); 239 290 //it->updatePositions(); … … 244 295 { 245 296 //sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z); 246 updatePositions(); 247 297 if( this->isVisible_ ) 298 updatePositions(); 299 //mReflectCam_->roll(Degree(1)); 300 301 } 302 303 void Map::rotateYaw(const Vector2& value) 304 { 305 //if (this->bMouseLook_) 306 //this->mReflectCam_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 307 if(Map::singletonMap_s) 308 singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_Y)); 309 } 310 311 void Map::rotatePitch(const Vector2& value) 312 { 313 //if (this->bMouseLook_) 314 //this->mReflectCam_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 315 if(Map::singletonMap_s) 316 singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X)); 248 317 } 249 318 -
code/branches/map/src/orxonox/overlays/map/Map.h
r2913 r2942 54 54 public: // functions 55 55 Map(BaseObject* creator); 56 virtual ~Map() {}56 ~Map(); 57 57 58 58 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); … … 65 65 66 66 static const int maxRange_s=1000; 67 68 static void rotateYaw(const Vector2& value); 69 static void rotatePitch(const Vector2& value); 70 71 // variables 72 73 74 bool inline getVisibility() 75 { return this->isVisible_; }; 76 77 static inline Ogre::SceneManager* getMapSceneManagerPtr() 78 { 79 return Map::singletonMap_s->mapSceneM_; 80 } 81 static inline Map* getSingletonPtr() 82 { 83 return Map::singletonMap_s; 84 } 85 86 87 67 88 68 89 private: // functions 90 69 91 void toggleVisibility(); 70 92 void updatePositions(); 71 93 72 94 73 95 private: // variables 96 static Map* singletonMap_s; 97 74 98 Ogre::SceneManager* sManager_; 75 99 Ogre::SceneManager* mapSceneM_; … … 77 101 Ogre::OverlayManager * oManager_; 78 102 Ogre::Camera* mReflectCam_; 79 80 81 103 //Ogre::SceneNode* playerShipNode_; 104 int mouseLookSpeed_; 82 105 bool isVisible_; 83 106 };
Note: See TracChangeset
for help on using the changeset viewer.