Changeset 1339 for code/branches/hud3
- Timestamp:
- May 20, 2008, 11:51:33 PM (16 years ago)
- Location:
- code/branches/hud3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/bin/levels/sample.oxw
r1309 r1339 14 14 <Skybox src="Orxonox/StarSkyBox" /> 15 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" /> 16 <Model position="1337,0,0" scale="10" mesh="tomato.mesh" yawpitchroll="0,0,0" /> 16 <Model position="1500,0,0" scale="10" mesh="tomato.mesh" yawpitchroll="-50,30,0" rotationAxis="1,0,0" rotationRate="-20"/> 17 <Model position="0,4000,0" scale="10" mesh="tomato.mesh" yawpitchroll="-50,30,0" rotationAxis="1,0,0" rotationRate="-20"/> 17 18 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> 18 19 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> -
code/branches/hud3/src/orxonox/hud/HUD.cc
r1335 r1339 46 46 HUD::HUD(int zoom){ 47 47 om = &Ogre::OverlayManager::getSingleton(); 48 48 49 49 // create Factories 50 50 BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory(); … … 55 55 orxonoxHUD = om->create("Orxonox/HUD"); 56 56 container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container")); 57 // create energy bar 57 // create energy bar 58 58 energyBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyBar")); 59 59 energyBar->show(); … … 67 67 // set up screen-wide container 68 68 container->show(); 69 69 70 70 orxonoxHUD->add2D(container); 71 71 orxonoxHUD->show(); … … 79 79 speedoBar->init(0.01, 0.90, 0.4, 0.04, container); 80 80 radar->init(0.5, 0.9, 0.2, container); 81 radar->addObject(Vector3(1337.0, 0.0, 0.0)); 81 radar->addObject(Vector3(1500.0, 0.0, 0.0)); 82 radar->addObject(Vector3(0.0, 4000.0, 0.0)); 82 83 } 83 84 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1335 r1339 54 54 55 55 void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){ 56 om = &Ogre::OverlayManager::getSingleton(); 56 // some initial data 57 om = &Ogre::OverlayManager::getSingleton(); 57 58 dimRel_ = dimRel; 58 59 leftRel_ = leftRel; 59 60 topRel_ = topRel; 60 61 container_ = container; 62 firstRadarObject_ = NULL; 63 lastRadarObject_ = NULL; 61 64 65 // these have to fit the data in the level 62 66 shipPos_ = Vector3(0.0, 0.0, 0.0); 63 67 initialDir_ = Vector3(1.0, 0.0, 0.0); … … 69 73 setMaterialName("Orxonox/Radar"); 70 74 resize(); 71 75 72 76 container_->addChild(this); 73 77 } … … 89 93 currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_; 90 94 91 if(tomato_ == NULL) return; 92 93 tomato_->radius_ = acos((currentDir_.dotProduct(tomato_->pos_ - shipPos_))/ 94 ((tomato_->pos_ - shipPos_).length()*currentDir_.length())); 95 tomato_->phi_ = acos((currentOrth_.dotProduct(tomato_->pos_ - shipPos_))/ 96 ((tomato_->pos_ - shipPos_).length()*currentOrth_.length())); 97 if((currentDir_.crossProduct(currentOrth_)).dotProduct(tomato_->pos_ - shipPos_) > 0) 98 tomato_->right_ = true; 99 else tomato_->right_=false; 95 RadarObject* ro = firstRadarObject_; 96 // iterate through all RadarObjects 97 while(ro != NULL){ 98 ro->radius_ = calcRadius(ro); 99 ro->phi_ = calcPhi(ro); 100 ro->right_ = calcRight(ro); 101 if (ro->right_){ 102 ro->panel_->setPosition(sin(ro->phi_)*ro->radius_/ 103 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 104 } 105 else { 106 ro->panel_->setPosition(-sin(ro->phi_)*ro->radius_/ 107 3.5*dim_/2+dim_/2+left_-2,-cos(ro->phi_)*ro->radius_/3.5*dim_/2+dim_/2+top_-2); 108 } 109 ro = ro->next; 110 } 111 } 100 112 101 if (tomato_->right_){ 102 tomato_->panel_->setPosition(sin(tomato_->phi_)*tomato_->radius_/ 103 3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2); 113 void RadarOverlayElement::addObject(Vector3 pos){ 114 if(firstRadarObject_ == NULL){ 115 firstRadarObject_ = new RadarObject(container_); 116 firstRadarObject_->pos_ = pos; 117 lastRadarObject_ = firstRadarObject_; 104 118 } 105 else { 106 tomato_->panel_->setPosition(-sin(tomato_->phi_)*tomato_->radius_/ 107 3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2); 119 else{ 120 lastRadarObject_->next = new RadarObject(container_); 121 lastRadarObject_->next->pos_ = pos; 122 lastRadarObject_ = lastRadarObject_->next; 108 123 } 109 }110 111 void RadarOverlayElement::addObject(Vector3 pos){112 tomato_ = new RadarObject(container_);113 tomato_->pos_ = pos;114 124 } 115 125 126 void RadarOverlayElement::listObjects(){ 127 int i = 0; 128 RadarObject* ro = firstRadarObject_; 129 COUT(3) << "List of RadarObjects:\n"; 130 // iterate through all Radar Objects 131 while(ro != NULL) { 132 COUT(3) << i++ << ": " << ro->pos_ << std::endl; 133 ro = ro->next; 134 } 135 } 136 137 float RadarOverlayElement::calcRadius(RadarObject* obj){ 138 return(acos((currentDir_.dotProduct(obj->pos_ - shipPos_))/ 139 ((obj->pos_ - shipPos_).length()*currentDir_.length()))); 140 } 141 142 float RadarOverlayElement::calcPhi(RadarObject* obj){ 143 return(acos((currentOrth_.dotProduct(firstRadarObject_->pos_ - shipPos_))/ 144 ((firstRadarObject_->pos_ - shipPos_).length()*currentOrth_.length()))); 145 } 146 147 bool RadarOverlayElement::calcRight(RadarObject* obj){ 148 if((currentDir_.crossProduct(currentOrth_)).dotProduct(obj->pos_ - shipPos_) > 0) 149 return true; 150 else return false; 151 } 152 116 153 //// RadarObject //// 117 154 118 155 int RadarObject::count = 0; 119 156 120 157 RadarObject::RadarObject(Ogre::OverlayContainer* container){ 121 158 container_ = container; … … 123 160 init(); 124 161 } 125 162 126 163 RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){ 127 164 container_ = container; … … 129 166 init(); 130 167 } 131 168 132 169 RadarObject::~RadarObject(){} 133 170 134 171 void RadarObject::init(){ 172 next = NULL; 135 173 om = &Ogre::OverlayManager::getSingleton(); 136 174 panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", … … 146 184 /* my local clipboard... 147 185 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 148 COUT(3) << tomato_->radius_ << " " << tomato_->phi_ << std::endl;186 COUT(3) << firstRadarObject_->radius_ << " " << firstRadarObject_->phi_ << std::endl; 149 187 COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n"; 150 188 */ -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1335 r1339 46 46 Ogre::OverlayManager* om; // our one and only overlay manager 47 47 void init(); 48 48 49 49 public: 50 50 RadarObject(Ogre::OverlayContainer* container); 51 51 RadarObject(Ogre::OverlayContainer* container, Vector3 pos); 52 52 ~RadarObject(); 53 53 54 bool right_; 54 55 Vector3 pos_; // position in space 55 56 Ogre::Real radius_, phi_; // position on radar 56 bool right_;57 57 Ogre::OverlayContainer* container_; 58 58 Ogre::PanelOverlayElement* panel_; // the panel used to show the dot 59 59 RadarObject* next; // next pointer of linked list 60 60 61 static int count; 61 62 }; … … 67 68 Ogre::OverlayContainer* container_; 68 69 Vector3 initialDir_; // direction of nose 69 Vector3 currentDir_; 70 Vector3 currentDir_; 70 71 Vector3 initialOrth_; // direction of normal 71 72 Vector3 currentOrth_; 72 73 Vector3 shipPos_; // position of ship 73 74 RadarObject* tomato_; 75 74 75 RadarObject* firstRadarObject_; // start of linked list 76 RadarObject* lastRadarObject_; // end of linked list 77 76 78 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 77 79 int left_, top_, dim_; // absolute position/dimension … … 82 84 ~RadarOverlayElement(); 83 85 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 84 void resize(); 86 void resize(); 85 87 void update(); 86 88 void addObject(Vector3 pos); 89 void listObjects(); 90 float calcRadius(RadarObject* obj); 91 float calcPhi(RadarObject* obj); 92 bool calcRight(RadarObject* obj); 87 93 }; 88 94 } -
code/branches/hud3/src/orxonox/objects/SpaceShip.cc
r1315 r1339 283 283 this->camNode_ = this->getNode()->createChildSceneNode(camName_); 284 284 COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl; 285 this->camNode_->setPosition(/*this->getNode()->getPosition() +*/ Vector3(-40,0, 0));285 this->camNode_->setPosition(/*this->getNode()->getPosition() +*/ Vector3(-40,0,5)); 286 286 COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl; 287 287 /*
Note: See TracChangeset
for help on using the changeset viewer.