Changeset 7163 for code/trunk/src/orxonox/interfaces/RadarViewable.cc
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r6417 r7163 29 29 #include "RadarViewable.h" 30 30 31 #include <OgreSceneManager.h>32 #include <OgreSceneNode.h>33 #include <OgreEntity.h>34 35 31 #include "util/StringUtils.h" 36 32 #include "core/CoreIncludes.h" 37 #include " tools/DynamicLines.h"33 #include "core/GameMode.h" 38 34 #include "worldentities/WorldEntity.h" 39 35 #include "Radar.h" 40 36 #include "Scene.h" 41 #include "overlays/Map.h"42 37 43 38 namespace orxonox … … 46 41 @brief Constructor. 47 42 */ 48 RadarViewable::RadarViewable() 49 : MapNode_(NULL) 50 , MapEntity_(NULL) 51 , line_(NULL) 52 , LineNode_(NULL) 53 , isHumanShip_(false) 43 RadarViewable::RadarViewable(BaseObject* creator, const WorldEntity* wePtr) 44 : isHumanShip_(false) 54 45 , bVisibility_(true) 46 , bInitialized_(false) 47 , creator_(creator) 48 , wePtr_(wePtr) 55 49 , radarObjectCamouflage_(0.0f) 56 50 , radarObjectShape_(Dot) … … 60 54 61 55 this->uniqueId_=getUniqueNumberString(); 62 /* 63 if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr()) 56 if( GameMode::showsGraphics() ) 64 57 { 65 this->addEntity(); 58 this->radar_ = this->creator_->getScene()->getRadar(); 59 this->radar_->addRadarObject(this); 66 60 } 67 68 */ 61 this->bInitialized_ = true; 69 62 } 70 63 … … 72 65 RadarViewable::~RadarViewable() 73 66 { 74 if (this->isHumanShip_ && MapNode_)75 MapNode_->removeAllChildren();76 67 77 if (MapNode_) 78 delete MapNode_; 79 80 if (MapEntity_) 81 delete MapEntity_; 82 83 if (line_) 84 delete line_; 85 86 if (LineNode_) 87 delete LineNode_; 88 } 89 90 void RadarViewable::addMapEntity() 91 { //TODO Check shape and add accordantly 92 if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() ) 68 if( this->bInitialized_ ) 93 69 { 94 COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n"; 95 this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh"); 96 /*this->line_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l"); 97 this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP); 98 //line_->position(0, -it->getRVWorldPosition().y, 0); 99 //this->line_->position(0, -20, 0); 100 this->line_->position(0, 0, -10); //Front Arrow 101 this->line_->position(0, 0, 0); 102 103 this->line_->end(); */ 104 this->line_ = new Ogre::DynamicLines(Ogre::RenderOperation::OT_LINE_LIST); 105 this->line_->addPoint( Vector3(0,0,0) ); 106 this->line_->addPoint( Vector3(0,0,0) ); 107 108 this->MapNode_->attachObject( this->MapEntity_ ); 109 110 this->LineNode_ = this->MapNode_->createChildSceneNode(); 111 this->LineNode_->attachObject( this->line_ ); 112 } 113 else 114 { 115 COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n"; 70 if( GameMode::showsGraphics() ) 71 { 72 this->radar_->removeRadarObject(this); 73 } 116 74 } 117 75 } 118 76 119 void RadarViewable::updateMapPosition() 120 { 121 if( this->MapNode_ ) 122 { 123 this->MapNode_->setPosition( this->getRVWorldPosition() ); 124 this->MapNode_->translate( this->getRVOrientedVelocity(), static_cast<Ogre::Node::TransformSpace>(3) ); 125 this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() ); 126 //Vector3 v = this->getRVWorldPosition(); 127 //this->line_->setPoint(1, Vector3(0,v.y,0) ); 128 this->line_->setPoint(1, Vector3( 0, static_cast<float>(static_cast<int>( -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ) ) ,0 )); 129 this->line_->update(); 130 if( Map::getSingletonPtr()->playerShipNode_ ) 131 this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y); 132 } 133 } 134 135 void RadarViewable::setRadarObjectDescription(const std::string& str) 136 { 137 Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 138 if (radar) 139 this->radarObjectShape_ = radar->addObjectDescription(str); 140 else 141 { 142 CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl; 143 } 144 this->radarObjectDescription_ = str; 145 } 77 // void RadarViewable::setRadarObjectDescription(const std::string& str) 78 // { 79 // Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 80 // if (radar) 81 // this->radarObjectShape_ = radar->addObjectDescription(str); 82 // else 83 // { 84 // CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl; 85 // } 86 // this->radarObjectDescription_ = str; 87 // } 146 88 147 89 const Vector3& RadarViewable::getRVWorldPosition() const … … 167 109 } 168 110 } 111 112 void RadarViewable::settingsChanged() 113 { 114 if( GameMode::showsGraphics() ) 115 { 116 this->radar_->radarObjectChanged(this); 117 } 118 } 169 119 }
Note: See TracChangeset
for help on using the changeset viewer.