]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/HUD/HUD_runway.cxx
better use unset() for unsetting ...
[flightgear.git] / src / Instrumentation / HUD / HUD_runway.cxx
index bff02fb013b73bbd1ad9dade62940468f2039c2c..434b73c2ecb8b677267fcefe6ce118d7815c0213 100644 (file)
 #include <simgear/compiler.h>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/polar3d.hxx>
-#include SG_GLU_H
+#include <osg/GLU>
 
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
 #include <Aircraft/aircraft.hxx>
+#include <Aircraft/controls.hxx>
+#include <FDM/flight.hxx>
 #include <Environment/environment.hxx>
 #include <Environment/environment_mgr.hxx>
 #include <Main/viewer.hxx>
 #include <Main/viewmgr.hxx>
-#include <ATC/ATCutils.hxx>
+#include <ATCDCL/ATCutils.hxx>
 
 #include "HUD.hxx"
 
@@ -60,13 +62,13 @@ HUD::Runway::Runway(HUD *hud, const SGPropertyNode *node, float x, float y) :
     _view[2] = 640;
     _view[3] = 480;
 
-    _center.x = _view[2] / 2;
-    _center.y = _view[3] / 2;
+    _center_x = _view[2] / 2;
+    _center_y = _view[3] / 2;
 
-    _left = _center.x - (_w / 2) + _x;
-    _right = _center.x + (_w / 2) + _x;
-    _bottom = _center.y - (_h / 2) + _y;
-    _top = _center.y + (_h / 2) + _y;
+    _left = _center_x - (_w / 2) + _x;
+    _right = _center_x + (_w / 2) + _x;
+    _bottom = _center_y - (_h / 2) + _y;
+    _top = _center_y + (_h / 2) + _y;
 }
 
 
@@ -98,19 +100,22 @@ void HUD::Runway::draw()
         globals->get_viewmgr()->copyToCurrent();
     }
     //Set the camera to the cockpit view to get the view of the runway from the cockpit
-    ssgSetCamera((sgVec4 *)_cockpit_view->get_VIEW());
+    // OSGFIXME
+//     ssgSetCamera((sgVec4 *)_cockpit_view->get_VIEW());
     get_rwy_points(_points3d);
     //Get the current project matrix
-    ssgGetProjectionMatrix(projMat);
+    // OSGFIXME
+//     ssgGetProjectionMatrix(projMat);
 //    const sgVec4 *viewMat = globals->get_current_view()->get_VIEW();
     //Get the current model view matrix (cockpit view)
-    ssgGetModelviewMatrix(modelView);
+    // OSGFIXME
+//     ssgGetModelviewMatrix(modelView);
     //Create a rotation matrix to correct for any offsets (other than default offsets) to the model view matrix
     sgMat4 xy; //rotation about the Rxy, negate the sin's on Ry
-    xy[0][0] = cYaw;         xy[1][0] = 0.0f;   xy[2][0] = -sYaw;        xy[3][0] = 0.0f;
-    xy[0][1] = sPitch*-sYaw; xy[1][1] = cPitch; xy[2][1] = -sPitch*cYaw; xy[3][1] = 0.0f;
-    xy[0][2] = cPitch*sYaw;  xy[1][2] = sPitch; xy[2][2] = cPitch*cYaw;  xy[3][2] = 0.0f;
-    xy[0][3] = 0.0f;         xy[1][3] = 0.0f;   xy[2][3] = 0.0f;         xy[3][3] = 1.0f;
+    xy[0][0] = cYaw,         xy[1][0] = 0.0f,   xy[2][0] = -sYaw,        xy[3][0] = 0.0f;
+    xy[0][1] = sPitch*-sYaw, xy[1][1] = cPitch, xy[2][1] = -sPitch*cYaw, xy[3][1] = 0.0f;
+    xy[0][2] = cPitch*sYaw,  xy[1][2] = sPitch, xy[2][2] = cPitch*cYaw,  xy[3][2] = 0.0f;
+    xy[0][3] = 0.0f,         xy[1][3] = 0.0f,   xy[2][3] = 0.0f,         xy[3][3] = 1.0f;
     //Re-center the model view
     sgPostMultMat4(modelView,xy);
     //copy float matrices to double
@@ -157,7 +162,8 @@ void HUD::Runway::draw()
         curr_view->setGoalPitchOffset_deg(gpo);
     }
     //Set the camera back to the current view
-    ssgSetCamera((sgVec4 *)curr_view);
+    // OSGFIXME
+//     ssgSetCamera((sgVec4 *)curr_view);
     glPopAttrib();
 }
 
@@ -173,14 +179,6 @@ bool HUD::Runway::get_active_runway(FGRunway& runway)
 
 void HUD::Runway::get_rwy_points(sgdVec3 *_points3d)
 {
-    static Point3D center = globals->get_scenery()->get_center();
-
-    //Get the current tile center
-    Point3D currentCenter = globals->get_scenery()->get_center();
-    Point3D tileCenter = currentCenter;
-    if (center != currentCenter) //if changing tiles
-        tileCenter = center; //use last center
-
     double alt = current_aircraft.fdm_state->get_Runway_altitude() * SG_FEET_TO_METER;
     double length = (_runway._length / 2.0) * SG_FEET_TO_METER;
     double width = (_runway._width / 2.0) * SG_FEET_TO_METER;
@@ -203,13 +201,6 @@ void HUD::Runway::get_rwy_points(sgdVec3 *_points3d)
 
     geo_direct_wgs_84(alt, frontLat, frontLon, _runway._heading + 90, width, &tempLat, &tempLon, &az);
     sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, _points3d[3]);
-
-    for (int i = 0; i < 6; i++) {
-        _points3d[i][0] -= tileCenter.x();
-        _points3d[i][1] -= tileCenter.y();
-        _points3d[i][2] -= tileCenter.z();
-    }
-    center = currentCenter;
 }