[Orxonox-commit 5214] r9877 - in code/branches/radarDreiD: data/overlays src/libraries/util src/modules/overlays/hud

wroennin at orxonox.net wroennin at orxonox.net
Mon Dec 9 14:06:55 CET 2013


Author: wroennin
Date: 2013-12-09 14:06:55 +0100 (Mon, 09 Dec 2013)
New Revision: 9877

Modified:
   code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo
   code/branches/radarDreiD/src/libraries/util/Math.cc
   code/branches/radarDreiD/src/libraries/util/Math.h
   code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc
Log:
Math: New function to determine the ZOrder of the radarobjects; HUDTemplates: cleenup

Modified: code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo	2013-12-09 12:04:09 UTC (rev 9876)
+++ code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo	2013-12-09 13:06:55 UTC (rev 9877)
@@ -107,24 +107,7 @@
      aimMarkerSize = 0.02
     />
 
-<!--
-    <HUDRadar
-     name          = "Radar"
-     background    = "Orxonox/Radar"
-     correctaspect = true
-     size          = "0.17, 0.17"
-     position      = "1.0, 1.0"
-     pickpoint     = "1.0, 1.0"
-     rotation      = 0
-     sensitivity   = 1.0
-     halfDotSizeDistance = 3000
-     maximumDotSize      = 0.1
-    />
-    -->
-   
-   
-  
-    <HUDRadar
+	<HUDRadar
      name          			= "Radar"
      background    			= "Orxonox/Radar3D"
      material2D    			= "Orxonox/Radar"
@@ -139,11 +122,10 @@
      sensitivity   			= 1.0
      halfDotSizeDistance 	= 3000
      maximumDotSize 		= 0.1
-     maximumDotSize3D      	= 0.07
+     maximumDotSize3D      	= 0.06
      mapAngle3D   			= 0.6435011
     />
     
-
     <HUDTimer
      name     = "Timer"
      position = "0.5, 0.85"

Modified: code/branches/radarDreiD/src/libraries/util/Math.cc
===================================================================
--- code/branches/radarDreiD/src/libraries/util/Math.cc	2013-12-09 12:04:09 UTC (rev 9876)
+++ code/branches/radarDreiD/src/libraries/util/Math.cc	2013-12-09 13:06:55 UTC (rev 9877)
@@ -207,13 +207,13 @@
     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)
     {
     	// Orxonox Vectors: x_direction you are looking, y_direction points up, z_direction points to the right
-    	orxonox::Vector3 distance = otherposition - myposition;
+    	orxonox::Vector3 distance = otherposition - myposition;	// get vector from Ship to object
 
     	// new coordinate system:	x_axsis:	mydirection		(points front)
     	//							y_axsis:	myorthonormal	(points up)
     	//							z_axsis:	myside			(points right)
 
-    	orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get vector from Ship to object
+    	orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); // get 3. base vector
 
     	distance = 4*distance / detectionlimit; // shrink vector on map
     	if(distance.length() > 1.0f) // if object would wander outside of the map
@@ -264,7 +264,33 @@
        		return false;
     }
 
+    /**
+                   @brief A value between 0 and 10, in order how other object is in front or in back
+                   @param myposition My position
+               	   @param mydirection My viewing direction
+               	   @param myorthonormal My orthonormalvector (pointing upwards through my head)
+               	   @param otherposition The position of the other object
+               	   @param detectionlimit The limit in which objects are shown on the map
+                   @return value between 0 and 100
+    */
+    int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit)
+    {
+    	orxonox::Vector3 distance = otherposition - myposition;	// get vector from Ship to object
+    	orxonox::Vector3 myside = mydirection.crossProduct(myorthonormal); 	// get vector to the side
 
+    	distance = 4*distance / detectionlimit; // shrink vector on map
+    	if(distance.length() > 1.0f) // if object would wander outside of the map
+    	{
+    		distance = distance / distance.length();
+    	}
+
+    	// perform a coordinate transformation to get distance in relation of the position of the ship
+       	orxonox::Vector3 distanceShip = getTransformedVector(distance, mydirection, myorthonormal, myside);
+
+       	return (int) 50 - 100*distanceShip.x;
+    }
+
+
     /**
                 @brief Gets the new vector after a coordinate transformation
                 @param distance Vector which will be transformed

Modified: code/branches/radarDreiD/src/libraries/util/Math.h
===================================================================
--- code/branches/radarDreiD/src/libraries/util/Math.h	2013-12-09 12:04:09 UTC (rev 9876)
+++ code/branches/radarDreiD/src/libraries/util/Math.h	2013-12-09 13:06:55 UTC (rev 9877)
@@ -93,6 +93,7 @@
     _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
     _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);
     _UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle);
+    _UtilExport int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit);
     _UtilExport orxonox::Vector3 getTransformedVector(const orxonox::Vector3& distance, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& myside);
     _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
 

Modified: code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc	2013-12-09 12:04:09 UTC (rev 9876)
+++ code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc	2013-12-09 13:06:55 UTC (rev 9877)
@@ -192,8 +192,8 @@
         if(RadarMode_)
         {
         	this->setBackgroundMaterial(material3D_);
-        	this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 10);
-        	this->map3DBack_->_notifyZOrder(this->overlay_->getZOrder() * 100 - 10);
+        	this->map3DFront_->_notifyZOrder(this->overlay_->getZOrder() * 100 + 250); // it seems that the ZOrder of overlayelements is 100 times the ZOrder of the overlay
+        	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
         	this->map3DFront_->show();
         	this->map3DBack_->show();
         }
@@ -234,10 +234,10 @@
             	// set zOrder on screen
             	bool overXZPlain = isObjectHigherThanShipOnMap(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), this->mapAngle_);
 
-            	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
-            		it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 1);
-            	if(overXZPlain == true && (it->second->getZOrder() <= 100 * this->overlay_->getZOrder()))
-            		it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 1);
+            	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
+            		it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_));
+            	if(overXZPlain == true /*&& (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())*/)
+            		it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_));
             }
             else
             	coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());




More information about the Orxonox-commit mailing list