Changeset 9904 for code/branches/presentationHS13
- Timestamp:
- Dec 16, 2013, 2:00:00 PM (11 years ago)
- Location:
- code/branches/presentationHS13
- Files:
-
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS13
- Property svn:mergeinfo changed
/code/branches/radarDreiD (added) merged: 9690,9719,9737,9740,9742,9749,9770-9771,9779,9787,9792,9796,9818,9824,9835,9847,9852,9877,9881-9882,9893
- Property svn:mergeinfo changed
-
code/branches/presentationHS13/data/gui/scripts/MiscConfigMenu.lua
r9016 r9904 38 38 table.insert(P.commandList, "HUDNavigation MarkerLimit_") 39 39 table.insert(P.commandList, "HUDNavigation showDistance") 40 table.insert(P.commandList, "HUDRadar RadarMode_") 40 41 41 42 P.nameList = {} … … 60 61 table.insert(P.nameList, "Marker Limit") 61 62 table.insert(P.nameList, "Show Distance next to cursor") 63 table.insert(P.nameList, "Set Radar on 3D mode") 62 64 63 65 P.linesList = {} -
code/branches/presentationHS13/data/overlays/HUD.oxo
r9526 r9904 68 68 <HUDRadar 69 69 name = "Radar" 70 background = "Orxonox/ Radar"70 background = "Orxonox/radar" 71 71 correctAspect = true 72 72 size = "0.17, 0.17" -
code/branches/presentationHS13/data/overlays/HUDTemplates3.oxo
r9526 r9904 108 108 /> 109 109 110 <HUDRadar 111 name = "Radar" 112 background = "Orxonox/Radar" 113 correctaspect = true 114 size = "0.17, 0.17" 115 position = "1.0, 1.0" 116 pickpoint = "1.0, 1.0" 117 rotation = 0 118 sensitivity = 1.0 119 halfDotSizeDistance = 3000 120 maximumDotSize = 0.1 110 <HUDRadar 111 name = "Radar" 112 background = "Orxonox/Radar3D" 113 material2D = "Orxonox/Radar" 114 material3DMiddle = "Orxonox/Radar3D" 115 material3DFront = "Orxonox/Radar3DFront" 116 material3DBack = "Orxonox/Radar3DBack" 117 correctaspect = true 118 size = "0.17, 0.17" 119 position = "1.0, 1.0" 120 pickpoint = "1.0, 1.0" 121 rotation = 0 122 sensitivity = 1.0 123 halfDotSizeDistance = 3000 124 detectionLimit = 10000.0 125 maximumDotSize = 0.1 126 maximumDotSize3D = 0.06 127 mapAngle3D = 0.6435011 121 128 /> 122 129 123 130 <HUDTimer 124 131 name = "Timer" -
code/branches/presentationHS13/src/libraries/util/Math.cc
r8400 r9904 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Wolfgang Roenninger 26 26 * 27 27 */ … … 147 147 148 148 /** 149 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0 ° = 0, 180°= 1).149 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0� = 0, 180� = 1). 150 150 @param myposition My position 151 151 @param mydirection My viewing direction … … 189 189 else 190 190 return orxonox::Vector2( -sin_value * radius, cos_value * radius); 191 } 192 193 194 /** 195 @brief Gets the 2D project vector for the 3D Radar . 196 @param myposition My position 197 @param mydirection My viewing direction 198 @param myorthonormal My orthonormalvector (pointing upwards through my head) 199 @param otherposition The position of the other object 200 @param mapangle The angle between line of sight on screen and the 3Dmap-x/z-plain in radian 201 @param detectionlimit The limit in which objects are shown on the map 202 @return The viewing direction 203 */ 204 orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit) 205 { 206 // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right 207 orxonox::Vector3 distance = otherposition - myposition; // get vector from Ship to object 208 209 // new coordinate system: x_axsis: mydirection (points front) 210 // y_axsis: myorthonormal (points up) 211 // z_axsis: myside (points right) 212 213 orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get 3. base vector 214 215 distance = 4*distance / detectionlimit; // shrink vector on map 216 if(distance.length() > 1.0f) // if object would wander outside of the map 217 { 218 distance = distance / distance.length(); 219 } 220 221 // perform a coordinate transformation to get distance in relation of the position of the ship 222 orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside); 223 224 // calculate 2D vector on the map (with angle between x/z - plain and line of sight) 225 float xcoordinate = distanceShip.z; // z; cause x direction on screen is to the right side 226 float ycoordinate = distanceShip.x*sin(mapangle)+distanceShip.y*cos(mapangle); 227 return orxonox::Vector2(xcoordinate , ycoordinate); 228 } 229 230 /** 231 @brief Gets if a object is over the x/z - plain on map 232 @param myposition My position 233 @param mydirection My viewing direction 234 @param myorthonormal My orthonormalvector (pointing upwards through my head) 235 @param otherposition The position of the other object 236 @param mapangle The angle you look on the 3Dmap in radian 237 @return If distancevector to the other object has a positive y-coordinate 238 239 Examples: 240 Returns true if object is over x/z - plain 241 Returns false if object is below x/z -plain 242 */ 243 bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle) 244 { 245 // Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right 246 orxonox::Vector3 distance = otherposition - myposition; 247 248 // new coordinate system: x_axsis: mydirection (points front) 249 // y_axsis: myorthonormal (points up) 250 // z_axsis: myside (points right) 251 252 orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector from Ship to object 253 254 255 // perform a coordinate transformation to get distance in relation of the position of the ship 256 orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside); 257 258 if(distanceShip.y >= 0) 259 return true; 260 else 261 return false; 262 } 263 264 /** 265 @brief A value between 0 and 10, in order how other object is in front or in back 266 @param myposition My position 267 @param mydirection My viewing direction 268 @param myorthonormal My orthonormalvector (pointing upwards through my head) 269 @param otherposition The position of the other object 270 @param detectionlimit The limit in which objects are shown on the map 271 @return value between 0 and 100 272 */ 273 int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit) 274 { 275 orxonox::Vector3 distance = otherposition - myposition; // get vector from Ship to object 276 orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector to the side 277 278 distance = 4*distance / detectionlimit; // shrink vector on map 279 if(distance.length() > 1.0f) // if object would wander outside of the map 280 { 281 distance = distance / distance.length(); 282 } 283 284 // perform a coordinate transformation to get distance in relation of the position of the ship 285 orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside); 286 287 return (int) 50 - 100*distanceShip.x; 288 } 289 290 291 /** 292 @brief Gets the new vector after a coordinate transformation 293 @param distance Vector which will be transformed 294 @param mydirection New x basevector 295 @param myorthonormal New y basevector 296 @param otherposition New z basevector 297 @return direction in the new coordinates 298 299 x is vector in old coordinates 300 y is vector in old coordinates 301 T is transform matrix with: 302 T = (t1 , t2 , t3) 303 t1 = mydirection 304 t2 = myorthonormal 305 t3 = myside 306 307 y = T^(-1)*x 308 */ 309 orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside) 310 { 311 // inverse of the transform matrix 312 float determinant = +mydirection.x * (myorthonormal.y*myside.z - myside.y*myorthonormal.z) 313 -mydirection.y * (myorthonormal.x*myside.z - myorthonormal.z*myside.x) 314 +mydirection.z * (myorthonormal.x*myside.y - myorthonormal.y*myside.x); 315 float invdet = 1/determinant; 316 317 // transform matrix 318 orxonox::Vector3 xinvtransform; 319 orxonox::Vector3 yinvtransform; 320 orxonox::Vector3 zinvtransform; 321 322 xinvtransform.x = (myorthonormal.y * myside.z - myside.y * myorthonormal.z)*invdet; 323 xinvtransform.y = (mydirection.z * myside.y - mydirection.y * myside.z )*invdet; 324 xinvtransform.z = (mydirection.y * myorthonormal.z - mydirection.z * myorthonormal.y)*invdet; 325 yinvtransform.x = (myorthonormal.z * myside.x - myorthonormal.x * myside.z )*invdet; 326 yinvtransform.y = (mydirection.x * myside.z - mydirection.z * myside.x )*invdet; 327 yinvtransform.z = (myorthonormal.x * mydirection.z - mydirection.x * myorthonormal.z)*invdet; 328 zinvtransform.x = (myorthonormal.x * myside.y - myside.x * myorthonormal.y)*invdet; 329 zinvtransform.y = (myside.x * mydirection.y - mydirection.x * myside.y )*invdet; 330 zinvtransform.z = (mydirection.x * myorthonormal.y - myorthonormal.x * mydirection.y )*invdet; 331 332 // coordinate transformation 333 orxonox::Vector3 distanceShip; 334 distanceShip.x = xinvtransform.x * distance.x + yinvtransform.x * distance.y + zinvtransform.x * distance.z; 335 distanceShip.y = xinvtransform.y * distance.x + yinvtransform.y * distance.y + zinvtransform.y * distance.z; 336 distanceShip.z = xinvtransform.z * distance.x + yinvtransform.z * distance.y + zinvtransform.z * distance.z; 337 338 return distanceShip; 191 339 } 192 340 -
code/branches/presentationHS13/src/libraries/util/Math.h
r9550 r9904 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Wolfgang Roenninger 26 26 * 27 27 */ … … 92 92 _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 93 93 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 94 _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit); 95 _UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle); 96 _UtilExport int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit); 97 _UtilExport orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside); 94 98 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity); 95 99 -
code/branches/presentationHS13/src/modules/overlays/hud/HUDNavigation.cc
r9667 r9904 74 74 OrxonoxOverlay(context) 75 75 { 76 RegisterObject(HUDNavigation) 77 ;this->setConfigValues();76 RegisterObject(HUDNavigation); 77 this->setConfigValues(); 78 78 79 79 // Set default values -
code/branches/presentationHS13/src/modules/overlays/hud/HUDRadar.cc
r9667 r9904 25 25 * Co-authors: 26 26 * Reto Grieder 27 * Wolfgang Roenninger 27 28 * 28 29 */ … … 41 42 #include "Scene.h" 42 43 #include "Radar.h" 44 #include "core/config/ConfigValueIncludes.h" 43 45 44 46 namespace orxonox … … 50 52 { 51 53 RegisterObject(HUDRadar); 54 this->setConfigValues(); 52 55 53 56 this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() … … 60 63 this->setHalfDotSizeDistance(3000.0f); 61 64 this->setMaximumDotSize(0.1f); 65 this->setMaximumDotSize3D(0.07f); 62 66 63 67 this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.png"; 64 68 this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png"; 65 69 this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.png"; 66 this->setDetectionLimit( 10000.0f );67 70 this->owner_ = 0; 71 72 this->map3DFront_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 73 .createOverlayElement("Panel", "HUDRadar_mapDreiDFront_" + getUniqueNumberString())); 74 this->map3DFront_->setMaterialName("Orxonox/Radar3DFront"); 75 this->overlay_->add2D(this->map3DFront_); 76 this->map3DFront_->hide(); 77 78 this->map3DBack_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 79 .createOverlayElement("Panel", "HUDRadar_mapDreiDBack_" + getUniqueNumberString())); 80 this->map3DBack_->setMaterialName("Orxonox/Radar3DBack"); 81 this->overlay_->add2D(this->map3DBack_); 82 this->map3DBack_->hide(); 83 68 84 } 69 85 … … 73 89 { 74 90 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 91 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DFront_); 92 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DBack_); 93 75 94 for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin(); 76 95 it != this->radarObjects_.end(); ++it) … … 80 99 } 81 100 } 101 102 103 104 void HUDRadar::setConfigValues() 105 { 106 SetConfigValue(RadarMode_, true); 107 } 82 108 83 109 void HUDRadar::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 88 114 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode); 89 115 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlelement, mode); 116 XMLPortParam(HUDRadar, "maximumDotSize3D", setMaximumDotSize3D, getMaximumDotSize3D, xmlelement, mode); 117 XMLPortParam(HUDRadar, "material2D", set2DMaterial, get2DMaterial, xmlelement, mode); 118 XMLPortParam(HUDRadar, "material3DMiddle", set3DMaterial, get3DMaterial, xmlelement, mode); 119 XMLPortParam(HUDRadar, "material3DFront", set3DMaterialFront, get3DMaterialFront, xmlelement, mode); 120 XMLPortParam(HUDRadar, "material3DBack", set3DMaterialBack, get3DMaterialBack, xmlelement, mode); 121 XMLPortParam(HUDRadar, "mapAngle3D", setMapAngle, getMapAngle, xmlelement, mode); 122 XMLPortParam(HUDRadar, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode); 90 123 } 91 124 … … 152 185 // update the distances for all objects 153 186 std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it; 187 188 189 if(RadarMode_) 190 { 191 this->setBackgroundMaterial(material3D_); 192 this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 250); // it seems that the ZOrder of overlayelements is 100 times the ZOrder of the overlay 193 this->map3DBack_->_notifyZOrder(this->overlay_->getZOrder() * 100 - 250); // 250 a little bit buffer so that the two shels are displayed all in the front / in the back 194 this->map3DFront_->show(); 195 this->map3DBack_->show(); 196 } 197 else 198 { 199 this->setBackgroundMaterial(material2D_); 200 this->map3DFront_->hide(); 201 this->map3DBack_->hide(); 202 } 203 154 204 for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it ) 155 205 { … … 165 215 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 166 216 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 167 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 217 218 float size; 219 if(RadarMode_) 220 size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 221 else 222 size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale(); 168 223 it->second->setDimensions(size, size); 169 224 170 225 // calc position on radar... 171 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 226 Vector2 coord; 227 228 if(RadarMode_) 229 { 230 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), 0.6435011, detectionLimit_); 231 232 // set zOrder on screen 233 bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), this->mapAngle_); 234 235 int zOrder = determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_); 236 if(overXZPlain == false /*&& (it->second->getZOrder() > 100 * this->overlay_->getZOrder())*/) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay 237 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + zOrder); 238 if(overXZPlain == true /*&& (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())*/) 239 it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + zOrder); 240 } 241 else 242 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 243 172 244 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture 173 245 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 246 174 247 if( distance < detectionLimit_ || detectionLimit_ < 0 ) 175 248 it->second->show(); … … 182 255 this->marker_->setDimensions(size * 1.5f, size * 1.5f); 183 256 this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f); 257 if(RadarMode_) 258 this->marker_->_notifyZOrder(it->second->getZOrder() -1); 184 259 this->marker_->show(); 185 260 } -
code/branches/presentationHS13/src/modules/overlays/hud/HUDRadar.h
r9667 r9904 35 35 #include <map> 36 36 #include <vector> 37 #include <string> 37 38 38 39 #include "util/OgreForwardRefs.h" … … 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 53 virtual void changedOwner(); 54 void setConfigValues(); 53 55 54 56 private: … … 57 59 void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; } 58 60 59 void setDetectionLimit( float limit ) 60 { this->detectionLimit_ = limit; } 61 float getDetectionLimit() const 62 { return this->detectionLimit_; } 61 void setDetectionLimit( float limit ) { this->detectionLimit_ = limit; } 62 float getDetectionLimit() const { return this->detectionLimit_; } 63 63 64 64 float getMaximumDotSize() const { return this->maximumDotSize_; } 65 65 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } 66 66 67 float getMaximumDotSize3D() const { return this->maximumDotSize3D_; } 68 void setMaximumDotSize3D(float size) { this->maximumDotSize3D_ = size;} 69 70 std::string get2DMaterial() const {return this->material2D_; } 71 void set2DMaterial(std::string material2D) { this->material2D_ = material2D; } 72 73 std::string get3DMaterial() const {return this->material3D_; } 74 void set3DMaterial(std::string material3D) { this->material3D_ = material3D; } 75 76 std::string get3DMaterialFront() const {return this->material3DFront_; } 77 void set3DMaterialFront(std::string material3DFront) { this->material3DFront_ = material3DFront; } 78 79 std::string get3DMaterialBack() const {return this->material3DBack_; } 80 void set3DMaterialBack(std::string material3DBack) { this->material3DBack_ = material3DBack; } 81 67 82 float getRadarSensitivity() const { return this->sensitivity_; } 68 83 // used also by RadarListener interface! 69 84 void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; } 85 86 // Determines angle between line of sight and x/z-plain on the 3D minimap 87 float getMapAngle() const { return this->mapAngle_; } 88 void setMapAngle(float mapAngle) { this->mapAngle_ = mapAngle; } 70 89 71 90 // RadarListener interface … … 85 104 Ogre::PanelOverlayElement* marker_; 86 105 106 bool RadarMode_; // Determines, if Radar runs in 3D or 2D Mode 107 87 108 float halfDotSizeDistance_; 88 109 float maximumDotSize_; 110 float maximumDotSize3D_; 111 float mapAngle_; 112 113 std::string material2D_; //Material name for 2D map 114 std::string material3D_; //Material names For the 3D minimap 115 std::string material3DFront_; 116 std::string material3DBack_; 117 118 Ogre::PanelOverlayElement* map3DFront_; //Overlayelements for the 3D minimap to be able to draw the points in a semi 3D matter 119 Ogre::PanelOverlayElement* map3DBack_; 89 120 90 121 float sensitivity_;
Note: See TracChangeset
for help on using the changeset viewer.