_odg(0),
_scale(0),
_view_heading(0),
- _resultTexture(0),
_font_size(0),
_font_spacing(0),
_rangeNm(0)
NavDisplay::~NavDisplay()
{
+ delete _odg;
}
-
void
NavDisplay::init ()
{
// texture name to use in 2D and 3D instruments
_texture_path = _Instrument->getStringValue("radar-texture-path",
"Aircraft/Instruments/Textures/od_wxradar.rgb");
- _resultTexture = FGTextureManager::createTexture(_texture_path.c_str(), false);
string path = _Instrument->getStringValue("symbol-texture-path",
"Aircraft/Instruments/Textures/nd-symbols.png");
// no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect
_symbolTexture = SGLoadTexture2D(tpath, NULL, false, false);
- FGInstrumentMgr *imgr = (FGInstrumentMgr *)globals->get_subsystem("instrumentation");
- _odg = (FGODGauge *)imgr->get_subsystem("od_gauge");
+ _odg = new FGODGauge;
_odg->setSize(_Instrument->getIntValue("texture-size", 512));
_route = static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"));
SGPropertyNode_ptr _navRadio2Node;
SGPropertyNode_ptr _xCenterNode, _yCenterNode;
- osg::ref_ptr<osg::Texture2D> _resultTexture;
osg::ref_ptr<osg::Texture2D> _symbolTexture;
osg::ref_ptr<osg::Geode> _radarGeode;
osg::ref_ptr<osg::Geode> _textGeode;
if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &_material)){
//_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
if (_material) {
- const vector<string>& names = _material->get_names();
+ const std::vector<std::string>& names = _material->get_names();
_solid = _material->get_solid();
_load_resistance = _material->get_load_resistance();
const SGMaterial* _material;
- string _mat_name; // ground material
+ std::string _mat_name; // ground material
SGVec3d getCartUserPos() const;
SGVec3d getCartAntennaPos()const;
_range_node->removeChangeListener(this);
}
+void GroundRadar::update (double /* dt */)
+{
+
+}
+
void GroundRadar::valueChanged(SGPropertyNode*)
{
updateTexture();
#include <osg/Geometry>
#include <simgear/props/props.hxx>
#include "od_gauge.hxx"
+#include <simgear/structure/subsystem_mgr.hxx>
// forward decls
class FGRunwayBase;
// Built-in layer for the atc radar.
////////////////////////////////////////////////////////////////////////
-class GroundRadar : public SGPropertyChangeListener, public FGODGauge
+class GroundRadar : public SGSubsystem, public SGPropertyChangeListener, private FGODGauge
{
public:
static const int TextureHalfSize = 256;
virtual ~GroundRadar();
void updateTexture();
virtual void valueChanged(SGPropertyNode*);
-
+ virtual void update (double dt);
protected:
void createTexture(const char* texture_name);
#include "turn_indicator.hxx"
#include "vertical_speed_indicator.hxx"
#include "inst_vertical_speed_indicator.hxx"
-#include "od_gauge.hxx"
#include "wxradar.hxx"
#include "tacan.hxx"
#include "mk_viii.hxx"
FGInstrumentMgr::FGInstrumentMgr () :
_explicitGps(false)
-{
- set_subsystem("od_gauge", new FGODGauge);
-
+{
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
}
subsystemname << '['<< index << ']';
string id = subsystemname.str();
_instruments.push_back(id);
-
+
if ( name == "adf" ) {
set_subsystem( id, new ADF( node ), 0.15 );
# include "config.h"
#endif
+#include <osg/Texture2D>
#include <osg/AlphaFunc>
#include <osg/BlendFunc>
#include <osg/Camera>
#include "od_gauge.hxx"
FGODGauge::FGODGauge() :
- rtAvailable( false )// ,
-// rt( 0 )
+ rtAvailable( false )
{
}
-void FGODGauge::allocRT () {
+void FGODGauge::allocRT ()
+{
camera = new osg::Camera;
// Only the far camera should trigger this texture to be rendered.
camera->setNodeMask(simgear::BACKGROUND_BIT);
camera->attach(osg::Camera::COLOR_BUFFER, texture.get());
globals->get_renderer()->addCamera(camera.get(), false);
rtAvailable = true;
-
- // GLint colorBits = 0;
-// glGetIntegerv( GL_BLUE_BITS, &colorBits );
-// rt = new RenderTexture();
-// if( colorBits < 8 )
-// rt->Reset("rgba=5,5,5,1 ctt");
-// else
-// rt->Reset("rgba ctt");
-
-// if( rt->Initialize(256, 256, true) ) {
-// SG_LOG(SG_INSTR, SG_INFO, "FGODGauge:Initialize sucessfull");
-// if (rt->BeginCapture())
-// {
-// SG_LOG(SG_INSTR, SG_INFO, "FGODGauge:BeginCapture sucessfull, RTT available");
-// rtAvailable = true;
-// glViewport(0, 0, textureWH, textureWH);
-// glMatrixMode(GL_PROJECTION);
-// glLoadIdentity();
-// gluOrtho2D( -256.0, 256.0, -256.0, 256.0 );
-// glMatrixMode(GL_MODELVIEW);
-// glLoadIdentity();
-// glDisable(GL_LIGHTING);
-// glEnable(GL_COLOR_MATERIAL);
-// glDisable(GL_CULL_FACE);
-// glDisable(GL_FOG);
-// glDisable(GL_DEPTH_TEST);
-// glClearColor(0.0, 0.0, 0.0, 0.0);
-// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-// glBindTexture(GL_TEXTURE_2D, 0);
-// glEnable(GL_TEXTURE_2D);
-// glEnable(GL_ALPHA_TEST);
-// glAlphaFunc(GL_GREATER, 0.0f);
-// glDisable(GL_SMOOTH);
-// glEnable(GL_BLEND);
-// glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
-// rt->EndCapture();
-// } else
-// SG_LOG(SG_INSTR, SG_WARN, "FGODGauge:BeginCapture failed, RTT not available, using backbuffer");
-// } else
-// SG_LOG(SG_INSTR, SG_WARN, "FGODGauge:Initialize failed, RTT not available, using backbuffer");
-}
-
-FGODGauge::~FGODGauge() {
-// delete rt;
-}
-
-void FGODGauge::init () {
}
-void FGODGauge::update (double dt) {
+FGODGauge::~FGODGauge()
+{
+ if (camera.valid()) {
+ globals->get_renderer()->removeCamera(camera.get());
+ }
}
-
-void FGODGauge::setSize(int viewSize) {
+void FGODGauge::setSize(int viewSize)
+{
textureWH = viewSize;
-// glViewport(0, 0, textureWH, textureWH);
+ if (texture.valid()) {
+ texture->setTextureSize(textureWH, textureWH);
+ }
}
-bool FGODGauge::serviceable(void) {
+bool FGODGauge::serviceable(void)
+{
return rtAvailable;
}
#ifndef _OD_GAUGE_HXX
#define _OD_GAUGE_HXX
-#include <osg/Camera>
-#include <osg/Texture2D>
-#include <simgear/structure/subsystem_mgr.hxx>
+#include <osg/ref_ptr>
+
+namespace osg {
+ class Camera;
+ class Texture2D;
+}
/**
* Owner Drawn Gauge helper class.
*/
-class FGODGauge : public SGSubsystem {
-
+class FGODGauge
+{
public:
- FGODGauge ( SGPropertyNode *node );
FGODGauge();
virtual ~FGODGauge();
- virtual void init ();
- virtual void update (double dt);
+
void setSize(int viewSize);
int size() const
{ return textureWH; }
wxRadarBg::~wxRadarBg ()
{
_font_node->removeChangeListener(this);
+ delete _odg;
}
// input range = n nm (20/40/80)
// input display-mode = arc | rose | map | plan
- FGInstrumentMgr *imgr = (FGInstrumentMgr *)globals->get_subsystem("instrumentation");
- _odg = (FGODGauge *)imgr->get_subsystem("od_gauge");
+ _odg = new FGODGauge;
_odg->setSize(512);
_ai_enabled_node = fgGetNode("/sim/ai/enabled", true);
#include <vector>
#include <string>
-using std::vector;
-using std::string;
-
class FGODGauge;
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener {
double elapsed_time;
}ground_echo;
- typedef vector <ground_echo*> ground_echo_vector_type;
+ typedef std::vector <ground_echo*> ground_echo_vector_type;
typedef ground_echo_vector_type::iterator ground_echo_vector_iterator;
ground_echo_vector_type ground_echoes;
mRealRoot->addChild(camera);
}
+void
+FGRenderer::removeCamera(osg::Camera* camera)
+{
+ mRealRoot->removeChild(camera);
+}
+
void
FGRenderer::setPlanes( double zNear, double zFar )
{
*/
void addCamera(osg::Camera* camera, bool useSceneData);
+ void removeCamera(osg::Camera* camera);
+
/** Add a camera to the group. The camera is added to the viewer
* as a slave. See osgViewer::Viewer::addSlave.
* @param flags properties of the camera; see CameraGroup::Flags