#endif
#include <sstream>
-#include <simgear/math/vector.hxx>
-#include <Main/viewer.hxx>
+#include <simgear/math/SGGeometry.hxx>
+#include <Viewer/viewer.hxx>
+
#include "HUD.hxx"
+#include "HUD_private.hxx"
+
+#include <Main/fg_props.hxx>
+using std::string;
// FIXME
-float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
-float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
-float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
-float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
-float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
-float get__Ax() { return fgGetFloat("/acclerations/pilot/x-accel-fps_sec"); }
-float get__Ay() { return fgGetFloat("/acclerations/pilot/y-accel-fps_sec"); }
-float get__Az() { return fgGetFloat("/acclerations/pilot/z-accel-fps_sec"); }
-float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
-float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
+static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
+static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
+static float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
+static float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
+static float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
+static float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
+static float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
+static float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
+static float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
+static float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
#undef ENABLE_SP_FDM
_roll(n->getNode("roll-input", false)),
_width_units(int(n->getFloatValue("display-span"))),
_div_units(int(fabs(n->getFloatValue("divisions")))),
- _scr_hole(fabsf(n->getFloatValue("screen-hole")) * 0.5f),
+ _scr_hole(fabs(n->getFloatValue("screen-hole")) * 0.5f),
_zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
_dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
_tick_length(n->getFloatValue("tick-length")),
_compression(n->getFloatValue("compression-factor")),
_dynamic_origin(n->getBoolValue("enable-dynamic-origin")),
- _clip_plane(n->getBoolValue("enable-clip-plane")),
_frl(n->getBoolValue("enable-fuselage-ref-line")),
_target_spot(n->getBoolValue("enable-target-spot")),
_target_markers(n->getBoolValue("enable-target-markers")),
_waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
_zenith(n->getBoolValue("enable-zenith")),
_nadir(n->getBoolValue("enable-nadir")),
- _hat(n->getBoolValue("enable-hat"))
+ _hat(n->getBoolValue("enable-hat")),
+ _clip_box(new ClipBox(n->getNode("clipping")))
{
const char *t = n->getStringValue("type");
_type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
}
+HUD::Ladder::~Ladder()
+{
+ delete _clip_box;
+}
+
void HUD::Ladder::draw(void)
{
if (!_pitch.isValid() || !_roll.isValid())
//****************************************************************
//velocity vector reticle - computations
float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
- float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
+ float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope; //, t1;
float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
float vel_x = 0.0, vel_y = 0.0, drift;
float alpha;
actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
}
- xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
+ xvvr = drift * _compression;
// drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
// yvvr = (-alpha * _compression);
// vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
// vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
// * (_compression / globals->get_current_view()->get_aspect_ratio());
vel_y = -alpha * _compression;
- vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
+ vel_x = drift * _compression;
// printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
//****************************************************************
glEnd();
}
- //****************************************************************
- // Clipping coordinates for ladder to be input from xml file
- // Clip hud ladder. FIXME, these should be configurable, but they
- // have always been hardcoded here.
- if (_clip_plane) {
- GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
- GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
- GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
-
- glClipPlane(GL_CLIP_PLANE0, eqn_top);
- glEnable(GL_CLIP_PLANE0);
- glClipPlane(GL_CLIP_PLANE1, eqn_left);
- glEnable(GL_CLIP_PLANE1);
- glClipPlane(GL_CLIP_PLANE2, eqn_right);
- glEnable(GL_CLIP_PLANE2);
- }
-
//****************************************************************
// OBJECT MOVING RETICLE
// TYPE VELOCITY VECTOR
SGPropertyNode *chld = models->getChild(i);
string name;
name = chld->getName();
- if (name == "aircraft" || name == "multiplayer") {
- string callsign = chld->getStringValue("callsign");
- if (callsign != "") {
+ if (name == "tanker" || name == "aircraft" || name == "multiplayer") {
+ bool valid = chld->getBoolValue("valid");
+ bool in_range = chld->getBoolValue("radar/in-range", true);
+ if (valid && in_range) {
float h_deg = chld->getFloatValue("radar/h-offset");
float v_deg = chld->getFloatValue("radar/v-offset");
float pos_x = (h_deg * cos(roll_value) -
if (_energy_marker) {
if (total_vel < 5.0) {
- t1 = 0;
+// t1 = 0;
t2 = 0;
} else {
- t1 = up_vel / total_vel;
+// t1 = up_vel / total_vel;
t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
}
pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
//****************************************************************
+ _clip_box->set();
+
if (_dynamic_origin) {
// ladder moves with alpha/beta offset projected onto horizon
// line (so that the horizon line always aligns with the
// however the horizon line should always stay on the horizon. We
// project the alpha/beta offset onto the horizon line to get the
// result we want.
- sgdVec3 p1; // result
- sgdVec3 p; sgdSetVec3(p, vel_x, vel_y, 0.0);
- sgdVec3 p0; sgdSetVec3(p0, 0.0, 0.0, 0.0);
- sgdVec3 d; sgdSetVec3(d, cos(roll_value), sin(roll_value), 0.0);
- sgdClosestPointToLine(p1, p, p0, d);
- glTranslatef(p1[0], p1[1], 0);
+
+ SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
+ SGRayd r(SGVec3d::zeros(), d);
+ SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
+ glTranslatef(p[0], p[1], 0);
}
} else {
// ladder position is fixed relative to the center of the screen.
else // _type == CLIMB_DIVE
y = float(i - actslope) * _compression + .5;
- // draw symbols
- if (i == 90 && _zenith)
- draw_zenith(0.0, y);
-
- if (i == -90 && _nadir)
- draw_nadir(0.0, y);
-
// OBJECT LADDER MARK
// TYPE LINE
// ATTRIB - ON CONDITION
- // draw appraoch glide slope marker
+ // draw approach glide slope marker
#ifdef ENABLE_SP_FDM
if (_glide_slope_marker && ihook) {
draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
}
#endif
- if (i > 85 || i < -85)
+ // draw symbols
+ if (i == 90 && _zenith)
+ draw_zenith(0.0, y);
+ else if (i == -90 && _nadir)
+ draw_nadir(0.0, y);
+
+ if ((_zenith && i > 85) || i > 90)
+ continue;
+ if ((_nadir && i < -85) || i < -90)
continue;
lo.x = -half_span;
// draw numbers
std::ostringstream str;
str << i;
- const char *num = str.str().c_str();
+ // must keep this string, otherwise it will free the c_str!
+ string num_str = str.str();
+ const char *num = num_str.c_str();
int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
_locStippleLineList.draw();
glDisable(GL_LINE_STIPPLE);
}
- glDisable(GL_CLIP_PLANE0);
- glDisable(GL_CLIP_PLANE1);
- glDisable(GL_CLIP_PLANE2);
+ _clip_box->unset();
glPopMatrix();
//*************************************************************