]> git.mxchange.org Git - flightgear.git/commitdiff
Add support for drawing target markers (circles on top of any AI/MP aircraft)
authorcurt <curt>
Thu, 27 Jul 2006 02:46:14 +0000 (02:46 +0000)
committercurt <curt>
Thu, 27 Jul 2006 02:46:14 +0000 (02:46 +0000)
as part of the conformal HUD ladder.

src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_ladder.cxx

index 113baf67b1a580e682e9f16fed69cae0ff35615b..6506cd7aa2c6517922d33806c1c39bdd03bc9e19 100644 (file)
@@ -570,6 +570,7 @@ private:
     float  _compression;
     bool   _frl;               // fuselage reference line
     bool   _target_spot;
+    bool   _target_markers;
     bool   _velocity_vector;
     bool   _drift_marker;
     bool   _alpha_bracket;
index 9a763d8688bd93636282c19cd8b5cfb3c44fd042..556f1b4a147ade85754cecd17294d893197c5dd1 100644 (file)
@@ -51,6 +51,7 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
     _compression(n->getFloatValue("compression-factor")),
     _frl(n->getBoolValue("enable-fuselage-ref-line")),
     _target_spot(n->getBoolValue("enable-target-spot")),
+    _target_markers(n->getBoolValue("enable-target-markers")),
     _velocity_vector(n->getBoolValue("enable-velocity-vector")),
     _drift_marker(n->getBoolValue("enable-drift-marker")),
     _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
@@ -282,6 +283,28 @@ void HUD::Ladder::draw(void)
 #endif
     } // if _velocity_vector
 
+    // draw hud markers on top of each AI/MP target
+    if ( _target_markers ) {
+        SGPropertyNode *models
+            = globals->get_props()->getNode("/ai/models", true);
+        for ( int i = 0; i < models->nChildren(); i++ ) {
+            SGPropertyNode *chld = models->getChild(i);
+            string name;
+            name = chld->getName();
+            if ( name == "aircraft" || name == "multiplayer" ) {
+                string callsign = chld->getStringValue("callsign");
+                if ( callsign != "" ) {
+                    float h_deg = chld->getFloatValue("radar/h-offset");
+                    float v_deg = chld->getFloatValue("radar/v-offset");
+                    float pos_x = (h_deg * cos(roll_value) -
+                                   v_deg * sin(roll_value)) * _compression;
+                    float pos_y = (v_deg * cos(roll_value) +
+                                   h_deg * sin(roll_value)) * _compression;
+                    draw_circle(pos_x, pos_y, 8);
+                }
+            }
+        }
+    }
 
     //***************************************************************
     // OBJECT MOVING RETICLE