Changeset 1308 for code/branches/hud3
- Timestamp:
- May 16, 2008, 11:27:09 AM (17 years ago)
- Location:
- code/branches/hud3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/bin/levels/sample.oxw
r1290 r1308 1 <!--audio> 1 <!-- 2 <audio> 2 3 <ambient> 3 4 <ogg src="allgorythm-lift_up" /> … … 7 8 <ogg src="tha_silent_partner_-_void" /> 8 9 </ambient> 9 </audio--> 10 </audio> 11 --> 10 12 11 13 <!--Ambient colourvalue="1,1,1" /--> 12 14 <Skybox src="Orxonox/StarSkyBox" /> 13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll=" -90,-90,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />15 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> 14 16 15 17 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> -
code/branches/hud3/src/orxonox/hud/HUD.h
r1302 r1308 44 44 namespace orxonox 45 45 { 46 class _OrxonoxExport HUD : Tickable46 class _OrxonoxExport HUD : public Tickable 47 47 { 48 48 private: -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1302 r1308 60 60 left_ = left; 61 61 top_ = top; 62 count_ = 0;62 count_ = 100; 63 63 container_ = container; 64 64 65 65 shipPos_ = Vector3(0.0, 0.0, 0.0); 66 targetPos_ = Vector3(42.0, 42.0, 0.0);67 initialDir_ = Vector3( 0.0, 0.0, 1.0);66 targetPos_ = Vector3(42.0, 0.0, 0.0); 67 initialDir_ = Vector3(1.0, 0.0, 0.0); 68 68 currentDir_ = initialDir_; 69 initialOrth_ = Vector3(0.0, 1.0, 0.0);69 initialOrth_ = Vector3(0.0, 0.0, 1.0); 70 70 currentOrth_ = initialOrth_; 71 72 alpha_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 73 beta_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 74 vec_ = currentDir_.crossProduct(currentOrth_); 75 76 if(vec_.dotProduct(targetPos_ - shipPos_) > 0) 77 right_ = true; 78 else 79 right_=false; 80 71 81 72 setMetricsMode(Ogre::GMM_PIXELS); 82 73 setPosition(left,top); … … 88 79 point->show(); 89 80 container->addChild(point); 81 point->setMaterialName("Orxonox/RedPoint"); 82 point->setDimensions(5,5); 83 point->setMetricsMode(Ogre::GMM_PIXELS); 90 84 91 if (right_){92 point->setPosition(sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);93 point->setMaterialName("Orxonox/RedPoint");94 point->setDimensions(5,5);95 point->setMetricsMode(Ogre::GMM_PIXELS);96 }97 98 else {99 point->setPosition(-sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);100 point->setMaterialName("Orxonox/RedPoint");101 point->setDimensions(5,5);102 point->setMetricsMode(Ogre::GMM_PIXELS);103 }104 85 } 105 86 … … 114 95 115 96 void RadarOverlayElement::update() { 97 if(count_++ >= 100) { // for testing purposes 98 count_ = 0; 99 COUT(3) << "pos: " << shipPos_ << std::endl; 100 COUT(3) << "dir: " << currentDir_ << std::endl; 101 COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl; 102 } 116 103 shipPos_ = SpaceShip::instance_s->getPosition(); 117 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 104 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 105 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 106 107 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 108 phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 109 vec_ = currentDir_.crossProduct(currentOrth_); 110 if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true; 111 else right_=false; 112 113 if (right_){ 114 point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 115 } 116 else { 117 point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 118 } 118 119 } 119 120 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~
r1295 r1308 26 26 */ 27 27 28 /* local coordinate system of space ship :28 /* local coordinate system of space ship at the beginning: 29 29 30 30 y … … 33 33 | / 34 34 |/ 35 35 x +------O 36 36 */ 37 37 … … 42 42 #include "RadarOverlayElement.h" 43 43 44 45 44 namespace orxonox 46 45 { 47 using namespace Ogre;46 using namespace Ogre; 48 47 49 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 50 initialDir = Vector3(0.0, 0.0, 1.0); 51 } 48 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 49 } 52 50 53 RadarOverlayElement::~RadarOverlayElement(){} 51 RadarOverlayElement::~RadarOverlayElement(){ 52 } 54 53 55 void RadarOverlayElement::initialise(){ 56 PanelOverlayElement::initialise(); 57 } 58 59 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){ 54 void RadarOverlayElement::initialise(){ 55 PanelOverlayElement::initialise(); 56 } 60 57 61 dirX_ = 0; // direction of travel 62 dirY_ = 0; 63 dirZ_ = 1; 64 65 ortX_ = 0; // normal of ship 66 ortY_ = 1; 67 ortZ_ = 0; 68 69 dX_ = 37; 70 dY_ = 0; 71 dZ_ = 0; 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; 81 82 setMetricsMode(Ogre::GMM_PIXELS); 83 setPosition(left,top); 84 setDimensions(dim,dim); 85 setMaterialName("Orxonox/Radar"); 86 87 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 58 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){ 59 dim_ = dim; 60 left_ = left; 61 top_ = top; 62 count_ = 100; 63 container_ = container; 88 64 89 PanelOverlayElement* point = static_cast<PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "point")); 90 point->show(); 91 92 container->addChild(point); 93 94 if (right_){ 95 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 point->setMaterialName("Orxonox/RedPoint"); 97 point->setDimensions(5,5); 98 point->setMetricsMode(Ogre::GMM_PIXELS); 65 shipPos_ = Vector3(0.0, 0.0, 0.0); 66 targetPos_ = Vector3(42.0, 0.0, 0.0); 67 initialDir_ = Vector3(1.0, 0.0, 0.0); 68 currentDir_ = initialDir_; 69 initialOrth_ = Vector3(0.0, 0.0, 1.0); 70 currentOrth_ = initialOrth_; 71 72 setMetricsMode(Ogre::GMM_PIXELS); 73 setPosition(left,top); 74 setDimensions(dim_,dim_); 75 setMaterialName("Orxonox/Radar"); 76 77 om = &Ogre::OverlayManager::getSingleton(); 78 point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point")); 79 point->show(); 80 container->addChild(point); 81 point->setMaterialName("Orxonox/RedPoint"); 82 point->setDimensions(5,5); 83 point->setMetricsMode(Ogre::GMM_PIXELS); 84 99 85 } 100 101 else { 102 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 point->setMaterialName("Orxonox/RedPoint"); 104 point->setDimensions(5,5); 105 point->setMetricsMode(Ogre::GMM_PIXELS); 86 87 // void RadarOverlayElement::setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ){ 88 // dirX_=dirX; 89 // dirY_=dirY; 90 // dirZ_=dirZ; 91 // ortX_=ortX; 92 // ortY_=ortY; 93 // ortZ_=ortZ; 94 // } 95 96 void RadarOverlayElement::update() { 97 if(count_++ >= 100) { // for testing purposes 98 count_ = 0; 99 COUT(3) << "pos: " << shipPos_ << std::endl; 100 COUT(3) << "dir: " << currentDir_ << std::endl; 101 COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl; 102 } 103 shipPos_ = SpaceShip::instance_s->getPosition(); 104 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... 105 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 106 107 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length())); 108 phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length())); 109 vec_ = currentDir_.crossProduct(currentOrth_); 110 if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true; 111 else right_=false; 112 113 if (right_){ 114 point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 115 } 116 else { 117 point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2); 118 } 106 119 } 107 } 108 109 void RadarOverlayElement::setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ){ 110 dirX_=dirX; 111 dirY_=dirY; 112 dirZ_=dirZ; 113 ortX_=ortX; 114 ortY_=ortY; 115 ortZ_=ortZ; 116 } 117 118 119 120 120 121 } 121 122 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1302 r1308 56 56 Vector3 shipPos_; //position of ship 57 57 Vector3 vec_; //vector product dir X ort 58 double alpha_; //defines the radius in the radar59 double beta_; //defines the angle in the radar58 double radius_; //defines the radius in the radar 59 double phi_; //defines the angle in the radar 60 60 float left_, top_; 61 61 bool right_; //checks whether the object is on the right side (since cos is not bijective) -
code/branches/hud3/src/orxonox/objects/SpaceShip.cc
r1295 r1308 432 432 433 433 std::string SpaceShip::whereAmI() { 434 return getConvertedValue< int, std::string>(SpaceShip::instance_s->getPosition().x)435 + " " + getConvertedValue< int, std::string>(SpaceShip::instance_s->getPosition().y)436 + " " + getConvertedValue< int, std::string>(SpaceShip::instance_s->getPosition().z);434 return getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().x) 435 + " " + getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().y) 436 + " " + getConvertedValue<float, std::string>(SpaceShip::instance_s->getPosition().z); 437 437 } 438 438
Note: See TracChangeset
for help on using the changeset viewer.