Changeset 2942
- Timestamp:
- Apr 30, 2009, 2:12:57 PM (16 years ago)
- Location:
- code/branches/map/src
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/map/src/orxonox/objects/RadarViewable.cc
r2913 r2942 35 35 #include "objects/worldentities/WorldEntity.h" 36 36 #include "objects/Radar.h" 37 #include "util/String.h" 38 #include <OgreManualObject.h> 39 #include "overlays/map/Map.h" 40 #include "orxonox/tools/DynamicLines.h" 37 41 38 42 namespace orxonox … … 47 51 , MapNode_(NULL) 48 52 , MapEntity_(NULL) 53 , line_(NULL) 49 54 { 50 55 RegisterRootObject(RadarViewable); 56 57 this->uniqueId_=getUniqueNumberString(); 58 /* 59 if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr()) 60 { 61 this->addEntity(); 62 } 63 64 */ 65 } 66 67 68 RadarViewable::~RadarViewable() 69 { 70 delete MapNode_; 71 delete MapEntity_; 72 } 73 74 void RadarViewable::addMapEntity() 75 { //TODO Check shape and add accordantly 76 if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() ) 77 { 78 COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n"; 79 this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh"); 80 /*this->line_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l"); 81 this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP); 82 //line_->position(0, -it->getRVWorldPosition().y, 0); 83 //this->line_->position(0, -20, 0); 84 this->line_->position(0, 0, -10); //Front Arrow 85 this->line_->position(0, 0, 0); 86 87 this->line_->end(); */ 88 this->line_ = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST); 89 this->line_->addPoint( Vector3(0,0,0) ); 90 this->line_->addPoint( Vector3(0,0,0) ); 91 92 this->MapNode_->attachObject( this->MapEntity_ ); 93 this->MapNode_->attachObject( this->line_ ); 94 } 95 else 96 { 97 COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n"; 98 } 99 } 100 101 void RadarViewable::updateMapPosition() 102 { 103 if( this->MapNode_ ) 104 { 105 this->MapNode_->setPosition( this->getRVWorldPosition() ); 106 this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 ); 107 this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() ); 108 Vector3 v = this->getRVWorldPosition(); 109 this->line_->setPoint(1, Vector3(0,v.y,0) ); 110 } 51 111 } 52 112 -
code/branches/map/src/orxonox/objects/RadarViewable.h
r2913 r2942 37 37 #include "core/OrxonoxClass.h" 38 38 39 #include <string> 39 40 #include <OgreSceneNode.h> 40 41 #include <OgreEntity.h> 42 #include <OgreManualObject.h> 43 #include "orxonox/tools/DynamicLines.h" 41 44 42 45 namespace orxonox … … 55 58 }; 56 59 60 57 61 public: 58 62 RadarViewable(); 59 virtual ~RadarViewable() { }63 virtual ~RadarViewable(); 60 64 61 65 inline void setRadarObjectCamouflage(float camouflage) … … 96 100 Ogre::SceneNode * MapNode_; 97 101 Ogre::Entity * MapEntity_; 98 102 DynamicLines* line_; 103 void addMapEntity(); 104 void updateMapPosition(); 99 105 private: 100 106 void validate(const WorldEntity* object) const … … 107 113 } 108 114 115 116 std::string uniqueId_; 117 109 118 float radarObjectCamouflage_; 110 119 Shape radarObjectShape_; -
code/branches/map/src/orxonox/objects/controllers/HumanController.cc
r2662 r2942 35 35 #include "objects/worldentities/pawns/Pawn.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "overlays/map/Map.h" 37 38 38 39 namespace orxonox … … 92 93 void HumanController::rotateYaw(const Vector2& value) 93 94 { 95 //Hack to enable mouselook in map 96 if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() ) 97 { 98 Map::getSingletonPtr()->rotateYaw(value); 99 return; 100 } 94 101 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 95 102 HumanController::localController_s->controllableEntity_->rotateYaw(value); … … 98 105 void HumanController::rotatePitch(const Vector2& value) 99 106 { 107 //Hack to enable mouselook in map 108 if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() ) 109 { 110 Map::getSingletonPtr()->rotatePitch(value); 111 return; 112 } 100 113 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 101 114 HumanController::localController_s->controllableEntity_->rotatePitch(value); -
code/branches/map/src/orxonox/objects/controllers/HumanController.h
r2662 r2942 66 66 static void killBots(unsigned int amount = 0); 67 67 68 //friend class, for mouselook 69 friend class Map; 70 68 71 private: 69 72 static HumanController* localController_s; -
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 }; -
code/branches/map/src/orxonox/tools/CMakeLists.txt
r2710 r2942 7 7 Timer.cc 8 8 WindowEventListener.cc 9 DynamicLines.cpp 10 DynamicRenderable.cpp 9 11 ) -
code/branches/map/src/util/CMakeLists.txt
r2773 r2942 37 37 UtilPrereqs.h 38 38 mbool.h 39 39 40 40 Clipboard.cc 41 41 CRC32.cc
Note: See TracChangeset
for help on using the changeset viewer.