Tweak ODGauge usage, fix multiple instances of NavDisplay or wxRadar.
This commit is contained in:
parent
0a1417e06d
commit
96ee2b1577
13 changed files with 50 additions and 84 deletions
|
@ -418,7 +418,6 @@ NavDisplay::NavDisplay(SGPropertyNode *node) :
|
|||
_odg(0),
|
||||
_scale(0),
|
||||
_view_heading(0),
|
||||
_resultTexture(0),
|
||||
_font_size(0),
|
||||
_font_spacing(0),
|
||||
_rangeNm(0)
|
||||
|
@ -485,9 +484,9 @@ NavDisplay::NavDisplay(SGPropertyNode *node) :
|
|||
|
||||
NavDisplay::~NavDisplay()
|
||||
{
|
||||
delete _odg;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NavDisplay::init ()
|
||||
{
|
||||
|
@ -517,7 +516,6 @@ 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");
|
||||
|
@ -529,8 +527,7 @@ NavDisplay::init ()
|
|||
// 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"));
|
||||
|
|
|
@ -147,7 +147,6 @@ private:
|
|||
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;
|
||||
|
|
|
@ -213,7 +213,7 @@ agRadar::getMaterial(){
|
|||
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();
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
const SGMaterial* _material;
|
||||
|
||||
string _mat_name; // ground material
|
||||
std::string _mat_name; // ground material
|
||||
|
||||
SGVec3d getCartUserPos() const;
|
||||
SGVec3d getCartAntennaPos()const;
|
||||
|
|
|
@ -77,6 +77,11 @@ GroundRadar::~GroundRadar()
|
|||
_range_node->removeChangeListener(this);
|
||||
}
|
||||
|
||||
void GroundRadar::update (double /* dt */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GroundRadar::valueChanged(SGPropertyNode*)
|
||||
{
|
||||
updateTexture();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <osg/Geometry>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include "od_gauge.hxx"
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
// forward decls
|
||||
class FGRunwayBase;
|
||||
|
@ -32,7 +33,7 @@ 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;
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
virtual ~GroundRadar();
|
||||
void updateTexture();
|
||||
virtual void valueChanged(SGPropertyNode*);
|
||||
|
||||
virtual void update (double dt);
|
||||
protected:
|
||||
void createTexture(const char* texture_name);
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#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"
|
||||
|
@ -56,9 +55,7 @@
|
|||
|
||||
FGInstrumentMgr::FGInstrumentMgr () :
|
||||
_explicitGps(false)
|
||||
{
|
||||
set_subsystem("od_gauge", new FGODGauge);
|
||||
|
||||
{
|
||||
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
|
||||
}
|
||||
|
||||
|
@ -138,7 +135,7 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
|
|||
subsystemname << '['<< index << ']';
|
||||
string id = subsystemname.str();
|
||||
_instruments.push_back(id);
|
||||
|
||||
|
||||
if ( name == "adf" ) {
|
||||
set_subsystem( id, new ADF( node ), 0.15 );
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/Camera>
|
||||
|
@ -46,12 +47,12 @@
|
|||
#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);
|
||||
|
@ -87,65 +88,25 @@ void FGODGauge::allocRT () {
|
|||
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;
|
||||
FGODGauge::~FGODGauge()
|
||||
{
|
||||
if (camera.valid()) {
|
||||
globals->get_renderer()->removeCamera(camera.get());
|
||||
}
|
||||
}
|
||||
|
||||
void FGODGauge::init () {
|
||||
}
|
||||
|
||||
void FGODGauge::update (double dt) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,23 +25,24 @@
|
|||
#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; }
|
||||
|
|
|
@ -119,6 +119,7 @@ wxRadarBg::wxRadarBg(SGPropertyNode *node) :
|
|||
wxRadarBg::~wxRadarBg ()
|
||||
{
|
||||
_font_node->removeChangeListener(this);
|
||||
delete _odg;
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,8 +156,7 @@ wxRadarBg::init ()
|
|||
// 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);
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
class FGODGauge;
|
||||
|
||||
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener {
|
||||
|
@ -78,7 +75,7 @@ protected:
|
|||
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;
|
||||
|
|
|
@ -1838,6 +1838,12 @@ FGRenderer::addCamera(osg::Camera* camera, bool useSceneData)
|
|||
mRealRoot->addChild(camera);
|
||||
}
|
||||
|
||||
void
|
||||
FGRenderer::removeCamera(osg::Camera* camera)
|
||||
{
|
||||
mRealRoot->removeChild(camera);
|
||||
}
|
||||
|
||||
void
|
||||
FGRenderer::setPlanes( double zNear, double zFar )
|
||||
{
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
*/
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue