Changeset 1399 for code/trunk/src/orxonox
- Timestamp:
- May 23, 2008, 10:27:52 PM (17 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/hud/HUD.cc
r1394 r1399 64 64 fpsText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "fpsText")); 65 65 fpsText->show(); 66 fpsText->setMetricsMode(Ogre::GMM_ RELATIVE);67 fpsText->setDimensions(0. 3, 0.3);68 fpsText->setPosition( 0.9, 0.02);66 fpsText->setMetricsMode(Ogre::GMM_PIXELS); 67 fpsText->setDimensions(0.001, 0.001); 68 fpsText->setPosition(10, 10); 69 69 fpsText->setFontName("Console"); 70 fpsText->setCharHeight(20); 70 71 fpsText->setCaption("init"); 71 72 -
code/trunk/src/orxonox/hud/Navigation.cc
r1396 r1399 27 27 28 28 #include <OgreOverlayManager.h> 29 #include <OgrePanelOverlayElement.h> 30 #include <OgreTextAreaOverlayElement.h> 29 31 #include <OgreStringConverter.h> 32 #include <OgreMatrix4.h> 30 33 #include <GraphicsEngine.h> 34 #include "core/Iterator.h" 31 35 #include "objects/SpaceShip.h" 36 #include "objects/CameraHandler.h" 32 37 #include "HUD.h" 33 38 #include "Navigation.h" … … 51 56 void Navigation::init(){ 52 57 om = &OverlayManager::getSingleton(); 58 // for (Iterator<Model> it = ObjectList<Model>::begin(); it; ++it) 59 // { 60 // if(it->getPosition() == Vector(2000.0, 1000.0, 1000.0)){ 61 // COUT(3) << "TARGET FOUND\n"; 62 // 63 // 64 // } 65 cam_ = NULL; 53 66 // create nav text 54 67 navText_ = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "navText")); 55 68 navText_->show(); 56 navText_->setMetricsMode(Ogre::GMM_ RELATIVE);57 navText_->setDimensions(0. 3, 0.3);69 navText_->setMetricsMode(Ogre::GMM_PIXELS); 70 navText_->setDimensions(0.001, 0.001); 58 71 navText_->setPosition(0.02, 0.02); 59 72 navText_->setFontName("Console"); 73 navText_->setCharHeight(20); 60 74 navText_->setCaption(""); 61 75 container_->addChild(navText_); … … 65 79 navMarker_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "NavMarker")); 66 80 navMarker_->setMetricsMode(GMM_PIXELS); 67 navMarker_->setMaterialName("Orxonox/NavMarker");68 navMarker_->setDimensions(16,16);69 81 navMarker_->hide(); 82 navText_->hide(); 70 83 container_->addChild(navMarker_); 71 84 } … … 73 86 void Navigation::update(){ 74 87 if(focus_ == NULL) return; 75 shipPos_ = SpaceShip:: instance_s->getPosition();88 shipPos_ = SpaceShip::getLocalShip()->getPosition(); 76 89 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 77 90 windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 78 // from the angle we find out where to draw the marker 79 // and which of the four arrows to take 80 float r1 = atan((float)(windowW_)/(float)(windowH_)); 81 float phi = focus_->phi_; 82 if(focus_->right_){ 83 if(phi<r1){ 84 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0); 85 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 91 updateMarker(); 92 } 93 94 void Navigation::updateMarker(){ 95 // set text 96 int dist = (float)(getDist2Focus()/100); 97 navText_->setCaption(Ogre::StringConverter::toString(dist)); 98 99 if(cam_ == NULL) cam_ = SpaceShip::getLocalShip()->getCamera()->cam_; 100 Vector3 pos = focus_->pos_; 101 // transform to screen coordinates 102 pos = cam_->getProjectionMatrix()*cam_->getViewMatrix()*pos; 103 float xPosRel = 0.5*pos.x+0.5; 104 float yPosRel = 1-(0.5*pos.y+0.5); 105 int xPos = xPosRel*windowW_; 106 int yPos = yPosRel*windowH_; 107 // is object in view? 108 bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1); 109 // if object is behind us, it is out of view anyway: 110 if(!outOfView && focus_->radius_>3.14/2) outOfView = true; 111 112 if(outOfView){ 113 // NO! 114 navMarker_->setMaterialName("Orxonox/NavArrows"); 115 navMarker_->setDimensions(16,16); 116 float phiUpRight = atan((float)(windowW_)/(float)(windowH_)); 117 // from the angle we find out where to draw the marker 118 // and which of the four arrows to take 119 float phi = focus_->phi_; 120 if(focus_->right_){ 121 if(phi<phiUpRight){ 122 // arrow up 123 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, 0); 124 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 125 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 126 navText_->setTop(navMarker_->getHeight()); 127 } 128 else if(phi>3.14-phiUpRight){ 129 // arrow down 130 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16); 131 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 132 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 133 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 134 } 135 else { 136 // arrow right 137 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 138 navMarker_->setUV(0.5, 0.5, 1.0, 1.0); 139 navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth()); 140 navText_->setTop(navMarker_->getTop()+navMarker_->getHeight()); 141 } 86 142 } 87 else if(phi>3.14-r1){ 88 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, windowH_-16); 89 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 143 else{ 144 if(phi<phiUpRight) { 145 // arrow up 146 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0); 147 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 148 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 149 navText_->setTop(navMarker_->getHeight()); 150 } 151 else if(phi>3.14-phiUpRight) { 152 // arrow down 153 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16); 154 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 155 navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth()); 156 navText_->setTop(navMarker_->getTop()-navMarker_->getHeight()); 157 } 158 else { 159 // arrow left 160 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 161 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); 162 navText_->setLeft(navMarker_->getWidth()); 163 navText_->setTop(navMarker_->getTop()+navMarker_->getHeight()); 164 } 90 165 } 91 else {92 navMarker_->setPosition(windowW_-16, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2);93 navMarker_->setUV(0.5, 0.5, 1.0, 1.0);94 }95 166 } 96 167 else{ 97 if(phi<r1) { 98 navMarker_->setPosition(-tan(phi)*windowH_/2+windowW_/2, 0); 99 navMarker_->setUV(0.5, 0.0, 1.0, 0.5); 100 } 101 else if(phi>3.14-r1) { 102 navMarker_->setPosition(tan(phi)*windowH_/2+windowW_/2, windowH_-16); 103 navMarker_->setUV(0.0, 0.5, 0.5, 1.0); 104 } 105 else { 106 navMarker_->setPosition(0, -tan((3.14-2*phi)/2)*windowW_/2+windowH_/2); 107 navMarker_->setUV(0.0, 0.0, 0.5, 0.5); 108 } 109 } 110 111 int d = (float)(getDist2Focus()/10); 112 if(d) navText_->setCaption("Distance: " + Ogre::StringConverter::toString(d)); 113 else navText_->setCaption(""); 114 } 168 // YES! 169 navMarker_->setMaterialName("Orxonox/NavTDC"); 170 navMarker_->setDimensions(24,24); 171 navMarker_->setUV(0.0,0.0,1.0,1.0); 172 navMarker_->setPosition(xPos-navMarker_->getWidth()/2, yPos-navMarker_->getHeight()/2); 173 navText_->setPosition(xPos+navMarker_->getWidth()/2, yPos+navMarker_->getHeight()/2); 174 } 175 } 115 176 116 177 void Navigation::cycleFocus(){ … … 120 181 else{ 121 182 focus_->panel_->setMaterialName("Orxonox/RedDot"); 122 focus_ = focus_->next;183 if(focus_ != NULL) focus_ = focus_->next; 123 184 } 124 185 125 186 if(focus_ == NULL){ 126 187 navMarker_->hide(); 188 navText_->hide(); 127 189 } 128 190 else{ 129 191 navMarker_->show(); 192 navText_->show(); 130 193 focus_->panel_->setMaterialName("Orxonox/WhiteDot"); 131 194 } -
code/trunk/src/orxonox/hud/Navigation.h
r1395 r1399 20 20 * 21 21 * Author: 22 * Yuning Chai22 * Felix Schulthess 23 23 * Co-authors: 24 24 * ... … … 30 30 31 31 #include <OgrePrerequisites.h> 32 #include <OgrePanelOverlayElement.h>33 #include <OgreTextAreaOverlayElement.h>34 32 #include "../OrxonoxPrereqs.h" 35 33 #include "util/Math.h" … … 44 42 Ogre::OverlayContainer* container_; 45 43 Ogre::PanelOverlayElement* navMarker_; // the panel used to show the arrow 46 Ogre::TextAreaOverlayElement* navText_; // displaying distance... 44 Ogre::TextAreaOverlayElement* navText_; // displaying distance 45 Ogre::MovableObject* movo_; 46 Ogre::Camera* cam_; 47 47 Vector3 shipPos_; // position of ship 48 48 int windowW_, windowH_; 49 49 50 50 void init(); 51 void updateMarker(); 51 52 52 53 public: -
code/trunk/src/orxonox/hud/RadarOverlayElement.cc
r1393 r1399 113 113 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 114 114 } 115 listObjects();116 115 ro = ro->next; 117 116 } -
code/trunk/src/orxonox/objects/Camera.h
r1293 r1399 50 50 void setTargetNode(Ogre::SceneNode* obj); 51 51 52 Ogre::Camera* cam_; 53 52 54 void tick(float dt); 53 55 void update(); … … 63 65 Ogre::SceneNode* cameraNode_; 64 66 Ogre::Vector3 oldPos; 65 Ogre::Camera* cam_;66 67 bool bHasFocus_; 67 68 }; -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1362 r1399 69 69 return NULL; 70 70 } 71 71 72 72 SpaceShip::SpaceShip() : 73 73 //testvector_(0,0,0), … … 239 239 } 240 240 241 Camera* SpaceShip::getCamera(){ 242 return cam_; 243 } 244 241 245 void SpaceShip::createCamera(){ 242 246 // COUT(4) << "begin camera creation" << std::endl; … … 422 426 if (this->bLMousePressed_ && this->timeToReload_ <= 0) 423 427 { 424 428 425 429 Projectile *p = new Projectile(this); 426 430 427 431 p->setBacksync(true); 428 432 this->timeToReload_ = this->reloadTime_; -
code/trunk/src/orxonox/objects/SpaceShip.h
r1362 r1399 44 44 { 45 45 public: 46 46 47 47 static SpaceShip *getLocalShip(); 48 48 49 49 SpaceShip(); 50 50 ~SpaceShip(); … … 66 66 67 67 void getFocus(); 68 Camera* getCamera(); 68 69 static SpaceShip* instance_s; 69 70 static Vector3 getSPosition();
Note: See TracChangeset
for help on using the changeset viewer.