1
0
Fork 0

Merge branches 'jmt/navradio', 'jmt/cleanup' and 'torsten/gps-fix'

This commit is contained in:
Tim Moore 2009-10-01 15:17:24 +02:00
commit 8b10bb12f5
23 changed files with 245 additions and 374 deletions

View file

@ -44,6 +44,7 @@
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/viewmgr.hxx> #include <Main/viewmgr.hxx>
#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
#include <GUI/gui.h> #include <GUI/gui.h>

View file

@ -48,6 +48,7 @@
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
#include <Airports/runways.hxx> #include <Airports/runways.hxx>
#include <Main/viewer.hxx>
#include "hud.hxx" #include "hud.hxx"

View file

@ -6,7 +6,7 @@
#include "hud.hxx" #include "hud.hxx"
#include "panel.hxx" #include "panel.hxx"
#include <Main/viewer.hxx>
// FIXME // FIXME
extern float get_roll(void); extern float get_roll(void);

View file

@ -31,6 +31,7 @@
#include <Environment/environment.hxx> #include <Environment/environment.hxx>
#include <Environment/environment_mgr.hxx> #include <Environment/environment_mgr.hxx>
#include <ATCDCL/ATCutils.hxx> #include <ATCDCL/ATCutils.hxx>
#include <Main/viewer.hxx>
#include <osg/GLU> #include <osg/GLU>

View file

@ -31,6 +31,8 @@
# include <config.h> # include <config.h>
#endif #endif
#include "panel.hxx"
#include <stdio.h> // sprintf #include <stdio.h> // sprintf
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
@ -55,9 +57,11 @@
#include <Main/viewmgr.hxx> #include <Main/viewmgr.hxx>
#include <Time/light.hxx> #include <Time/light.hxx>
#include <GUI/new_gui.hxx> // FGFontCache #include <GUI/new_gui.hxx> // FGFontCache
#include <Main/viewer.hxx>
#include <Instrumentation/dclgps.hxx>
#include "hud.hxx" #include "hud.hxx"
#include "panel.hxx"
#define WIN_X 0 #define WIN_X 0
#define WIN_Y 0 #define WIN_Y 0

View file

@ -21,21 +21,10 @@
#ifndef __PANEL_HXX #ifndef __PANEL_HXX
#define __PANEL_HXX #define __PANEL_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/StateSet> #include <osg/StateSet>
#include <osg/Texture2D> #include <osg/Texture2D>
#include <plib/fnt.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
@ -48,16 +37,11 @@
#include <map> #include <map>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Instrumentation/dclgps.hxx>
using std::vector;
using std::map;
class FGPanelInstrument; class FGPanelInstrument;
class fntFont;
class DCLGPS;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Texture management. // Texture management.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -71,11 +55,11 @@ class FGPanelInstrument;
class FGTextureManager class FGTextureManager
{ {
public: public:
static osg::Texture2D* createTexture(const string &relativePath, static osg::Texture2D* createTexture(const std::string &relativePath,
bool staticTexture = true); bool staticTexture = true);
static void addTexture(const string &relativePath, osg::Texture2D* texture); static void addTexture(const std::string &relativePath, osg::Texture2D* texture);
private: private:
static map<string,osg::ref_ptr<osg::Texture2D> > _textureMap; static std::map<std::string,osg::ref_ptr<osg::Texture2D> > _textureMap;
}; };
@ -89,14 +73,14 @@ class FGCroppedTexture
public: public:
FGCroppedTexture (); FGCroppedTexture ();
FGCroppedTexture (const string &path, FGCroppedTexture (const std::string &path,
float _minX = 0.0, float _minY = 0.0, float _minX = 0.0, float _minY = 0.0,
float _maxX = 1.0, float _maxY = 1.0); float _maxX = 1.0, float _maxY = 1.0);
virtual ~FGCroppedTexture (); virtual ~FGCroppedTexture ();
virtual void setPath (const string &path) { _path = path; } virtual void setPath (const std::string &path) { _path = path; }
virtual const string &getPath () const { return _path; } virtual const std::string &getPath () const { return _path; }
virtual osg::StateSet* getTexture (); virtual osg::StateSet* getTexture ();
@ -111,7 +95,7 @@ public:
private: private:
string _path; std::string _path;
osg::ref_ptr<osg::StateSet> _texture; osg::ref_ptr<osg::StateSet> _texture;
float _minX, _minY, _maxX, _maxY; float _minX, _minY, _maxX, _maxY;
}; };
@ -199,7 +183,7 @@ private:
mutable int _mouseButton, _mouseX, _mouseY; mutable int _mouseButton, _mouseX, _mouseY;
mutable int _mouseDelay; mutable int _mouseDelay;
mutable FGPanelInstrument * _mouseInstrument; mutable FGPanelInstrument * _mouseInstrument;
typedef vector<FGPanelInstrument *> instrument_list_type; typedef std::vector<FGPanelInstrument *> instrument_list_type;
int _width; int _width;
int _height; int _height;
int _view_height; int _view_height;
@ -273,7 +257,7 @@ public:
virtual bool doAction (int updown); virtual bool doAction (int updown);
private: private:
typedef vector<SGBinding *> binding_list_t; typedef std::vector<SGBinding *> binding_list_t;
int _button; int _button;
int _x; int _x;
@ -356,7 +340,7 @@ public:
protected: protected:
int _w, _h; int _w, _h;
typedef vector<FGPanelTransformation *> transformation_list; typedef std::vector<FGPanelTransformation *> transformation_list;
transformation_list _transformations; transformation_list _transformations;
}; };
@ -403,7 +387,7 @@ public:
protected: protected:
int _x, _y, _w, _h; int _x, _y, _w, _h;
typedef vector<FGPanelAction *> action_list_type; typedef std::vector<FGPanelAction *> action_list_type;
action_list_type _actions; action_list_type _actions;
}; };
@ -430,7 +414,7 @@ public:
virtual void addTransformation (FGPanelTransformation * transformation); virtual void addTransformation (FGPanelTransformation * transformation);
protected: protected:
typedef vector<FGInstrumentLayer *> layer_list; typedef std::vector<FGInstrumentLayer *> layer_list;
layer_list _layers; layer_list _layers;
}; };
@ -473,7 +457,7 @@ public:
// transfer pointer ownership // transfer pointer ownership
virtual void addLayer (FGInstrumentLayer * layer); virtual void addLayer (FGInstrumentLayer * layer);
protected: protected:
vector<FGInstrumentLayer *> _layers; std::vector<FGInstrumentLayer *> _layers;
}; };
@ -526,17 +510,17 @@ public:
class Chunk : public SGConditional class Chunk : public SGConditional
{ {
public: public:
Chunk (const string &text, const string &fmt = "%s"); Chunk (const std::string &text, const std::string &fmt = "%s");
Chunk (ChunkType type, const SGPropertyNode * node, Chunk (ChunkType type, const SGPropertyNode * node,
const string &fmt = "", float mult = 1.0, float offs = 0.0, const std::string &fmt = "", float mult = 1.0, float offs = 0.0,
bool truncation = false); bool truncation = false);
const char * getValue () const; const char * getValue () const;
private: private:
ChunkType _type; ChunkType _type;
string _text; std::string _text;
SGConstPropertyNode_ptr _node; SGConstPropertyNode_ptr _node;
string _fmt; std::string _fmt;
float _mult; float _mult;
float _offs; float _offs;
bool _trunc; bool _trunc;
@ -552,20 +536,20 @@ public:
virtual void addChunk (Chunk * chunk); virtual void addChunk (Chunk * chunk);
virtual void setColor (float r, float g, float b); virtual void setColor (float r, float g, float b);
virtual void setPointSize (float size); virtual void setPointSize (float size);
virtual void setFontName ( const string &name ); virtual void setFontName ( const std::string &name );
virtual void setFont (fntFont * font); virtual void setFont (fntFont * font);
private: private:
void recalc_value () const; void recalc_value () const;
typedef vector<Chunk *> chunk_list; typedef std::vector<Chunk *> chunk_list;
chunk_list _chunks; chunk_list _chunks;
float _color[4]; float _color[4];
float _pointSize; float _pointSize;
mutable string _font_name; mutable std::string _font_name;
mutable string _value; mutable std::string _value;
mutable SGTimeStamp _then; mutable SGTimeStamp _then;
mutable SGTimeStamp _now; mutable SGTimeStamp _now;
}; };

View file

@ -29,8 +29,6 @@
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <plib/sg.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/math/interpolater.hxx> #include <simgear/math/interpolater.hxx>

View file

@ -30,8 +30,6 @@
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <plib/sg.h>
#include "ls_constants.h" #include "ls_constants.h"
#include "ls_types.h" #include "ls_types.h"
@ -43,6 +41,7 @@ CLASS DECLARATION
#define M_TO_FT 3.2808399 #define M_TO_FT 3.2808399
#define DEFAULT_AGL_ALT 3.758099 #define DEFAULT_AGL_ALT 3.758099
#define DEFAULT_PITCH_ON_GROUND 0.0074002 #define DEFAULT_PITCH_ON_GROUND 0.0074002
#define DEGREES_TO_RADIANS (M_PI / 180.0)
enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned }; enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned };
enum lsaltset { lssetasl, lssetagl }; enum lsaltset { lssetasl, lssetagl };
@ -71,7 +70,7 @@ public:
void SetAltitudeAGLFtIC(SCALAR tt); void SetAltitudeAGLFtIC(SCALAR tt);
//"vertical" flight path, recalculate theta //"vertical" flight path, recalculate theta
inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*SGD_DEGREES_TO_RADIANS); } inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*DEGREES_TO_RADIANS); }
void SetFlightPathAngleRadIC(SCALAR tt); void SetFlightPathAngleRadIC(SCALAR tt);
//set speed first //set speed first
@ -79,26 +78,26 @@ public:
void SetClimbRateFpsIC(SCALAR tt); void SetClimbRateFpsIC(SCALAR tt);
//use currently stored gamma, recalcualte theta //use currently stored gamma, recalcualte theta
inline void SetAlphaDegIC(SCALAR tt) { alpha=tt*SGD_DEGREES_TO_RADIANS; getTheta(); } inline void SetAlphaDegIC(SCALAR tt) { alpha=tt*DEGREES_TO_RADIANS; getTheta(); }
inline void SetAlphaRadIC(SCALAR tt) { alpha=tt; getTheta(); } inline void SetAlphaRadIC(SCALAR tt) { alpha=tt; getTheta(); }
//use currently stored gamma, recalcualte alpha //use currently stored gamma, recalcualte alpha
inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*SGD_DEGREES_TO_RADIANS); } inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*DEGREES_TO_RADIANS); }
void SetPitchAngleRadIC(SCALAR tt); void SetPitchAngleRadIC(SCALAR tt);
inline void SetBetaDegIC(SCALAR tt) { beta=tt*SGD_DEGREES_TO_RADIANS; getTheta();} inline void SetBetaDegIC(SCALAR tt) { beta=tt*DEGREES_TO_RADIANS; getTheta();}
inline void SetBetaRadIC(SCALAR tt) { beta=tt; getTheta(); } inline void SetBetaRadIC(SCALAR tt) { beta=tt; getTheta(); }
inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*SGD_DEGREES_TO_RADIANS; getTheta(); } inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*DEGREES_TO_RADIANS; getTheta(); }
inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); } inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); }
inline void SetHeadingDegIC(SCALAR tt) { psi=tt*SGD_DEGREES_TO_RADIANS; } inline void SetHeadingDegIC(SCALAR tt) { psi=tt*DEGREES_TO_RADIANS; }
inline void SetHeadingRadIC(SCALAR tt) { psi=tt; } inline void SetHeadingRadIC(SCALAR tt) { psi=tt; }
inline void SetLatitudeGDDegIC(SCALAR tt) { SetLatitudeGDRadIC(tt*SGD_DEGREES_TO_RADIANS); } inline void SetLatitudeGDDegIC(SCALAR tt) { SetLatitudeGDRadIC(tt*DEGREES_TO_RADIANS); }
void SetLatitudeGDRadIC(SCALAR tt); void SetLatitudeGDRadIC(SCALAR tt);
inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*SGD_DEGREES_TO_RADIANS; } inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*DEGREES_TO_RADIANS; }
inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; } inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; }
void SetRunwayAltitudeFtIC(SCALAR tt); void SetRunwayAltitudeFtIC(SCALAR tt);
@ -114,32 +113,32 @@ public:
inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; } inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; }
inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*DEGREES_TO_RADIANS; }
inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; } inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; }
inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; } inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; }
inline SCALAR GetClimbRateFpsIC(void) { return hdot; } inline SCALAR GetClimbRateFpsIC(void) { return hdot; }
inline SCALAR GetAlphaDegIC(void) { return alpha*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetAlphaDegIC(void) { return alpha*DEGREES_TO_RADIANS; }
inline SCALAR GetAlphaRadIC(void) { return alpha; } inline SCALAR GetAlphaRadIC(void) { return alpha; }
inline SCALAR GetPitchAngleDegIC(void) { return theta*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetPitchAngleDegIC(void) { return theta*DEGREES_TO_RADIANS; }
inline SCALAR GetPitchAngleRadIC(void) { return theta; } inline SCALAR GetPitchAngleRadIC(void) { return theta; }
inline SCALAR GetBetaDegIC(void) { return beta*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetBetaDegIC(void) { return beta*DEGREES_TO_RADIANS; }
inline SCALAR GetBetaRadIC(void) { return beta*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetBetaRadIC(void) { return beta*DEGREES_TO_RADIANS; }
inline SCALAR GetRollAngleDegIC(void) { return phi*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetRollAngleDegIC(void) { return phi*DEGREES_TO_RADIANS; }
inline SCALAR GetRollAngleRadIC(void) { return phi; } inline SCALAR GetRollAngleRadIC(void) { return phi; }
inline SCALAR GetHeadingDegIC(void) { return psi*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetHeadingDegIC(void) { return psi*DEGREES_TO_RADIANS; }
inline SCALAR GetHeadingRadIC(void) { return psi; } inline SCALAR GetHeadingRadIC(void) { return psi; }
inline SCALAR GetLatitudeGDDegIC(void) { return latitude_gd*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetLatitudeGDDegIC(void) { return latitude_gd*DEGREES_TO_RADIANS; }
inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; } inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; }
inline SCALAR GetLongitudeDegIC(void) { return longitude*SGD_RADIANS_TO_DEGREES; } inline SCALAR GetLongitudeDegIC(void) { return longitude*DEGREES_TO_RADIANS; }
inline SCALAR GetLongitudeRadIC(void) { return longitude; } inline SCALAR GetLongitudeRadIC(void) { return longitude; }
inline SCALAR GetUBodyFpsIC(void) { return vt*cos(alpha)*cos(beta); } inline SCALAR GetUBodyFpsIC(void) { return vt*cos(alpha)*cos(beta); }

View file

@ -35,6 +35,7 @@
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/viewmgr.hxx> #include <Main/viewmgr.hxx>
#include <Main/viewer.hxx>
#include "HUD.hxx" #include "HUD.hxx"

View file

@ -476,8 +476,9 @@ GPS::updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr nod
// increase. Makes most sense when travelling directly towards // increase. Makes most sense when travelling directly towards
// the waypoint. // the waypoint.
double TTW = 0.0; double TTW = 0.0;
if (ctx.speed_kt > 0.0 && distance_m > 0.0) { double speed_nm_per_second = ctx.speed_kt / 3600;
TTW = (distance_m * SG_METER_TO_NM) / (ctx.speed_kt / 3600); if (speed_nm_per_second > SGLimitsd::min() && distance_m > 0.0) {
TTW = (distance_m * SG_METER_TO_NM) / speed_nm_per_second;
} }
if (TTW < 356400.5) { // That's 99 hours if (TTW < 356400.5) { // That's 99 hours
unsigned int TTW_seconds = (int) (TTW + 0.5); unsigned int TTW_seconds = (int) (TTW + 0.5);

View file

@ -10,7 +10,6 @@
# include <config.h> # include <config.h>
#endif #endif
#include <plib/sg.h>
#include <simgear/sg_inlines.h> #include <simgear/sg_inlines.h>
#include "mag_compass.hxx" #include "mag_compass.hxx"

View file

@ -28,11 +28,6 @@
#include "render_area_2d.hxx" #include "render_area_2d.hxx"
static const float dummy_normals[][3] = {{0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f}};
RA2DPrimitive::RA2DPrimitive() { RA2DPrimitive::RA2DPrimitive() {
invert = false; invert = false;
debug = false; debug = false;
@ -184,13 +179,13 @@ void RenderArea2D::oldDrawPixel(int x, int y, bool invert) {
//cout << "DP: " << fx1 << ", " << fy1 << " ... " << fx2 << ", " << fy2 << '\n'; //cout << "DP: " << fx1 << ", " << fy1 << " ... " << fx2 << ", " << fy2 << '\n';
doSetColor(invert ? _backgroundColor : _pixelColor); doSetColor(invert ? _backgroundColor : _pixelColor);
sgVec2 corners[4]; SGVec2f corners[4] = {
sgSetVec2(corners[0], fx1, fy1); SGVec2f(fx1, fy1),
sgSetVec2(corners[1], fx2, fy1); SGVec2f(fx2, fy1),
sgSetVec2(corners[2], fx2, fy2); SGVec2f(fx2, fy2),
sgSetVec2(corners[3], fx1, fy2); SGVec2f(fx1, fy2)
//cout << "Drawing pixel, x,y is " << x << ", " << y << ", fx is [x1,x2,y1,y2] " << fx1 << ", " << fx2 << ", " << fy1 << ", " << fy2 << '\n'; };
doDrawQuad(&corners[0], dummy_normals); doDrawQuad(corners);
} }
void RenderArea2D::DrawLine(int x1, int y1, int x2, int y2) { void RenderArea2D::DrawLine(int x1, int y1, int x2, int y2) {
@ -314,12 +309,13 @@ void RenderArea2D::oldDrawQuad(int x1, int y1, int x2, int y2, bool invert) {
//cout << "DP: " << fx1 << ", " << fy1 << " ... " << fx2 << ", " << fy2 << '\n'; //cout << "DP: " << fx1 << ", " << fy1 << " ... " << fx2 << ", " << fy2 << '\n';
doSetColor(invert ? _backgroundColor : _pixelColor); doSetColor(invert ? _backgroundColor : _pixelColor);
sgVec2 corners[4]; SGVec2f corners[4] = {
sgSetVec2(corners[0], fx1, fy1); SGVec2f(fx1, fy1),
sgSetVec2(corners[1], fx2, fy1); SGVec2f(fx2, fy1),
sgSetVec2(corners[2], fx2, fy2); SGVec2f(fx2, fy2),
sgSetVec2(corners[3], fx1, fy2); SGVec2f(fx1, fy2)
doDrawQuad(&corners[0], dummy_normals); };
doDrawQuad(corners);
} }
void RenderArea2D::DrawBackground() { void RenderArea2D::DrawBackground() {
@ -328,12 +324,14 @@ void RenderArea2D::DrawBackground() {
void RenderArea2D::oldDrawBackground() { void RenderArea2D::oldDrawBackground() {
doSetColor(_backgroundColor); doSetColor(_backgroundColor);
sgVec2 corners[4]; SGVec2f corners[4] = {
sgSetVec2(corners[0], (float)_posx, (float)_posy); SGVec2f(_posx, _posy),
sgSetVec2(corners[1], (float)(_posx + _sizex), (float)_posy); SGVec2f(_posx + _sizex, _posy),
sgSetVec2(corners[2], (float)(_posx + _sizex), (float)(_posy + _sizey)); SGVec2f(_posx + _sizex, _posy + _sizey),
sgSetVec2(corners[3], (float)_posx, (float)(_posy + _sizey)); SGVec2f(_posx, _posy + _sizey)
doDrawQuad(&corners[0], dummy_normals); };
doDrawQuad(corners);
} }
void RenderArea2D::Flush() { void RenderArea2D::Flush() {
@ -351,20 +349,23 @@ void RenderArea2D::doSetColor( const float *rgba ) {
glColor4fv( rgba ); glColor4fv( rgba );
} }
void RenderArea2D::doDrawQuad( const sgVec2 *p, const sgVec3 *normals ) { void RenderArea2D::doDrawQuad( const SGVec2f *p) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glNormal3fv( normals[0] ); glVertex2fv( p[0] ); glNormal3f(0.0f, 0.0f, 0.0f);
glNormal3fv( normals[1] ); glVertex2fv( p[1] ); glVertex2fv( p[0].data() );
glNormal3fv( normals[2] ); glVertex2fv( p[2] ); glVertex2fv( p[1].data() );
glNormal3fv( normals[3] ); glVertex2fv( p[3] ); glVertex2fv( p[2].data() );
glVertex2fv( p[3].data() );
glEnd(); glEnd();
} }
void RenderArea2D::doDrawQuad( const sgVec2 *p, const sgVec3 *normals, const sgVec4 *color ) { void RenderArea2D::doDrawQuad( const SGVec2f *p, const SGVec4f *color ) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glColor4fv( color[0] );glNormal3fv( normals[0] ); glVertex2fv( p[0] ); glNormal3f(0.0f, 0.0f, 0.0f);
glColor4fv( color[1] );glNormal3fv( normals[1] ); glVertex2fv( p[1] ); glColor4fv( color[0].data() ); glVertex2fv( p[0].data() );
glColor4fv( color[2] );glNormal3fv( normals[2] ); glVertex2fv( p[2] ); glColor4fv( color[1].data() ); glVertex2fv( p[1].data() );
glColor4fv( color[3] );glNormal3fv( normals[3] ); glVertex2fv( p[3] ); glColor4fv( color[2].data() ); glVertex2fv( p[2].data() );
glColor4fv( color[3].data() ); glVertex2fv( p[3].data() );
glEnd(); glEnd();
} }

View file

@ -32,8 +32,8 @@
#include <osg/State> #include <osg/State>
#include <osg/StateSet> #include <osg/StateSet>
#include <plib/sg.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/SGMath.hxx>
#include <vector> #include <vector>
@ -106,8 +106,8 @@ private:
// Actual drawing routines copied from Atlas // Actual drawing routines copied from Atlas
void doSetColor( const float *rgb ); void doSetColor( const float *rgb );
void doDrawQuad( const sgVec2 *p, const sgVec3 *normals ); void doDrawQuad( const SGVec2f *p);
void doDrawQuad( const sgVec2 *p, const sgVec3 *normals, const sgVec4 *color ); void doDrawQuad( const SGVec2f *p, const SGVec4f *color );
vector<RA2DPrimitive> drawing_list; vector<RA2DPrimitive> drawing_list;

View file

@ -47,6 +47,7 @@
#include "util.hxx" #include "util.hxx"
#include "viewmgr.hxx" #include "viewmgr.hxx"
#include "main.hxx" #include "main.hxx"
#include <Main/viewer.hxx>
using std::string; using std::string;
using std::ifstream; using std::ifstream;

View file

@ -12,7 +12,7 @@
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Property management. // Property management.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

View file

@ -63,6 +63,7 @@
#include <Scenery/tilemgr.hxx> #include <Scenery/tilemgr.hxx>
#include <Sound/beacon.hxx> #include <Sound/beacon.hxx>
#include <Sound/morse.hxx> #include <Sound/morse.hxx>
#include <Sound/fg_fx.hxx>
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
#include <ATCDCL/ATCmgr.hxx> #include <ATCDCL/ATCmgr.hxx>
#include <ATCDCL/AIMgr.hxx> #include <ATCDCL/AIMgr.hxx>
@ -81,7 +82,7 @@
#include "fg_init.hxx" #include "fg_init.hxx"
#include "fg_os.hxx" #include "fg_os.hxx"
#include "WindowSystemAdapter.hxx" #include "WindowSystemAdapter.hxx"
#include <Main/viewer.hxx>
static double real_delta_time_sec = 0.0; static double real_delta_time_sec = 0.0;
double delta_time_sec = 0.0; double delta_time_sec = 0.0;
@ -451,13 +452,6 @@ static void fgMainLoop( void ) {
"Elapsed time is zero ... we're zinging" ); "Elapsed time is zero ... we're zinging" );
} }
// Run audio scheduler
#ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_soundmgr()->is_working() ) {
globals->get_soundmgr()->update( delta_time_sec );
}
#endif
globals->get_subsystem_mgr()->update(delta_time_sec); globals->get_subsystem_mgr()->update(delta_time_sec);
// //
@ -466,7 +460,6 @@ static void fgMainLoop( void ) {
// we may want to move this to its own class at some point // we may want to move this to its own class at some point
// //
double visibility_meters = fgGetDouble("/environment/visibility-m"); double visibility_meters = fgGetDouble("/environment/visibility-m");
FGViewer *current_view = globals->get_current_view();
globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters ); globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
// update tile manager for view... // update tile manager for view...
@ -484,123 +477,10 @@ static void fgMainLoop( void ) {
// update the view angle as late as possible, but before sound calculations // update the view angle as late as possible, but before sound calculations
globals->get_viewmgr()->update(real_delta_time_sec); globals->get_viewmgr()->update(real_delta_time_sec);
// Run audio scheduler
#ifdef ENABLE_AUDIO_SUPPORT #ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_soundmgr()->is_working() ) { FGFX* fx = (FGFX*) globals->get_subsystem("fx");
// Right now we make a simplifying assumption that the primary fx->update_fx_late(delta_time_sec);
// aircraft is the source of all sounds and that all sounds are
// positioned in the aircraft base
static sgdVec3 last_listener_pos = {0, 0, 0};
static sgdVec3 last_model_pos = {0, 0, 0};
// get the orientation
const SGQuatd view_or = current_view->getViewOrientation();
SGQuatd surf_or = SGQuatd::fromLonLat(current_view->getPosition());
SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
globals->get_aircraft_model()->get3DModel()->getHeadingDeg(),
globals->get_aircraft_model()->get3DModel()->getPitchDeg(),
globals->get_aircraft_model()->get3DModel()->getRollDeg());
// get the up and at vector in the aircraft base
// (ok, the up vector is a down vector, but the coordinates
// are finally calculated in a left hand system and openal
// lives in a right hand system. Therefore we need to pass
// the down vector to get correct stereo sound.)
SGVec3d sgv_up = model_or.rotateBack(
surf_or.rotateBack(view_or.rotate(SGVec3d(0, 1, 0))));
sgVec3 up;
sgSetVec3(up, sgv_up[0], sgv_up[1], sgv_up[2]);
SGVec3d sgv_at = model_or.rotateBack(
surf_or.rotateBack(view_or.rotate(SGVec3d(0, 0, 1))));
sgVec3 at;
sgSetVec3(at, sgv_at[0], sgv_at[1], sgv_at[2]);
// get the location data for the primary FDM (now hardcoded to ac model)...
SGGeod geodPos = globals->get_aircraft_model()->get3DModel()->getPosition();
SGVec3d model_pos = SGVec3d::fromGeod(geodPos);
// Calculate speed of listener and model. This code assumes the
// listener is either tracking the model at the same speed or
// stationary.
sgVec3 listener_vel, model_vel;
SGVec3d SGV3d_help;
sgdVec3 sgdv3_help;
sgdVec3 sgdv3_null = {0, 0, 0};
// the aircraft velocity as reported by the fdm (this will not
// vary or be affected by frame rates or timing jitter.)
sgVec3 fdm_vel_vec;
sgSetVec3( fdm_vel_vec,
vn_fps->getDoubleValue() * SG_FEET_TO_METER,
ve_fps->getDoubleValue() * SG_FEET_TO_METER,
vd_fps->getDoubleValue() * SG_FEET_TO_METER );
double fdm_vel = sgLengthVec3(fdm_vel_vec);
// compute the aircraft velocity vector and scale it to the length
// of the fdm velocity vector. This gives us a vector in the
// proper coordinate system, but also with the proper time
// invariant magnitude.
sgdSubVec3( sgdv3_help,
last_model_pos, model_pos.data());
sgdAddVec3( last_model_pos, sgdv3_null, model_pos.data());
SGV3d_help = model_or.rotateBack(
surf_or.rotateBack(SGVec3d(sgdv3_help[0],
sgdv3_help[1], sgdv3_help[2])));
sgSetVec3( model_vel, SGV3d_help[0], SGV3d_help[1], SGV3d_help[2]);
float vel = sgLengthVec3(model_vel);
if ( fabs(vel) > 0.0001 ) {
if ( fabs(fdm_vel / vel) > 0.0001 ) {
sgScaleVec3( model_vel, fdm_vel / vel );
}
}
// check for moving or stationary listener (view position)
sgdSubVec3( sgdv3_help,
last_listener_pos, current_view->get_view_pos().data());
sgdAddVec3( last_listener_pos,
sgdv3_null, current_view->get_view_pos().data());
if ( sgdLengthVec3(sgdv3_help) > 0.2 ) {
sgCopyVec3( listener_vel, model_vel );
} else {
sgSetVec3( listener_vel, 0.0, 0.0, 0.0 );
}
globals->get_soundmgr()->set_listener_vel( listener_vel );
// set positional offset for sources
sgdVec3 dsource_pos_offset;
sgdSubVec3( dsource_pos_offset,
current_view->get_view_pos().data(),
model_pos.data() );
SGVec3d sgv_dsource_pos_offset = model_or.rotateBack(
surf_or.rotateBack(SGVec3d(dsource_pos_offset[0],
dsource_pos_offset[1], dsource_pos_offset[2])));
sgVec3 source_pos_offset;
sgSetVec3(source_pos_offset, sgv_dsource_pos_offset[0],
sgv_dsource_pos_offset[1], sgv_dsource_pos_offset[2]);
globals->get_soundmgr()->set_source_pos_all( source_pos_offset );
float orient[6];
for (int i = 0; i < 3; i++) {
orient[i] = sgv_at[i];
orient[i + 3] = sgv_up[i];
}
globals->get_soundmgr()->set_listener_orientation( orient );
// set the velocity
// all sources are defined to be in the model
globals->get_soundmgr()->set_source_vel_all( model_vel );
// The listener is always positioned at the origin.
sgVec3 listener_pos;
sgSetVec3( listener_pos, 0.0, 0.0, 0.0 );
globals->get_soundmgr()->set_listener_pos( listener_pos );
}
#endif #endif
// END Tile Manager udpates // END Tile Manager udpates

View file

@ -60,7 +60,7 @@
#include "options.hxx" #include "options.hxx"
#include "util.hxx" #include "util.hxx"
#include "viewmgr.hxx" #include "viewmgr.hxx"
#include <Main/viewer.hxx>
using std::string; using std::string;
using std::sort; using std::sort;

View file

@ -99,6 +99,7 @@
#include "main.hxx" #include "main.hxx"
#include "CameraGroup.hxx" #include "CameraGroup.hxx"
#include "FGEventHandler.hxx" #include "FGEventHandler.hxx"
#include <Main/viewer.hxx>
using namespace osg; using namespace osg;
using namespace simgear; using namespace simgear;

View file

@ -27,11 +27,6 @@
#ifndef _VIEWER_HXX #ifndef _VIEWER_HXX
#define _VIEWER_HXX #define _VIEWER_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
namespace flightgear namespace flightgear
{ {
class CameraGroup; class CameraGroup;

View file

@ -25,14 +25,14 @@
# include "config.h" # include "config.h"
#endif #endif
#include "viewmgr.hxx"
#include <string.h> // strcmp #include <string.h> // strcmp
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <Model/acmodel.hxx> #include <Model/acmodel.hxx>
#include <Main/viewer.hxx>
#include "viewmgr.hxx" #include <Main/fg_props.hxx>
// Constructor // Constructor
FGViewMgr::FGViewMgr( void ) : FGViewMgr::FGViewMgr( void ) :
@ -341,6 +341,70 @@ FGViewMgr::copyToCurrent()
get_current_view()->getInternal()); get_current_view()->getInternal());
} }
void FGViewMgr::clear()
{
views.clear();
}
FGViewer*
FGViewMgr::get_current_view()
{
if ( current < (int)views.size() ) {
return views[current];
} else {
return NULL;
}
}
const FGViewer*
FGViewMgr::get_current_view() const
{
if ( current < (int)views.size() ) {
return views[current];
} else {
return NULL;
}
}
FGViewer*
FGViewMgr::get_view( int i )
{
if ( i < 0 ) { i = 0; }
if ( i >= (int)views.size() ) { i = views.size() - 1; }
return views[i];
}
const FGViewer*
FGViewMgr::get_view( int i ) const
{
if ( i < 0 ) { i = 0; }
if ( i >= (int)views.size() ) { i = views.size() - 1; }
return views[i];
}
FGViewer*
FGViewMgr::next_view()
{
setView((current+1 < (int)views.size()) ? (current + 1) : 0);
view_number->fireValueChanged();
return views[current];
}
FGViewer*
FGViewMgr::prev_view()
{
setView((0 < current) ? (current - 1) : (views.size() - 1));
view_number->fireValueChanged();
return views[current];
}
void
FGViewMgr::add_view( FGViewer * v )
{
views.push_back(v);
v->init();
}
double double
FGViewMgr::getViewHeadingOffset_deg () const FGViewMgr::getViewHeadingOffset_deg () const

View file

@ -28,16 +28,11 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/SGMath.hxx>
#ifdef HAVE_CONFIG_H // forward decls
# include <config.h> class FGViewer;
#endif typedef SGSharedPtr<FGViewer> FGViewerPtr;
#include "fg_props.hxx"
#include "viewer.hxx"
using std::vector;
// Define a structure containing view information // Define a structure containing view information
class FGViewMgr : public SGSubsystem class FGViewMgr : public SGSubsystem
@ -60,48 +55,21 @@ public:
// getters // getters
inline int size() const { return views.size(); } inline int size() const { return views.size(); }
inline int get_current() const { return current; } inline int get_current() const { return current; }
inline FGViewer *get_current_view() {
if ( current < (int)views.size() ) { FGViewer *get_current_view();
return views[current]; const FGViewer *get_current_view() const;
} else {
return NULL; FGViewer *get_view( int i );
} const FGViewer *get_view( int i ) const;
}
inline const FGViewer *get_current_view() const { FGViewer *next_view();
if ( current < (int)views.size() ) { FGViewer *prev_view();
return views[current];
} else {
return NULL;
}
}
inline FGViewer *get_view( int i ) {
if ( i < 0 ) { i = 0; }
if ( i >= (int)views.size() ) { i = views.size() - 1; }
return views[i];
}
inline const FGViewer *get_view( int i ) const {
if ( i < 0 ) { i = 0; }
if ( i >= (int)views.size() ) { i = views.size() - 1; }
return views[i];
}
inline FGViewer *next_view() {
setView((current+1 < (int)views.size()) ? (current + 1) : 0);
view_number->fireValueChanged();
return views[current];
}
inline FGViewer *prev_view() {
setView((0 < current) ? (current - 1) : (views.size() - 1));
view_number->fireValueChanged();
return views[current];
}
// setters // setters
inline void clear() { views.clear(); } void clear();
inline void set_view( const int v ) { current = v; } inline void set_view( const int v ) { current = v; }
inline void add_view( FGViewer * v ) { void add_view( FGViewer * v );
views.push_back(v);
v->init();
}
// copies current offset settings to current-view path... // copies current offset settings to current-view path...
void copyToCurrent (); void copyToCurrent ();
@ -150,7 +118,7 @@ private:
SGPropertyNode_ptr view_number; SGPropertyNode_ptr view_number;
vector<SGPropertyNode_ptr> config_list; vector<SGPropertyNode_ptr> config_list;
typedef vector<SGSharedPtr<FGViewer> > viewer_list; typedef std::vector<FGViewerPtr> viewer_list;
viewer_list views; viewer_list views;
SGVec3d abs_viewer_position; SGVec3d abs_viewer_position;

View file

@ -29,11 +29,14 @@
# include <config.h> # include <config.h>
#endif #endif
#include "fg_fx.hxx"
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/sound/xmlsound.hxx> #include <simgear/sound/xmlsound.hxx>
#include <simgear/sound/soundmgr_openal.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
@ -41,17 +44,14 @@
#include <Model/acmodel.hxx> #include <Model/acmodel.hxx>
#include <Main/viewer.hxx> #include <Main/viewer.hxx>
#include "fg_fx.hxx"
FGFX::FGFX () : FGFX::FGFX () :
last_visitor_pos(SGVec3d::zeros()),
last_model_pos(SGVec3d::zeros()),
last_pause( true ), last_pause( true ),
last_volume( 0.0 ), last_volume( 0.0 ),
_pause( fgGetNode("/sim/sound/pause") ), _pause( fgGetNode("/sim/sound/pause") ),
_volume( fgGetNode("/sim/sound/volume") ) _volume( fgGetNode("/sim/sound/volume") )
{ {
sgdSetVec3(last_visitor_pos, 0, 0, 0);
sgdSetVec3(last_model_pos, 0, 0, 0);
} }
FGFX::~FGFX () FGFX::~FGFX ()
@ -137,12 +137,6 @@ FGFX::update (double dt)
return; return;
} }
#if 0
// moved back to the mainloop to prevent audio problems
smgr->update(dt);
update_pos_and_orientation(smgr, dt);
#endif
// command sound manger // command sound manger
bool pause = _pause->getBoolValue(); bool pause = _pause->getBoolValue();
if ( pause != last_pause ) { if ( pause != last_pause ) {
@ -190,6 +184,18 @@ FGFX::update (double dt)
} }
} }
void
FGFX::update_fx_late(double dt)
{
SGSoundMgr *smgr = globals->get_soundmgr();
if (!smgr->is_working()) {
return;
}
smgr->update(dt);
update_pos_and_orientation(smgr, dt);
}
/** /**
* add a sound sample to the message queue which is played sequentially * add a sound sample to the message queue which is played sequentially
* in order. * in order.
@ -200,7 +206,7 @@ FGFX::play_message( SGSoundSample *_sample )
_samplequeue.push( _sample ); _samplequeue.push( _sample );
} }
void void
FGFX::play_message( const string path, const string fname, double volume ) FGFX::play_message( const std::string& path, const std::string& fname, double volume )
{ {
if (globals->get_soundmgr()->is_working() == true) { if (globals->get_soundmgr()->is_working() == true) {
SGSoundSample *sample; SGSoundSample *sample;
@ -237,87 +243,50 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
// are finally calculated in a left hand system and openal // are finally calculated in a left hand system and openal
// lives in a right hand system. Therefore we need to pass // lives in a right hand system. Therefore we need to pass
// the down vector to get correct stereo sound.) // the down vector to get correct stereo sound.)
SGVec3d sgv_up, sgv_at; SGVec3d sgv_up
sgVec3 up, at;
sgv_up
= model_or.rotateBack(surf_or.rotateBack(view_or.rotate(SGVec3d(0,1,0)))); = model_or.rotateBack(surf_or.rotateBack(view_or.rotate(SGVec3d(0,1,0))));
sgSetVec3(up, sgv_up[0], sgv_up[1], sgv_up[2]); SGVec3d sgv_at
sgv_at
= model_or.rotateBack(surf_or.rotateBack(view_or.rotate(SGVec3d(0,0,1)))); = model_or.rotateBack(surf_or.rotateBack(view_or.rotate(SGVec3d(0,0,1))));
sgSetVec3(at, sgv_at[0], sgv_at[1], sgv_at[2]);
// get the location data for the primary FDM (now hardcoded to ac model)... // get the location data for the primary FDM (now hardcoded to ac model)...
// EMH: to add multiple sound sources this should be replaced // EMH: to add multiple sound sources this should be replaced
SGVec3d absolute_view_pos = SGVec3d::fromGeod(model->getPosition()); SGVec3d absolute_view_pos = SGVec3d::fromGeod(model->getPosition());
// calculate speed of visitor and model // calculate speed of visitor and model
sgVec3 listener_vel, model_vel; SGVec3d moved = last_visitor_pos - observer->get_view_pos();
SGVec3d SGV3d_help; last_visitor_pos = observer->get_view_pos();
sgdVec3 sgdv3_help; SGVec3f listener_vel(model_or.rotateBack(surf_or.rotateBack(moved)));
sgdVec3 sgdv3_null = {0, 0, 0};
moved = last_model_pos - absolute_view_pos;
sgdSubVec3(sgdv3_help, last_model_pos = absolute_view_pos;
last_visitor_pos, (double *)&observer->get_view_pos()); SGVec3f model_vel(model_or.rotateBack(surf_or.rotateBack(moved)));
sgdAddVec3(last_visitor_pos,
sgdv3_null, (double *)&observer->get_view_pos());
SGV3d_help = model_or.rotateBack(
surf_or.rotateBack(
SGVec3d(sgdv3_help[0], sgdv3_help[1], sgdv3_help[2])
));
sgSetVec3(listener_vel, SGV3d_help[0], SGV3d_help[1], SGV3d_help[2]);
sgdSubVec3(sgdv3_help, last_model_pos, absolute_view_pos.data());
sgdAddVec3(last_model_pos, sgdv3_null, absolute_view_pos.data());
SGV3d_help = model_or.rotateBack(
surf_or.rotateBack(
SGVec3d(sgdv3_help[0], sgdv3_help[1], sgdv3_help[2])
));
sgSetVec3( model_vel, SGV3d_help[0], SGV3d_help[1], SGV3d_help[2]);
if (dt > 0) { if (dt > 0) {
sgScaleVec3( model_vel, 1 / dt ); model_vel /= dt;
sgScaleVec3( listener_vel, 1 / dt ); listener_vel /= dt;
} }
// checking, if the listener pos has moved suddenly // checking, if the listener pos has moved suddenly
if (sgLengthVec3(listener_vel) > 1000) if (length(listener_vel) > 1000) {
{
// check if the relative speed model vs listener has moved suddenly, too // check if the relative speed model vs listener has moved suddenly, too
sgVec3 delta_vel; SGVec3f delta_vel = listener_vel - model_vel;
sgSubVec3(delta_vel, listener_vel, model_vel); if (length(delta_vel) > 1000)
if (sgLengthVec3(delta_vel) > 1000)
// a sane value // a sane value
sgSetVec3(listener_vel, model_vel[0], model_vel[1], model_vel[2]); smgr->set_listener_vel(model_vel.data());
else else
smgr->set_listener_vel(listener_vel); smgr->set_listener_vel(listener_vel.data());
} else {
smgr->set_listener_vel( listener_vel.data());
} }
else
smgr->set_listener_vel( listener_vel );
// set positional offset for sources // set positional offset for sources
sgdVec3 dsource_pos_offset; SGVec3d dsource_pos_offset = observer->get_view_pos() - absolute_view_pos;
sgdSubVec3( dsource_pos_offset, dsource_pos_offset = model_or.rotateBack(surf_or.rotateBack(
(double*) &observer->get_view_pos(), dsource_pos_offset
absolute_view_pos.data() );
SGVec3d sgv_dsource_pos_offset;
sgv_dsource_pos_offset = model_or.rotateBack(
surf_or.rotateBack(
SGVec3d(dsource_pos_offset[0],
dsource_pos_offset[1],
dsource_pos_offset[2])
)); ));
sgVec3 source_pos_offset;
sgSetVec3(source_pos_offset,
sgv_dsource_pos_offset[0],
sgv_dsource_pos_offset[1],
sgv_dsource_pos_offset[2]);
smgr->set_source_pos_all( source_pos_offset ); smgr->set_source_pos_all( SGVec3f(dsource_pos_offset).data() );
smgr->set_source_vel_all( model_vel ); smgr->set_source_vel_all(model_vel.data() );
float orient[6]; float orient[6];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -327,9 +296,7 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
smgr->set_listener_orientation( orient ); smgr->set_listener_orientation( orient );
// The listener is always positioned at the origin. // The listener is always positioned at the origin.
sgVec3 listener_pos; smgr->set_listener_pos( SGVec3f::zeros().data() );
sgSetVec3( listener_pos, 0.0, 0.0, 0.0 );
smgr->set_listener_pos( listener_pos );
} }
// end of fg_fx.cxx // end of fg_fx.cxx

View file

@ -29,13 +29,12 @@
#include <queue> #include <queue>
#include <vector> #include <vector>
#include <simgear/sound/sample_openal.hxx>
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/SGMath.hxx>
using std::queue;
using std::vector;
class SGXmlSound; class SGXmlSound;
class SGSoundSample;
class SGSoundMgr;
/** /**
* Generator for FlightGear sound effects. * Generator for FlightGear sound effects.
@ -72,16 +71,22 @@ public:
* in order. * in order.
*/ */
void play_message( SGSoundSample *_sample ); void play_message( SGSoundSample *_sample );
void play_message( const string path, const string fname, double volume ); void play_message( const std::string& path, const std::string& fname, double volume );
/**
* Explicit late update hook, to avoid problems which occur if done during
* normal SGSubsytem updating.
*/
void update_fx_late(double dt);
private: private:
void update_pos_and_orientation(SGSoundMgr *smgr, double dt); void update_pos_and_orientation(SGSoundMgr *smgr, double dt);
sgdVec3 last_visitor_pos; SGVec3d last_visitor_pos;
sgdVec3 last_model_pos; SGVec3d last_model_pos;
vector<SGXmlSound *> _sound; std::vector<SGXmlSound *> _sound;
queue<SGSoundSample *> _samplequeue; std::queue<SGSoundSample *> _samplequeue;
bool last_pause; bool last_pause;
double last_volume; double last_volume;