Changeset 1450
- Timestamp:
- May 28, 2008, 2:08:03 PM (16 years ago)
- Location:
- code/branches/network/src/orxonox/hud
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/hud/HUD.cc
r1446 r1450 53 53 HUD::HUD(){ 54 54 om = &Ogre::OverlayManager::getSingleton(); 55 sm = GraphicsEngine::getSingleton().getSceneManager(); 55 56 firstRadarObject = NULL; 56 57 lastRadarObject = NULL; … … 117 118 118 119 radar->init(0.5, 0.9, 0.2, container); 119 addRadarObject(Vector3(2000.0, 0.0, 0.0)); 120 addRadarObject(Vector3(0.0, 2000.0, 0.0)); 121 addRadarObject(Vector3(0.0, 0.0, 2000.0)); 120 SceneNode* node; 121 node = sm->getRootSceneNode()->createChildSceneNode("tomato1", Vector3(2000.0, 0.0, 0.0)); 122 addRadarObject(node); 123 node = sm->getRootSceneNode()->createChildSceneNode("tomato2", Vector3(0.0, 2000.0, 0.0)); 124 addRadarObject(node); 125 node = sm->getRootSceneNode()->createChildSceneNode("tomato3", Vector3(0.0, 0.0, 2000.0)); 126 addRadarObject(node); 122 127 } 123 128 … … 151 156 } 152 157 153 void HUD::addRadarObject( Vector3 pos){158 void HUD::addRadarObject(SceneNode* node, int colour){ 154 159 // check if this is the first RadarObject to create 155 160 if(firstRadarObject == NULL){ 156 firstRadarObject = new RadarObject(container, pos);161 firstRadarObject = new RadarObject(container, node, colour); 157 162 lastRadarObject = firstRadarObject; 158 163 } 159 164 else{ // if not, append to list 160 lastRadarObject->next = new RadarObject(container, pos);165 lastRadarObject->next = new RadarObject(container, node, colour); 161 166 lastRadarObject = lastRadarObject->next; 162 167 } -
code/branches/network/src/orxonox/hud/HUD.h
r1422 r1450 34 34 #include <OgrePrerequisites.h> 35 35 #include <OgreTextAreaOverlayElement.h> 36 #include <OgreSceneNode.h> 36 37 #include "core/Tickable.h" 37 38 #include "util/Math.h" … … 46 47 ~HUD(); 47 48 Ogre::OverlayManager* om; 49 Ogre::SceneManager* sm; 48 50 Ogre::Overlay* orxonoxHUD; 49 51 Ogre::OverlayContainer* container; … … 59 61 public: 60 62 virtual void tick(float); 61 void addRadarObject( Vector3 pos);63 void addRadarObject(Ogre::SceneNode* node, int colour = 0); 62 64 RadarObject* getFirstRadarObject(); 63 65 void setRenderTimeRatio(float ratio); -
code/branches/network/src/orxonox/hud/Navigation.cc
r1444 r1450 96 96 97 97 if(navCam_ == NULL) navCam_ = SpaceShip::getLocalShip()->getCamera()->cam_; 98 Vector3 pos = focus_-> pos_;98 Vector3 pos = focus_->getPosition(); 99 99 // transform to screen coordinates 100 100 pos = navCam_->getProjectionMatrix()*navCam_->getViewMatrix()*pos; … … 107 107 // is object in view? 108 108 float radius = RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_); 109 bool isRight = (currentDir_.crossProduct(currentOrth_)).dotProduct(focus_-> pos_- navCamPos_)>0;110 bool isAbove = currentOrth_.dotProduct(focus_-> pos_- navCamPos_)>0;109 bool isRight = (currentDir_.crossProduct(currentOrth_)).dotProduct(focus_->getPosition() - navCamPos_)>0; 110 bool isAbove = currentOrth_.dotProduct(focus_->getPosition() - navCamPos_)>0; 111 111 bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1); 112 112 // if object is behind us, it is out of view anyway: … … 206 206 } 207 207 else{ 208 focus_-> panel_->setMaterialName("Orxonox/RedDot");208 focus_->resetColour(); 209 209 if(focus_ != NULL) focus_ = focus_->next; 210 210 } … … 217 217 navMarker_->show(); 218 218 navText_->show(); 219 focus_-> panel_->setMaterialName("Orxonox/WhiteDot");219 focus_->setColour(RadarObject::WHITE); 220 220 } 221 221 } … … 223 223 float Navigation::getDist2Focus(){ 224 224 if(focus_ == NULL) return(0.0); 225 return((focus_-> pos_-SpaceShip::getLocalShip()->getPosition()).length());225 return((focus_->getPosition()-SpaceShip::getLocalShip()->getPosition()).length()); 226 226 } 227 227 } -
code/branches/network/src/orxonox/hud/RadarObject.cc
r1410 r1450 26 26 */ 27 27 28 #include "OrxonoxStableHeaders.h"29 #include "RadarObject.h"30 31 28 #include <OgreOverlayManager.h> 32 29 #include <OgreStringConverter.h> 30 #include "OrxonoxStableHeaders.h" 31 #include "GraphicsEngine.h" 32 #include "RadarObject.h" 33 33 34 34 namespace orxonox … … 38 38 int RadarObject::count = 0; // initialize static variable 39 39 40 RadarObject::RadarObject(OverlayContainer* container ){40 RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){ 41 41 container_ = container; 42 pos_ = Vector3(0.0, 0.0, 0.0); 43 init(); 44 } 45 46 RadarObject::RadarObject(OverlayContainer* container, Vector3 pos){ 47 container_ = container; 48 pos_ = pos; 49 init(); 50 } 51 52 RadarObject::~RadarObject(){} 53 54 void RadarObject::init(){ 42 node_ = node; 43 colour_ = colour; 55 44 next = NULL; 56 45 om = &OverlayManager::getSingleton(); 57 46 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", 58 "Object"+StringConverter::toString(count)));59 panel_->setMaterialName("Orxonox/RedDot");47 "Object"+StringConverter::toString(count))); 48 setColour(colour_); 60 49 panel_->setDimensions(3,3); 61 50 panel_->setMetricsMode(Ogre::GMM_PIXELS); … … 65 54 container_->addChild(panel_); 66 55 } 56 57 RadarObject::~RadarObject(){ 58 // todo: clean up stuff 59 } 60 61 void RadarObject::setColour(int colour){ 62 switch(colour){ 63 case RED: panel_->setMaterialName("Orxonox/RedDot"); break; 64 case YELLOW: panel_->setMaterialName("Orxonox/YellowDot"); break; 65 case GREEN: panel_->setMaterialName("Orxonox/GreenDot"); break; 66 case BLUE: panel_->setMaterialName("Orxonox/BlueDot"); break; 67 case WHITE: panel_->setMaterialName("Orxonox/WhiteDot"); break; 68 default: panel_->setMaterialName("Orxonox/RedDot"); break; 69 } 70 } 71 72 void RadarObject::resetColour(){ 73 setColour(colour_); 74 } 75 76 Vector3 RadarObject::getPosition(){ 77 return node_->getPosition(); 78 } 67 79 } 80 -
code/branches/network/src/orxonox/hud/RadarObject.h
r1411 r1450 29 29 #define _RadarObject_H__ 30 30 31 #include <OgrePrerequisites.h> 32 #include <OgreSceneNode.h> 33 #include <OgrePanelOverlayElement.h> 31 34 #include "OrxonoxPrereqs.h" 32 33 #include <OgrePrerequisites.h>34 #include <OgrePanelOverlayElement.h>35 35 #include "util/Math.h" 36 36 … … 41 41 private: 42 42 Ogre::OverlayManager* om; // our one and only overlay manager 43 void init(); 43 Ogre::SceneNode* node_; // node of object 44 int colour_; 44 45 45 46 public: 46 RadarObject(Ogre::OverlayContainer* container); 47 RadarObject(Ogre::OverlayContainer* container, Vector3 pos); 47 RadarObject(Ogre::OverlayContainer* container, Ogre::SceneNode* node, int colour = 0); 48 48 ~RadarObject(); 49 void setColour(int colour); 50 void resetColour(); 51 Vector3 getPosition(); 49 52 50 53 bool right_; 51 54 int index_; // index number of object 52 Vector3 pos_; // position in space53 55 Ogre::OverlayContainer* container_; 54 56 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot … … 56 58 57 59 static int count; 60 static const int RED = 0; 61 static const int YELLOW = 1; 62 static const int GREEN = 2; 63 static const int BLUE = 3; 64 static const int WHITE = 99; // used if object got nav focus 58 65 }; 59 66 } -
code/branches/network/src/orxonox/hud/RadarOverlayElement.cc
r1410 r1450 89 89 90 90 // set size to fit distance... 91 float d = (ro-> pos_-shipPos_).length();91 float d = (ro->getPosition()-shipPos_).length(); 92 92 if(d<4000) ro->panel_->setDimensions(4,4); 93 93 else if(d<8000) ro->panel_->setDimensions(3,3); … … 113 113 // iterate through all Radar Objects 114 114 while(ro != NULL) { 115 COUT(3) << i++ << ": " << ro-> pos_<< std::endl;115 COUT(3) << i++ << ": " << ro->getPosition() << std::endl; 116 116 ro = ro->next; 117 117 } … … 119 119 120 120 float RadarOverlayElement::calcRadius(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 121 return(acos((dir.dotProduct(obj-> pos_- pos))/122 ((obj-> pos_- pos).length()*dir.length())));121 return(acos((dir.dotProduct(obj->getPosition() - pos))/ 122 ((obj->getPosition() - pos).length()*dir.length()))); 123 123 } 124 124 125 125 float RadarOverlayElement::calcPhi(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 126 126 // project difference vector on our plane... 127 Vector3 proj = Plane(dir, pos).projectVector(obj-> pos_- pos);127 Vector3 proj = Plane(dir, pos).projectVector(obj->getPosition() - pos); 128 128 // ...and find out the angle 129 129 return(acos((orth.dotProduct(proj))/ … … 132 132 133 133 bool RadarOverlayElement::calcRight(Vector3 pos, Vector3 dir, Vector3 orth, RadarObject* obj){ 134 if((dir.crossProduct(orth)).dotProduct(obj-> pos_- pos) > 0)134 if((dir.crossProduct(orth)).dotProduct(obj->getPosition() - pos) > 0) 135 135 return true; 136 136 else return false;
Note: See TracChangeset
for help on using the changeset viewer.