Changeset 2956 for code/branches/map/src/orxonox
- Timestamp:
- May 7, 2009, 4:44:12 PM (16 years ago)
- Location:
- code/branches/map/src/orxonox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/map/src/orxonox/objects/RadarViewable.cc
r2942 r2956 52 52 , MapEntity_(NULL) 53 53 , line_(NULL) 54 , isHumanShip_(false) 54 55 { 55 56 RegisterRootObject(RadarViewable); … … 69 70 { 70 71 delete MapNode_; 72 MapNode_=0; 71 73 delete MapEntity_; 74 MapEntity_=0; 75 delete line_; 76 line_=0; 77 delete LineNode_; 78 LineNode_=0; 72 79 } 73 80 … … 91 98 92 99 this->MapNode_->attachObject( this->MapEntity_ ); 93 this->MapNode_->attachObject( this->line_ ); 100 101 this->LineNode_ = this->MapNode_->createChildSceneNode(); 102 this->LineNode_->attachObject( this->line_ ); 94 103 } 95 104 else … … 106 115 this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 ); 107 116 this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() ); 108 Vector3 v = this->getRVWorldPosition(); 109 this->line_->setPoint(1, Vector3(0,v.y,0) ); 117 //Vector3 v = this->getRVWorldPosition(); 118 //this->line_->setPoint(1, Vector3(0,v.y,0) ); 119 this->line_->setPoint(1, Vector3(0, -this->getRVWorldPosition().y ,0) ); 120 this->line_->update(); 121 this->LineNode_->setDirection(Vector3::UNIT_Y,Ogre::Node::TS_WORLD,Vector3::UNIT_Y); 110 122 } 111 123 } -
code/branches/map/src/orxonox/objects/RadarViewable.h
r2942 r2956 101 101 Ogre::Entity * MapEntity_; 102 102 DynamicLines* line_; 103 Ogre::SceneNode * LineNode_; 103 104 void addMapEntity(); 104 105 void updateMapPosition(); 106 bool isHumanShip_; 107 inline std::string getUniqueId() 108 { 109 return this->uniqueId_; 110 } 111 105 112 private: 106 113 void validate(const WorldEntity* object) const … … 113 120 } 114 121 122 //Map 123 std::string uniqueId_; 115 124 116 std::string uniqueId_;117 125 126 //Radar 118 127 float radarObjectCamouflage_; 119 128 Shape radarObjectShape_; -
code/branches/map/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2782 r2956 75 75 76 76 this->registerVariables(); 77 78 this->isHumanShip_ = this->hasLocalController(); 77 79 } 78 80 … … 291 293 } 292 294 295 //Tell the Map (RadarViewable), if this is a playership 296 void Pawn::startLocalHumanControl() 297 { 298 // SUPER(ControllableEntity, changedPlayer()); 299 ControllableEntity::startLocalHumanControl(); 300 this->isHumanShip_ = true; 301 } 302 293 303 294 304 /////////////////// -
code/branches/map/src/orxonox/objects/worldentities/pawns/Pawn.h
r2662 r2956 108 108 109 109 virtual void dropItems(); 110 111 virtual void startLocalHumanControl(); 110 112 111 113 protected: -
code/branches/map/src/orxonox/overlays/map/Map.cc
r2942 r2956 61 61 CreateFactory(Map); 62 62 SetConsoleCommand(Map, openMap, true); 63 SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand(); 64 SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand(); 63 //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand(); 64 //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand(); 65 SetConsoleCommand(Map, Zoom, true).setAsInputCommand(); 65 66 66 67 Map* Map::singletonMap_s = 0; 67 68 Ogre::SceneManager* Map::mapSceneM_s = 0; 69 //int Map::mouseLookSpeed_ = 200; 70 //Ogre::SceneNode* Map::playerShipNode_ = 0; 71 72 const int PITCH=-30; 73 const int DISTANCE=200; 74 68 75 Map::Map(BaseObject* creator) : OrxonoxOverlay(creator) 69 76 { 70 77 RegisterObject(Map); 71 78 Map::singletonMap_s=this; 79 72 80 //Getting Scene Manager (Hack) 73 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); 74 this->sManager_ = it->getSceneManager(); 75 76 this->mapSceneM_ = Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ); 77 rootNode_ = mapSceneM_->getRootSceneNode(); 78 81 if( !sManager_ ) 82 { 83 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); 84 this->sManager_ = it->getSceneManager(); 85 } 86 if( !Map::getMapSceneManager() ) 87 { 88 Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) ); 89 } 90 91 this->playerShipNode_ = 0; 79 92 //this->sNode_ = new Ogre::SceneNode(sManager_); 80 93 //oManager_ = Ogre::OverlayManager::getSingletonPtr(); … … 85 98 //this->isVisible_=false; 86 99 //overlay_->hide(); 87 100 this->mouseLookSpeed_ = 200; 88 101 89 102 //TestEntity 90 //Ogre::Entity * ent = mapSceneM_ ->createEntity("ent", "drone.mesh");91 92 // rootNode_->attachObject( ent );103 //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh"); 104 105 //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent ); 93 106 /*sNode_->setPosition(0,0,-50); 94 107 overlay_->add3D(sNode_); 95 108 */ 96 109 97 this->mouseLookSpeed_ = 200;110 98 111 99 112 … … 101 114 // Alter the camera aspect ratio to match the viewport 102 115 //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); 103 mReflectCam_ = mapSceneM_->createCamera("ReflectCam"); 104 mReflectCam_->setPosition(200,170, -160); 105 mReflectCam_->lookAt(0,0,0); 106 mReflectCam_->setAspectRatio(1); 116 Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam"); 117 //Cam_->setPosition(200,170, -160); 118 //Cam_->lookAt(0,0,0); 119 Cam_->setAspectRatio(1); 120 //Cam_->setRenderingDistance(0); 121 CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode(); 122 107 123 108 124 //Create overlay material 109 125 std::string camMat_id = "RttMat"; 110 Ogre::MaterialPtr material = this->createRenderCamera( mReflectCam_, camMat_id);126 Ogre::MaterialPtr material = this->createRenderCamera(Cam_, camMat_id); 111 127 /* 112 128 Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET); … … 114 130 Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget(); 115 131 116 renderTexture->addViewport( mReflectCam_);132 renderTexture->addViewport(Cam_); 117 133 renderTexture->getViewport(0)->setClearEveryFrame(true); 118 134 renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black); … … 154 170 155 171 //Create plane in map 156 Ogre::Entity* plane_ent = this->mapSceneM_->createEntity( "MapPlane", "plane.mesh");157 Ogre::SceneNode* plane_node = this->mapSceneM_->getRootSceneNode()->createChildSceneNode();172 Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh"); 173 planeNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode(); 158 174 159 175 //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General"); … … 161 177 //plane_ent->setMaterialName("mapgrid"); 162 178 plane_ent->setMaterialName("Map/Grid"); 163 plane _node->attachObject(plane_ent);164 plane _node->scale(10,1,10);179 planeNode_->attachObject(plane_ent); 180 planeNode_->scale(10,1,10); 165 181 //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock"); 166 182 … … 178 194 Map::~Map() 179 195 { 180 singletonMap_s = 0; 196 this->singletonMap_s = 0; 197 /*if (this->isInitialized()) 198 { 181 199 //delete sManager_; 182 //delete rootNode_;200 //delete Map::getMapSceneManager()->getRootSceneNode(); 183 201 //delete oManager_; 184 //delete mReflectCam_; 185 //delete mapSceneM_; 202 //delete CamNode_; 203 //delete Cam_; 204 //delete mapSceneM_s; 205 //Map::getMapSceneManager()->destroyAllEntities(); 206 //Map::getMapSceneManager()->destroyAllCameras(); 207 delete Map::getMapSceneManager(); 208 }*/ 186 209 } 187 210 … … 208 231 { 209 232 210 //Ogre::Entity * ent;// = mapSceneM_ ->createEntity("ent1", "drone.mesh");233 //Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh"); 211 234 for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); 212 235 it!=ObjectList<orxonox::RadarViewable>::end(); … … 218 241 if( !(it->MapNode_) ) 219 242 { 220 it->MapNode_ = rootNode_->createChildSceneNode( it->getRVWorldPosition() );243 it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() ); 221 244 //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD ); 222 245 /*if(it->getRadarObjectShape() == RadarViewable::Dot) … … 224 247 //if( !(it->MapEntity_) )//check wether the entity is already attached 225 248 //{ 226 //it->MapEntity_ = this->mapSceneM_->createEntity( getUniqueNumberString(), "drone.mesh");249 //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh"); 227 250 //it->addEntity(); 228 251 //it->MapNode_->attachObject( it->MapEntity_ ); … … 234 257 235 258 it->updateMapPosition(); 236 237 238 239 259 240 260 261 262 if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_) 263 { 264 this->playerShipNode_ = it->MapNode_; 265 this->planeNode_->getParent()->removeChild(this->planeNode_); 266 this->playerShipNode_->addChild(this->planeNode_); 267 this->CamNode_->getParent()->removeChild(this->CamNode_); 268 this->playerShipNode_->addChild(this->CamNode_); 269 this->CamNode_->attachObject(this->Cam_); 270 //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode(); 271 //this->CamNodeHelper_->attachObject(this->Cam_); 272 this->Cam_->setPosition(0, 0, DISTANCE); 273 this->Cam_->pitch( (Degree)PITCH ); 274 //this->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT); 275 this->Cam_->setAutoTracking(true, this->playerShipNode_); 276 } 241 277 242 } 243 } 244 278 279 } 280 } 281 282 283 245 284 void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode) 246 285 { … … 254 293 { 255 294 //COUT(0) << "foo"; 256 this->getOwner()->getReverseCamera()->attachCamera(this-> mReflectCam_);295 this->getOwner()->getReverseCamera()->attachCamera(this->Cam_); 257 296 } 258 297 } … … 297 336 if( this->isVisible_ ) 298 337 updatePositions(); 299 // mReflectCam_->roll(Degree(1));338 //Cam_->roll(Degree(1)); 300 339 301 340 } … … 303 342 void Map::rotateYaw(const Vector2& value) 304 343 { 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)); 344 if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) 345 return; 346 347 /* 348 singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) )); 349 350 Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y); 351 Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT); 352 */ 353 singletonMap_s->CamNode_->yaw( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT); 309 354 } 310 355 311 356 void Map::rotatePitch(const Vector2& value) 312 357 { 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)); 317 } 318 358 if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) 359 return; 360 //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X)); 361 /* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) )); 362 363 Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y); 364 Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT); 365 */ 366 singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT); 367 368 } 369 370 void Map::Zoom(const Vector2& value) 371 { 372 if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) 373 return; 374 //COUT(0) << value.y << std::endl; 375 Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ ); 376 } 319 377 } -
code/branches/map/src/orxonox/overlays/map/Map.h
r2942 r2956 64 64 static void openMap(); 65 65 66 //Not yet implemented 66 67 static const int maxRange_s=1000; 67 68 68 69 static void rotateYaw(const Vector2& value); 69 70 static void rotatePitch(const Vector2& value); 70 71 static void Zoom(const Vector2& value); 71 72 // variables 72 73 … … 77 78 static inline Ogre::SceneManager* getMapSceneManagerPtr() 78 79 { 79 return Map::singletonMap_s->mapSceneM_ ;80 return Map::singletonMap_s->mapSceneM_s; 80 81 } 81 82 static inline Map* getSingletonPtr() … … 84 85 } 85 86 87 static inline Ogre::SceneManager* getMapSceneManager() 88 { 89 return Map::mapSceneM_s; 90 } 86 91 87 92 … … 91 96 void toggleVisibility(); 92 97 void updatePositions(); 93 98 // void changedPlayerNode(); 99 static inline void setMapSceneManager( Ogre::SceneManager * sm) 100 { 101 Map::mapSceneM_s = sm; 102 } 94 103 95 104 private: // variables … … 97 106 98 107 Ogre::SceneManager* sManager_; 99 Ogre::SceneManager* mapSceneM_;100 Ogre::SceneNode* rootNode_;101 108 Ogre::OverlayManager * oManager_; 102 Ogre::Camera* mReflectCam_; 103 //Ogre::SceneNode* playerShipNode_; 109 110 static Ogre::SceneManager* mapSceneM_s; 111 Ogre::SceneNode* CamNode_; 112 Ogre::Camera* Cam_; 113 //Ogre::SceneNode* CamNodeHelper_; 114 Ogre::SceneNode* playerShipNode_; 115 Ogre::SceneNode* planeNode_; 116 104 117 int mouseLookSpeed_; 105 118 bool isVisible_;
Note: See TracChangeset
for help on using the changeset viewer.