Changeset 1562
- Timestamp:
- Jun 7, 2008, 3:39:48 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/hud/HUD.cc
r1505 r1562 124 124 SceneNode* node; 125 125 node = sm->getRootSceneNode()->createChildSceneNode("tomato1", Vector3(2000.0, 0.0, 0.0)); 126 addRadarObject(node, ColourValue(0.5, 0, 0, 1)); 127 node = sm->getRootSceneNode()->createChildSceneNode("tomato2", Vector3(0.0, 2000.0, 0.0)); 128 addRadarObject(node, ColourValue(0.5, 0, 0, 1)); 129 node = sm->getRootSceneNode()->createChildSceneNode("tomato3", Vector3(0.0, 0.0, 2000.0)); 130 addRadarObject(node, ColourValue(0.5, 0, 0, 1)); 131 node = sm->getRootSceneNode()->createChildSceneNode("station", Vector3(10000.0,16000.0,0.0)); 126 132 addRadarObject(node); 127 node = sm->getRootSceneNode()->createChildSceneNode("tomato2", Vector3(0.0, 2000.0, 0.0));128 addRadarObject(node);129 node = sm->getRootSceneNode()->createChildSceneNode("tomato3", Vector3(0.0, 0.0, 2000.0));130 addRadarObject(node);131 node = sm->getRootSceneNode()->createChildSceneNode("station", Vector3(10000.0,16000.0,0.0));132 addRadarObject(node, 3);133 133 } 134 134 … … 178 178 } 179 179 180 void HUD::addRadarObject(SceneNode* node, intcolour){180 void HUD::addRadarObject(SceneNode* node, const ColourValue& colour){ 181 181 RadarObject* obj = new RadarObject(container, node, colour); 182 182 roSet.insert(obj); … … 193 193 194 194 void HUD::removeRadarObject(Ogre::SceneNode* node){ 195 COUT(3) << "blabla" << std::endl; 196 for(std::set<RadarObject*>::iterator it=roSet.begin(); it!=roSet.end(); it++){ 197 if((*it)->getNode() == node) { 195 for(std::set<RadarObject*>::iterator it=roSet.begin(); it!=roSet.end(); ++it){ 196 if ((*it)->getNode() == node) 197 { 198 if (this->nav->focus_ == (*it)) 199 { 200 this->nav->cycleFocus(); 201 if (this->nav->focus_ == (*it)) 202 this->nav->focus_ = 0; 203 } 198 204 delete (*it); 199 205 roSet.erase(it); 206 return; 200 207 } 201 208 } -
code/trunk/src/orxonox/hud/HUD.h
r1535 r1562 63 63 public: 64 64 virtual void tick(float); 65 void addRadarObject(Ogre::SceneNode* node, int colour = 0);65 void addRadarObject(Ogre::SceneNode* node, const ColourValue& colour = ColourValue(0.5, 0.5, 0.5, 1)); 66 66 void removeRadarObject(Ogre::SceneNode* node); 67 67 void setRenderTimeRatio(float ratio); -
code/trunk/src/orxonox/hud/Navigation.cc
r1505 r1562 210 210 } 211 211 else{ 212 focus_->reset Colour();212 focus_->resetMaterial(); 213 213 if(it_ != HUD::getSingleton().roSet.end()){ 214 214 focus_ = *it_; … … 224 224 navMarker_->show(); 225 225 navText_->show(); 226 focus_->setColour( RadarObject::WHITE);226 focus_->setColour(ColourValue::White); 227 227 } 228 228 } -
code/trunk/src/orxonox/hud/RadarObject.cc
r1505 r1562 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 33 #include <OgreMaterialManager.h> 34 #include <OgreTechnique.h> 35 34 36 #include "GraphicsEngine.h" 37 #include "util/Convert.h" 38 39 namespace std 40 { 41 template <> 42 class less<orxonox::ColourValue> 43 { 44 public: 45 bool operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) 46 { 47 if (__x.r == __y.r) 48 { 49 if (__x.g == __y.g) 50 { 51 if (__x.b == __y.b) 52 { 53 return __x.a < __y.a; 54 } 55 return __x.b < __y.b; 56 } 57 return __x.g < __y.g; 58 } 59 return __x.r < __y.r; 60 } 61 }; 62 } 35 63 36 64 namespace orxonox 37 65 { 38 using namespace Ogre; 66 unsigned int RadarObject::count_s = 0; 67 std::map<std::string, std::map<ColourValue, std::string> > RadarObject::materials_s; 39 68 40 int RadarObject::count = 0; // initialize static variable 69 RadarObject::RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, const ColourValue& colour, const std::string& texturename) 70 { 71 this->colour_ = colour; 72 this->texturename_ = texturename; 41 73 42 RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){ 43 container_ = container; 44 node_ = node; 45 colour_ = colour; 46 om = &OverlayManager::getSingleton(); 47 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 48 "Object"+StringConverter::toString(count))); 49 setColour(colour_); 50 panel_->setDimensions(3,3); 51 panel_->setMetricsMode(Ogre::GMM_PIXELS); 52 panel_->show(); 53 index_ = count; 54 count++; 55 container_->addChild(panel_); 74 this->container_ = container; 75 this->node_ = node; 76 77 this->panel_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarObject" + getConvertedValue<unsigned int, std::string>(RadarObject::count_s))); 78 this->setMaterial(colour, texturename); 79 80 this->panel_->setDimensions(3,3); 81 this->panel_->setMetricsMode(Ogre::GMM_PIXELS); 82 this->panel_->show(); 83 84 this->index_ = count_s++; 85 this->container_->addChild(panel_); 56 86 } 57 87 58 RadarObject::~RadarObject(){ 88 RadarObject::~RadarObject() 89 { 59 90 delete panel_; 60 91 } 61 92 62 void RadarObject::setColour(int colour){ 63 switch(colour){ 64 case RED: panel_->setMaterialName("Orxonox/RedDot"); break; 65 case YELLOW: panel_->setMaterialName("Orxonox/YellowDot"); break; 66 case GREEN: panel_->setMaterialName("Orxonox/GreenDot"); break; 67 case BLUE: panel_->setMaterialName("Orxonox/BlueDot"); break; 68 case WHITE: panel_->setMaterialName("Orxonox/WhiteDot"); break; 69 default: panel_->setMaterialName("Orxonox/RedDot"); break; 93 void RadarObject::setMaterial(const ColourValue& colour, const std::string& texturename) 94 { 95 std::map<ColourValue, std::string>& colourmap = this->materials_s[texturename]; 96 std::map<ColourValue, std::string>::const_iterator it = colourmap.find(colour); 97 std::string materialname; 98 99 if (it == colourmap.end()) 100 { 101 materialname = "radarmaterial" + getConvertedValue<unsigned int, std::string>(RadarObject::count_s); 102 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 103 Ogre::TextureUnitState* textureunitstate = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 104 textureunitstate->setTextureName(texturename); 105 textureunitstate->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour); 106 colourmap[colour] = materialname; 70 107 } 108 else 109 { 110 materialname = (*it).second; 111 } 112 113 this->panel_->setMaterialName(materialname); 71 114 } 72 115 73 void RadarObject::resetColour(){ 74 setColour(colour_); 75 } 76 77 Vector3 RadarObject::getPosition(){ 116 Vector3 RadarObject::getPosition() 117 { 78 118 return node_->getPosition(); 79 119 } 80 120 81 SceneNode* RadarObject::getNode(){ 121 Ogre::SceneNode* RadarObject::getNode() 122 { 82 123 return node_; 83 124 } -
code/trunk/src/orxonox/hud/RadarObject.h
r1505 r1562 30 30 #define _RadarObject_H__ 31 31 32 #include <map> 33 32 34 #include <OgrePrerequisites.h> 33 35 #include <OgreSceneNode.h> … … 40 42 class _OrxonoxExport RadarObject 41 43 { 42 private: 43 Ogre::OverlayManager* om; // our one and only overlay manager 44 Ogre::SceneNode* node_; // node of object 45 int colour_; 44 public: 45 RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, const ColourValue& colour = ColourValue(0.5, 0.5, 0.5, 1), const std::string& texturename = "white.tga"); 46 ~RadarObject(); 46 47 47 public: 48 RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, int colour = 0); 49 ~RadarObject(); 50 void setColour(int colour); 51 void resetColour(); 48 void setMaterial(const ColourValue& colour, const std::string& texturename); 49 inline void setColour(const ColourValue& colour) 50 { this->setMaterial(colour, this->texturename_); } 51 inline void setTexture(const std::string& texturename) 52 { this->setMaterial(this->colour_, texturename); } 53 inline void resetMaterial() 54 { this->setMaterial(this->colour_, this->texturename_); } 55 52 56 Vector3 getPosition(); 53 57 Ogre::SceneNode* getNode(); … … 58 62 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 59 63 60 static int count;61 static const int RED = 0;62 static const int YELLOW = 1;63 static const int GREEN = 2;64 static const int BLUE = 3;65 st atic const int WHITE = 99; // used if object got nav focus64 private: 65 static std::map<std::string, std::map<ColourValue, std::string> > materials_s; 66 unsigned static int count_s; 67 Ogre::SceneNode* node_; // node of object 68 ColourValue colour_; 69 std::string texturename_; 66 70 }; 67 71 } -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1559 r1562 151 151 delete this->cam_; 152 152 153 if (! myShip_ && &HUD::getSingleton()!=NULL)154 HUD::getSingleton().removeRadarObject(this->getNode());153 if (!this->myShip_) 154 HUD::getSingleton().removeRadarObject(this->getNode()); 155 155 } 156 156 } … … 161 161 myShip_=true; 162 162 else 163 HUD::getSingleton().addRadarObject(this->getNode(), 3);163 HUD::getSingleton().addRadarObject(this->getNode(), this->getProjectileColour()); 164 164 } 165 165 if(Model::create()) … … 282 282 void SpaceShip::setCamera(const std::string& camera) 283 283 { 284 myShip_=true; // TODO: this is only a hack 284 285 camName_=camera; 285 286 // change camera attributes here, if you want to ;) … … 353 354 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode); 354 355 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode); 355 myShip_=true; // TODO: this is only a hack356 356 357 357 SpaceShip::create(); -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1558 r1562 80 80 SpaceShip::XMLPort(xmlelement, mode); 81 81 82 this->myShip_=true;83 82 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action))); 84 83 }
Note: See TracChangeset
for help on using the changeset viewer.