add MIL-STD-1787B Aiming Reticle (stadiametric; TODO: standby)
This commit is contained in:
parent
aad3c711a1
commit
a5125b6124
5 changed files with 84 additions and 2 deletions
|
@ -379,6 +379,8 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
|
||||||
item = static_cast<Item *>(new Ladder(this, n, x, y));
|
item = static_cast<Item *>(new Ladder(this, n, x, y));
|
||||||
} else if (!strcmp(name, "runway")) {
|
} else if (!strcmp(name, "runway")) {
|
||||||
item = static_cast<Item *>(new Runway(this, n, x, y));
|
item = static_cast<Item *>(new Runway(this, n, x, y));
|
||||||
|
} else if (!strcmp(name, "aiming-reticle")) {
|
||||||
|
item = static_cast<Item *>(new AimingReticle(this, n, x, y));
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_INPUT, TREE, indent << " \\...unsupported!");
|
SG_LOG(SG_INPUT, TREE, indent << " \\...unsupported!");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -261,6 +261,7 @@ private:
|
||||||
class TurnBankIndicator;
|
class TurnBankIndicator;
|
||||||
class Ladder;
|
class Ladder;
|
||||||
class Runway;
|
class Runway;
|
||||||
|
class AimingReticle;
|
||||||
|
|
||||||
deque<Item *> _items;
|
deque<Item *> _items;
|
||||||
|
|
||||||
|
@ -322,6 +323,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getBoolValue() const {
|
||||||
|
assert(_property);
|
||||||
|
return _property->getBoolValue();
|
||||||
|
}
|
||||||
|
|
||||||
const char *getStringValue() const {
|
const char *getStringValue() const {
|
||||||
assert(_property);
|
assert(_property);
|
||||||
return _property->getStringValue();
|
return _property->getStringValue();
|
||||||
|
@ -631,4 +637,18 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class HUD::AimingReticle : public Item {
|
||||||
|
public:
|
||||||
|
AimingReticle(HUD *parent, const SGPropertyNode *, float x, float y);
|
||||||
|
virtual void draw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SGCondition *_active_condition; // stadiametric (true) or standby (false)
|
||||||
|
Input _diameter; // inner/outer radius relation
|
||||||
|
float _bullet_size;
|
||||||
|
float _inner_radius;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _HUD_HXX
|
#endif // _HUD_HXX
|
||||||
|
|
|
@ -116,8 +116,8 @@ void HUD::Item::draw_text(float x, float y, char *msg, int digit)
|
||||||
void HUD::Item::draw_circle(float xoffs, float yoffs, float r) const
|
void HUD::Item::draw_circle(float xoffs, float yoffs, float r) const
|
||||||
{
|
{
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
for (int i = 0; i < 25; i++) {
|
float step = SG_PI / r;
|
||||||
float alpha = i * 2.0 * SG_PI / 10.0;
|
for (float alpha = 0; alpha < SG_PI * 2.0; alpha += step) {
|
||||||
float x = r * cos(alpha);
|
float x = r * cos(alpha);
|
||||||
float y = r * sin(alpha);
|
float y = r * sin(alpha);
|
||||||
glVertex2f(x + xoffs, y + yoffs);
|
glVertex2f(x + xoffs, y + yoffs);
|
||||||
|
|
59
src/Instrumentation/HUD/HUD_misc.cxx
Normal file
59
src/Instrumentation/HUD/HUD_misc.cxx
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// HUD_misc.cxx -- HUD miscellaneous elements
|
||||||
|
//
|
||||||
|
// Written by Melchior FRANZ, started September 2006.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at]
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
#include <simgear/props/condition.hxx>
|
||||||
|
#include "HUD.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
// MIL-STD-1787B aiming reticle
|
||||||
|
|
||||||
|
HUD::AimingReticle::AimingReticle(HUD *hud, const SGPropertyNode *n, float x, float y) :
|
||||||
|
Item(hud, n, x, y),
|
||||||
|
_active_condition(0),
|
||||||
|
_diameter(n->getNode("diameter-input", false)),
|
||||||
|
_bullet_size(_w / 3.0),
|
||||||
|
_inner_radius(_w)
|
||||||
|
{
|
||||||
|
const SGPropertyNode *node = n->getNode("active-condition");
|
||||||
|
if (node)
|
||||||
|
_active_condition = sgReadCondition(globals->get_props(), node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HUD::AimingReticle::draw(void)
|
||||||
|
{
|
||||||
|
bool active = _active_condition ? _active_condition->test() : true;
|
||||||
|
float diameter = _diameter.isValid() ? _diameter.getFloatValue() : 2.0f; // outer circle
|
||||||
|
|
||||||
|
Point centroid = get_centroid();
|
||||||
|
float x = centroid.x;
|
||||||
|
float y = centroid.y;
|
||||||
|
|
||||||
|
if (active) { // stadiametric (4.2.4.4)
|
||||||
|
draw_bullet(x, y, _bullet_size);
|
||||||
|
draw_circle(x, y, _inner_radius);
|
||||||
|
draw_circle(x, y, diameter * _inner_radius);
|
||||||
|
|
||||||
|
} else { // standby (4.2.4.5)
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ libHUD_a_SOURCES = \
|
||||||
HUD_instrument.cxx \
|
HUD_instrument.cxx \
|
||||||
HUD_label.cxx \
|
HUD_label.cxx \
|
||||||
HUD_ladder.cxx \
|
HUD_ladder.cxx \
|
||||||
|
HUD_misc.cxx \
|
||||||
HUD_runway.cxx \
|
HUD_runway.cxx \
|
||||||
HUD_scale.cxx \
|
HUD_scale.cxx \
|
||||||
HUD_tbi.cxx
|
HUD_tbi.cxx
|
||||||
|
|
Loading…
Reference in a new issue