- Timestamp:
- May 15, 2008, 3:49:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1283 r1286 50 50 51 51 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){ 52 53 52 54 53 int dirX, dirY, dirZ; //flying direction 54 int ortX, ortY, ortZ; //orthogonal direction 55 int dX, dY, dZ; //distance between main ship and the object 56 int vecX, vecY, vecZ; //vector product dir X ort 57 double alpha; //defines the radius in the radar 58 double beta; //defines the angle in the radar 59 bool right; //checks whether the object is on the right side (since cos is not bijective) 55 dirX_ = 1; 56 dirY_ = 0; 57 dirZ_ = 0; 60 58 61 dirX = 1;62 dirY= 0;63 dirZ = 0;59 ortX_ = 0; 60 ortY_ = 0; 61 ortZ_ = 1; 64 62 65 ortX= 0;66 ortY= 0;67 ortZ =1;63 dX_ = 0; 64 dY_ = 0; 65 dZ_ = -1; 68 66 69 dX = 0; 70 dY = 2; 71 dZ = 0; 67 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)))); 68 beta_ = acos((ortX_*dX_+ortY_*dY_+ortZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(ortX_,2)+pow(ortY_,2)+pow(ortZ_,2)))); 69 vecX_ = dirY_*ortZ_ - dirZ_*ortY_; 70 vecY_ = dirZ_*ortX_ - dirX_*ortZ_; 71 vecZ_ = dirX_*ortY_ - dirY_*ortX_; 72 72 73 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)))); 74 beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2)))); 75 vecX = dirY*ortZ - dirZ*ortY; 76 vecY = dirZ*ortX - dirX*ortZ; 77 vecZ = dirX*ortY - dirY*ortX; 78 79 if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;} 80 else right=false; 73 if((vecX_*dX_+vecY_*dY_+vecZ_*dZ_)>0){right_=true;} 74 else right_=false; 81 75 82 76 setMetricsMode(Ogre::GMM_PIXELS); 83 77 setPosition(left,top); 84 setDimensions(dim -15,dim-20);78 setDimensions(dim,dim); 85 79 setMaterialName("Orxonox/Radar"); 86 80 … … 92 86 container->addChild(point); 93 87 94 if (right ){95 point->setPosition(sin(beta )*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);88 if (right_){ 89 point->setPosition(sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2); 96 90 point->setMaterialName("Orxonox/RedPoint"); 97 91 point->setDimensions(5,5); … … 100 94 101 95 else { 102 point->setPosition(-sin(beta )*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);96 point->setPosition(-sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2); 103 97 point->setMaterialName("Orxonox/RedPoint"); 104 98 point->setDimensions(5,5); 105 99 point->setMetricsMode(Ogre::GMM_PIXELS); 106 100 } 107 108 109 110 111 } 101 } 102 103 void RadarOverlayElement::setMainShipPosition(int dirX, dirY, dirZ, ortX, ortY, ortZ){ 104 dirX_=dirX; 105 dirY_=dirY; 106 dirZ_=dirZ; 107 ortX_=ortX; 108 ortY_=ortY; 109 ortZ_=ortZ; 110 } 111 112 113 112 114 } 113 115
Note: See TracChangeset
for help on using the changeset viewer.