[Orxonox-commit 5055] r9719 - in code/branches/radarDreiD: data/overlays src/libraries/util src/modules/overlays/hud
wroennin at orxonox.net
wroennin at orxonox.net
Mon Oct 28 15:58:20 CET 2013
Author: wroennin
Date: 2013-10-28 15:58:20 +0100 (Mon, 28 Oct 2013)
New Revision: 9719
Modified:
code/branches/radarDreiD/data/overlays/HUD.oxo
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:
Radar.cc: new function call, detectionlimit 10000->1000 ; Math.cc: new function get3DProjection; HUDTemplates.oxo: new HUDRadar
Modified: code/branches/radarDreiD/data/overlays/HUD.oxo
===================================================================
--- code/branches/radarDreiD/data/overlays/HUD.oxo 2013-10-28 14:53:33 UTC (rev 9718)
+++ code/branches/radarDreiD/data/overlays/HUD.oxo 2013-10-28 14:58:20 UTC (rev 9719)
@@ -67,7 +67,7 @@
<HUDRadar
name = "Radar"
- background = "Orxonox/Radar"
+ background = "Orxonox/radar"
correctAspect = true
size = "0.17, 0.17"
position = "0.5, 1.0"
Modified: code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo 2013-10-28 14:53:33 UTC (rev 9718)
+++ code/branches/radarDreiD/data/overlays/HUDTemplates3.oxo 2013-10-28 14:58:20 UTC (rev 9719)
@@ -107,9 +107,10 @@
aimMarkerSize = 0.02
/>
+<!--
<HUDRadar
name = "Radar"
- background = "Orxonox/Radar"
+ backgroundtex = "radar.png"
correctaspect = true
size = "0.17, 0.17"
position = "1.0, 1.0"
@@ -119,6 +120,20 @@
halfDotSizeDistance = 3000
maximumDotSize = 0.1
/>
+ -->
+
+ <HUDRadar
+ name = "Radar"
+ backgroundtex = "radar3D_test.png"
+ 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
+ />
<HUDTimer
name = "Timer"
Modified: code/branches/radarDreiD/src/libraries/util/Math.cc
===================================================================
--- code/branches/radarDreiD/src/libraries/util/Math.cc 2013-10-28 14:53:33 UTC (rev 9718)
+++ code/branches/radarDreiD/src/libraries/util/Math.cc 2013-10-28 14:58:20 UTC (rev 9719)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Wolfgang Roenninger
*
*/
@@ -146,7 +146,7 @@
}
/**
- @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).
+ @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).
@param myposition My position
@param mydirection My viewing direction
@param myorthonormal My orthonormalvector (pointing upwards through my head)
@@ -190,7 +190,37 @@
return orxonox::Vector2( -sin_value * radius, cos_value * radius);
}
+
/**
+ @brief Gets the 2D project vector for the 3D Radar .
+ @param myposition My position
+ @param mydirection My viewing direction
+ @param otherposition The position of the other object
+ @param mapangle The angle you look on the 3Dmap
+ @param detectionlimit The limit in which objects are shown on the map
+ @return The viewing direction
+
+ Examples:
+ -
+ */
+ orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit)
+ {
+ //
+ orxonox::Vector3 distance = otherposition - myposition;
+
+ // project difference vector on our plane
+ orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
+
+ //float projectionlength = projection.length();
+
+ // project vector for the rotated 3DMap
+ float xcoordinate = projection.y/(2*detectionlimit);
+ float ycoordinate = (projection.x*sin(mapangle)+projection.z*cos(mapangle))/(2*detectionlimit);
+ return orxonox::Vector2(xcoordinate , ycoordinate);
+ }
+
+
+ /**
@brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.
@param myposition My position
@param projectilespeed The speed of my projectile
Modified: code/branches/radarDreiD/src/libraries/util/Math.h
===================================================================
--- code/branches/radarDreiD/src/libraries/util/Math.h 2013-10-28 14:53:33 UTC (rev 9718)
+++ code/branches/radarDreiD/src/libraries/util/Math.h 2013-10-28 14:58:20 UTC (rev 9719)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Wolfgang Roenninger
*
*/
@@ -91,6 +91,7 @@
_UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
_UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
_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& otherposition, const float mapangle, const float detectionlimit);
_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-10-28 14:53:33 UTC (rev 9718)
+++ code/branches/radarDreiD/src/modules/overlays/hud/HUDRadar.cc 2013-10-28 14:58:20 UTC (rev 9719)
@@ -63,7 +63,7 @@
this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.png";
this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png";
this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.png";
- this->setDetectionLimit( 10000.0f );
+ this->setDetectionLimit( 1000.0f );
this->owner_ = 0;
}
@@ -168,7 +168,8 @@
it->second->setDimensions(size, size);
// calc position on radar...
- Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
+ //Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
+ Vector2 coord = get3DProjection(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, wePointer->getWorldPosition(), 0.6435011, detectionLimit_);
coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
if( distance < detectionLimit_ || detectionLimit_ < 0 )
More information about the Orxonox-commit
mailing list