better follow simgear conventions.
-// condition.hxx - Declarations and inline methods for property conditions.
+// condition.cxx - Declarations and inline methods for property conditions.
+//
// Written by David Megginson, started 2000.
// CLO May 2003 - Split out condition specific code.
//
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGCondition.
+// Implementation of SGCondition.
////////////////////////////////////////////////////////////////////////
-FGCondition::FGCondition ()
+SGCondition::SGCondition ()
{
}
-FGCondition::~FGCondition ()
+SGCondition::~SGCondition ()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGPropertyCondition.
+// Implementation of SGPropertyCondition.
////////////////////////////////////////////////////////////////////////
-FGPropertyCondition::FGPropertyCondition ( SGPropertyNode *prop_root,
+SGPropertyCondition::SGPropertyCondition ( SGPropertyNode *prop_root,
const char *propname )
: _node( prop_root->getNode(propname, true) )
{
}
-FGPropertyCondition::~FGPropertyCondition ()
+SGPropertyCondition::~SGPropertyCondition ()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGNotCondition.
+// Implementation of SGNotCondition.
////////////////////////////////////////////////////////////////////////
-FGNotCondition::FGNotCondition (FGCondition * condition)
+SGNotCondition::SGNotCondition (SGCondition * condition)
: _condition(condition)
{
}
-FGNotCondition::~FGNotCondition ()
+SGNotCondition::~SGNotCondition ()
{
delete _condition;
}
bool
-FGNotCondition::test () const
+SGNotCondition::test () const
{
return !(_condition->test());
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGAndCondition.
+// Implementation of SGAndCondition.
////////////////////////////////////////////////////////////////////////
-FGAndCondition::FGAndCondition ()
+SGAndCondition::SGAndCondition ()
{
}
-FGAndCondition::~FGAndCondition ()
+SGAndCondition::~SGAndCondition ()
{
for (unsigned int i = 0; i < _conditions.size(); i++)
delete _conditions[i];
}
bool
-FGAndCondition::test () const
+SGAndCondition::test () const
{
int nConditions = _conditions.size();
for (int i = 0; i < nConditions; i++) {
}
void
-FGAndCondition::addCondition (FGCondition * condition)
+SGAndCondition::addCondition (SGCondition * condition)
{
_conditions.push_back(condition);
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGOrCondition.
+// Implementation of SGOrCondition.
////////////////////////////////////////////////////////////////////////
-FGOrCondition::FGOrCondition ()
+SGOrCondition::SGOrCondition ()
{
}
-FGOrCondition::~FGOrCondition ()
+SGOrCondition::~SGOrCondition ()
{
for (unsigned int i = 0; i < _conditions.size(); i++)
delete _conditions[i];
}
bool
-FGOrCondition::test () const
+SGOrCondition::test () const
{
int nConditions = _conditions.size();
for (int i = 0; i < nConditions; i++) {
}
void
-FGOrCondition::addCondition (FGCondition * condition)
+SGOrCondition::addCondition (SGCondition * condition)
{
_conditions.push_back(condition);
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGComparisonCondition.
+// Implementation of SGComparisonCondition.
////////////////////////////////////////////////////////////////////////
static int
bool v1 = left->getBoolValue();
bool v2 = right->getBoolValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::INT: {
int v1 = left->getIntValue();
int v2 = right->getIntValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::LONG: {
long v1 = left->getLongValue();
long v2 = right->getLongValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::FLOAT: {
float v1 = left->getFloatValue();
float v2 = right->getFloatValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::DOUBLE: {
double v1 = left->getDoubleValue();
double v2 = right->getDoubleValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
case SGPropertyNode::STRING:
string v1 = left->getStringValue();
string v2 = right->getStringValue();
if (v1 < v2)
- return FGComparisonCondition::LESS_THAN;
+ return SGComparisonCondition::LESS_THAN;
else if (v1 > v2)
- return FGComparisonCondition::GREATER_THAN;
+ return SGComparisonCondition::GREATER_THAN;
else
- return FGComparisonCondition::EQUALS;
+ return SGComparisonCondition::EQUALS;
break;
}
}
}
-FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
+SGComparisonCondition::SGComparisonCondition (Type type, bool reverse)
: _type(type),
_reverse(reverse),
_left_property(0),
{
}
-FGComparisonCondition::~FGComparisonCondition ()
+SGComparisonCondition::~SGComparisonCondition ()
{
delete _right_value;
}
bool
-FGComparisonCondition::test () const
+SGComparisonCondition::test () const
{
// Always fail if incompletely specified
if (_left_property == 0 ||
}
void
-FGComparisonCondition::setLeftProperty( SGPropertyNode *prop_root,
+SGComparisonCondition::setLeftProperty( SGPropertyNode *prop_root,
const char * propname )
{
_left_property = prop_root->getNode(propname, true);
}
void
-FGComparisonCondition::setRightProperty( SGPropertyNode *prop_root,
+SGComparisonCondition::setRightProperty( SGPropertyNode *prop_root,
const char * propname )
{
delete _right_value;
}
void
-FGComparisonCondition::setRightValue (const SGPropertyNode *node)
+SGComparisonCondition::setRightValue (const SGPropertyNode *node)
{
_right_property = 0;
delete _right_value;
////////////////////////////////////////////////////////////////////////
// Forward declaration
-static FGCondition * readCondition( SGPropertyNode *prop_root,
+static SGCondition * readCondition( SGPropertyNode *prop_root,
const SGPropertyNode *node );
-static FGCondition *
+static SGCondition *
readPropertyCondition( SGPropertyNode *prop_root,
const SGPropertyNode *node )
{
- return new FGPropertyCondition( prop_root, node->getStringValue() );
+ return new SGPropertyCondition( prop_root, node->getStringValue() );
}
-static FGCondition *
+static SGCondition *
readNotCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
{
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
- FGCondition * condition = readCondition(prop_root, child);
+ SGCondition * condition = readCondition(prop_root, child);
if (condition != 0)
- return new FGNotCondition(condition);
+ return new SGNotCondition(condition);
}
SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
return 0;
}
-static FGCondition *
+static SGCondition *
readAndConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
{
- FGAndCondition * andCondition = new FGAndCondition;
+ SGAndCondition * andCondition = new SGAndCondition;
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
- FGCondition * condition = readCondition(prop_root, child);
+ SGCondition * condition = readCondition(prop_root, child);
if (condition != 0)
andCondition->addCondition(condition);
}
return andCondition;
}
-static FGCondition *
+static SGCondition *
readOrConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
{
- FGOrCondition * orCondition = new FGOrCondition;
+ SGOrCondition * orCondition = new SGOrCondition;
int nChildren = node->nChildren();
for (int i = 0; i < nChildren; i++) {
const SGPropertyNode * child = node->getChild(i);
- FGCondition * condition = readCondition(prop_root, child);
+ SGCondition * condition = readCondition(prop_root, child);
if (condition != 0)
orCondition->addCondition(condition);
}
return orCondition;
}
-static FGCondition *
+static SGCondition *
readComparison( SGPropertyNode *prop_root,
const SGPropertyNode *node,
- FGComparisonCondition::Type type,
+ SGComparisonCondition::Type type,
bool reverse)
{
- FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
+ SGComparisonCondition * condition = new SGComparisonCondition(type, reverse);
condition->setLeftProperty(prop_root, node->getStringValue("property[0]"));
if (node->hasValue("property[1]"))
condition->setRightProperty(prop_root, node->getStringValue("property[1]"));
return condition;
}
-static FGCondition *
+static SGCondition *
readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
{
const string &name = node->getName();
else if (name == "or")
return readOrConditions(prop_root, node);
else if (name == "less-than")
- return readComparison(prop_root, node, FGComparisonCondition::LESS_THAN,
+ return readComparison(prop_root, node, SGComparisonCondition::LESS_THAN,
false);
else if (name == "less-than-equals")
- return readComparison(prop_root, node, FGComparisonCondition::GREATER_THAN,
+ return readComparison(prop_root, node, SGComparisonCondition::GREATER_THAN,
true);
else if (name == "greater-than")
- return readComparison(prop_root, node, FGComparisonCondition::GREATER_THAN,
+ return readComparison(prop_root, node, SGComparisonCondition::GREATER_THAN,
false);
else if (name == "greater-than-equals")
- return readComparison(prop_root, node, FGComparisonCondition::LESS_THAN,
+ return readComparison(prop_root, node, SGComparisonCondition::LESS_THAN,
true);
else if (name == "equals")
- return readComparison(prop_root, node, FGComparisonCondition::EQUALS,
+ return readComparison(prop_root, node, SGComparisonCondition::EQUALS,
false);
else if (name == "not-equals")
- return readComparison(prop_root, node, FGComparisonCondition::EQUALS, true);
+ return readComparison(prop_root, node, SGComparisonCondition::EQUALS, true);
else
return 0;
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGConditional.
+// Implementation of SGConditional.
////////////////////////////////////////////////////////////////////////
-FGConditional::FGConditional ()
+SGConditional::SGConditional ()
: _condition (0)
{
}
-FGConditional::~FGConditional ()
+SGConditional::~SGConditional ()
{
delete _condition;
}
void
-FGConditional::setCondition (FGCondition * condition)
+SGConditional::setCondition (SGCondition * condition)
{
delete _condition;
_condition = condition;
}
bool
-FGConditional::test () const
+SGConditional::test () const
{
return ((_condition == 0) || _condition->test());
}
\f
// The top-level is always an implicit 'and' group
-FGCondition *
-fgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
+SGCondition *
+sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
{
return readAndConditions(prop_root, node);
}
-// end of fg_props.cxx
+// end of condition.cxx
-// condition.hxx - Declarations and inline methods for property conditions.
-// Written by David Megginson, started 2000.
-// CLO May 2003 - Split out condition specific code.
-//
-// This file is in the Public Domain, and comes with no warranty.
+/**
+ * \file condition.hxx
+ * Declarations and inline methods for property conditions.
+ * Written by David Megginson, started 2000.
+ * CLO May 2003 - Split out condition specific code.
+ *
+ * This file is in the Public Domain, and comes with no warranty.
+ */
#ifndef __SG_CONDITION_HXX
#define __SG_CONDITION_HXX
*
* This class should migrate to somewhere more general.
*/
-class FGCondition
+class SGCondition
{
public:
- FGCondition ();
- virtual ~FGCondition ();
+ SGCondition ();
+ virtual ~SGCondition ();
virtual bool test () const = 0;
};
* This condition is true only if the property returns a boolean
* true value.
*/
-class FGPropertyCondition : public FGCondition
+class SGPropertyCondition : public SGCondition
{
public:
- FGPropertyCondition ( SGPropertyNode *prop_root,
+ SGPropertyCondition ( SGPropertyNode *prop_root,
const char * propname );
- virtual ~FGPropertyCondition ();
+ virtual ~SGPropertyCondition ();
virtual bool test () const { return _node->getBoolValue(); }
private:
const SGPropertyNode * _node;
*
* This condition is true only if the child condition is false.
*/
-class FGNotCondition : public FGCondition
+class SGNotCondition : public SGCondition
{
public:
// transfer pointer ownership
- FGNotCondition (FGCondition * condition);
- virtual ~FGNotCondition ();
+ SGNotCondition (SGCondition * condition);
+ virtual ~SGNotCondition ();
virtual bool test () const;
private:
- FGCondition * _condition;
+ SGCondition * _condition;
};
* This condition is true only if all of the conditions
* in the group are true.
*/
-class FGAndCondition : public FGCondition
+class SGAndCondition : public SGCondition
{
public:
- FGAndCondition ();
- virtual ~FGAndCondition ();
+ SGAndCondition ();
+ virtual ~SGAndCondition ();
virtual bool test () const;
// transfer pointer ownership
- virtual void addCondition (FGCondition * condition);
+ virtual void addCondition (SGCondition * condition);
private:
- vector<FGCondition *> _conditions;
+ vector<SGCondition *> _conditions;
};
* This condition is true if at least one of the conditions in the
* group is true.
*/
-class FGOrCondition : public FGCondition
+class SGOrCondition : public SGCondition
{
public:
- FGOrCondition ();
- virtual ~FGOrCondition ();
+ SGOrCondition ();
+ virtual ~SGOrCondition ();
virtual bool test () const;
// transfer pointer ownership
- virtual void addCondition (FGCondition * condition);
+ virtual void addCondition (SGCondition * condition);
private:
- vector<FGCondition *> _conditions;
+ vector<SGCondition *> _conditions;
};
/**
* Abstract base class for property comparison conditions.
*/
-class FGComparisonCondition : public FGCondition
+class SGComparisonCondition : public SGCondition
{
public:
enum Type {
GREATER_THAN,
EQUALS
};
- FGComparisonCondition (Type type, bool reverse = false);
- virtual ~FGComparisonCondition ();
+ SGComparisonCondition (Type type, bool reverse = false);
+ virtual ~SGComparisonCondition ();
virtual bool test () const;
virtual void setLeftProperty( SGPropertyNode *prop_root,
const char * propname );
* invoke the test() method whenever it needs to decide whether to
* active itself, draw itself, and so on.
*/
-class FGConditional
+class SGConditional
{
public:
- FGConditional ();
- virtual ~FGConditional ();
+ SGConditional ();
+ virtual ~SGConditional ();
// transfer pointer ownership
- virtual void setCondition (FGCondition * condition);
- virtual const FGCondition * getCondition () const { return _condition; }
+ virtual void setCondition (SGCondition * condition);
+ virtual const SGCondition * getCondition () const { return _condition; }
virtual bool test () const;
private:
- FGCondition * _condition;
+ SGCondition * _condition;
};
* responsibility of the caller to delete the condition when
* it is no longer needed.
*/
-FGCondition * fgReadCondition( SGPropertyNode *prop_root,
- const SGPropertyNode *node );
+SGCondition *sgReadCondition( SGPropertyNode *prop_root,
+ const SGPropertyNode *node );
#endif // __SG_CONDITION_HXX
-// newmat.cxx -- class to handle material properties
+// mat.cxx -- class to handle material properties
//
// Written by Curtis Olson, started May 1998.
//
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGNewMat::Object.
+// Implementation of SGMaterial::Object.
////////////////////////////////////////////////////////////////////////
-FGNewMat::Object::Object (const SGPropertyNode * node, double range_m)
+SGMaterial::Object::Object (const SGPropertyNode * node, double range_m)
: _models_loaded(false),
_coverage_m2(node->getDoubleValue("coverage-m2", 1000000)),
_range_m(range_m)
// load_models();
}
-FGNewMat::Object::~Object ()
+SGMaterial::Object::~Object ()
{
for (unsigned int i = 0; i < _models.size(); i++) {
if (_models[i] != 0) {
}
int
-FGNewMat::Object::get_model_count( FGModelLoader *loader,
+SGMaterial::Object::get_model_count( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec )
}
inline void
-FGNewMat::Object::load_models ( FGModelLoader *loader,
+SGMaterial::Object::load_models ( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec )
}
ssgEntity *
-FGNewMat::Object::get_model( int index,
- FGModelLoader *loader,
+SGMaterial::Object::get_model( int index,
+ SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec )
}
ssgEntity *
-FGNewMat::Object::get_random_model( FGModelLoader *loader,
+SGMaterial::Object::get_random_model( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec )
}
double
-FGNewMat::Object::get_coverage_m2 () const
+SGMaterial::Object::get_coverage_m2 () const
{
return _coverage_m2;
}
-FGNewMat::Object::HeadingType
-FGNewMat::Object::get_heading_type () const
+SGMaterial::Object::HeadingType
+SGMaterial::Object::get_heading_type () const
{
return _heading_type;
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGNewMat::ObjectGroup.
+// Implementation of SGMaterial::ObjectGroup.
////////////////////////////////////////////////////////////////////////
-FGNewMat::ObjectGroup::ObjectGroup (SGPropertyNode * node)
+SGMaterial::ObjectGroup::ObjectGroup (SGPropertyNode * node)
: _range_m(node->getDoubleValue("range-m", 2000))
{
// Load the object subnodes
}
}
-FGNewMat::ObjectGroup::~ObjectGroup ()
+SGMaterial::ObjectGroup::~ObjectGroup ()
{
for (unsigned int i = 0; i < _objects.size(); i++) {
delete _objects[i];
}
double
-FGNewMat::ObjectGroup::get_range_m () const
+SGMaterial::ObjectGroup::get_range_m () const
{
return _range_m;
}
int
-FGNewMat::ObjectGroup::get_object_count () const
+SGMaterial::ObjectGroup::get_object_count () const
{
return _objects.size();
}
-FGNewMat::Object *
-FGNewMat::ObjectGroup::get_object (int index) const
+SGMaterial::Object *
+SGMaterial::ObjectGroup::get_object (int index) const
{
return _objects[index];
}
////////////////////////////////////////////////////////////////////////
-FGNewMat::FGNewMat( const string &fg_root,
+SGMaterial::SGMaterial( const string &fg_root,
const SGPropertyNode *props,
bool smooth_shading,
bool use_textures )
build_ssg_state( false, smooth_shading, use_textures );
}
-FGNewMat::FGNewMat( const string &texpath,
+SGMaterial::SGMaterial( const string &texpath,
bool smooth_shading,
bool use_textures )
{
build_ssg_state( true, smooth_shading, use_textures );
}
-FGNewMat::FGNewMat( ssgSimpleState *s,
+SGMaterial::SGMaterial( ssgSimpleState *s,
bool smooth_shading,
bool use_textures )
{
set_ssg_state( s, smooth_shading, use_textures );
}
-FGNewMat::~FGNewMat (void)
+SGMaterial::~SGMaterial (void)
{
for (unsigned int i = 0; i < object_groups.size(); i++) {
delete object_groups[i];
////////////////////////////////////////////////////////////////////////
void
-FGNewMat::read_properties( const string &fg_root, const SGPropertyNode * props )
+SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props )
{
// Get the path to the texture
string tname = props->getStringValue("texture", "unknown.rgb");
////////////////////////////////////////////////////////////////////////
void
-FGNewMat::init ()
+SGMaterial::init ()
{
texture_path = "";
state = 0;
}
bool
-FGNewMat::load_texture ()
+SGMaterial::load_texture ()
{
if (texture_loaded) {
return false;
void
-FGNewMat::build_ssg_state( bool defer_tex_load,
+SGMaterial::build_ssg_state( bool defer_tex_load,
bool smooth_shading,
bool use_textures )
{
}
-void FGNewMat::set_ssg_state( ssgSimpleState *s,
+void SGMaterial::set_ssg_state( ssgSimpleState *s,
bool smooth_shading, bool use_textures )
{
GLenum shade_model = ( smooth_shading ? GL_SMOOTH : GL_FLAT);
-// newmat.hxx -- a material in the scene graph.
+// mat.hxx -- a material in the scene graph.
// TODO: this class needs to be renamed.
//
// Written by Curtis Olson, started May 1998.
// $Id$
-#ifndef _NEWMAT_HXX
-#define _NEWMAT_HXX
+#ifndef _SG_MAT_HXX
+#define _SG_MAT_HXX
#ifndef __cplusplus
# error This library requires C++
* defined in the $FG_ROOT/materials.xml file, and can be changed
* at runtime.
*/
-class FGNewMat {
+class SGMaterial {
public:
/**
* A randomly-placeable object.
*
- * FGNewMat uses this class to keep track of the model(s) and
+ * SGMaterial uses this class to keep track of the model(s) and
* parameters for a single instance of a randomly-placeable object.
* The object can have more than one variant model (i.e. slightly
* different shapes of trees), but they are considered equivalent
*
* @return The number of variant models.
*/
- int get_model_count( FGModelLoader *loader,
+ int get_model_count( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec );
* @return The model.
*/
ssgEntity *get_model( int index,
- FGModelLoader *loader,
+ SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec );
*
* @return A randomly select model from the variants.
*/
- ssgEntity *get_random_model( FGModelLoader *loader,
+ ssgEntity *get_random_model( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec );
* This class uses lazy loading so that models won't be held
* in memory for materials that are never referenced.
*/
- void load_models( FGModelLoader *loader,
+ void load_models( SGModelLoader *loader,
const string &fg_root,
SGPropertyNode *prop_root,
double sim_time_sec );
*
* Grouping objects with the same range together significantly
* reduces the memory requirements of randomly-placed objects.
- * Each FGNewMat instance keeps a (possibly-empty) list of
+ * Each SGMaterial instance keeps a (possibly-empty) list of
* object groups for placing randomly on the scenery.
*/
class ObjectGroup
protected:
- friend class FGNewMat;
+ friend class SGMaterial;
ObjectGroup (SGPropertyNode * node);
* state information for the material. This node is usually
* loaded from the $FG_ROOT/materials.xml file.
*/
- FGNewMat( const string &fg_root, const SGPropertyNode *props,
+ SGMaterial( const string &fg_root, const SGPropertyNode *props,
bool smooth_shading, bool use_textures );
* @param texture_path A string containing an absolute path
* to a texture file (usually RGB).
*/
- FGNewMat( const string &texpath, bool smooth_shading, bool use_textures );
+ SGMaterial( const string &texpath, bool smooth_shading, bool use_textures );
/**
*
* @param s The SSG state for this material.
*/
- FGNewMat( ssgSimpleState *s, bool smooth_shading, bool use_textures );
+ SGMaterial( ssgSimpleState *s, bool smooth_shading, bool use_textures );
/**
* Destructor.
*/
- virtual ~FGNewMat( void );
+ virtual ~SGMaterial( void );
\f
// Internal constructors and methods.
////////////////////////////////////////////////////////////////////
- FGNewMat( const string &fg_root, const FGNewMat &mat ); // unimplemented
+ SGMaterial( const string &fg_root, const SGMaterial &mat ); // unimplemented
void read_properties( const string &fg_root, const SGPropertyNode *props );
void build_ssg_state( bool defer_tex_load,
};
-#endif // _NEWMAT_HXX
+#endif // _SG_MAT_HXX
// global material management class
-FGMaterialLib material_lib;
+SGMaterialLib material_lib;
// Constructor
-FGMaterialLib::FGMaterialLib ( void ) {
+SGMaterialLib::SGMaterialLib ( void ) {
set_step(0);
}
// Load a library of material properties
-bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
+bool SGMaterialLib::load( const string &fg_root, const string& mpath ) {
SGPropertyNode materials;
for (int i = 0; i < nMaterials; i++) {
const SGPropertyNode * node = materials.getChild(i);
if (!strcmp(node->getName(), "material")) {
- FGNewMat *m = new FGNewMat( fg_root, node, true, true );
+ SGMaterial *m = new SGMaterial( fg_root, node, true, true );
vector<SGPropertyNode_ptr>names = node->getChildren("name");
for ( unsigned int j = 0; j < names.size(); j++ ) {
gnd_lights->enable( GL_BLEND );
gnd_lights->disable( GL_ALPHA_TEST );
gnd_lights->disable( GL_LIGHTING );
- matlib["GROUND_LIGHTS"] = new FGNewMat( gnd_lights, true, true );
+ matlib["GROUND_LIGHTS"] = new SGMaterial( gnd_lights, true, true );
GLuint tex_name;
rwy_white_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
rwy_white_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_white_lights->setTexture( tex_name );
- matlib["RWY_WHITE_LIGHTS"] = new FGNewMat( rwy_white_lights, true, true );
+ matlib["RWY_WHITE_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
// For backwards compatibility ... remove someday
- matlib["RUNWAY_LIGHTS"] = new FGNewMat( rwy_white_lights, true, true );
- matlib["RWY_LIGHTS"] = new FGNewMat( rwy_white_lights, true, true );
+ matlib["RUNWAY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
+ matlib["RWY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
// end of backwards compatitibilty
// hard coded runway medium intensity white light state
rwy_white_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_white_medium_lights->setTexture( tex_name );
matlib["RWY_WHITE_MEDIUM_LIGHTS"]
- = new FGNewMat( rwy_white_medium_lights, true, true );
+ = new SGMaterial( rwy_white_medium_lights, true, true );
// hard coded runway low intensity white light state
tex_name = gen_standard_dir_light_map( 235, 235, 195, 155 );
rwy_white_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_white_low_lights->setTexture( tex_name );
matlib["RWY_WHITE_LOW_LIGHTS"]
- = new FGNewMat( rwy_white_low_lights, true, true );
+ = new SGMaterial( rwy_white_low_lights, true, true );
// hard coded runway yellow light state
tex_name = gen_standard_dir_light_map( 235, 215, 20, 255 );
rwy_yellow_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
rwy_yellow_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_yellow_lights->setTexture( tex_name );
- matlib["RWY_YELLOW_LIGHTS"] = new FGNewMat( rwy_yellow_lights, true, true );
+ matlib["RWY_YELLOW_LIGHTS"] = new SGMaterial( rwy_yellow_lights, true, true );
// hard coded runway medium intensity yellow light state
tex_name = gen_standard_dir_light_map( 235, 215, 20, 205 );
rwy_yellow_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_yellow_medium_lights->setTexture( tex_name );
matlib["RWY_YELLOW_MEDIUM_LIGHTS"]
- = new FGNewMat( rwy_yellow_medium_lights, true, true );
+ = new SGMaterial( rwy_yellow_medium_lights, true, true );
// hard coded runway low intensity yellow light state
tex_name = gen_standard_dir_light_map( 235, 215, 20, 155 );
rwy_yellow_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_yellow_low_lights->setTexture( tex_name );
matlib["RWY_YELLOW_LOW_LIGHTS"]
- = new FGNewMat( rwy_yellow_low_lights, true, true );
+ = new SGMaterial( rwy_yellow_low_lights, true, true );
// hard coded runway red light state
tex_name = gen_standard_dir_light_map( 235, 90, 90, 255 );
rwy_red_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_red_lights->setTexture( tex_name );
matlib["RWY_RED_LIGHTS"]
- = new FGNewMat( rwy_red_lights, true, true );
+ = new SGMaterial( rwy_red_lights, true, true );
// hard coded medium intensity runway red light state
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
rwy_red_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_red_medium_lights->setTexture( tex_name );
matlib["RWY_RED_MEDIUM_LIGHTS"]
- = new FGNewMat( rwy_red_medium_lights, true, true );
+ = new SGMaterial( rwy_red_medium_lights, true, true );
// hard coded low intensity runway red light state
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
rwy_red_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_red_low_lights->setTexture( tex_name );
matlib["RWY_RED_LOW_LIGHTS"]
- = new FGNewMat( rwy_red_low_lights, true, true );
+ = new SGMaterial( rwy_red_low_lights, true, true );
// hard coded runway green light state
tex_name = gen_standard_dir_light_map( 20, 235, 20, 255 );
rwy_green_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_green_lights->setTexture( tex_name );
matlib["RWY_GREEN_LIGHTS"]
- = new FGNewMat( rwy_green_lights, true, true );
+ = new SGMaterial( rwy_green_lights, true, true );
// hard coded medium intensity runway green light state
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
rwy_green_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_green_medium_lights->setTexture( tex_name );
matlib["RWY_GREEN_MEDIUM_LIGHTS"]
- = new FGNewMat( rwy_green_medium_lights, true, true );
+ = new SGMaterial( rwy_green_medium_lights, true, true );
// hard coded low intensity runway green light state
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
rwy_green_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_green_low_lights->setTexture( tex_name );
matlib["RWY_GREEN_LOW_LIGHTS"]
- = new FGNewMat( rwy_green_low_lights, true, true );
+ = new SGMaterial( rwy_green_low_lights, true, true );
// hard coded low intensity taxiway blue light state
tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
taxiway_blue_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
taxiway_blue_low_lights->setTexture( tex_name );
matlib["RWY_BLUE_TAXIWAY_LIGHTS"]
- = new FGNewMat( taxiway_blue_low_lights, true, true );
+ = new SGMaterial( taxiway_blue_low_lights, true, true );
// hard coded runway vasi light state
ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
rwy_vasi_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
rwy_vasi_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
rwy_vasi_lights->setTexture( gen_vasi_light_map() );
- matlib["RWY_VASI_LIGHTS"] = new FGNewMat( rwy_vasi_lights, true, true );
+ matlib["RWY_VASI_LIGHTS"] = new SGMaterial( rwy_vasi_lights, true, true );
return true;
}
// Load a library of material properties
-bool FGMaterialLib::add_item ( const string &tex_path )
+bool SGMaterialLib::add_item ( const string &tex_path )
{
string material_name = tex_path;
int pos = tex_path.rfind( "/" );
// Load a library of material properties
-bool FGMaterialLib::add_item ( const string &mat_name, const string &full_path )
+bool SGMaterialLib::add_item ( const string &mat_name, const string &full_path )
{
int pos = full_path.rfind( "/" );
string tex_name = full_path.substr( pos + 1 );
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
<< mat_name << " (" << full_path << ")");
- material_lib.matlib[mat_name] = new FGNewMat( full_path, true, true );
+ material_lib.matlib[mat_name] = new SGMaterial( full_path, true, true );
return true;
}
// Load a library of material properties
-bool FGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
+bool SGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
{
- FGNewMat *m = new FGNewMat( state, true, true );
+ SGMaterial *m = new SGMaterial( state, true, true );
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material given a premade "
<< "ssgSimpleState = " << mat_name );
// find a material record by material name
-FGNewMat *FGMaterialLib::find( const string& material ) {
- FGNewMat *result = NULL;
+SGMaterial *SGMaterialLib::find( const string& material ) {
+ SGMaterial *result = NULL;
material_map_iterator it = matlib.find( material );
if ( it != end() ) {
result = it->second;
// Destructor
-FGMaterialLib::~FGMaterialLib ( void ) {
+SGMaterialLib::~SGMaterialLib ( void ) {
// Free up all the material entries first
for ( material_map_iterator it = begin(); it != end(); it++ ) {
- FGNewMat *slot = it->second;
+ SGMaterial *slot = it->second;
slot->deRef();
if ( slot->getRef() <= 0 ) {
delete slot;
// Set the step for all of the state selectors in the material slots
-void FGMaterialLib::set_step ( int step )
+void SGMaterialLib::set_step ( int step )
{
// container::iterator it = begin();
for ( material_map_iterator it = begin(); it != end(); it++ ) {
const string &key = it->first;
SG_LOG( SG_GENERAL, SG_INFO,
"Updating material " << key << " to step " << step );
- FGNewMat *slot = it->second;
+ SGMaterial *slot = it->second;
slot->get_state()->selectStep(step);
}
}
// Get the step for the state selectors
-int FGMaterialLib::get_step ()
+int SGMaterialLib::get_step ()
{
material_map_iterator it = begin();
return it->second->get_state()->getSelectStep();
// Load one pending "deferred" texture. Return true if a texture
// loaded successfully, false if no pending, or error.
-void FGMaterialLib::load_next_deferred() {
+void SGMaterialLib::load_next_deferred() {
// container::iterator it = begin();
for ( material_map_iterator it = begin(); it != end(); it++ ) {
/* we don't need the key, but here's how we'd get it if we wanted it. */
// const string &key = it->first;
- FGNewMat *slot = it->second;
+ SGMaterial *slot = it->second;
if (slot->load_texture())
return;
}
#include <plib/ssg.h> // plib include
-class FGNewMat;
+class SGMaterial;
SG_USING_STD(string);
SG_USING_STD(map);
// Material management class
-class FGMaterialLib {
+class SGMaterialLib {
private:
// associative array of materials
- typedef map < string, FGNewMat *, less<string> > material_map;
+ typedef map < string, SGMaterial *, less<string> > material_map;
typedef material_map::iterator material_map_iterator;
typedef material_map::const_iterator const_material_map_iterator;
public:
// Constructor
- FGMaterialLib ( void );
+ SGMaterialLib ( void );
// Load a library of material properties
bool load( const string &fg_root, const string& mpath );
bool add_item( const string &mat_name, ssgSimpleState *state );
// find a material record by material name
- FGNewMat *find( const string& material );
+ SGMaterial *find( const string& material );
void set_step (int step);
int get_step ();
const_material_map_iterator end() const { return matlib.end(); }
// Destructor
- ~FGMaterialLib ( void );
+ ~SGMaterialLib ( void );
};
// global material management class
-extern FGMaterialLib material_lib;
+extern SGMaterialLib material_lib;
#endif // _MATLIB_HXX
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of Animation
+// Implementation of SGAnimation
////////////////////////////////////////////////////////////////////////
// Initialize the static data member
-double Animation::sim_time_sec = 0.0;
+double SGAnimation::sim_time_sec = 0.0;
-Animation::Animation (SGPropertyNode_ptr props, ssgBranch * branch)
+SGAnimation::SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch)
: _branch(branch)
{
_branch->setName(props->getStringValue("name", 0));
}
-Animation::~Animation ()
+SGAnimation::~SGAnimation ()
{
}
void
-Animation::init ()
+SGAnimation::init ()
{
}
void
-Animation::update()
+SGAnimation::update()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of NullAnimation
+// Implementation of SGNullAnimation
////////////////////////////////////////////////////////////////////////
-NullAnimation::NullAnimation (SGPropertyNode_ptr props)
- : Animation(props, new ssgBranch)
+SGNullAnimation::SGNullAnimation (SGPropertyNode_ptr props)
+ : SGAnimation(props, new ssgBranch)
{
}
-NullAnimation::~NullAnimation ()
+SGNullAnimation::~SGNullAnimation ()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of RangeAnimation
+// Implementation of SGRangeAnimation
////////////////////////////////////////////////////////////////////////
-RangeAnimation::RangeAnimation (SGPropertyNode_ptr props)
- : Animation(props, new ssgRangeSelector)
+SGRangeAnimation::SGRangeAnimation (SGPropertyNode_ptr props)
+ : SGAnimation(props, new ssgRangeSelector)
{
float ranges[] = { props->getFloatValue("min-m", 0),
props->getFloatValue("max-m", 5000) };
}
-RangeAnimation::~RangeAnimation ()
+SGRangeAnimation::~SGRangeAnimation ()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of BillboardAnimation
+// Implementation of SGBillboardAnimation
////////////////////////////////////////////////////////////////////////
-BillboardAnimation::BillboardAnimation (SGPropertyNode_ptr props)
- : Animation(props, new ssgCutout(props->getBoolValue("spherical", true)))
+SGBillboardAnimation::SGBillboardAnimation (SGPropertyNode_ptr props)
+ : SGAnimation(props, new ssgCutout(props->getBoolValue("spherical", true)))
{
}
-BillboardAnimation::~BillboardAnimation ()
+SGBillboardAnimation::~SGBillboardAnimation ()
{
}
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of SelectAnimation
+// Implementation of SGSelectAnimation
////////////////////////////////////////////////////////////////////////
-SelectAnimation::SelectAnimation( SGPropertyNode *prop_root,
+SGSelectAnimation::SGSelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
- : Animation(props, new ssgSelector),
+ : SGAnimation(props, new ssgSelector),
_condition(0)
{
SGPropertyNode_ptr node = props->getChild("condition");
if (node != 0)
- _condition = fgReadCondition(prop_root, node);
+ _condition = sgReadCondition(prop_root, node);
}
-SelectAnimation::~SelectAnimation ()
+SGSelectAnimation::~SGSelectAnimation ()
{
delete _condition;
}
void
-SelectAnimation::update()
+SGSelectAnimation::update()
{
if (_condition != 0 && _condition->test())
((ssgSelector *)_branch)->select(0xffff);
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of SpinAnimation
+// Implementation of SGSpinAnimation
////////////////////////////////////////////////////////////////////////
-SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
+SGSpinAnimation::SGSpinAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props,
double sim_time_sec )
- : Animation(props, new ssgTransform),
+ : SGAnimation(props, new ssgTransform),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_factor(props->getDoubleValue("factor", 1.0)),
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
sgNormalizeVec3(_axis);
}
-SpinAnimation::~SpinAnimation ()
+SGSpinAnimation::~SGSpinAnimation ()
{
}
void
-SpinAnimation::update()
+SGSpinAnimation::update()
{
double dt = sim_time_sec - _last_time_sec;
_last_time_sec = sim_time_sec;
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of TimedAnimation
+// Implementation of SGTimedAnimation
////////////////////////////////////////////////////////////////////////
-TimedAnimation::TimedAnimation (SGPropertyNode_ptr props)
- : Animation(props, new ssgSelector),
+SGTimedAnimation::SGTimedAnimation (SGPropertyNode_ptr props)
+ : SGAnimation(props, new ssgSelector),
_duration_sec(props->getDoubleValue("duration-sec", 1.0)),
_last_time_sec(0),
_step(-1)
{
}
-TimedAnimation::~TimedAnimation ()
+SGTimedAnimation::~SGTimedAnimation ()
{
}
void
-TimedAnimation::update()
+SGTimedAnimation::update()
{
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
_last_time_sec = sim_time_sec;
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of RotateAnimation
+// Implementation of SGRotateAnimation
////////////////////////////////////////////////////////////////////////
-RotateAnimation::RotateAnimation( SGPropertyNode *prop_root,
+SGRotateAnimation::SGRotateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
- : Animation(props, new ssgTransform),
+ : SGAnimation(props, new ssgTransform),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_offset_deg(props->getDoubleValue("offset-deg", 0.0)),
_factor(props->getDoubleValue("factor", 1.0)),
sgNormalizeVec3(_axis);
}
-RotateAnimation::~RotateAnimation ()
+SGRotateAnimation::~SGRotateAnimation ()
{
delete _table;
}
void
-RotateAnimation::update()
+SGRotateAnimation::update()
{
if (_table == 0) {
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of TranslateAnimation
+// Implementation of SGTranslateAnimation
////////////////////////////////////////////////////////////////////////
-TranslateAnimation::TranslateAnimation( SGPropertyNode *prop_root,
+SGTranslateAnimation::SGTranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props )
- : Animation(props, new ssgTransform),
+ : SGAnimation(props, new ssgTransform),
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_offset_m(props->getDoubleValue("offset-m", 0.0)),
_factor(props->getDoubleValue("factor", 1.0)),
sgNormalizeVec3(_axis);
}
-TranslateAnimation::~TranslateAnimation ()
+SGTranslateAnimation::~SGTranslateAnimation ()
{
delete _table;
}
void
-TranslateAnimation::update()
+SGTranslateAnimation::update()
{
if (_table == 0) {
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
// Don't pull in the headers, since we don't need them here.
class SGInterpTable;
-class FGCondition;
+class SGCondition;
// Has anyone done anything *really* stupid, like making min and max macros?
/**
* Abstract base class for all animations.
*/
-class Animation : public ssgBase
+class SGAnimation : public ssgBase
{
public:
- Animation (SGPropertyNode_ptr props, ssgBranch * branch);
+ SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch);
- virtual ~Animation ();
+ virtual ~SGAnimation ();
/**
* Get the SSG branch holding the animation.
/**
* A no-op animation.
*/
-class NullAnimation : public Animation
+class SGNullAnimation : public SGAnimation
{
public:
- NullAnimation (SGPropertyNode_ptr props);
- virtual ~NullAnimation ();
+ SGNullAnimation (SGPropertyNode_ptr props);
+ virtual ~SGNullAnimation ();
};
/**
* A range, or level-of-detail (LOD) animation.
*/
-class RangeAnimation : public Animation
+class SGRangeAnimation : public SGAnimation
{
public:
- RangeAnimation (SGPropertyNode_ptr props);
- virtual ~RangeAnimation ();
+ SGRangeAnimation (SGPropertyNode_ptr props);
+ virtual ~SGRangeAnimation ();
};
/**
* Animation to turn and face the screen.
*/
-class BillboardAnimation : public Animation
+class SGBillboardAnimation : public SGAnimation
{
public:
- BillboardAnimation (SGPropertyNode_ptr props);
- virtual ~BillboardAnimation ();
+ SGBillboardAnimation (SGPropertyNode_ptr props);
+ virtual ~SGBillboardAnimation ();
};
/**
* Animation to select alternative versions of the same object.
*/
-class SelectAnimation : public Animation
+class SGSelectAnimation : public SGAnimation
{
public:
- SelectAnimation( SGPropertyNode *prop_root,
+ SGSelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
- virtual ~SelectAnimation ();
+ virtual ~SGSelectAnimation ();
virtual void update();
private:
- FGCondition * _condition;
+ SGCondition * _condition;
};
*
* This animation rotates at a specific velocity.
*/
-class SpinAnimation : public Animation
+class SGSpinAnimation : public SGAnimation
{
public:
- SpinAnimation( SGPropertyNode *prop_root,
+ SGSpinAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props,
double sim_time_sec );
- virtual ~SpinAnimation ();
+ virtual ~SGSpinAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
/**
* Animation to draw objects for a specific amount of time each.
*/
-class TimedAnimation : public Animation
+class SGTimedAnimation : public SGAnimation
{
public:
- TimedAnimation (SGPropertyNode_ptr props);
- virtual ~TimedAnimation ();
+ SGTimedAnimation (SGPropertyNode_ptr props);
+ virtual ~SGTimedAnimation ();
virtual void update();
private:
double _duration_sec;
*
* This animation rotates to a specific position.
*/
-class RotateAnimation : public Animation
+class SGRotateAnimation : public SGAnimation
{
public:
- RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
- virtual ~RotateAnimation ();
+ SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
+ virtual ~SGRotateAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
/**
* Animation to slide along an axis.
*/
-class TranslateAnimation : public Animation
+class SGTranslateAnimation : public SGAnimation
{
public:
- TranslateAnimation( SGPropertyNode *prop_root,
+ SGTranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
- virtual ~TranslateAnimation ();
+ virtual ~SGTranslateAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGSSGLoader.
+// Implementation of SGssgLoader.
////////////////////////////////////////////////////////////////////////
-FGSSGLoader::FGSSGLoader ()
+SGssgLoader::SGssgLoader ()
{
// no op
}
-FGSSGLoader::~FGSSGLoader ()
+SGssgLoader::~SGssgLoader ()
{
std::map<string, ssgBase *>::iterator it = _table.begin();
while (it != _table.end()) {
}
void
-FGSSGLoader::flush ()
+SGssgLoader::flush ()
{
std::map<string, ssgBase *>::iterator it = _table.begin();
while (it != _table.end()) {
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGModelLoader.
+// Implementation of SGModelLoader.
////////////////////////////////////////////////////////////////////////
-FGModelLoader::FGModelLoader ()
+SGModelLoader::SGModelLoader ()
{
}
-FGModelLoader::~FGModelLoader ()
+SGModelLoader::~SGModelLoader ()
{
}
ssgEntity *
-FGModelLoader::load_model( const string &fg_root,
+SGModelLoader::load_model( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
double sim_time_sec )
// avoid duplicates.
std::map<string, ssgBase *>::iterator it = _table.find(path);
if (it == _table.end()) {
- _table[path] = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
+ _table[path] = sgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
it = _table.find(path);
it->second->ref(); // add one reference to keep it around
}
/**
* Base class for loading and managing SSG things.
*/
-class FGSSGLoader
+class SGssgLoader
{
public:
- FGSSGLoader ();
- virtual ~FGSSGLoader ();
+ SGssgLoader ();
+ virtual ~SGssgLoader ();
virtual void flush ();
protected:
std::map<string,ssgBase *> _table;
/**
* Class for loading and managing models with XML wrappers.
*/
-class FGModelLoader : public FGSSGLoader
+class SGModelLoader : public SGssgLoader
{
public:
- FGModelLoader ();
- virtual ~FGModelLoader ();
+ SGModelLoader ();
+ virtual ~SGModelLoader ();
virtual ssgEntity *load_model( const string &fg_root,
const string &path,
////////////////////////////////////////////////////////////////////////
-// Implementation of FGLocation.
+// Implementation of SGLocation.
////////////////////////////////////////////////////////////////////////
// Constructor
-FGLocation::FGLocation( void ):
+SGLocation::SGLocation( void ):
_dirty(true),
_lon_deg(0),
_lat_deg(0),
// Destructor
-FGLocation::~FGLocation( void ) {
+SGLocation::~SGLocation( void ) {
}
void
-FGLocation::init ()
+SGLocation::init ()
{
}
void
-FGLocation::bind ()
+SGLocation::bind ()
{
}
void
-FGLocation::unbind ()
+SGLocation::unbind ()
{
}
void
-FGLocation::setPosition (double lon_deg, double lat_deg, double alt_ft)
+SGLocation::setPosition (double lon_deg, double lat_deg, double alt_ft)
{
_dirty = true;
_lon_deg = lon_deg;
}
void
-FGLocation::setOrientation (double roll_deg, double pitch_deg, double heading_deg)
+SGLocation::setOrientation (double roll_deg, double pitch_deg, double heading_deg)
{
_dirty = true;
_roll_deg = roll_deg;
}
double *
-FGLocation::get_absolute_view_pos( const Point3D scenery_center )
+SGLocation::get_absolute_view_pos( const Point3D scenery_center )
{
if ( _dirty ) {
recalc( scenery_center );
}
float *
-FGLocation::getRelativeViewPos( const Point3D scenery_center )
+SGLocation::getRelativeViewPos( const Point3D scenery_center )
{
if ( _dirty ) {
recalc( scenery_center );
}
float *
-FGLocation::getZeroElevViewPos( const Point3D scenery_center )
+SGLocation::getZeroElevViewPos( const Point3D scenery_center )
{
if ( _dirty ) {
recalc( scenery_center );
// cached data "dirty") on the next "get". It calculates all the outputs
// for viewer.
void
-FGLocation::recalc( const Point3D scenery_center )
+SGLocation::recalc( const Point3D scenery_center )
{
recalcPosition( _lon_deg, _lat_deg, _alt_ft, scenery_center );
}
void
-FGLocation::recalcPosition( double lon_deg, double lat_deg, double alt_ft,
+SGLocation::recalcPosition( double lon_deg, double lat_deg, double alt_ft,
const Point3D scenery_center ) const
{
double sea_level_radius_m;
}
void
-FGLocation::update (int dt)
+SGLocation::update (int dt)
{
}
// Define a structure containing view information
-class FGLocation
+class SGLocation
{
public:
// Constructor
- FGLocation( void );
+ SGLocation( void );
// Destructor
- virtual ~FGLocation( void );
+ virtual ~SGLocation( void );
//////////////////////////////////////////////////////////////////////
// Part 1: standard FGSubsystem implementation.
static int
animation_callback (ssgEntity * entity, int mask)
{
- ((Animation *)entity->getUserData())->update();
+ ((SGAnimation *)entity->getUserData())->update();
return true;
}
* Make an offset matrix from rotations and position offset.
*/
void
-fgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
+sgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
double x_off, double y_off, double z_off )
{
sgMat4 rot_matrix;
void
-fgMakeAnimation( ssgBranch * model,
+sgMakeAnimation( ssgBranch * model,
const char * name,
vector<SGPropertyNode_ptr> &name_nodes,
SGPropertyNode *prop_root,
SGPropertyNode_ptr node,
double sim_time_sec )
{
- Animation * animation = 0;
+ SGAnimation * animation = 0;
const char * type = node->getStringValue("type", "none");
if (!strcmp("none", type)) {
- animation = new NullAnimation(node);
+ animation = new SGNullAnimation(node);
} else if (!strcmp("range", type)) {
- animation = new RangeAnimation(node);
+ animation = new SGRangeAnimation(node);
} else if (!strcmp("billboard", type)) {
- animation = new BillboardAnimation(node);
+ animation = new SGBillboardAnimation(node);
} else if (!strcmp("select", type)) {
- animation = new SelectAnimation(prop_root, node);
+ animation = new SGSelectAnimation(prop_root, node);
} else if (!strcmp("spin", type)) {
- animation = new SpinAnimation(prop_root, node, sim_time_sec );
+ animation = new SGSpinAnimation(prop_root, node, sim_time_sec );
} else if (!strcmp("timed", type)) {
- animation = new TimedAnimation(node);
+ animation = new SGTimedAnimation(node);
} else if (!strcmp("rotate", type)) {
- animation = new RotateAnimation(prop_root, node);
+ animation = new SGRotateAnimation(prop_root, node);
} else if (!strcmp("translate", type)) {
- animation = new TranslateAnimation(prop_root, node);
+ animation = new SGTranslateAnimation(prop_root, node);
} else {
- animation = new NullAnimation(node);
+ animation = new SGNullAnimation(node);
SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
}
////////////////////////////////////////////////////////////////////////
ssgBranch *
-fgLoad3DModel( const string &fg_root, const string &path,
+sgLoad3DModel( const string &fg_root, const string &path,
SGPropertyNode *prop_root,
double sim_time_sec )
{
ssgTransform * alignmainmodel = new ssgTransform;
alignmainmodel->addKid(model);
sgMat4 res_matrix;
- fgMakeOffsetsMatrix(&res_matrix,
+ sgMakeOffsetsMatrix(&res_matrix,
props.getFloatValue("/offsets/heading-deg", 0.0),
props.getFloatValue("/offsets/roll-deg", 0.0),
props.getFloatValue("/offsets/pitch-deg", 0.0),
const char * name = animation_nodes[i]->getStringValue("name", 0);
vector<SGPropertyNode_ptr> name_nodes =
animation_nodes[i]->getChildren("object-name");
- fgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
+ sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
sim_time_sec);
}
SGPropertyNode_ptr node = model_nodes[i];
ssgTransform * align = new ssgTransform;
sgMat4 res_matrix;
- fgMakeOffsetsMatrix(&res_matrix,
+ sgMakeOffsetsMatrix(&res_matrix,
node->getFloatValue("offsets/heading-deg", 0.0),
node->getFloatValue("offsets/roll-deg", 0.0),
node->getFloatValue("offsets/pitch-deg", 0.0),
node->getFloatValue("offsets/z-m", 0.0));
align->setTransform(res_matrix);
- ssgBranch * kid = fgLoad3DModel( fg_root, node->getStringValue("path"),
+ ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"),
prop_root, sim_time_sec );
align->addKid(kid);
model->addKid(align);
* Subsystems should not normally invoke this function directly;
* instead, they should use the FGModelLoader declared in loader.hxx.
*/
-ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
- SGPropertyNode *prop_root, double sim_time_sec );
+ssgBranch *
+sgLoad3DModel( const string& fg_root, const string &path,
+ SGPropertyNode *prop_root, double sim_time_sec );
/**
* Make an offset matrix from rotations and position offset.
*/
void
-fgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
+sgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
double x_off, double y_off, double z_off );
/**
* Make the animation
*/
void
-fgMakeAnimation( ssgBranch * model,
+sgMakeAnimation( ssgBranch * model,
const char * name,
vector<SGPropertyNode_ptr> &name_nodes,
SGPropertyNode *prop_root,
\f
////////////////////////////////////////////////////////////////////////
-// Implementation of FGModelPlacement.
+// Implementation of SGModelPlacement.
////////////////////////////////////////////////////////////////////////
-FGModelPlacement::FGModelPlacement ()
+SGModelPlacement::SGModelPlacement ()
: _lon_deg(0),
_lat_deg(0),
_elev_ft(0),
_heading_deg(0),
_selector(new ssgSelector),
_position(new ssgTransform),
- _location(new FGLocation)
+ _location(new SGLocation)
{
}
-FGModelPlacement::~FGModelPlacement ()
+SGModelPlacement::~SGModelPlacement ()
{
}
void
-FGModelPlacement::init( ssgBranch * model )
+SGModelPlacement::init( ssgBranch * model )
{
if (model != 0) {
_position->addKid(model);
}
void
-FGModelPlacement::update( const Point3D scenery_center )
+SGModelPlacement::update( const Point3D scenery_center )
{
_location->setPosition( _lon_deg, _lat_deg, _elev_ft );
_location->setOrientation( _roll_deg, _pitch_deg, _heading_deg );
}
bool
-FGModelPlacement::getVisible () const
+SGModelPlacement::getVisible () const
{
return (_selector->getSelect() != 0);
}
void
-FGModelPlacement::setVisible (bool visible)
+SGModelPlacement::setVisible (bool visible)
{
_selector->select(visible);
}
void
-FGModelPlacement::setLongitudeDeg (double lon_deg)
+SGModelPlacement::setLongitudeDeg (double lon_deg)
{
_lon_deg = lon_deg;
}
void
-FGModelPlacement::setLatitudeDeg (double lat_deg)
+SGModelPlacement::setLatitudeDeg (double lat_deg)
{
_lat_deg = lat_deg;
}
void
-FGModelPlacement::setElevationFt (double elev_ft)
+SGModelPlacement::setElevationFt (double elev_ft)
{
_elev_ft = elev_ft;
}
void
-FGModelPlacement::setPosition (double lon_deg, double lat_deg, double elev_ft)
+SGModelPlacement::setPosition (double lon_deg, double lat_deg, double elev_ft)
{
_lon_deg = lon_deg;
_lat_deg = lat_deg;
}
void
-FGModelPlacement::setRollDeg (double roll_deg)
+SGModelPlacement::setRollDeg (double roll_deg)
{
_roll_deg = roll_deg;
}
void
-FGModelPlacement::setPitchDeg (double pitch_deg)
+SGModelPlacement::setPitchDeg (double pitch_deg)
{
_pitch_deg = pitch_deg;
}
void
-FGModelPlacement::setHeadingDeg (double heading_deg)
+SGModelPlacement::setHeadingDeg (double heading_deg)
{
_heading_deg = heading_deg;
}
void
-FGModelPlacement::setOrientation (double roll_deg, double pitch_deg,
+SGModelPlacement::setOrientation (double roll_deg, double pitch_deg,
double heading_deg)
{
_roll_deg = roll_deg;
// Don't pull in the headers, since we don't need them here.
-class FGLocation;
+class SGLocation;
// Has anyone done anything *really* stupid, like making min and max macros?
/**
* A wrapper for a model with a definite placement.
*/
-class FGModelPlacement
+class SGModelPlacement
{
public:
- FGModelPlacement ();
- virtual ~FGModelPlacement ();
+ SGModelPlacement ();
+ virtual ~SGModelPlacement ();
- virtual void FGModelPlacement::init( ssgBranch * model );
+ virtual void SGModelPlacement::init( ssgBranch * model );
/* virtual void init( const string &fg_root,
const string &path,
SGPropertyNode *prop_root,
virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
- virtual FGLocation * getFGLocation () { return _location; }
+ virtual SGLocation * getSGLocation () { return _location; }
virtual bool getVisible () const;
virtual void setVisible (bool visible);
ssgTransform * _position;
// Location
- FGLocation * _location;
+ SGLocation * _location;
// Addition by Diarmuid Tyson for Multiplayer Support
stars->repaint( sun_angle, nstars, star_data );
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
- cloud_layers[i]->repaint( fog_color );
+ if (cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR){
+ cloud_layers[i]->repaint( fog_color );
+ }
}
} else {
// turn off sky
stars->reposition( view_pos, angle );
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
- cloud_layers[i]->reposition( zero_elev, view_up, lon, lat, alt );
+ if ( cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR ) {
+ cloud_layers[i]->reposition( zero_elev, view_up, lon, lat, alt );
+ }
}
return true;
_property = root->getNode(node->getStringValue("property", ""), true);
SGPropertyNode *condition = node->getChild("condition");
if (condition != NULL)
- _condition = fgReadCondition(root, condition);
+ _condition = sgReadCondition(root, condition);
if (!_property && !_condition)
SG_LOG(SG_GENERAL, SG_WARN,
SGSoundMgr * _mgr;
SGSimpleSound * _sample;
- FGCondition * _condition;
+ SGCondition * _condition;
SGPropertyNode * _property;
bool _active;
/**
* Condition to signal when queue not empty.
*/
- SGCondition not_empty;
+ SGPthreadCond not_empty;
private:
// Prevent copying.
#endif
bool
-SGCondition::wait( SGMutex& mutex, unsigned long ms )
+SGPthreadCond::wait( SGMutex& mutex, unsigned long ms )
{
struct timeval now;
::gettimeofday( &now, 0 );
*/
class SGMutex
{
- friend class SGCondition;
+ friend class SGPthreadCond;
public:
* A condition variable is always associated with a mutex to avoid race
* conditions.
*/
-class SGCondition
+class SGPthreadCond
{
public:
/**
* Create a new condition variable.
*/
- SGCondition();
+ SGPthreadCond();
/**
* Destroy the condition object.
*/
- ~SGCondition();
+ ~SGPthreadCond();
/**
* Wait for this condition variable to be signaled.
private:
// Disable copying.
- SGCondition(const SGCondition& );
- SGCondition& operator=(const SGCondition& );
+ SGPthreadCond(const SGPthreadCond& );
+ SGPthreadCond& operator=(const SGPthreadCond& );
private:
pthread_cond_t cond;
};
-inline SGCondition::SGCondition()
+inline SGPthreadCond::SGPthreadCond()
{
int status = pthread_cond_init( &cond, 0 );
assert( status == 0 );
}
-inline SGCondition::~SGCondition()
+inline SGPthreadCond::~SGPthreadCond()
{
int status = pthread_cond_destroy( &cond );
assert( status == 0 );
}
-inline void SGCondition::signal()
+inline void SGPthreadCond::signal()
{
int status = pthread_cond_signal( &cond );
assert( status == 0 );
}
-inline void SGCondition::broadcast()
+inline void SGPthreadCond::broadcast()
{
int status = pthread_cond_broadcast( &cond );
assert( status == 0 );
}
-inline void SGCondition::wait( SGMutex& mutex )
+inline void SGPthreadCond::wait( SGMutex& mutex )
{
int status = pthread_cond_wait( &cond, &mutex.mutex );
assert( status == 0 );