_font_renderer(new fntRenderer()),
_font(0),
_font_size(0.0),
- _style(0)
+ _style(0),
+ _clip_box(0)
{
SG_LOG(SG_COCKPIT, SG_INFO, "Initializing HUD Instrument");
_scr_heightN->removeChangeListener(this);
_unitsN->removeChangeListener(this);
delete _font_renderer;
+ delete _clip_box;
deque<Item *>::const_iterator it, end = _items.end();
for (it = _items.begin(); it != end; ++it)
delete *it;
+ end = _ladders.end();
+ for (it = _ladders.begin(); it != end; ++it)
+ delete *it;
}
if (!isVisible())
return;
- if (!_items.size())
+ if (!_items.size() && !_ladders.size())
return;
if (is3D()) {
}
setColor();
+ _clip_box->set();
+
deque<Item *>::const_iterator it, end = _items.end();
for (it = _items.begin(); it != end; ++it)
if ((*it)->isEnabled())
glDisable(GL_LINE_STIPPLE);
}
+ // ladders last, as they can have their own clip planes
+ end = _ladders.end();
+ for (it = _ladders.begin(); it != end; ++it)
+ if ((*it)->isEnabled())
+ (*it)->draw();
+
if (isAntialiased()) {
glDisable(GL_ALPHA_TEST);
glDisable(GL_LINE_SMOOTH);
if (!level) {
SG_LOG(SG_INPUT, TREE, endl << "load " << file);
_items.erase(_items.begin(), _items.end());
+ _ladders.erase(_ladders.begin(), _ladders.end());
} else if (level > MAXNEST) {
SG_LOG(SG_INPUT, SG_ALERT, "HUD: files nested more than " << MAXNEST << " levels");
return 0x1;
return 0x8;
}
+ delete _clip_box;
+ _clip_box = new ClipBox(fgGetNode("/sim/hud/clip"), x, y);
+
for (int i = 0; i < root.nChildren(); i++) {
SGPropertyNode *n = root.getChild(i);
const char *d = n->getStringValue("name", 0);
item = static_cast<Item *>(new TurnBankIndicator(this, n, x, y));
} else if (!strcmp(name, "ladder")) {
item = static_cast<Item *>(new Ladder(this, n, x, y));
+ _ladders.insert(_ladders.begin(), item);
+ continue;
} else if (!strcmp(name, "runway")) {
item = static_cast<Item *>(new Runway(this, n, x, y));
} else if (!strcmp(name, "aiming-reticle")) {
}
+ClipBox::ClipBox(const SGPropertyNode *n, float xoffset, float yoffset) :
+ _active(false),
+ _xoffs(xoffset),
+ _yoffs(yoffset)
+{
+ if (!n)
+ return;
+
+ // const_cast is necessary because ATM there's no matching getChild(const ...)
+ // prototype and getNode(const ..., <bool>) is wrongly interpreted as
+ // getNode(const ..., <int>)
+ _top_node = (const_cast<SGPropertyNode *>(n))->getChild("top", 0, true);
+ _bot_node = (const_cast<SGPropertyNode *>(n))->getChild("bottom", 0, true);
+ _left_node = (const_cast<SGPropertyNode *>(n))->getChild("left", 0, true);
+ _right_node = (const_cast<SGPropertyNode *>(n))->getChild("right", 0, true);
+
+ _left[0] = 1.0, _left[1] = _left[2] = 0.0;
+ _right[0] = -1.0, _right[1] = _right[2] = 0.0;
+ _top[0] = 0.0, _top[1] = -1.0, _top[2] = 0.0;
+ _bot[0] = 0.0, _bot[1] = 1.0, _bot[2] = 0.0;
+ _active = true;
+}
+
+
+void ClipBox::set()
+{
+ if (!_active)
+ return;
+
+ _left[3] = -_left_node->getDoubleValue() - _xoffs;
+ _right[3] = _right_node->getDoubleValue() + _xoffs;
+ _bot[3] = -_bot_node->getDoubleValue() - _yoffs;
+ _top[3] = _top_node->getDoubleValue() + _yoffs;
+
+ glClipPlane(GL_CLIP_PLANE0, _top);
+ glEnable(GL_CLIP_PLANE0);
+ glClipPlane(GL_CLIP_PLANE1, _bot);
+ glEnable(GL_CLIP_PLANE1);
+ glClipPlane(GL_CLIP_PLANE2, _left);
+ glEnable(GL_CLIP_PLANE2);
+ glClipPlane(GL_CLIP_PLANE3, _right);
+ glEnable(GL_CLIP_PLANE3);
+}
+
class FGViewer;
+class ClipBox {
+public:
+ ClipBox(const SGPropertyNode *, float xoffset = 0, float yoffset = 0);
+ void set();
+
+private:
+ bool _active;
+ float _xoffs, _yoffs;
+ SGConstPropertyNode_ptr _top_node;
+ SGConstPropertyNode_ptr _bot_node;
+ SGConstPropertyNode_ptr _left_node;
+ SGConstPropertyNode_ptr _right_node;
+ GLdouble _top[4];
+ GLdouble _bot[4];
+ GLdouble _left[4];
+ GLdouble _right[4];
+};
+
+
+
class LineSegment {
public:
LineSegment(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1)
class AimingReticle;
deque<Item *> _items;
+ deque<Item *> _ladders;
SGPropertyNode_ptr _current;
SGPropertyNode_ptr _visibility;
float _font_size;
int _style;
+ ClipBox *_clip_box;
TextList _text_list;
LineList _line_list;
LineList _stipple_line_list;
class HUD::Ladder : public Item {
public:
Ladder(HUD *parent, const SGPropertyNode *, float x, float y);
+ ~Ladder();
virtual void draw();
private:
float _vmin;
float _compression;
bool _dynamic_origin;
- bool _clip_plane;
bool _frl; // fuselage reference line
bool _target_spot;
bool _target_markers;
bool _nadir;
bool _hat;
+ ClipBox *_clip_box;
// The Ladder has its own temporary display lists
TextList _locTextList;
LineList _locLineList;
};
-
#endif // _HUD_HXX
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__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
+float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
+float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
#undef ENABLE_SP_FDM
_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("clip")))
{
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())
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
//****************************************************************
+ _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
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;