- avoids confusion with osgViewer and fgviewer application.
(source files to be renamed in a follow-up commit)
void HUD::draw3D()
{
using namespace osg;
- FGViewer* view = globals->get_current_view();
+ flightgear::View* view = globals->get_current_view();
// Standard fgfs projection, with essentially meaningless clip
// planes (we'll map the whole HUD plane to z=-1)
// double po = curr_view->getPitchOffset_deg();
// double ho = curr_view->getHeadingOffset_deg();
- FGViewer* cockpitView = globals->get_viewmgr()->get_view(0);
+ flightgear::View* cockpitView = globals->get_viewmgr()->get_view(0);
double yaw = -(cockpitView->getHeadingOffset_deg() - _default_heading) * SG_DEGREES_TO_RADIANS;
double pitch = (cockpitView->getPitchOffset_deg() - _default_pitch) * SG_DEGREES_TO_RADIANS;
return get_subsystem<FGViewMgr>();
}
-FGViewer* FGGlobals::get_current_view () const
+flightgear::View* FGGlobals::get_current_view () const
{
FGViewMgr* vm = get_viewmgr();
return vm ? vm->get_current_view() : 0;
class FGScenery;
class FGTileMgr;
class FGViewMgr;
-class FGViewer;
class FGRenderer;
namespace simgear { namespace pkg {
class Root;
}}
+namespace flightgear
+{
+ class View;
+}
+
/**
* Bucket for subsystem pointers representing the sim's state.
*/
}
FGViewMgr *get_viewmgr() const;
- FGViewer *get_current_view() const;
+ flightgear::View *get_current_view() const;
FGControls *get_controls() const;
Camera* camera = info->getCamera(MAIN_CAMERA);
if ( camera ) {
- const View::Slave& slave = _viewer->getSlave(info->getMainSlaveIndex());
+ const osg::View::Slave& slave = _viewer->getSlave(info->getMainSlaveIndex());
Matrix viewMatrix;
if (info->flags & GUI) {
Camera* camera = ii->second.camera.get();
int slaveIndex = ii->second.slaveIndex;
- const View::Slave& slave = _viewer->getSlave(slaveIndex);
+ const osg::View::Slave& slave = _viewer->getSlave(slaveIndex);
if ( !viewDone ) {
if ((info->flags & VIEW_ABSOLUTE) != 0)
// initializations and are running the main loop, so this will
// now work without seg faulting the system.
- FGViewer *current__view = globals->get_current_view();
+ flightgear::View *current__view = globals->get_current_view();
// Force update of center dependent values ...
current__view->set_dirty();
VisibleSceneInfoVistor vsv;
Viewport* vp = 0;
if (!viewer->getCamera()->getViewport() && viewer->getNumSlaves() > 0) {
- const View::Slave& slave = viewer->getSlave(0);
+ const osg::View::Slave& slave = viewer->getSlave(0);
vp = slave._camera->getViewport();
}
vsv.doTraversal(viewer->getCamera(), viewer->getSceneData(), vp);
////////////////////////////////////////////////////////////////////////
// Constructor...
-FGViewer::FGViewer( ViewType Type, bool from_model, int from_model_index,
+View::View( ViewType Type, bool from_model, int from_model_index,
bool at_model, int at_model_index,
double damp_roll, double damp_pitch, double damp_heading,
double x_offset_m, double y_offset_m, double z_offset_m,
// Destructor
-FGViewer::~FGViewer( void ) {
+View::~View( void ) {
}
void
-FGViewer::init ()
+View::init ()
{
}
void
-FGViewer::bind ()
+View::bind ()
{
}
void
-FGViewer::unbind ()
+View::unbind ()
{
}
void
-FGViewer::setType ( int type )
+View::setType ( int type )
{
if (type == 0)
_type = FG_LOOKFROM;
}
void
-FGViewer::setInternal ( bool internal )
+View::setInternal ( bool internal )
{
_internal = internal;
}
void
-FGViewer::setPosition (double lon_deg, double lat_deg, double alt_ft)
+View::setPosition (double lon_deg, double lat_deg, double alt_ft)
{
_dirty = true;
_position = SGGeod::fromDegFt(lon_deg, lat_deg, alt_ft);
}
void
-FGViewer::setTargetPosition (double lon_deg, double lat_deg, double alt_ft)
+View::setTargetPosition (double lon_deg, double lat_deg, double alt_ft)
{
_dirty = true;
_target = SGGeod::fromDegFt(lon_deg, lat_deg, alt_ft);
}
void
-FGViewer::setRoll_deg (double roll_deg)
+View::setRoll_deg (double roll_deg)
{
_dirty = true;
_roll_deg = roll_deg;
}
void
-FGViewer::setPitch_deg (double pitch_deg)
+View::setPitch_deg (double pitch_deg)
{
_dirty = true;
_pitch_deg = pitch_deg;
}
void
-FGViewer::setHeading_deg (double heading_deg)
+View::setHeading_deg (double heading_deg)
{
_dirty = true;
_heading_deg = heading_deg;
}
void
-FGViewer::setOrientation (double roll_deg, double pitch_deg, double heading_deg)
+View::setOrientation (double roll_deg, double pitch_deg, double heading_deg)
{
_dirty = true;
_roll_deg = roll_deg;
}
void
-FGViewer::setTargetRoll_deg (double target_roll_deg)
+View::setTargetRoll_deg (double target_roll_deg)
{
_dirty = true;
_target_roll_deg = target_roll_deg;
}
void
-FGViewer::setTargetPitch_deg (double target_pitch_deg)
+View::setTargetPitch_deg (double target_pitch_deg)
{
_dirty = true;
_target_pitch_deg = target_pitch_deg;
}
void
-FGViewer::setTargetHeading_deg (double target_heading_deg)
+View::setTargetHeading_deg (double target_heading_deg)
{
_dirty = true;
_target_heading_deg = target_heading_deg;
}
void
-FGViewer::setTargetOrientation (double target_roll_deg, double target_pitch_deg, double target_heading_deg)
+View::setTargetOrientation (double target_roll_deg, double target_pitch_deg, double target_heading_deg)
{
_dirty = true;
_target_roll_deg = target_roll_deg;
}
void
-FGViewer::setXOffset_m (double x_offset_m)
+View::setXOffset_m (double x_offset_m)
{
_dirty = true;
_offset_m.x() = x_offset_m;
}
void
-FGViewer::setYOffset_m (double y_offset_m)
+View::setYOffset_m (double y_offset_m)
{
_dirty = true;
_offset_m.y() = y_offset_m;
}
void
-FGViewer::setZOffset_m (double z_offset_m)
+View::setZOffset_m (double z_offset_m)
{
_dirty = true;
_offset_m.z() = z_offset_m;
}
void
-FGViewer::setTargetXOffset_m (double target_x_offset_m)
+View::setTargetXOffset_m (double target_x_offset_m)
{
_dirty = true;
_target_offset_m.x() = target_x_offset_m;
}
void
-FGViewer::setTargetYOffset_m (double target_y_offset_m)
+View::setTargetYOffset_m (double target_y_offset_m)
{
_dirty = true;
_target_offset_m.y() = target_y_offset_m;
}
void
-FGViewer::setTargetZOffset_m (double target_z_offset_m)
+View::setTargetZOffset_m (double target_z_offset_m)
{
_dirty = true;
_target_offset_m.z() = target_z_offset_m;
}
void
-FGViewer::setPositionOffsets (double x_offset_m, double y_offset_m, double z_offset_m)
+View::setPositionOffsets (double x_offset_m, double y_offset_m, double z_offset_m)
{
_dirty = true;
_offset_m.x() = x_offset_m;
}
void
-FGViewer::setRollOffset_deg (double roll_offset_deg)
+View::setRollOffset_deg (double roll_offset_deg)
{
_dirty = true;
_roll_offset_deg = roll_offset_deg;
}
void
-FGViewer::setPitchOffset_deg (double pitch_offset_deg)
+View::setPitchOffset_deg (double pitch_offset_deg)
{
_dirty = true;
_pitch_offset_deg = pitch_offset_deg;
}
void
-FGViewer::setHeadingOffset_deg (double heading_offset_deg)
+View::setHeadingOffset_deg (double heading_offset_deg)
{
_dirty = true;
if (_at_model && (_offset_m.x() == 0.0)&&(_offset_m.z() == 0.0))
}
void
-FGViewer::setGoalRollOffset_deg (double goal_roll_offset_deg)
+View::setGoalRollOffset_deg (double goal_roll_offset_deg)
{
_dirty = true;
_goal_roll_offset_deg = goal_roll_offset_deg;
}
void
-FGViewer::setGoalPitchOffset_deg (double goal_pitch_offset_deg)
+View::setGoalPitchOffset_deg (double goal_pitch_offset_deg)
{
_dirty = true;
_goal_pitch_offset_deg = goal_pitch_offset_deg;
}
void
-FGViewer::setGoalHeadingOffset_deg (double goal_heading_offset_deg)
+View::setGoalHeadingOffset_deg (double goal_heading_offset_deg)
{
_dirty = true;
if (_at_model && (_offset_m.x() == 0.0)&&(_offset_m.z() == 0.0))
}
void
-FGViewer::setOrientationOffsets (double roll_offset_deg, double pitch_offset_deg, double heading_offset_deg)
+View::setOrientationOffsets (double roll_offset_deg, double pitch_offset_deg, double heading_offset_deg)
{
_dirty = true;
_roll_offset_deg = roll_offset_deg;
// cached data "dirty") on the next "get". It calculates all the outputs
// for viewer.
void
-FGViewer::recalc ()
+View::recalc ()
{
if (_type == FG_LOOKFROM) {
recalcLookFrom();
// recalculate for LookFrom view type...
void
-FGViewer::recalcLookFrom ()
+View::recalcLookFrom ()
{
// Update location data ...
if ( _from_model ) {
}
void
-FGViewer::recalcLookAt ()
+View::recalcLookAt ()
{
// The geodetic position of our target to look at
if ( _at_model ) {
}
void
-FGViewer::setDampTarget(double roll, double pitch, double heading)
+View::setDampTarget(double roll, double pitch, double heading)
{
_dampTarget = SGVec3d(roll, pitch, heading);
}
void
-FGViewer::getDampOutput(double& roll, double& pitch, double& heading)
+View::getDampOutput(double& roll, double& pitch, double& heading)
{
roll = _dampOutput[0];
pitch = _dampOutput[1];
void
-FGViewer::updateDampOutput(double dt)
+View::updateDampOutput(double dt)
{
- static FGViewer *last_view = 0;
+ static View *last_view = 0;
if ((last_view != this) || (dt > 1.0)) {
_dampOutput = _dampTarget;
last_view = this;
}
double
-FGViewer::get_h_fov()
+View::get_h_fov()
{
double aspectRatio = get_aspect_ratio();
switch (_scaling_type) {
double
-FGViewer::get_v_fov()
+View::get_v_fov()
{
double aspectRatio = get_aspect_ratio();
switch (_scaling_type) {
}
void
-FGViewer::update (double dt)
+View::update (double dt)
{
updateDampOutput(dt);
recalc();
}
-double FGViewer::get_aspect_ratio() const
+double View::get_aspect_ratio() const
{
return flightgear::CameraGroup::getDefault()->getMasterAspectRatio();
}
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9
+namespace flightgear
+{
+
// Define a structure containing view information
-class FGViewer : public SGSubsystem {
+class View : public SGSubsystem {
public:
// Constructor
- FGViewer( ViewType Type, bool from_model, int from_model_index,
+ View( ViewType Type, bool from_model, int from_model_index,
bool at_model, int at_model_index,
double damp_roll, double damp_pitch, double damp_heading,
double x_offset_m, double y_offset_m, double z_offset_m,
double target_z_offset_m, double near_m, bool internal );
// Destructor
- virtual ~FGViewer( void );
+ virtual ~View();
//////////////////////////////////////////////////////////////////////
// Part 1: standard SGSubsystem implementation.
_roll_offset_deg += amt;
}
-};
+}; // of class View
+
+} // of namespace flightgear
#endif // _VIEWER_HXX
double target_y_offset_m = config->getDoubleValue("target-y-offset-m");
double target_z_offset_m = config->getDoubleValue("target-z-offset-m");
- add_view(new FGViewer ( FGViewer::FG_LOOKAT, from_model, from_model_index,
+ add_view(new flightgear::View ( flightgear::View::FG_LOOKAT, from_model, from_model_index,
at_model, at_model_index,
damp_roll, damp_pitch, damp_heading,
x_offset_m, y_offset_m,z_offset_m,
target_x_offset_m, target_y_offset_m,
target_z_offset_m, near_m, internal ));
} else {
- add_view(new FGViewer ( FGViewer::FG_LOOKFROM, from_model, from_model_index,
+ add_view(new flightgear::View ( flightgear::View::FG_LOOKFROM, from_model, from_model_index,
false, 0, 0.0, 0.0, 0.0,
x_offset_m, y_offset_m, z_offset_m,
heading_offset_deg, pitch_offset_deg,
void
FGViewMgr::update (double dt)
{
- FGViewer* currentView = (FGViewer *)get_current_view();
+ flightgear::View* currentView = get_current_view();
if (!currentView) return;
SGPropertyNode *n = config_list[current];
}
// if lookat (type 1) then get target data...
- if (currentView->getType() == FGViewer::FG_LOOKAT) {
+ if (currentView->getType() == flightgear::View::FG_LOOKAT) {
if (!config->getBoolValue("from-model")) {
lon_deg = fgGetDouble(config->getStringValue("target-lon-deg-path"));
lat_deg = fgGetDouble(config->getStringValue("target-lat-deg-path"));
views.clear();
}
-FGViewer*
+flightgear::View*
FGViewMgr::get_current_view()
{
if ( current < (int)views.size() ) {
}
}
-const FGViewer*
+const flightgear::View*
FGViewMgr::get_current_view() const
{
if ( current < (int)views.size() ) {
}
-FGViewer*
+flightgear::View*
FGViewMgr::get_view( int i )
{
if ( i < 0 ) { i = 0; }
return views[i];
}
-const FGViewer*
+const flightgear::View*
FGViewMgr::get_view( int i ) const
{
if ( i < 0 ) { i = 0; }
return views[i];
}
-FGViewer*
+flightgear::View*
FGViewMgr::next_view()
{
setView((current+1 < (int)views.size()) ? (current + 1) : 0);
return views[current];
}
-FGViewer*
+flightgear::View*
FGViewMgr::prev_view()
{
setView((0 < current) ? (current - 1) : (views.size() - 1));
}
void
-FGViewMgr::add_view( FGViewer * v )
+FGViewMgr::add_view( flightgear::View * v )
{
views.push_back(v);
v->init();
double
FGViewMgr::getViewHeadingOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getHeadingOffset_deg());
}
void
FGViewMgr::setViewHeadingOffset_deg (double offset)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setGoalHeadingOffset_deg(offset);
view->setHeadingOffset_deg(offset);
double
FGViewMgr::getViewGoalHeadingOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getGoalHeadingOffset_deg());
}
void
FGViewMgr::setViewGoalHeadingOffset_deg (double offset)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->setGoalHeadingOffset_deg(offset);
}
double
FGViewMgr::getViewPitchOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getPitchOffset_deg());
}
void
FGViewMgr::setViewPitchOffset_deg (double tilt)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setGoalPitchOffset_deg(tilt);
view->setPitchOffset_deg(tilt);
double
FGViewMgr::getGoalViewPitchOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getGoalPitchOffset_deg());
}
void
FGViewMgr::setGoalViewPitchOffset_deg (double tilt)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->setGoalPitchOffset_deg(tilt);
}
double
FGViewMgr::getViewRollOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getRollOffset_deg());
}
void
FGViewMgr::setViewRollOffset_deg (double tilt)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setGoalRollOffset_deg(tilt);
view->setRollOffset_deg(tilt);
double
FGViewMgr::getGoalViewRollOffset_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->getGoalRollOffset_deg());
}
void
FGViewMgr::setGoalViewRollOffset_deg (double tilt)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->setGoalRollOffset_deg(tilt);
}
double
FGViewMgr::getViewXOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getXOffset_m();
+ return ((flightgear::View *)view)->getXOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewXOffset_m (double x)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setXOffset_m(x);
}
double
FGViewMgr::getViewYOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getYOffset_m();
+ return ((flightgear::View *)view)->getYOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewYOffset_m (double y)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setYOffset_m(y);
}
double
FGViewMgr::getViewZOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getZOffset_m();
+ return ((flightgear::View *)view)->getZOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewZOffset_m (double z)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setZOffset_m(z);
}
double
FGViewMgr::getViewTargetXOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getTargetXOffset_m();
+ return ((flightgear::View *)view)->getTargetXOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewTargetXOffset_m (double x)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setTargetXOffset_m(x);
}
double
FGViewMgr::getViewTargetYOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getTargetYOffset_m();
+ return ((flightgear::View *)view)->getTargetYOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewTargetYOffset_m (double y)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setTargetYOffset_m(y);
}
double
FGViewMgr::getViewTargetZOffset_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
if (view != 0) {
- return ((FGViewer *)view)->getTargetZOffset_m();
+ return ((flightgear::View *)view)->getTargetZOffset_m();
} else {
return 0;
}
void
FGViewMgr::setViewTargetZOffset_m (double z)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0) {
view->setTargetZOffset_m(z);
}
double
FGViewMgr::getFOV_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->get_fov());
}
void
FGViewMgr::setFOV_deg (double fov)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->set_fov(fov);
}
double
FGViewMgr::getARM_deg () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->get_aspect_ratio_multiplier());
}
void
FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);
}
double
FGViewMgr::getNear_m () const
{
- const FGViewer * view = get_current_view();
+ const flightgear::View * view = get_current_view();
return (view == 0 ? 0.5f : view->getNear_m());
}
void
FGViewMgr::setNear_m (double near_m)
{
- FGViewer * view = get_current_view();
+ flightgear::View * view = get_current_view();
if (view != 0)
view->setNear_m(near_m);
}
double
FGViewMgr::getViewLon_deg() const
{
- const FGViewer* view = get_current_view();
+ const flightgear::View* view = get_current_view();
return (view != NULL) ? view->getPosition().getLongitudeDeg() : 0.0;
}
double
FGViewMgr::getViewLat_deg() const
{
- const FGViewer* view = get_current_view();
+ const flightgear::View* view = get_current_view();
return (view != NULL) ? view->getPosition().getLatitudeDeg() : 0.0;
}
double
FGViewMgr::getViewElev_ft() const
{
- const FGViewer* view = get_current_view();
+ const flightgear::View* view = get_current_view();
return (view != NULL) ? view->getPosition().getElevationFt() : 0.0;
}
#include <simgear/math/SGMath.hxx>
// forward decls
-class FGViewer;
-typedef SGSharedPtr<FGViewer> FGViewerPtr;
+namespace flightgear
+{
+ class View;
+ typedef SGSharedPtr<flightgear::View> ViewPtr;
+}
// Define a structure containing view information
class FGViewMgr : public SGSubsystem
inline int size() const { return views.size(); }
inline int get_current() const { return current; }
- FGViewer *get_current_view();
- const FGViewer *get_current_view() const;
+ flightgear::View* get_current_view();
+ const flightgear::View* get_current_view() const;
- FGViewer *get_view( int i );
- const FGViewer *get_view( int i ) const;
+ flightgear::View* get_view( int i );
+ const flightgear::View* get_view( int i ) const;
- FGViewer *next_view();
- FGViewer *prev_view();
+ flightgear::View* next_view();
+ flightgear::View* prev_view();
// setters
void clear();
- void add_view( FGViewer * v );
+ void add_view( flightgear::View * v );
static const char* subsystemName() { return "view-manager"; }
private:
bool inited;
SGPropertyNode_ptr view_number;
std::vector<SGPropertyNode_ptr> config_list;
- typedef std::vector<FGViewerPtr> viewer_list;
+ typedef std::vector<flightgear::ViewPtr> viewer_list;
viewer_list views;
SGVec3d abs_viewer_position;