1
0
Fork 0

This is step "1" of probably "many" in the process of separating out the

scene management code and organizing it within simgear.  My strategy is
to identify the code I want to move, and break it's direct flightgear
dependencies.  Then it will be free to move over into the simgear package.

- Moved some property specific code into simgear/props/
- Split out the condition code from fgfs/src/Main/fg_props and put it
  in it's own source file in simgear/props/
- Created a scene subdirectory for scenery, model, and material property
  related code.
- Moved location.[ch]xx into simgear/scene/model/
- The location and condition code had dependencies on flightgear's global
  state (all the globals-> stuff, the flightgear property tree, etc.)  SimGear
  code can't depend on it so that data has to be passed as parameters to the
  functions/methods/constructors.
- This need to pass data as function parameters had a dramatic cascading
  effect throughout the FlightGear code.
This commit is contained in:
curt 2003-05-06 23:46:24 +00:00
parent f347d6d291
commit 2119db35c3
54 changed files with 214 additions and 708 deletions

View file

@ -54,5 +54,5 @@ void FGAIEntity::RegisterTransmission(int code) {
void FGAIEntity::Transform() {
aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
aip.setOrientation(roll, pitch, hdg);
aip.update();
aip.update( globals->get_scenery()->get_center() );
}

View file

@ -23,9 +23,10 @@
# include <config.h>
#endif
#include <simgear/scene/model/location.hxx>
#include <Airports/runways.hxx>
#include <Main/globals.hxx>
#include <Main/location.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <simgear/math/point3d.hxx>
@ -156,7 +157,8 @@ bool FGAILocalTraffic::Init(string ICAO, OperatingState initialState, PatternLeg
string planepath = "Aircraft/c172/Models/c172-dpm.ac";
SGPath path = globals->get_fg_root();
path.append(planepath);
aip.init(planepath.c_str());
aip.init( path.str(), planepath.c_str(), globals->get_props(),
globals->get_sim_time_sec() );
aip.setVisible(false); // This will be set to true once a valid ground elevation has been determined
globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
@ -1117,7 +1119,8 @@ void FGAILocalTraffic::DoGroundElev() {
double visibility_meters = fgGetDouble("/environment/visibility-m");
//globals->get_tile_mgr()->prep_ssg_nodes( acmodel_location,
globals->get_tile_mgr()->prep_ssg_nodes( aip.getFGLocation(), visibility_meters );
globals->get_tile_mgr()->update( aip.getFGLocation(), visibility_meters, (aip.getFGLocation())->get_absolute_view_pos() );
Point3D scenery_center = globals->get_scenery()->get_center();
globals->get_tile_mgr()->update( aip.getFGLocation(), visibility_meters, (aip.getFGLocation())->get_absolute_view_pos( scenery_center ) );
// save results of update in FGLocation for fdm...
//if ( globals->get_scenery()->get_cur_elev() > -9990 ) {

View file

@ -22,7 +22,7 @@
# include <config.h>
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Include/general.hxx>
#include <Main/fg_props.hxx>

View file

@ -90,7 +90,7 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
// Show available aircraft types
void fgReadAircraft(void) {
SGPropertyNode *aircraft_types = fgGetNode("/sim/aircraft-types", true);
// SGPropertyNode *aircraft_types = fgGetNode("/sim/aircraft-types", true);
SGPath path( globals->get_fg_root() );
path.append("Aircraft");
@ -127,10 +127,8 @@ void fgReadAircraft(void) {
SGPropertyNode *desc = node->getNode("description");
if (desc) {
#endif
SGPropertyNode *aircraft =
SGPropertyNode *aircraft =
aircraft_types->getChild(dire->d_name, 0, true);
#if 0
aircraft->setStringValue(strdup(desc->getStringValue()));
}

View file

@ -27,7 +27,7 @@
#define _NEWAUTO_HXX
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <simgear/route/waypoint.hxx>
#include <Main/fgfs.hxx>

View file

@ -38,7 +38,7 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <simgear/timing/sg_time.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -47,10 +47,8 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <simgear/misc/sg_path.hxx>
//#include <simgear/math/fg_random.h>
//#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>
#include <Autopilot/newauto.hxx>
@ -61,7 +59,6 @@
#include <NetworkOLK/network.h>
#endif
#include <Scenery/scenery.hxx>
//#include <Time/fg_timer.hxx>
#if defined ( __sun__ ) || defined ( __sgi )
extern "C" {

View file

@ -41,7 +41,7 @@
#include <plib/ssg.h>
#include <simgear/math/interpolater.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <simgear/timing/timestamp.hxx>
#include <cmath>

View file

@ -31,9 +31,9 @@
#include <simgear/compiler.h>
#include <simgear/misc/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include STL_IOSTREAM
#include STL_FSTREAM
@ -137,7 +137,8 @@ readConditions (FGConditional * component, const SGPropertyNode * node)
const SGPropertyNode * conditionNode = node->getChild("condition");
if (conditionNode != 0)
// The top level is implicitly AND
component->setCondition(fgReadCondition(conditionNode));
component->setCondition(fgReadCondition(globals->get_props(),
conditionNode) );
}

View file

@ -24,7 +24,7 @@
#ifndef _CONTROLS_HXX
#define _CONTROLS_HXX
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include <Main/globals.hxx>

View file

@ -28,7 +28,7 @@
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include "FGPropertyManager.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -36,7 +36,7 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS

View file

@ -53,7 +53,7 @@ DEFINITIONS
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <FDM/JSBSim/FGFDMExec.h>

View file

@ -24,19 +24,18 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/model/location.hxx>
#include <Main/fg_props.hxx>
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Model/model.hxx>
#include <Main/location.hxx>
#include <FDM/flight.hxx>
#include <FDM/LaRCsim/ls_cockpit.h>
#include <FDM/LaRCsim/ls_generic.h>
#include <FDM/LaRCsim/ls_interface.h>
#include <FDM/LaRCsimIC.hxx>
#include <FDM/UIUCModel/uiuc_aircraft.h>
#include <Main/fg_props.hxx>
#include <Model/acmodel.hxx>
#include "IO360.hxx"

View file

@ -2,7 +2,7 @@
#define _FGFDM_HPP
#include <simgear/xml/easyxml.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include "Airplane.hpp"
#include "Vector.hpp"

View file

@ -55,6 +55,6 @@ yasim_SOURCES = yasim-test.cpp \
Vector.hpp \
Wing.cpp Wing.hpp
yasim_LDADD = -lsgxml -lsgmisc -lsgdebug
yasim_LDADD = -lsgxml -lsgprops -lsgmisc -lsgdebug
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,11 +1,12 @@
#include <simgear/misc/sg_path.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/model/location.hxx>
#include <simgear/xml/easyxml.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Model/acmodel.hxx>
#include <Model/model.hxx>
#include <Main/location.hxx>
#include "FGFDM.hpp"
#include "Atmosphere.hpp"

View file

@ -1,7 +1,7 @@
#include <stdio.h>
#include <simgear/props/props.hxx>
#include <simgear/xml/easyxml.hxx>
#include <simgear/misc/props.hxx>
#include "FGFDM.hpp"
#include "Airplane.hpp"

View file

@ -28,13 +28,13 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/scene/model/location.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Scenery/scenery.hxx>
#include <FDM/LaRCsim/ls_interface.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/location.hxx>
#include <Model/model.hxx>
#include <Model/acmodel.hxx>

View file

@ -10,7 +10,7 @@
#include <plib/pu.h>
#include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <vector>
SG_USING_STD(vector);

View file

@ -34,10 +34,10 @@
# include <windows.h>
#endif
#include <simgear/misc/props.hxx>
#include <simgear/misc/props_io.hxx>
#include <simgear/misc/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <plib/pu.h>

View file

@ -10,7 +10,7 @@
#include <plib/pu.h>
#include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <vector>
SG_USING_STD(vector);

View file

@ -35,13 +35,15 @@
# include <config.h>
#endif
#include "prop_picker.hxx"
#include <Main/globals.hxx>
#include <simgear/compiler.h>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include STL_STRING
#include <Main/globals.hxx>
#include "prop_picker.hxx"
SG_USING_STD(string);
// A local alternative name, for use when a variable called "string" is in scope - e.g. in classes derived from puInput.

View file

@ -7,7 +7,7 @@
#include <stdio.h>
#include "gui.h"
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
void prop_pickerInit();
void prop_pickerView( puObject * );

View file

@ -45,7 +45,7 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Aircraft/aircraft.hxx>
#include <Autopilot/auto_gui.hxx>
@ -104,7 +104,7 @@ FGBinding::read (const SGPropertyNode * node)
{
const SGPropertyNode * conditionNode = node->getChild("condition");
if (conditionNode != 0)
setCondition(fgReadCondition(conditionNode));
setCondition(fgReadCondition(globals->get_props(), conditionNode));
_command_name = node->getStringValue("command", "");
if (_command_name.empty()) {

View file

@ -33,7 +33,8 @@
#include <simgear/compiler.h>
#include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/condition.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -11,7 +11,7 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include "gyro.hxx"

View file

@ -12,7 +12,8 @@
#endif
#include <simgear/math/point3d.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include "gyro.hxx"

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include "gyro.hxx"

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>
#include "gyro.hxx"

View file

@ -11,7 +11,8 @@
# error This library requires C++
#endif
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include <Main/fgfs.hxx>

View file

@ -54,8 +54,7 @@ fgfs_SOURCES = \
splash.cxx splash.hxx \
util.cxx util.hxx \
viewer.cxx viewer.hxx \
viewmgr.cxx viewmgr.hxx \
location.cxx location.hxx
viewmgr.cxx viewmgr.hxx
fgfs_LDADD = \
$(top_builddir)/src/Aircraft/libAircraft.a \
@ -89,8 +88,8 @@ fgfs_LDADD = \
$(top_builddir)/src/Systems/libSystems.a \
$(top_builddir)/src/Time/libTime.a \
$(WEATHER_LIBS) \
-lsgroute -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen \
-lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \
-lsgroute -lsgsky -lsgephem -lsgmodel -lsgtiming -lsgio -lsgscreen \
-lsgmath -lsgbucket -lsgprops -lsgdebug -lsgmagvar -lsgmisc -lsgxml \
-lsgserial \
$(THREAD_LIBS) \
-lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul \

View file

@ -8,11 +8,11 @@
#include STL_STRING
#include STL_FSTREAM
#include <simgear/sg_inlines.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/props/props.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
@ -22,7 +22,7 @@
#include <GUI/dialog.hxx>
#include <Scenery/tilemgr.hxx>
#if defined(HAVE_PLIB_PSL)
#include <Scripting/scriptmgr.hxx>
# include <Scripting/scriptmgr.hxx>
#endif
#include <Time/tmp.hxx>
@ -196,7 +196,7 @@ do_reinit (const SGPropertyNode * arg)
vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
if (subsystems.size() == 0)
globals->get_subsystem_mgr()->reinit();
else for (int i = 0; i < subsystems.size(); i++) {
else for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
FGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
@ -220,7 +220,7 @@ do_suspend (const SGPropertyNode * arg)
bool result = true;
vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
for (int i = 0; i < subsystems.size(); i++) {
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
FGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {
@ -244,7 +244,7 @@ do_resume (const SGPropertyNode * arg)
bool result = true;
vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
for (int i = 0; i < subsystems.size(); i++) {
for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
const char * name = subsystems[i]->getStringValue();
FGSubsystem * subsystem = globals->get_subsystem(name);
if (subsystem == 0) {

View file

@ -17,7 +17,7 @@
#endif
#include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
/**
* Initialize the built-in commands.

View file

@ -1298,12 +1298,12 @@ SGTime *fgInitTime() {
// gear, its initialization call should located in this routine.
// Returns non-zero if a problem encountered.
bool fgInitSubsystems() {
static const SGPropertyNode *longitude
= fgGetNode("/sim/presets/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/sim/presets/latitude-deg");
static const SGPropertyNode *altitude
= fgGetNode("/sim/presets/altitude-ft");
// static const SGPropertyNode *longitude
// = fgGetNode("/sim/presets/longitude-deg");
// static const SGPropertyNode *latitude
// = fgGetNode("/sim/presets/latitude-deg");
// static const SGPropertyNode *altitude
// = fgGetNode("/sim/presets/altitude-ft");
fgLIGHT *l = &cur_light_params;
@ -1669,10 +1669,10 @@ bool fgInitSubsystems() {
void fgReInitSubsystems()
{
static const SGPropertyNode *longitude
= fgGetNode("/sim/presets/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/sim/presets/latitude-deg");
// static const SGPropertyNode *longitude
// = fgGetNode("/sim/presets/longitude-deg");
// static const SGPropertyNode *latitude
// = fgGetNode("/sim/presets/latitude-deg");
static const SGPropertyNode *altitude
= fgGetNode("/sim/presets/altitude-ft");
static const SGPropertyNode *master_freeze

View file

@ -857,398 +857,4 @@ fgUntie (const char * name)
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGCondition.
////////////////////////////////////////////////////////////////////////
FGCondition::FGCondition ()
{
}
FGCondition::~FGCondition ()
{
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGPropertyCondition.
////////////////////////////////////////////////////////////////////////
FGPropertyCondition::FGPropertyCondition (const char * propname)
: _node(fgGetNode(propname, true))
{
}
FGPropertyCondition::~FGPropertyCondition ()
{
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGNotCondition.
////////////////////////////////////////////////////////////////////////
FGNotCondition::FGNotCondition (FGCondition * condition)
: _condition(condition)
{
}
FGNotCondition::~FGNotCondition ()
{
delete _condition;
}
bool
FGNotCondition::test () const
{
return !(_condition->test());
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGAndCondition.
////////////////////////////////////////////////////////////////////////
FGAndCondition::FGAndCondition ()
{
}
FGAndCondition::~FGAndCondition ()
{
for (unsigned int i = 0; i < _conditions.size(); i++)
delete _conditions[i];
}
bool
FGAndCondition::test () const
{
int nConditions = _conditions.size();
for (int i = 0; i < nConditions; i++) {
if (!_conditions[i]->test())
return false;
}
return true;
}
void
FGAndCondition::addCondition (FGCondition * condition)
{
_conditions.push_back(condition);
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGOrCondition.
////////////////////////////////////////////////////////////////////////
FGOrCondition::FGOrCondition ()
{
}
FGOrCondition::~FGOrCondition ()
{
for (unsigned int i = 0; i < _conditions.size(); i++)
delete _conditions[i];
}
bool
FGOrCondition::test () const
{
int nConditions = _conditions.size();
for (int i = 0; i < nConditions; i++) {
if (_conditions[i]->test())
return true;
}
return false;
}
void
FGOrCondition::addCondition (FGCondition * condition)
{
_conditions.push_back(condition);
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGComparisonCondition.
////////////////////////////////////////////////////////////////////////
static int
doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
{
switch (left->getType()) {
case SGPropertyNode::BOOL: {
bool v1 = left->getBoolValue();
bool v2 = right->getBoolValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::INT: {
int v1 = left->getIntValue();
int v2 = right->getIntValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::LONG: {
long v1 = left->getLongValue();
long v2 = right->getLongValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::FLOAT: {
float v1 = left->getFloatValue();
float v2 = right->getFloatValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::DOUBLE: {
double v1 = left->getDoubleValue();
double v2 = right->getDoubleValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::STRING:
case SGPropertyNode::NONE:
case SGPropertyNode::UNSPECIFIED: {
string v1 = left->getStringValue();
string v2 = right->getStringValue();
if (v1 < v2)
return FGComparisonCondition::LESS_THAN;
else if (v1 > v2)
return FGComparisonCondition::GREATER_THAN;
else
return FGComparisonCondition::EQUALS;
break;
}
}
throw sg_exception("Unrecognized node type");
return 0;
}
FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
: _type(type),
_reverse(reverse),
_left_property(0),
_right_property(0),
_right_value(0)
{
}
FGComparisonCondition::~FGComparisonCondition ()
{
delete _right_value;
}
bool
FGComparisonCondition::test () const
{
// Always fail if incompletely specified
if (_left_property == 0 ||
(_right_property == 0 && _right_value == 0))
return false;
// Get LESS_THAN, EQUALS, or GREATER_THAN
int cmp =
doComparison(_left_property,
(_right_property != 0 ? _right_property : _right_value));
if (!_reverse)
return (cmp == _type);
else
return (cmp != _type);
}
void
FGComparisonCondition::setLeftProperty (const char * propname)
{
_left_property = fgGetNode(propname, true);
}
void
FGComparisonCondition::setRightProperty (const char * propname)
{
delete _right_value;
_right_value = 0;
_right_property = fgGetNode(propname, true);
}
void
FGComparisonCondition::setRightValue (const SGPropertyNode *node)
{
_right_property = 0;
delete _right_value;
_right_value = new SGPropertyNode(*node);
}
////////////////////////////////////////////////////////////////////////
// Read a condition and use it if necessary.
////////////////////////////////////////////////////////////////////////
// Forward declaration
static FGCondition * readCondition (const SGPropertyNode * node);
static FGCondition *
readPropertyCondition (const SGPropertyNode * node)
{
return new FGPropertyCondition(node->getStringValue());
}
static FGCondition *
readNotCondition (const SGPropertyNode * node)
{
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
FGCondition * condition = readCondition(child);
if (condition != 0)
return new FGNotCondition(condition);
}
SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
return 0;
}
static FGCondition *
readAndConditions (const SGPropertyNode * node)
{
FGAndCondition * andCondition = new FGAndCondition;
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
FGCondition * condition = readCondition(child);
if (condition != 0)
andCondition->addCondition(condition);
}
return andCondition;
}
static FGCondition *
readOrConditions (const SGPropertyNode * node)
{
FGOrCondition * orCondition = new FGOrCondition;
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
FGCondition * condition = readCondition(child);
if (condition != 0)
orCondition->addCondition(condition);
}
return orCondition;
}
static FGCondition *
readComparison (const SGPropertyNode * node,
FGComparisonCondition::Type type,
bool reverse)
{
FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
condition->setLeftProperty(node->getStringValue("property[0]"));
if (node->hasValue("property[1]"))
condition->setRightProperty(node->getStringValue("property[1]"));
else
condition->setRightValue(node->getChild("value", 0));
return condition;
}
static FGCondition *
readCondition (const SGPropertyNode * node)
{
const string &name = node->getName();
if (name == "property")
return readPropertyCondition(node);
else if (name == "not")
return readNotCondition(node);
else if (name == "and")
return readAndConditions(node);
else if (name == "or")
return readOrConditions(node);
else if (name == "less-than")
return readComparison(node, FGComparisonCondition::LESS_THAN, false);
else if (name == "less-than-equals")
return readComparison(node, FGComparisonCondition::GREATER_THAN, true);
else if (name == "greater-than")
return readComparison(node, FGComparisonCondition::GREATER_THAN, false);
else if (name == "greater-than-equals")
return readComparison(node, FGComparisonCondition::LESS_THAN, true);
else if (name == "equals")
return readComparison(node, FGComparisonCondition::EQUALS, false);
else if (name == "not-equals")
return readComparison(node, FGComparisonCondition::EQUALS, true);
else
return 0;
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGConditional.
////////////////////////////////////////////////////////////////////////
FGConditional::FGConditional ()
: _condition (0)
{
}
FGConditional::~FGConditional ()
{
delete _condition;
}
void
FGConditional::setCondition (FGCondition * condition)
{
delete _condition;
_condition = condition;
}
bool
FGConditional::test () const
{
return ((_condition == 0) || _condition->test());
}
// The top-level is always an implicit 'and' group
FGCondition *
fgReadCondition (const SGPropertyNode * node)
{
return readAndConditions(node);
}
// end of fg_props.cxx

View file

@ -7,8 +7,8 @@
#define __FG_PROPS_HXX 1
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/misc/props_io.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include "globals.hxx"
@ -539,162 +539,5 @@ fgTie (const char * name, T * obj, int index,
}
////////////////////////////////////////////////////////////////////////
// Conditions.
////////////////////////////////////////////////////////////////////////
/**
* An encoded condition.
*
* This class encodes a single condition of some sort, possibly
* connected with properties.
*
* This class should migrate to somewhere more general.
*/
class FGCondition
{
public:
FGCondition ();
virtual ~FGCondition ();
virtual bool test () const = 0;
};
/**
* Condition for a single property.
*
* This condition is true only if the property returns a boolean
* true value.
*/
class FGPropertyCondition : public FGCondition
{
public:
FGPropertyCondition (const char * propname);
virtual ~FGPropertyCondition ();
virtual bool test () const { return _node->getBoolValue(); }
private:
const SGPropertyNode * _node;
};
/**
* Condition for a 'not' operator.
*
* This condition is true only if the child condition is false.
*/
class FGNotCondition : public FGCondition
{
public:
// transfer pointer ownership
FGNotCondition (FGCondition * condition);
virtual ~FGNotCondition ();
virtual bool test () const;
private:
FGCondition * _condition;
};
/**
* Condition for an 'and' group.
*
* This condition is true only if all of the conditions
* in the group are true.
*/
class FGAndCondition : public FGCondition
{
public:
FGAndCondition ();
virtual ~FGAndCondition ();
virtual bool test () const;
// transfer pointer ownership
virtual void addCondition (FGCondition * condition);
private:
vector<FGCondition *> _conditions;
};
/**
* Condition for an 'or' group.
*
* This condition is true if at least one of the conditions in the
* group is true.
*/
class FGOrCondition : public FGCondition
{
public:
FGOrCondition ();
virtual ~FGOrCondition ();
virtual bool test () const;
// transfer pointer ownership
virtual void addCondition (FGCondition * condition);
private:
vector<FGCondition *> _conditions;
};
/**
* Abstract base class for property comparison conditions.
*/
class FGComparisonCondition : public FGCondition
{
public:
enum Type {
LESS_THAN,
GREATER_THAN,
EQUALS
};
FGComparisonCondition (Type type, bool reverse = false);
virtual ~FGComparisonCondition ();
virtual bool test () const;
virtual void setLeftProperty (const char * propname);
virtual void setRightProperty (const char * propname);
// will make a local copy
virtual void setRightValue (const SGPropertyNode * value);
private:
Type _type;
bool _reverse;
const SGPropertyNode * _left_property;
const SGPropertyNode * _right_property;
const SGPropertyNode * _right_value;
};
/**
* Base class for a conditional components.
*
* This class manages the conditions and tests; the component should
* invoke the test() method whenever it needs to decide whether to
* active itself, draw itself, and so on.
*/
class FGConditional
{
public:
FGConditional ();
virtual ~FGConditional ();
// transfer pointer ownership
virtual void setCondition (FGCondition * condition);
virtual const FGCondition * getCondition () const { return _condition; }
virtual bool test () const;
private:
FGCondition * _condition;
};
/**
* Global function to make a condition out of properties.
*
* The top-level is always an implicit 'and' group, whatever the
* node's name (it should usually be "condition").
*
* @param node The top-level condition node (usually named "condition").
* @return A pointer to a newly-allocated condition; it is the
* responsibility of the caller to delete the condition when
* it is no longer needed.
*/
FGCondition * fgReadCondition (const SGPropertyNode * node);
#endif // __FG_PROPS_HXX

View file

@ -49,7 +49,7 @@ SG_USING_STD(vector);
#include <map>
SG_USING_STD(map);
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>

View file

@ -20,7 +20,7 @@
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/exception.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
SG_USING_STD(ostream);
SG_USING_STD(vector);

View file

@ -77,6 +77,7 @@ SG_USING_STD(endl);
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/model/location.hxx>
#ifdef FG_USE_CLOUDS_3D
# include <simgear/sky/clouds3d/SkySceneLoader.hpp>
# include <simgear/sky/clouds3d/SkyUtil.hpp>
@ -105,7 +106,6 @@ SG_USING_STD(endl);
#include <Model/loader.hxx>
#include <Model/model.hxx>
#include <Model/modelmgr.hxx>
#include <Main/location.hxx>
#include <Model/panelnode.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
@ -445,12 +445,12 @@ void fgRenderFrame() {
// Process/manage pending events
global_events.update( delta_time_sec );
static const SGPropertyNode *longitude
= fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg");
static const SGPropertyNode *altitude
= fgGetNode("/position/altitude-ft");
// static const SGPropertyNode *longitude
// = fgGetNode("/position/longitude-deg");
// static const SGPropertyNode *latitude
// = fgGetNode("/position/latitude-deg");
// static const SGPropertyNode *altitude
// = fgGetNode("/position/altitude-ft");
static const SGPropertyNode *groundlevel_nearplane
= fgGetNode("/sim/current-view/ground-level-nearplane-m");
@ -1277,7 +1277,7 @@ static void fgMainLoop( void ) {
visibility_meters );
globals->get_tile_mgr()->
update( acmodel_location, visibility_meters,
acmodel_location->get_absolute_view_pos() );
acmodel_location->get_absolute_view_pos(globals->get_scenery()->get_center()) );
// save results of update in FGLocation for fdm...
if ( globals->get_scenery()->get_cur_elev() > -9990 ) {
acmodel_location->
@ -1955,7 +1955,7 @@ void fgLoadDCS(void) {
if ( strcmp(obj_filename,"repeat") != 0) {
ship_obj =
globals->get_model_loader()->load_model( obj_filename );
globals->get_model_loader()->load_model( globals->get_fg_root(), obj_filename, globals->get_props(), globals->get_sim_time_sec() );
}
if ( ship_obj != NULL ) {
@ -1976,11 +1976,11 @@ void fgLoadDCS(void) {
// temporary hack for deck lights - ultimately should move to PLib (when??)
//const char *extn = file_extension ( obj_filename ) ;
if ( objc == 1 ){
ssgVertexArray *lights = new ssgVertexArray( 100 );
// ssgVertexArray *lights = new ssgVertexArray( 100 );
ssgVertexArray *lightpoints = new ssgVertexArray( 100 );
ssgVertexArray *lightnormals = new ssgVertexArray( 100 );
ssgVertexArray *lightdir = new ssgVertexArray( 100 );
int ltype[500], light_type;
int ltype[500], light_type = 0;
static int ltcount = 0;
string token;
sgVec3 rway_dir,rway_normal,lightpt;

View file

@ -485,7 +485,8 @@ FGViewer::updateFromModelLocation (FGLocation * location)
void
FGViewer::updateAtModelLocation (FGLocation * location)
{
sgCopyMat4(ATLOCAL, location->getCachedTransformMatrix());
sgCopyMat4(ATLOCAL,
location->getCachedTransformMatrix());
}
void
@ -495,7 +496,8 @@ FGViewer::recalcOurOwnLocation (FGLocation * location, double lon_deg, double la
// update from our own data...
location->setPosition( lon_deg, lat_deg, alt_ft );
location->setOrientation( roll_deg, pitch_deg, heading_deg );
sgCopyMat4(LOCAL, location->getTransformMatrix());
sgCopyMat4(LOCAL,
location->getTransformMatrix(globals->get_scenery()->get_center()));
}
// recalc() is done every time one of the setters is called (making the
@ -519,7 +521,7 @@ FGViewer::recalcLookFrom ()
{
sgVec3 right, forward;
sgVec3 eye_pos;
// sgVec3 eye_pos;
sgVec3 position_offset; // eye position offsets (xyz)
// LOOKFROM mode...
@ -606,7 +608,9 @@ FGViewer::recalcLookAt ()
// calculate the "at" target object positon relative to eye or view's tile center...
sgdVec3 dVec3;
sgdSetVec3(dVec3, _location->get_tile_center()[0], _location->get_tile_center()[1], _location->get_tile_center()[2]);
sgdSubVec3(dVec3, _target_location->get_absolute_view_pos(), dVec3 );
sgdSubVec3(dVec3,
_target_location->get_absolute_view_pos(globals->get_scenery()->get_center()),
dVec3 );
sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]);
// Update location data for eye...
@ -668,7 +672,8 @@ FGViewer::copyLocationData()
// Get our friendly vectors from the eye location...
sgCopyVec3(_zero_elev_view_pos, _location->get_zero_elev());
sgCopyVec3(_relative_view_pos, _location->get_view_pos());
sgdCopyVec3(_absolute_view_pos, _location->get_absolute_view_pos());
sgdCopyVec3(_absolute_view_pos,
_location->get_absolute_view_pos(globals->get_scenery()->get_center()));
sgCopyMat4(UP, _location->getCachedUpMatrix());
sgCopyVec3(_world_up, _location->get_world_up());
// these are the vectors that the sun and moon code like to get...

View file

@ -34,13 +34,12 @@
#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/scene/model/location.hxx>
#include <plib/sg.h> // plib include
#include "fgfs.hxx"
#include <Main/location.hxx>
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9

View file

@ -54,11 +54,17 @@ FGAircraftModel::init ()
_aircraft = new FGModelPlacement;
string path = fgGetString("/sim/model/path", "Models/Geometry/glider.ac");
try {
_aircraft->init(path);
_aircraft->init( globals->get_fg_root(),
path,
globals->get_props(),
globals->get_sim_time_sec() );
} catch (const sg_exception &ex) {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path);
SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)");
_aircraft->init("Models/Geometry/glider.ac");
_aircraft->init( globals->get_fg_root(),
"Models/Geometry/glider.ac",
globals->get_props(),
globals->get_sim_time_sec() );
}
_scene->addKid(_aircraft->getSceneGraph());
_selector->addKid(_aircraft->getSceneGraph());
@ -94,7 +100,7 @@ FGAircraftModel::update (double dt)
_aircraft->setOrientation(fgGetDouble("/orientation/roll-deg"),
fgGetDouble("/orientation/pitch-deg"),
fgGetDouble("/orientation/heading-deg"));
_aircraft->update();
_aircraft->update( globals->get_scenery()->get_center() );
}

View file

@ -5,7 +5,7 @@
#endif
#include <simgear/compiler.h>
#include <simgear/misc/props.hxx>
#include <simgear/props/props.hxx>
#include "loader.hxx"
#include "model.hxx"
@ -61,13 +61,16 @@ FGModelLoader::~FGModelLoader ()
}
ssgEntity *
FGModelLoader::load_model (const string &path)
FGModelLoader::load_model( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
double sim_time_sec )
{
// FIXME: normalize path to
// avoid duplicates.
std::map<string, ssgBase *>::iterator it = _table.find(path);
if (it == _table.end()) {
_table[path] = fgLoad3DModel((char *)path.c_str());
_table[path] = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
it = _table.find(path);
it->second->ref(); // add one reference to keep it around
}
@ -89,7 +92,7 @@ FGTextureLoader::~FGTextureLoader ()
}
ssgTexture *
FGTextureLoader::load_texture (const string &path)
FGTextureLoader::load_texture( const string &fg_root, const string &path )
{
std::map<string, ssgBase *>::iterator it = _table.find(path);
if (it == _table.end()) {

View file

@ -39,7 +39,10 @@ public:
FGModelLoader ();
virtual ~FGModelLoader ();
virtual ssgEntity * load_model (const string &path);
virtual ssgEntity * load_model( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
double sim_time_sec );
};
@ -52,7 +55,8 @@ public:
FGTextureLoader ();
virtual ~FGTextureLoader ();
virtual ssgTexture * load_texture (const string &path);
virtual ssgTexture * load_texture( const string &fg_root,
const string &path );
};
#endif

View file

@ -20,11 +20,13 @@
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/misc/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/condition.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/scene/model/location.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/location.hxx>
#include <Scenery/scenery.hxx>
// #include <Main/fg_props.hxx>
// #include <Main/globals.hxx>
// #include <Scenery/scenery.hxx>
#include "model.hxx"
#include "panelnode.hxx"
@ -177,7 +179,9 @@ static void
make_animation (ssgBranch * model,
const char * name,
vector<SGPropertyNode_ptr> &name_nodes,
SGPropertyNode_ptr node)
SGPropertyNode *prop_root,
SGPropertyNode_ptr node,
double sim_time_sec )
{
Animation * animation = 0;
const char * type = node->getStringValue("type", "none");
@ -188,15 +192,15 @@ make_animation (ssgBranch * model,
} else if (!strcmp("billboard", type)) {
animation = new BillboardAnimation(node);
} else if (!strcmp("select", type)) {
animation = new SelectAnimation(node);
animation = new SelectAnimation(prop_root, node);
} else if (!strcmp("spin", type)) {
animation = new SpinAnimation(node);
animation = new SpinAnimation(prop_root, node, sim_time_sec );
} else if (!strcmp("timed", type)) {
animation = new TimedAnimation(node);
} else if (!strcmp("rotate", type)) {
animation = new RotateAnimation(node);
animation = new RotateAnimation(prop_root, node);
} else if (!strcmp("translate", type)) {
animation = new TranslateAnimation(node);
animation = new TranslateAnimation(prop_root, node);
} else {
animation = new NullAnimation(node);
SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
@ -221,7 +225,7 @@ make_animation (ssgBranch * model,
ssgBranch * branch = animation->getBranch();
splice_branch(branch, object);
for (int i = 1; i < name_nodes.size(); i++) {
for (unsigned int i = 1; i < name_nodes.size(); i++) {
const char * name = name_nodes[i]->getStringValue();
object = find_named_node(model, name);
if (object == 0) {
@ -246,7 +250,9 @@ make_animation (ssgBranch * model,
////////////////////////////////////////////////////////////////////////
ssgBranch *
fgLoad3DModel (const string &path)
fgLoad3DModel( const string &fg_root, const string &path,
SGPropertyNode *prop_root,
double sim_time_sec )
{
ssgBranch * model = 0;
SGPropertyNode props;
@ -258,7 +264,7 @@ fgLoad3DModel (const string &path)
xmlpath = modelpath;
}
else {
xmlpath = globals->get_fg_root();
xmlpath = fg_root;
xmlpath.append(modelpath.str());
}
@ -313,7 +319,8 @@ fgLoad3DModel (const string &path)
const char * name = animation_nodes[i]->getStringValue("name", 0);
vector<SGPropertyNode_ptr> name_nodes =
animation_nodes[i]->getChildren("object-name");
make_animation(model, name, name_nodes, animation_nodes[i]);
make_animation( model, name, name_nodes, prop_root, animation_nodes[i],
sim_time_sec);
}
// Load sub-models
@ -331,7 +338,8 @@ fgLoad3DModel (const string &path)
node->getFloatValue("offsets/z-m", 0.0));
align->setTransform(res_matrix);
ssgBranch * kid = fgLoad3DModel(node->getStringValue("path"));
ssgBranch * kid = fgLoad3DModel( fg_root, node->getStringValue("path"),
prop_root, sim_time_sec );
align->addKid(kid);
model->addKid(align);
}
@ -420,13 +428,14 @@ BillboardAnimation::~BillboardAnimation ()
// Implementation of SelectAnimation
////////////////////////////////////////////////////////////////////////
SelectAnimation::SelectAnimation (SGPropertyNode_ptr props)
SelectAnimation::SelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
: Animation(props, new ssgSelector),
_condition(0)
{
SGPropertyNode_ptr node = props->getChild("condition");
if (node != 0)
_condition = fgReadCondition(node);
_condition = fgReadCondition(prop_root, node);
}
SelectAnimation::~SelectAnimation ()
@ -449,12 +458,14 @@ SelectAnimation::update ()
// Implementation of SpinAnimation
////////////////////////////////////////////////////////////////////////
SpinAnimation::SpinAnimation (SGPropertyNode_ptr props)
SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props,
double sim_time_sec )
: Animation(props, new ssgTransform),
_prop(fgGetNode(props->getStringValue("property", "/null"), true)),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_factor(props->getDoubleValue("factor", 1.0)),
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
_last_time_sec(globals->get_sim_time_sec())
_last_time_sec( sim_time_sec /* globals->get_sim_time_sec() */ )
{
_center[0] = props->getFloatValue("center/x-m", 0);
_center[1] = props->getFloatValue("center/y-m", 0);
@ -470,11 +481,10 @@ SpinAnimation::~SpinAnimation ()
}
void
SpinAnimation::update ()
SpinAnimation::update( double sim_time_sec )
{
double sim_time = globals->get_sim_time_sec();
double dt = sim_time - _last_time_sec;
_last_time_sec = sim_time;
double dt = sim_time_sec - _last_time_sec;
_last_time_sec = sim_time_sec;
float velocity_rpms = (_prop->getDoubleValue() * _factor / 60.0);
_position_deg += (dt * velocity_rpms * 360);
@ -505,9 +515,8 @@ TimedAnimation::~TimedAnimation ()
}
void
TimedAnimation::update ()
TimedAnimation::update( double sim_time_sec )
{
float sim_time_sec = globals->get_sim_time_sec();
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
_last_time_sec = sim_time_sec;
_step++;
@ -523,9 +532,10 @@ TimedAnimation::update ()
// Implementation of RotateAnimation
////////////////////////////////////////////////////////////////////////
RotateAnimation::RotateAnimation (SGPropertyNode_ptr props)
RotateAnimation::RotateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
: Animation(props, new ssgTransform),
_prop(fgGetNode(props->getStringValue("property", "/null"), true)),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_offset_deg(props->getDoubleValue("offset-deg", 0.0)),
_factor(props->getDoubleValue("factor", 1.0)),
_table(read_interpolation_table(props)),
@ -550,7 +560,7 @@ RotateAnimation::~RotateAnimation ()
}
void
RotateAnimation::update ()
RotateAnimation::update()
{
if (_table == 0) {
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
@ -571,9 +581,10 @@ RotateAnimation::update ()
// Implementation of TranslateAnimation
////////////////////////////////////////////////////////////////////////
TranslateAnimation::TranslateAnimation (SGPropertyNode_ptr props)
TranslateAnimation::TranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
: Animation(props, new ssgTransform),
_prop(fgGetNode(props->getStringValue("property", "/null"), true)),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_offset_m(props->getDoubleValue("offset-m", 0.0)),
_factor(props->getDoubleValue("factor", 1.0)),
_table(read_interpolation_table(props)),
@ -634,9 +645,12 @@ FGModelPlacement::~FGModelPlacement ()
}
void
FGModelPlacement::init (const string &path)
FGModelPlacement::init( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
double sim_time_sec )
{
ssgBranch * model = fgLoad3DModel(path);
ssgBranch * model = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
if (model != 0)
_position->addKid(model);
_selector->addKid(_position);
@ -644,12 +658,12 @@ FGModelPlacement::init (const string &path)
}
void
FGModelPlacement::update ()
FGModelPlacement::update( const Point3D scenery_center )
{
_location->setPosition( _lon_deg, _lat_deg, _elev_ft );
_location->setOrientation( _roll_deg, _pitch_deg, _heading_deg );
sgCopyMat4(POS, _location->getTransformMatrix());
sgCopyMat4( POS, _location->getTransformMatrix(scenery_center) );
sgVec3 trans;
sgCopyVec3(trans, _location->get_view_pos());

View file

@ -17,7 +17,8 @@ SG_USING_STD(vector);
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/misc/props.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/props/props.hxx>
// Don't pull in the headers, since we don't need them here.
@ -51,7 +52,9 @@ class FGLocation;
* Subsystems should not normally invoke this function directly;
* instead, they should use the FGModelLoader declared in loader.hxx.
*/
ssgBranch * fgLoad3DModel (const string &path);
ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
SGPropertyNode *prop_root,
double sim_time_sec );
@ -131,7 +134,8 @@ public:
class SelectAnimation : public Animation
{
public:
SelectAnimation (SGPropertyNode_ptr props);
SelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
virtual ~SelectAnimation ();
virtual void update ();
private:
@ -147,9 +151,11 @@ private:
class SpinAnimation : public Animation
{
public:
SpinAnimation (SGPropertyNode_ptr props);
SpinAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props,
double sim_time_sec );
virtual ~SpinAnimation ();
virtual void update ();
virtual void update( double sim_time_sec );
private:
SGPropertyNode_ptr _prop;
double _factor;
@ -169,7 +175,7 @@ class TimedAnimation : public Animation
public:
TimedAnimation (SGPropertyNode_ptr props);
virtual ~TimedAnimation ();
virtual void update ();
virtual void update( double sim_time_sec );
private:
double _duration_sec;
double _last_time_sec;
@ -185,9 +191,9 @@ private:
class RotateAnimation : public Animation
{
public:
RotateAnimation (SGPropertyNode_ptr props);
RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
virtual ~RotateAnimation ();
virtual void update ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
double _offset_deg;
@ -210,7 +216,8 @@ private:
class TranslateAnimation : public Animation
{
public:
TranslateAnimation (SGPropertyNode_ptr props);
TranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
virtual ~TranslateAnimation ();
virtual void update ();
private:
@ -243,8 +250,11 @@ public:
FGModelPlacement ();
virtual ~FGModelPlacement ();
virtual void init (const string &path);
virtual void update ();
virtual void init( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
double sim_time_sec );
virtual void update( const Point3D scenery_center );
virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }

View file

@ -38,7 +38,10 @@ FGModelMgr::init ()
Instance * instance = new Instance;
FGModelPlacement * model = new FGModelPlacement;
instance->model = model;
model->init(node->getStringValue("path", "Models/Geometry/glider.ac"));
model->init( globals->get_fg_root(),
node->getStringValue("path", "Models/Geometry/glider.ac"),
globals->get_props(),
globals->get_sim_time_sec() );
// Set position and orientation either
// indirectly through property refs
@ -120,7 +123,7 @@ FGModelMgr::update (double dt)
if (instance->heading_deg_node != 0)
model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
instance->model->update();
instance->model->update( globals->get_scenery()->get_center() );
}
}

View file

@ -16,18 +16,21 @@
// Static (!) handling for all 3D panels in the program. Very
// clumsy. Replace with per-aircraft handling.
vector<FGPanelNode*> all_3d_panels;
bool fgHandle3DPanelMouseEvent(int button, int updown, int x, int y)
bool fgHandle3DPanelMouseEvent( int button, int updown, int x, int y )
{
for(int i=0; i<all_3d_panels.size(); i++)
if(all_3d_panels[i]->doMouseAction(button, updown, x, y))
for ( unsigned int i = 0; i < all_3d_panels.size(); i++ ) {
if ( all_3d_panels[i]->doMouseAction(button, updown, x, y) ) {
return true;
}
}
return false;
}
void fgUpdate3DPanels()
{
for(int i=0; i<all_3d_panels.size(); i++)
for ( unsigned int i = 0; i < all_3d_panels.size(); i++ ) {
all_3d_panels[i]->getPanel()->updateMouseDelay();
}
}
FGPanelNode::FGPanelNode(SGPropertyNode* props)