Changeset 1218 for code/branches/hud2/src/orxonox/hud
- Timestamp:
- May 2, 2008, 10:24:41 PM (17 years ago)
- Location:
- code/branches/hud2/src/orxonox/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc
r1099 r1218 28 28 #include <OgreOverlayManager.h> 29 29 #include <OgreOverlayElement.h> 30 #include <OgreTextAreaOverlayElement.h>31 30 #include <OgreStringConverter.h> 31 #include <math.h> 32 32 #include <string.h> 33 33 34 #include "Radar .h"34 #include "RadarOverlayElement.h" 35 35 36 36 … … 39 39 using namespace Ogre; 40 40 41 RadarObject::RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z){ 42 name_ = name; 43 x = x_; 44 y = y_; 45 z = z_; 41 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){} 42 43 RadarOverlayElement::~RadarOverlayElement(){} 44 45 void RadarOverlayElement::initialise(){ 46 PanelOverlayElement::initialise(); 46 47 } 47 48 RadarObject::~RadarObject(void){} 48 49 void RadarOverlayElement::initRadarOverlayElement(){ 50 int dirX, dirY, dirZ; //flying direction 51 int ortX, ortY, ortZ; //orthogonal direction 52 int dX, dY, dZ; //distance between main ship and the object 53 int vecX, vecY, vecZ; //vector product dir X ort 54 double alpha; //defines the radius in the radar 55 double beta; //defines the angle in the radar 56 bool right; //checks whether the object is on the right side (since cos is not bijective) 49 57 50 void RadarObject::reset(Ogre::Real x, Ogre::Real y, Ogre::Real z){ 51 x = x_; 52 y = y_; 53 z = z_; 54 } 55 56 57 Radar::Radar(){ 58 number = 0; 58 dirX = 1; 59 dirY = 0; 60 dirZ = 0; 59 61 60 61 62 63 64 65 66 67 68 69 70 71 72 62 ortX = 0; 63 ortY = 0; 64 ortZ = 1; 65 66 dX = 2; 67 dY = 0; 68 dZ = 0; 69 70 alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))+sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2)))); 71 beta = acos((ortX*X+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))+sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2)))); 72 vecX = dirY*ortZ - dirZ*ortY; 73 vecY = dirZ*ortX - dirX*ortZ; 74 vecZ = dirX*ortY - dirY*ortX; 75 76 if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;} 77 else right=false; 73 78 74 79 -
code/branches/hud2/src/orxonox/hud/RadarOverlayElement.h
r1099 r1218 32 32 #include <string.h> 33 33 #include <OgreOverlayElement.h> 34 #include <OgreTextAreaOverlayElement.h>35 34 #include <OgrePrerequisites.h> 36 35 #include "../OrxonoxPrereqs.h" … … 39 38 { 40 39 41 class _OrxonoxExport RadarO bject40 class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement 42 41 { 43 42 private: 44 int name_; 45 Ogre::Real x_; 46 Ogre::Real y_; 47 Ogre::Real z_; 48 public: 49 RadarObject(int name, Ogre::Real x, Ogre::Real y, Ogre::Real z); 50 ~RadarObject(); 51 void reset(Ogre::Real x, Ogre::Real y, Ogre::Real z); 52 inline Ogre::Real getX(){return x_;} 53 inline Ogre::Real getY(){return y_;} 54 inline Ogre::Real getZ(){return z_;} 55 inline int getName(){return name_;} 56 }; 57 58 59 class _OrxonoxExport Radar 60 { 61 private: 62 int number; 43 int number_; 63 44 64 45 65 46 public: 66 Radar(); 67 ~Radar(); 68 69 70 47 48 RadarOverlayElement(const Ogre::String& name); 49 virtual ~RadarOverlayElement(); 50 virtual void initialise(); 71 51 72 52
Note: See TracChangeset
for help on using the changeset viewer.