Cosmetic changes for new code moved into simgear to make the naming scheme
better follow simgear conventions.
This commit is contained in:
+77
-76
@@ -1,4 +1,5 @@
|
|||||||
// condition.hxx - Declarations and inline methods for property conditions.
|
// condition.cxx - Declarations and inline methods for property conditions.
|
||||||
|
//
|
||||||
// Written by David Megginson, started 2000.
|
// Written by David Megginson, started 2000.
|
||||||
// CLO May 2003 - Split out condition specific code.
|
// CLO May 2003 - Split out condition specific code.
|
||||||
//
|
//
|
||||||
@@ -25,51 +26,51 @@ SG_USING_STD(ostream);
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGCondition.
|
// Implementation of SGCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGCondition::FGCondition ()
|
SGCondition::SGCondition ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGCondition::~FGCondition ()
|
SGCondition::~SGCondition ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGPropertyCondition.
|
// Implementation of SGPropertyCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGPropertyCondition::FGPropertyCondition ( SGPropertyNode *prop_root,
|
SGPropertyCondition::SGPropertyCondition ( SGPropertyNode *prop_root,
|
||||||
const char *propname )
|
const char *propname )
|
||||||
: _node( prop_root->getNode(propname, true) )
|
: _node( prop_root->getNode(propname, true) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGPropertyCondition::~FGPropertyCondition ()
|
SGPropertyCondition::~SGPropertyCondition ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGNotCondition.
|
// Implementation of SGNotCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGNotCondition::FGNotCondition (FGCondition * condition)
|
SGNotCondition::SGNotCondition (SGCondition * condition)
|
||||||
: _condition(condition)
|
: _condition(condition)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNotCondition::~FGNotCondition ()
|
SGNotCondition::~SGNotCondition ()
|
||||||
{
|
{
|
||||||
delete _condition;
|
delete _condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGNotCondition::test () const
|
SGNotCondition::test () const
|
||||||
{
|
{
|
||||||
return !(_condition->test());
|
return !(_condition->test());
|
||||||
}
|
}
|
||||||
@@ -77,21 +78,21 @@ FGNotCondition::test () const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGAndCondition.
|
// Implementation of SGAndCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGAndCondition::FGAndCondition ()
|
SGAndCondition::SGAndCondition ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGAndCondition::~FGAndCondition ()
|
SGAndCondition::~SGAndCondition ()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _conditions.size(); i++)
|
for (unsigned int i = 0; i < _conditions.size(); i++)
|
||||||
delete _conditions[i];
|
delete _conditions[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGAndCondition::test () const
|
SGAndCondition::test () const
|
||||||
{
|
{
|
||||||
int nConditions = _conditions.size();
|
int nConditions = _conditions.size();
|
||||||
for (int i = 0; i < nConditions; i++) {
|
for (int i = 0; i < nConditions; i++) {
|
||||||
@@ -102,7 +103,7 @@ FGAndCondition::test () const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGAndCondition::addCondition (FGCondition * condition)
|
SGAndCondition::addCondition (SGCondition * condition)
|
||||||
{
|
{
|
||||||
_conditions.push_back(condition);
|
_conditions.push_back(condition);
|
||||||
}
|
}
|
||||||
@@ -110,21 +111,21 @@ FGAndCondition::addCondition (FGCondition * condition)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGOrCondition.
|
// Implementation of SGOrCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGOrCondition::FGOrCondition ()
|
SGOrCondition::SGOrCondition ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGOrCondition::~FGOrCondition ()
|
SGOrCondition::~SGOrCondition ()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _conditions.size(); i++)
|
for (unsigned int i = 0; i < _conditions.size(); i++)
|
||||||
delete _conditions[i];
|
delete _conditions[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGOrCondition::test () const
|
SGOrCondition::test () const
|
||||||
{
|
{
|
||||||
int nConditions = _conditions.size();
|
int nConditions = _conditions.size();
|
||||||
for (int i = 0; i < nConditions; i++) {
|
for (int i = 0; i < nConditions; i++) {
|
||||||
@@ -135,7 +136,7 @@ FGOrCondition::test () const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGOrCondition::addCondition (FGCondition * condition)
|
SGOrCondition::addCondition (SGCondition * condition)
|
||||||
{
|
{
|
||||||
_conditions.push_back(condition);
|
_conditions.push_back(condition);
|
||||||
}
|
}
|
||||||
@@ -143,7 +144,7 @@ FGOrCondition::addCondition (FGCondition * condition)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGComparisonCondition.
|
// Implementation of SGComparisonCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -154,55 +155,55 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
|
|||||||
bool v1 = left->getBoolValue();
|
bool v1 = left->getBoolValue();
|
||||||
bool v2 = right->getBoolValue();
|
bool v2 = right->getBoolValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SGPropertyNode::INT: {
|
case SGPropertyNode::INT: {
|
||||||
int v1 = left->getIntValue();
|
int v1 = left->getIntValue();
|
||||||
int v2 = right->getIntValue();
|
int v2 = right->getIntValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SGPropertyNode::LONG: {
|
case SGPropertyNode::LONG: {
|
||||||
long v1 = left->getLongValue();
|
long v1 = left->getLongValue();
|
||||||
long v2 = right->getLongValue();
|
long v2 = right->getLongValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SGPropertyNode::FLOAT: {
|
case SGPropertyNode::FLOAT: {
|
||||||
float v1 = left->getFloatValue();
|
float v1 = left->getFloatValue();
|
||||||
float v2 = right->getFloatValue();
|
float v2 = right->getFloatValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SGPropertyNode::DOUBLE: {
|
case SGPropertyNode::DOUBLE: {
|
||||||
double v1 = left->getDoubleValue();
|
double v1 = left->getDoubleValue();
|
||||||
double v2 = right->getDoubleValue();
|
double v2 = right->getDoubleValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SGPropertyNode::STRING:
|
case SGPropertyNode::STRING:
|
||||||
@@ -211,11 +212,11 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
|
|||||||
string v1 = left->getStringValue();
|
string v1 = left->getStringValue();
|
||||||
string v2 = right->getStringValue();
|
string v2 = right->getStringValue();
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return FGComparisonCondition::LESS_THAN;
|
return SGComparisonCondition::LESS_THAN;
|
||||||
else if (v1 > v2)
|
else if (v1 > v2)
|
||||||
return FGComparisonCondition::GREATER_THAN;
|
return SGComparisonCondition::GREATER_THAN;
|
||||||
else
|
else
|
||||||
return FGComparisonCondition::EQUALS;
|
return SGComparisonCondition::EQUALS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +225,7 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
|
SGComparisonCondition::SGComparisonCondition (Type type, bool reverse)
|
||||||
: _type(type),
|
: _type(type),
|
||||||
_reverse(reverse),
|
_reverse(reverse),
|
||||||
_left_property(0),
|
_left_property(0),
|
||||||
@@ -233,13 +234,13 @@ FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGComparisonCondition::~FGComparisonCondition ()
|
SGComparisonCondition::~SGComparisonCondition ()
|
||||||
{
|
{
|
||||||
delete _right_value;
|
delete _right_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGComparisonCondition::test () const
|
SGComparisonCondition::test () const
|
||||||
{
|
{
|
||||||
// Always fail if incompletely specified
|
// Always fail if incompletely specified
|
||||||
if (_left_property == 0 ||
|
if (_left_property == 0 ||
|
||||||
@@ -257,14 +258,14 @@ FGComparisonCondition::test () const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGComparisonCondition::setLeftProperty( SGPropertyNode *prop_root,
|
SGComparisonCondition::setLeftProperty( SGPropertyNode *prop_root,
|
||||||
const char * propname )
|
const char * propname )
|
||||||
{
|
{
|
||||||
_left_property = prop_root->getNode(propname, true);
|
_left_property = prop_root->getNode(propname, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGComparisonCondition::setRightProperty( SGPropertyNode *prop_root,
|
SGComparisonCondition::setRightProperty( SGPropertyNode *prop_root,
|
||||||
const char * propname )
|
const char * propname )
|
||||||
{
|
{
|
||||||
delete _right_value;
|
delete _right_value;
|
||||||
@@ -273,7 +274,7 @@ FGComparisonCondition::setRightProperty( SGPropertyNode *prop_root,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGComparisonCondition::setRightValue (const SGPropertyNode *node)
|
SGComparisonCondition::setRightValue (const SGPropertyNode *node)
|
||||||
{
|
{
|
||||||
_right_property = 0;
|
_right_property = 0;
|
||||||
delete _right_value;
|
delete _right_value;
|
||||||
@@ -287,65 +288,65 @@ FGComparisonCondition::setRightValue (const SGPropertyNode *node)
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
static FGCondition * readCondition( SGPropertyNode *prop_root,
|
static SGCondition * readCondition( SGPropertyNode *prop_root,
|
||||||
const SGPropertyNode *node );
|
const SGPropertyNode *node );
|
||||||
|
|
||||||
static FGCondition *
|
static SGCondition *
|
||||||
readPropertyCondition( SGPropertyNode *prop_root,
|
readPropertyCondition( SGPropertyNode *prop_root,
|
||||||
const SGPropertyNode *node )
|
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 )
|
readNotCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
||||||
{
|
{
|
||||||
int nChildren = node->nChildren();
|
int nChildren = node->nChildren();
|
||||||
for (int i = 0; i < nChildren; i++) {
|
for (int i = 0; i < nChildren; i++) {
|
||||||
const SGPropertyNode * child = node->getChild(i);
|
const SGPropertyNode * child = node->getChild(i);
|
||||||
FGCondition * condition = readCondition(prop_root, child);
|
SGCondition * condition = readCondition(prop_root, child);
|
||||||
if (condition != 0)
|
if (condition != 0)
|
||||||
return new FGNotCondition(condition);
|
return new SGNotCondition(condition);
|
||||||
}
|
}
|
||||||
SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
|
SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGCondition *
|
static SGCondition *
|
||||||
readAndConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
readAndConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
||||||
{
|
{
|
||||||
FGAndCondition * andCondition = new FGAndCondition;
|
SGAndCondition * andCondition = new SGAndCondition;
|
||||||
int nChildren = node->nChildren();
|
int nChildren = node->nChildren();
|
||||||
for (int i = 0; i < nChildren; i++) {
|
for (int i = 0; i < nChildren; i++) {
|
||||||
const SGPropertyNode * child = node->getChild(i);
|
const SGPropertyNode * child = node->getChild(i);
|
||||||
FGCondition * condition = readCondition(prop_root, child);
|
SGCondition * condition = readCondition(prop_root, child);
|
||||||
if (condition != 0)
|
if (condition != 0)
|
||||||
andCondition->addCondition(condition);
|
andCondition->addCondition(condition);
|
||||||
}
|
}
|
||||||
return andCondition;
|
return andCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGCondition *
|
static SGCondition *
|
||||||
readOrConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
readOrConditions( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
||||||
{
|
{
|
||||||
FGOrCondition * orCondition = new FGOrCondition;
|
SGOrCondition * orCondition = new SGOrCondition;
|
||||||
int nChildren = node->nChildren();
|
int nChildren = node->nChildren();
|
||||||
for (int i = 0; i < nChildren; i++) {
|
for (int i = 0; i < nChildren; i++) {
|
||||||
const SGPropertyNode * child = node->getChild(i);
|
const SGPropertyNode * child = node->getChild(i);
|
||||||
FGCondition * condition = readCondition(prop_root, child);
|
SGCondition * condition = readCondition(prop_root, child);
|
||||||
if (condition != 0)
|
if (condition != 0)
|
||||||
orCondition->addCondition(condition);
|
orCondition->addCondition(condition);
|
||||||
}
|
}
|
||||||
return orCondition;
|
return orCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGCondition *
|
static SGCondition *
|
||||||
readComparison( SGPropertyNode *prop_root,
|
readComparison( SGPropertyNode *prop_root,
|
||||||
const SGPropertyNode *node,
|
const SGPropertyNode *node,
|
||||||
FGComparisonCondition::Type type,
|
SGComparisonCondition::Type type,
|
||||||
bool reverse)
|
bool reverse)
|
||||||
{
|
{
|
||||||
FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
|
SGComparisonCondition * condition = new SGComparisonCondition(type, reverse);
|
||||||
condition->setLeftProperty(prop_root, node->getStringValue("property[0]"));
|
condition->setLeftProperty(prop_root, node->getStringValue("property[0]"));
|
||||||
if (node->hasValue("property[1]"))
|
if (node->hasValue("property[1]"))
|
||||||
condition->setRightProperty(prop_root, node->getStringValue("property[1]"));
|
condition->setRightProperty(prop_root, node->getStringValue("property[1]"));
|
||||||
@@ -355,7 +356,7 @@ readComparison( SGPropertyNode *prop_root,
|
|||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGCondition *
|
static SGCondition *
|
||||||
readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
||||||
{
|
{
|
||||||
const string &name = node->getName();
|
const string &name = node->getName();
|
||||||
@@ -368,22 +369,22 @@ readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
|||||||
else if (name == "or")
|
else if (name == "or")
|
||||||
return readOrConditions(prop_root, node);
|
return readOrConditions(prop_root, node);
|
||||||
else if (name == "less-than")
|
else if (name == "less-than")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::LESS_THAN,
|
return readComparison(prop_root, node, SGComparisonCondition::LESS_THAN,
|
||||||
false);
|
false);
|
||||||
else if (name == "less-than-equals")
|
else if (name == "less-than-equals")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::GREATER_THAN,
|
return readComparison(prop_root, node, SGComparisonCondition::GREATER_THAN,
|
||||||
true);
|
true);
|
||||||
else if (name == "greater-than")
|
else if (name == "greater-than")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::GREATER_THAN,
|
return readComparison(prop_root, node, SGComparisonCondition::GREATER_THAN,
|
||||||
false);
|
false);
|
||||||
else if (name == "greater-than-equals")
|
else if (name == "greater-than-equals")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::LESS_THAN,
|
return readComparison(prop_root, node, SGComparisonCondition::LESS_THAN,
|
||||||
true);
|
true);
|
||||||
else if (name == "equals")
|
else if (name == "equals")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::EQUALS,
|
return readComparison(prop_root, node, SGComparisonCondition::EQUALS,
|
||||||
false);
|
false);
|
||||||
else if (name == "not-equals")
|
else if (name == "not-equals")
|
||||||
return readComparison(prop_root, node, FGComparisonCondition::EQUALS, true);
|
return readComparison(prop_root, node, SGComparisonCondition::EQUALS, true);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -391,28 +392,28 @@ readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGConditional.
|
// Implementation of SGConditional.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGConditional::FGConditional ()
|
SGConditional::SGConditional ()
|
||||||
: _condition (0)
|
: _condition (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGConditional::~FGConditional ()
|
SGConditional::~SGConditional ()
|
||||||
{
|
{
|
||||||
delete _condition;
|
delete _condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGConditional::setCondition (FGCondition * condition)
|
SGConditional::setCondition (SGCondition * condition)
|
||||||
{
|
{
|
||||||
delete _condition;
|
delete _condition;
|
||||||
_condition = condition;
|
_condition = condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGConditional::test () const
|
SGConditional::test () const
|
||||||
{
|
{
|
||||||
return ((_condition == 0) || _condition->test());
|
return ((_condition == 0) || _condition->test());
|
||||||
}
|
}
|
||||||
@@ -420,11 +421,11 @@ FGConditional::test () const
|
|||||||
|
|
||||||
|
|
||||||
// The top-level is always an implicit 'and' group
|
// The top-level is always an implicit 'and' group
|
||||||
FGCondition *
|
SGCondition *
|
||||||
fgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
|
||||||
{
|
{
|
||||||
return readAndConditions(prop_root, node);
|
return readAndConditions(prop_root, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// end of fg_props.cxx
|
// end of condition.cxx
|
||||||
|
|||||||
+39
-36
@@ -1,8 +1,11 @@
|
|||||||
// condition.hxx - Declarations and inline methods for property conditions.
|
/**
|
||||||
// Written by David Megginson, started 2000.
|
* \file condition.hxx
|
||||||
// CLO May 2003 - Split out condition specific code.
|
* Declarations and inline methods for property conditions.
|
||||||
//
|
* Written by David Megginson, started 2000.
|
||||||
// This file is in the Public Domain, and comes with no warranty.
|
* CLO May 2003 - Split out condition specific code.
|
||||||
|
*
|
||||||
|
* This file is in the Public Domain, and comes with no warranty.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __SG_CONDITION_HXX
|
#ifndef __SG_CONDITION_HXX
|
||||||
#define __SG_CONDITION_HXX
|
#define __SG_CONDITION_HXX
|
||||||
@@ -25,11 +28,11 @@
|
|||||||
*
|
*
|
||||||
* This class should migrate to somewhere more general.
|
* This class should migrate to somewhere more general.
|
||||||
*/
|
*/
|
||||||
class FGCondition
|
class SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGCondition ();
|
SGCondition ();
|
||||||
virtual ~FGCondition ();
|
virtual ~SGCondition ();
|
||||||
virtual bool test () const = 0;
|
virtual bool test () const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,12 +43,12 @@ public:
|
|||||||
* This condition is true only if the property returns a boolean
|
* This condition is true only if the property returns a boolean
|
||||||
* true value.
|
* true value.
|
||||||
*/
|
*/
|
||||||
class FGPropertyCondition : public FGCondition
|
class SGPropertyCondition : public SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGPropertyCondition ( SGPropertyNode *prop_root,
|
SGPropertyCondition ( SGPropertyNode *prop_root,
|
||||||
const char * propname );
|
const char * propname );
|
||||||
virtual ~FGPropertyCondition ();
|
virtual ~SGPropertyCondition ();
|
||||||
virtual bool test () const { return _node->getBoolValue(); }
|
virtual bool test () const { return _node->getBoolValue(); }
|
||||||
private:
|
private:
|
||||||
const SGPropertyNode * _node;
|
const SGPropertyNode * _node;
|
||||||
@@ -57,15 +60,15 @@ private:
|
|||||||
*
|
*
|
||||||
* This condition is true only if the child condition is false.
|
* This condition is true only if the child condition is false.
|
||||||
*/
|
*/
|
||||||
class FGNotCondition : public FGCondition
|
class SGNotCondition : public SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// transfer pointer ownership
|
// transfer pointer ownership
|
||||||
FGNotCondition (FGCondition * condition);
|
SGNotCondition (SGCondition * condition);
|
||||||
virtual ~FGNotCondition ();
|
virtual ~SGNotCondition ();
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
private:
|
private:
|
||||||
FGCondition * _condition;
|
SGCondition * _condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -75,16 +78,16 @@ private:
|
|||||||
* This condition is true only if all of the conditions
|
* This condition is true only if all of the conditions
|
||||||
* in the group are true.
|
* in the group are true.
|
||||||
*/
|
*/
|
||||||
class FGAndCondition : public FGCondition
|
class SGAndCondition : public SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGAndCondition ();
|
SGAndCondition ();
|
||||||
virtual ~FGAndCondition ();
|
virtual ~SGAndCondition ();
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
// transfer pointer ownership
|
// transfer pointer ownership
|
||||||
virtual void addCondition (FGCondition * condition);
|
virtual void addCondition (SGCondition * condition);
|
||||||
private:
|
private:
|
||||||
vector<FGCondition *> _conditions;
|
vector<SGCondition *> _conditions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -94,23 +97,23 @@ private:
|
|||||||
* This condition is true if at least one of the conditions in the
|
* This condition is true if at least one of the conditions in the
|
||||||
* group is true.
|
* group is true.
|
||||||
*/
|
*/
|
||||||
class FGOrCondition : public FGCondition
|
class SGOrCondition : public SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGOrCondition ();
|
SGOrCondition ();
|
||||||
virtual ~FGOrCondition ();
|
virtual ~SGOrCondition ();
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
// transfer pointer ownership
|
// transfer pointer ownership
|
||||||
virtual void addCondition (FGCondition * condition);
|
virtual void addCondition (SGCondition * condition);
|
||||||
private:
|
private:
|
||||||
vector<FGCondition *> _conditions;
|
vector<SGCondition *> _conditions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for property comparison conditions.
|
* Abstract base class for property comparison conditions.
|
||||||
*/
|
*/
|
||||||
class FGComparisonCondition : public FGCondition
|
class SGComparisonCondition : public SGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -118,8 +121,8 @@ public:
|
|||||||
GREATER_THAN,
|
GREATER_THAN,
|
||||||
EQUALS
|
EQUALS
|
||||||
};
|
};
|
||||||
FGComparisonCondition (Type type, bool reverse = false);
|
SGComparisonCondition (Type type, bool reverse = false);
|
||||||
virtual ~FGComparisonCondition ();
|
virtual ~SGComparisonCondition ();
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
virtual void setLeftProperty( SGPropertyNode *prop_root,
|
virtual void setLeftProperty( SGPropertyNode *prop_root,
|
||||||
const char * propname );
|
const char * propname );
|
||||||
@@ -143,17 +146,17 @@ private:
|
|||||||
* invoke the test() method whenever it needs to decide whether to
|
* invoke the test() method whenever it needs to decide whether to
|
||||||
* active itself, draw itself, and so on.
|
* active itself, draw itself, and so on.
|
||||||
*/
|
*/
|
||||||
class FGConditional
|
class SGConditional
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGConditional ();
|
SGConditional ();
|
||||||
virtual ~FGConditional ();
|
virtual ~SGConditional ();
|
||||||
// transfer pointer ownership
|
// transfer pointer ownership
|
||||||
virtual void setCondition (FGCondition * condition);
|
virtual void setCondition (SGCondition * condition);
|
||||||
virtual const FGCondition * getCondition () const { return _condition; }
|
virtual const SGCondition * getCondition () const { return _condition; }
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
private:
|
private:
|
||||||
FGCondition * _condition;
|
SGCondition * _condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -168,8 +171,8 @@ private:
|
|||||||
* responsibility of the caller to delete the condition when
|
* responsibility of the caller to delete the condition when
|
||||||
* it is no longer needed.
|
* it is no longer needed.
|
||||||
*/
|
*/
|
||||||
FGCondition * fgReadCondition( SGPropertyNode *prop_root,
|
SGCondition *sgReadCondition( SGPropertyNode *prop_root,
|
||||||
const SGPropertyNode *node );
|
const SGPropertyNode *node );
|
||||||
|
|
||||||
|
|
||||||
#endif // __SG_CONDITION_HXX
|
#endif // __SG_CONDITION_HXX
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// newmat.cxx -- class to handle material properties
|
// mat.cxx -- class to handle material properties
|
||||||
//
|
//
|
||||||
// Written by Curtis Olson, started May 1998.
|
// Written by Curtis Olson, started May 1998.
|
||||||
//
|
//
|
||||||
@@ -68,10 +68,10 @@ local_file_exists( const string& path ) {
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// 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),
|
: _models_loaded(false),
|
||||||
_coverage_m2(node->getDoubleValue("coverage-m2", 1000000)),
|
_coverage_m2(node->getDoubleValue("coverage-m2", 1000000)),
|
||||||
_range_m(range_m)
|
_range_m(range_m)
|
||||||
@@ -106,7 +106,7 @@ FGNewMat::Object::Object (const SGPropertyNode * node, double range_m)
|
|||||||
// load_models();
|
// load_models();
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::Object::~Object ()
|
SGMaterial::Object::~Object ()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _models.size(); i++) {
|
for (unsigned int i = 0; i < _models.size(); i++) {
|
||||||
if (_models[i] != 0) {
|
if (_models[i] != 0) {
|
||||||
@@ -117,7 +117,7 @@ FGNewMat::Object::~Object ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
FGNewMat::Object::get_model_count( FGModelLoader *loader,
|
SGMaterial::Object::get_model_count( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
@@ -127,7 +127,7 @@ FGNewMat::Object::get_model_count( FGModelLoader *loader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
FGNewMat::Object::load_models ( FGModelLoader *loader,
|
SGMaterial::Object::load_models ( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
@@ -163,8 +163,8 @@ FGNewMat::Object::load_models ( FGModelLoader *loader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssgEntity *
|
ssgEntity *
|
||||||
FGNewMat::Object::get_model( int index,
|
SGMaterial::Object::get_model( int index,
|
||||||
FGModelLoader *loader,
|
SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
@@ -174,7 +174,7 @@ FGNewMat::Object::get_model( int index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssgEntity *
|
ssgEntity *
|
||||||
FGNewMat::Object::get_random_model( FGModelLoader *loader,
|
SGMaterial::Object::get_random_model( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
@@ -188,13 +188,13 @@ FGNewMat::Object::get_random_model( FGModelLoader *loader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
FGNewMat::Object::get_coverage_m2 () const
|
SGMaterial::Object::get_coverage_m2 () const
|
||||||
{
|
{
|
||||||
return _coverage_m2;
|
return _coverage_m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::Object::HeadingType
|
SGMaterial::Object::HeadingType
|
||||||
FGNewMat::Object::get_heading_type () const
|
SGMaterial::Object::get_heading_type () const
|
||||||
{
|
{
|
||||||
return _heading_type;
|
return _heading_type;
|
||||||
}
|
}
|
||||||
@@ -202,10 +202,10 @@ FGNewMat::Object::get_heading_type () const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// 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))
|
: _range_m(node->getDoubleValue("range-m", 2000))
|
||||||
{
|
{
|
||||||
// Load the object subnodes
|
// Load the object subnodes
|
||||||
@@ -220,7 +220,7 @@ FGNewMat::ObjectGroup::ObjectGroup (SGPropertyNode * node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::ObjectGroup::~ObjectGroup ()
|
SGMaterial::ObjectGroup::~ObjectGroup ()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _objects.size(); i++) {
|
for (unsigned int i = 0; i < _objects.size(); i++) {
|
||||||
delete _objects[i];
|
delete _objects[i];
|
||||||
@@ -229,19 +229,19 @@ FGNewMat::ObjectGroup::~ObjectGroup ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
FGNewMat::ObjectGroup::get_range_m () const
|
SGMaterial::ObjectGroup::get_range_m () const
|
||||||
{
|
{
|
||||||
return _range_m;
|
return _range_m;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
FGNewMat::ObjectGroup::get_object_count () const
|
SGMaterial::ObjectGroup::get_object_count () const
|
||||||
{
|
{
|
||||||
return _objects.size();
|
return _objects.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::Object *
|
SGMaterial::Object *
|
||||||
FGNewMat::ObjectGroup::get_object (int index) const
|
SGMaterial::ObjectGroup::get_object (int index) const
|
||||||
{
|
{
|
||||||
return _objects[index];
|
return _objects[index];
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ FGNewMat::ObjectGroup::get_object (int index) const
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
FGNewMat::FGNewMat( const string &fg_root,
|
SGMaterial::SGMaterial( const string &fg_root,
|
||||||
const SGPropertyNode *props,
|
const SGPropertyNode *props,
|
||||||
bool smooth_shading,
|
bool smooth_shading,
|
||||||
bool use_textures )
|
bool use_textures )
|
||||||
@@ -263,7 +263,7 @@ FGNewMat::FGNewMat( const string &fg_root,
|
|||||||
build_ssg_state( false, smooth_shading, use_textures );
|
build_ssg_state( false, smooth_shading, use_textures );
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::FGNewMat( const string &texpath,
|
SGMaterial::SGMaterial( const string &texpath,
|
||||||
bool smooth_shading,
|
bool smooth_shading,
|
||||||
bool use_textures )
|
bool use_textures )
|
||||||
{
|
{
|
||||||
@@ -272,7 +272,7 @@ FGNewMat::FGNewMat( const string &texpath,
|
|||||||
build_ssg_state( true, smooth_shading, use_textures );
|
build_ssg_state( true, smooth_shading, use_textures );
|
||||||
}
|
}
|
||||||
|
|
||||||
FGNewMat::FGNewMat( ssgSimpleState *s,
|
SGMaterial::SGMaterial( ssgSimpleState *s,
|
||||||
bool smooth_shading,
|
bool smooth_shading,
|
||||||
bool use_textures )
|
bool use_textures )
|
||||||
{
|
{
|
||||||
@@ -280,7 +280,7 @@ FGNewMat::FGNewMat( ssgSimpleState *s,
|
|||||||
set_ssg_state( s, smooth_shading, 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++) {
|
for (unsigned int i = 0; i < object_groups.size(); i++) {
|
||||||
delete object_groups[i];
|
delete object_groups[i];
|
||||||
@@ -295,7 +295,7 @@ FGNewMat::~FGNewMat (void)
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
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
|
// Get the path to the texture
|
||||||
string tname = props->getStringValue("texture", "unknown.rgb");
|
string tname = props->getStringValue("texture", "unknown.rgb");
|
||||||
@@ -351,7 +351,7 @@ FGNewMat::read_properties( const string &fg_root, const SGPropertyNode * props )
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void
|
||||||
FGNewMat::init ()
|
SGMaterial::init ()
|
||||||
{
|
{
|
||||||
texture_path = "";
|
texture_path = "";
|
||||||
state = 0;
|
state = 0;
|
||||||
@@ -372,7 +372,7 @@ FGNewMat::init ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGNewMat::load_texture ()
|
SGMaterial::load_texture ()
|
||||||
{
|
{
|
||||||
if (texture_loaded) {
|
if (texture_loaded) {
|
||||||
return false;
|
return false;
|
||||||
@@ -388,7 +388,7 @@ FGNewMat::load_texture ()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FGNewMat::build_ssg_state( bool defer_tex_load,
|
SGMaterial::build_ssg_state( bool defer_tex_load,
|
||||||
bool smooth_shading,
|
bool smooth_shading,
|
||||||
bool use_textures )
|
bool use_textures )
|
||||||
{
|
{
|
||||||
@@ -473,7 +473,7 @@ FGNewMat::build_ssg_state( bool defer_tex_load,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FGNewMat::set_ssg_state( ssgSimpleState *s,
|
void SGMaterial::set_ssg_state( ssgSimpleState *s,
|
||||||
bool smooth_shading, bool use_textures )
|
bool smooth_shading, bool use_textures )
|
||||||
{
|
{
|
||||||
GLenum shade_model = ( smooth_shading ? GL_SMOOTH : GL_FLAT);
|
GLenum shade_model = ( smooth_shading ? GL_SMOOTH : GL_FLAT);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// newmat.hxx -- a material in the scene graph.
|
// mat.hxx -- a material in the scene graph.
|
||||||
// TODO: this class needs to be renamed.
|
// TODO: this class needs to be renamed.
|
||||||
//
|
//
|
||||||
// Written by Curtis Olson, started May 1998.
|
// Written by Curtis Olson, started May 1998.
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#ifndef _NEWMAT_HXX
|
#ifndef _SG_MAT_HXX
|
||||||
#define _NEWMAT_HXX
|
#define _SG_MAT_HXX
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
# error This library requires C++
|
# error This library requires C++
|
||||||
@@ -52,7 +52,7 @@ SG_USING_STD(string);
|
|||||||
* defined in the $FG_ROOT/materials.xml file, and can be changed
|
* defined in the $FG_ROOT/materials.xml file, and can be changed
|
||||||
* at runtime.
|
* at runtime.
|
||||||
*/
|
*/
|
||||||
class FGNewMat {
|
class SGMaterial {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* A randomly-placeable object.
|
* 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.
|
* parameters for a single instance of a randomly-placeable object.
|
||||||
* The object can have more than one variant model (i.e. slightly
|
* The object can have more than one variant model (i.e. slightly
|
||||||
* different shapes of trees), but they are considered equivalent
|
* different shapes of trees), but they are considered equivalent
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return The number of variant models.
|
* @return The number of variant models.
|
||||||
*/
|
*/
|
||||||
int get_model_count( FGModelLoader *loader,
|
int get_model_count( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec );
|
double sim_time_sec );
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
* @return The model.
|
* @return The model.
|
||||||
*/
|
*/
|
||||||
ssgEntity *get_model( int index,
|
ssgEntity *get_model( int index,
|
||||||
FGModelLoader *loader,
|
SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec );
|
double sim_time_sec );
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return A randomly select model from the variants.
|
* @return A randomly select model from the variants.
|
||||||
*/
|
*/
|
||||||
ssgEntity *get_random_model( FGModelLoader *loader,
|
ssgEntity *get_random_model( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec );
|
double sim_time_sec );
|
||||||
@@ -152,7 +152,7 @@ public:
|
|||||||
* This class uses lazy loading so that models won't be held
|
* This class uses lazy loading so that models won't be held
|
||||||
* in memory for materials that are never referenced.
|
* in memory for materials that are never referenced.
|
||||||
*/
|
*/
|
||||||
void load_models( FGModelLoader *loader,
|
void load_models( SGModelLoader *loader,
|
||||||
const string &fg_root,
|
const string &fg_root,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec );
|
double sim_time_sec );
|
||||||
@@ -171,7 +171,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Grouping objects with the same range together significantly
|
* Grouping objects with the same range together significantly
|
||||||
* reduces the memory requirements of randomly-placed objects.
|
* 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.
|
* object groups for placing randomly on the scenery.
|
||||||
*/
|
*/
|
||||||
class ObjectGroup
|
class ObjectGroup
|
||||||
@@ -206,7 +206,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class FGNewMat;
|
friend class SGMaterial;
|
||||||
|
|
||||||
ObjectGroup (SGPropertyNode * node);
|
ObjectGroup (SGPropertyNode * node);
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ public:
|
|||||||
* state information for the material. This node is usually
|
* state information for the material. This node is usually
|
||||||
* loaded from the $FG_ROOT/materials.xml file.
|
* 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 );
|
bool smooth_shading, bool use_textures );
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ public:
|
|||||||
* @param texture_path A string containing an absolute path
|
* @param texture_path A string containing an absolute path
|
||||||
* to a texture file (usually RGB).
|
* 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 );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,12 +253,12 @@ public:
|
|||||||
*
|
*
|
||||||
* @param s The SSG state for this material.
|
* @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.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~FGNewMat( void );
|
virtual ~SGMaterial( void );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ private:
|
|||||||
// Internal constructors and methods.
|
// 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 read_properties( const string &fg_root, const SGPropertyNode *props );
|
||||||
void build_ssg_state( bool defer_tex_load,
|
void build_ssg_state( bool defer_tex_load,
|
||||||
@@ -416,4 +416,4 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _NEWMAT_HXX
|
#endif // _SG_MAT_HXX
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ SG_USING_STD(string);
|
|||||||
|
|
||||||
|
|
||||||
// global material management class
|
// global material management class
|
||||||
FGMaterialLib material_lib;
|
SGMaterialLib material_lib;
|
||||||
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGMaterialLib::FGMaterialLib ( void ) {
|
SGMaterialLib::SGMaterialLib ( void ) {
|
||||||
set_step(0);
|
set_step(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ static int gen_vasi_light_map() {
|
|||||||
|
|
||||||
|
|
||||||
// Load a library of material properties
|
// 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;
|
SGPropertyNode materials;
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
for (int i = 0; i < nMaterials; i++) {
|
for (int i = 0; i < nMaterials; i++) {
|
||||||
const SGPropertyNode * node = materials.getChild(i);
|
const SGPropertyNode * node = materials.getChild(i);
|
||||||
if (!strcmp(node->getName(), "material")) {
|
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");
|
vector<SGPropertyNode_ptr>names = node->getChildren("name");
|
||||||
for ( unsigned int j = 0; j < names.size(); j++ ) {
|
for ( unsigned int j = 0; j < names.size(); j++ ) {
|
||||||
@@ -273,7 +273,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
gnd_lights->enable( GL_BLEND );
|
gnd_lights->enable( GL_BLEND );
|
||||||
gnd_lights->disable( GL_ALPHA_TEST );
|
gnd_lights->disable( GL_ALPHA_TEST );
|
||||||
gnd_lights->disable( GL_LIGHTING );
|
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;
|
GLuint tex_name;
|
||||||
|
|
||||||
@@ -292,10 +292,10 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_white_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
|
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->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_white_lights->setTexture( tex_name );
|
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
|
// For backwards compatibility ... remove someday
|
||||||
matlib["RUNWAY_LIGHTS"] = new FGNewMat( rwy_white_lights, true, true );
|
matlib["RUNWAY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
|
||||||
matlib["RWY_LIGHTS"] = new FGNewMat( rwy_white_lights, true, true );
|
matlib["RWY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
|
||||||
// end of backwards compatitibilty
|
// end of backwards compatitibilty
|
||||||
|
|
||||||
// hard coded runway medium intensity white light state
|
// hard coded runway medium intensity white light state
|
||||||
@@ -314,7 +314,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_white_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_white_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_white_medium_lights->setTexture( tex_name );
|
rwy_white_medium_lights->setTexture( tex_name );
|
||||||
matlib["RWY_WHITE_MEDIUM_LIGHTS"]
|
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
|
// hard coded runway low intensity white light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 235, 195, 155 );
|
tex_name = gen_standard_dir_light_map( 235, 235, 195, 155 );
|
||||||
@@ -332,7 +332,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_white_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_white_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_white_low_lights->setTexture( tex_name );
|
rwy_white_low_lights->setTexture( tex_name );
|
||||||
matlib["RWY_WHITE_LOW_LIGHTS"]
|
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
|
// hard coded runway yellow light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 255 );
|
tex_name = gen_standard_dir_light_map( 235, 215, 20, 255 );
|
||||||
@@ -349,7 +349,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_yellow_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
|
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->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_yellow_lights->setTexture( tex_name );
|
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
|
// hard coded runway medium intensity yellow light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 205 );
|
tex_name = gen_standard_dir_light_map( 235, 215, 20, 205 );
|
||||||
@@ -367,7 +367,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_yellow_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_yellow_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_yellow_medium_lights->setTexture( tex_name );
|
rwy_yellow_medium_lights->setTexture( tex_name );
|
||||||
matlib["RWY_YELLOW_MEDIUM_LIGHTS"]
|
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
|
// hard coded runway low intensity yellow light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 155 );
|
tex_name = gen_standard_dir_light_map( 235, 215, 20, 155 );
|
||||||
@@ -385,7 +385,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_yellow_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_yellow_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_yellow_low_lights->setTexture( tex_name );
|
rwy_yellow_low_lights->setTexture( tex_name );
|
||||||
matlib["RWY_YELLOW_LOW_LIGHTS"]
|
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
|
// hard coded runway red light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 255 );
|
tex_name = gen_standard_dir_light_map( 235, 90, 90, 255 );
|
||||||
@@ -403,7 +403,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_red_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_red_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_red_lights->setTexture( tex_name );
|
rwy_red_lights->setTexture( tex_name );
|
||||||
matlib["RWY_RED_LIGHTS"]
|
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
|
// hard coded medium intensity runway red light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
|
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
|
||||||
@@ -421,7 +421,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_red_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_red_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_red_medium_lights->setTexture( tex_name );
|
rwy_red_medium_lights->setTexture( tex_name );
|
||||||
matlib["RWY_RED_MEDIUM_LIGHTS"]
|
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
|
// hard coded low intensity runway red light state
|
||||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
|
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
|
||||||
@@ -439,7 +439,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_red_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_red_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_red_low_lights->setTexture( tex_name );
|
rwy_red_low_lights->setTexture( tex_name );
|
||||||
matlib["RWY_RED_LOW_LIGHTS"]
|
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
|
// hard coded runway green light state
|
||||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 255 );
|
tex_name = gen_standard_dir_light_map( 20, 235, 20, 255 );
|
||||||
@@ -457,7 +457,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_green_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_green_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_green_lights->setTexture( tex_name );
|
rwy_green_lights->setTexture( tex_name );
|
||||||
matlib["RWY_GREEN_LIGHTS"]
|
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
|
// hard coded medium intensity runway green light state
|
||||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
|
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
|
||||||
@@ -475,7 +475,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_green_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_green_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_green_medium_lights->setTexture( tex_name );
|
rwy_green_medium_lights->setTexture( tex_name );
|
||||||
matlib["RWY_GREEN_MEDIUM_LIGHTS"]
|
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
|
// hard coded low intensity runway green light state
|
||||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
|
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
|
||||||
@@ -493,7 +493,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_green_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
rwy_green_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_green_low_lights->setTexture( tex_name );
|
rwy_green_low_lights->setTexture( tex_name );
|
||||||
matlib["RWY_GREEN_LOW_LIGHTS"]
|
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
|
// hard coded low intensity taxiway blue light state
|
||||||
tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
|
tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
|
||||||
@@ -511,7 +511,7 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
taxiway_blue_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
taxiway_blue_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
taxiway_blue_low_lights->setTexture( tex_name );
|
taxiway_blue_low_lights->setTexture( tex_name );
|
||||||
matlib["RWY_BLUE_TAXIWAY_LIGHTS"]
|
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
|
// hard coded runway vasi light state
|
||||||
ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
|
ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
|
||||||
@@ -527,14 +527,14 @@ bool FGMaterialLib::load( const string &fg_root, const string& mpath ) {
|
|||||||
rwy_vasi_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
|
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->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
|
||||||
rwy_vasi_lights->setTexture( gen_vasi_light_map() );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load a library of material properties
|
// 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;
|
string material_name = tex_path;
|
||||||
int pos = tex_path.rfind( "/" );
|
int pos = tex_path.rfind( "/" );
|
||||||
@@ -545,7 +545,7 @@ bool FGMaterialLib::add_item ( const string &tex_path )
|
|||||||
|
|
||||||
|
|
||||||
// Load a library of material properties
|
// 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( "/" );
|
int pos = full_path.rfind( "/" );
|
||||||
string tex_name = full_path.substr( pos + 1 );
|
string tex_name = full_path.substr( pos + 1 );
|
||||||
@@ -554,16 +554,16 @@ bool FGMaterialLib::add_item ( const string &mat_name, const string &full_path )
|
|||||||
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
|
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
|
||||||
<< mat_name << " (" << full_path << ")");
|
<< 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load a library of material properties
|
// 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 "
|
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material given a premade "
|
||||||
<< "ssgSimpleState = " << mat_name );
|
<< "ssgSimpleState = " << mat_name );
|
||||||
@@ -575,8 +575,8 @@ bool FGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
|
|||||||
|
|
||||||
|
|
||||||
// find a material record by material name
|
// find a material record by material name
|
||||||
FGNewMat *FGMaterialLib::find( const string& material ) {
|
SGMaterial *SGMaterialLib::find( const string& material ) {
|
||||||
FGNewMat *result = NULL;
|
SGMaterial *result = NULL;
|
||||||
material_map_iterator it = matlib.find( material );
|
material_map_iterator it = matlib.find( material );
|
||||||
if ( it != end() ) {
|
if ( it != end() ) {
|
||||||
result = it->second;
|
result = it->second;
|
||||||
@@ -588,10 +588,10 @@ FGNewMat *FGMaterialLib::find( const string& material ) {
|
|||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
FGMaterialLib::~FGMaterialLib ( void ) {
|
SGMaterialLib::~SGMaterialLib ( void ) {
|
||||||
// Free up all the material entries first
|
// Free up all the material entries first
|
||||||
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
||||||
FGNewMat *slot = it->second;
|
SGMaterial *slot = it->second;
|
||||||
slot->deRef();
|
slot->deRef();
|
||||||
if ( slot->getRef() <= 0 ) {
|
if ( slot->getRef() <= 0 ) {
|
||||||
delete slot;
|
delete slot;
|
||||||
@@ -601,21 +601,21 @@ FGMaterialLib::~FGMaterialLib ( void ) {
|
|||||||
|
|
||||||
|
|
||||||
// Set the step for all of the state selectors in the material slots
|
// 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();
|
// container::iterator it = begin();
|
||||||
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
||||||
const string &key = it->first;
|
const string &key = it->first;
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
SG_LOG( SG_GENERAL, SG_INFO,
|
||||||
"Updating material " << key << " to step " << step );
|
"Updating material " << key << " to step " << step );
|
||||||
FGNewMat *slot = it->second;
|
SGMaterial *slot = it->second;
|
||||||
slot->get_state()->selectStep(step);
|
slot->get_state()->selectStep(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the step for the state selectors
|
// Get the step for the state selectors
|
||||||
int FGMaterialLib::get_step ()
|
int SGMaterialLib::get_step ()
|
||||||
{
|
{
|
||||||
material_map_iterator it = begin();
|
material_map_iterator it = begin();
|
||||||
return it->second->get_state()->getSelectStep();
|
return it->second->get_state()->getSelectStep();
|
||||||
@@ -624,12 +624,12 @@ int FGMaterialLib::get_step ()
|
|||||||
|
|
||||||
// Load one pending "deferred" texture. Return true if a texture
|
// Load one pending "deferred" texture. Return true if a texture
|
||||||
// loaded successfully, false if no pending, or error.
|
// loaded successfully, false if no pending, or error.
|
||||||
void FGMaterialLib::load_next_deferred() {
|
void SGMaterialLib::load_next_deferred() {
|
||||||
// container::iterator it = begin();
|
// container::iterator it = begin();
|
||||||
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
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. */
|
/* we don't need the key, but here's how we'd get it if we wanted it. */
|
||||||
// const string &key = it->first;
|
// const string &key = it->first;
|
||||||
FGNewMat *slot = it->second;
|
SGMaterial *slot = it->second;
|
||||||
if (slot->load_texture())
|
if (slot->load_texture())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include <plib/ssg.h> // plib include
|
#include <plib/ssg.h> // plib include
|
||||||
|
|
||||||
|
|
||||||
class FGNewMat;
|
class SGMaterial;
|
||||||
|
|
||||||
SG_USING_STD(string);
|
SG_USING_STD(string);
|
||||||
SG_USING_STD(map);
|
SG_USING_STD(map);
|
||||||
@@ -47,12 +47,12 @@ SG_USING_STD(less);
|
|||||||
|
|
||||||
|
|
||||||
// Material management class
|
// Material management class
|
||||||
class FGMaterialLib {
|
class SGMaterialLib {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// associative array of materials
|
// 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::iterator material_map_iterator;
|
||||||
typedef material_map::const_iterator const_material_map_iterator;
|
typedef material_map::const_iterator const_material_map_iterator;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGMaterialLib ( void );
|
SGMaterialLib ( void );
|
||||||
|
|
||||||
// Load a library of material properties
|
// Load a library of material properties
|
||||||
bool load( const string &fg_root, const string& mpath );
|
bool load( const string &fg_root, const string& mpath );
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
bool add_item( const string &mat_name, ssgSimpleState *state );
|
bool add_item( const string &mat_name, ssgSimpleState *state );
|
||||||
|
|
||||||
// find a material record by material name
|
// find a material record by material name
|
||||||
FGNewMat *find( const string& material );
|
SGMaterial *find( const string& material );
|
||||||
|
|
||||||
void set_step (int step);
|
void set_step (int step);
|
||||||
int get_step ();
|
int get_step ();
|
||||||
@@ -89,12 +89,12 @@ public:
|
|||||||
const_material_map_iterator end() const { return matlib.end(); }
|
const_material_map_iterator end() const { return matlib.end(); }
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~FGMaterialLib ( void );
|
~SGMaterialLib ( void );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// global material management class
|
// global material management class
|
||||||
extern FGMaterialLib material_lib;
|
extern SGMaterialLib material_lib;
|
||||||
|
|
||||||
|
|
||||||
#endif // _MATLIB_HXX
|
#endif // _MATLIB_HXX
|
||||||
|
|||||||
@@ -101,55 +101,55 @@ read_interpolation_table (SGPropertyNode_ptr props)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of Animation
|
// Implementation of SGAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Initialize the static data member
|
// 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(branch)
|
||||||
{
|
{
|
||||||
_branch->setName(props->getStringValue("name", 0));
|
_branch->setName(props->getStringValue("name", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::~Animation ()
|
SGAnimation::~SGAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Animation::init ()
|
SGAnimation::init ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Animation::update()
|
SGAnimation::update()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of NullAnimation
|
// Implementation of SGNullAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
NullAnimation::NullAnimation (SGPropertyNode_ptr props)
|
SGNullAnimation::SGNullAnimation (SGPropertyNode_ptr props)
|
||||||
: Animation(props, new ssgBranch)
|
: SGAnimation(props, new ssgBranch)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NullAnimation::~NullAnimation ()
|
SGNullAnimation::~SGNullAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of RangeAnimation
|
// Implementation of SGRangeAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RangeAnimation::RangeAnimation (SGPropertyNode_ptr props)
|
SGRangeAnimation::SGRangeAnimation (SGPropertyNode_ptr props)
|
||||||
: Animation(props, new ssgRangeSelector)
|
: SGAnimation(props, new ssgRangeSelector)
|
||||||
{
|
{
|
||||||
float ranges[] = { props->getFloatValue("min-m", 0),
|
float ranges[] = { props->getFloatValue("min-m", 0),
|
||||||
props->getFloatValue("max-m", 5000) };
|
props->getFloatValue("max-m", 5000) };
|
||||||
@@ -157,48 +157,48 @@ RangeAnimation::RangeAnimation (SGPropertyNode_ptr props)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeAnimation::~RangeAnimation ()
|
SGRangeAnimation::~SGRangeAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of BillboardAnimation
|
// Implementation of SGBillboardAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BillboardAnimation::BillboardAnimation (SGPropertyNode_ptr props)
|
SGBillboardAnimation::SGBillboardAnimation (SGPropertyNode_ptr props)
|
||||||
: Animation(props, new ssgCutout(props->getBoolValue("spherical", true)))
|
: SGAnimation(props, new ssgCutout(props->getBoolValue("spherical", true)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BillboardAnimation::~BillboardAnimation ()
|
SGBillboardAnimation::~SGBillboardAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of SelectAnimation
|
// Implementation of SGSelectAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SelectAnimation::SelectAnimation( SGPropertyNode *prop_root,
|
SGSelectAnimation::SGSelectAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props )
|
SGPropertyNode_ptr props )
|
||||||
: Animation(props, new ssgSelector),
|
: SGAnimation(props, new ssgSelector),
|
||||||
_condition(0)
|
_condition(0)
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr node = props->getChild("condition");
|
SGPropertyNode_ptr node = props->getChild("condition");
|
||||||
if (node != 0)
|
if (node != 0)
|
||||||
_condition = fgReadCondition(prop_root, node);
|
_condition = sgReadCondition(prop_root, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectAnimation::~SelectAnimation ()
|
SGSelectAnimation::~SGSelectAnimation ()
|
||||||
{
|
{
|
||||||
delete _condition;
|
delete _condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SelectAnimation::update()
|
SGSelectAnimation::update()
|
||||||
{
|
{
|
||||||
if (_condition != 0 && _condition->test())
|
if (_condition != 0 && _condition->test())
|
||||||
((ssgSelector *)_branch)->select(0xffff);
|
((ssgSelector *)_branch)->select(0xffff);
|
||||||
@@ -209,13 +209,13 @@ SelectAnimation::update()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of SpinAnimation
|
// Implementation of SGSpinAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
|
SGSpinAnimation::SGSpinAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props,
|
SGPropertyNode_ptr props,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
: Animation(props, new ssgTransform),
|
: SGAnimation(props, new ssgTransform),
|
||||||
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
||||||
_factor(props->getDoubleValue("factor", 1.0)),
|
_factor(props->getDoubleValue("factor", 1.0)),
|
||||||
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
|
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
|
||||||
@@ -230,12 +230,12 @@ SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
|
|||||||
sgNormalizeVec3(_axis);
|
sgNormalizeVec3(_axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinAnimation::~SpinAnimation ()
|
SGSpinAnimation::~SGSpinAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpinAnimation::update()
|
SGSpinAnimation::update()
|
||||||
{
|
{
|
||||||
double dt = sim_time_sec - _last_time_sec;
|
double dt = sim_time_sec - _last_time_sec;
|
||||||
_last_time_sec = sim_time_sec;
|
_last_time_sec = sim_time_sec;
|
||||||
@@ -253,23 +253,23 @@ SpinAnimation::update()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of TimedAnimation
|
// Implementation of SGTimedAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TimedAnimation::TimedAnimation (SGPropertyNode_ptr props)
|
SGTimedAnimation::SGTimedAnimation (SGPropertyNode_ptr props)
|
||||||
: Animation(props, new ssgSelector),
|
: SGAnimation(props, new ssgSelector),
|
||||||
_duration_sec(props->getDoubleValue("duration-sec", 1.0)),
|
_duration_sec(props->getDoubleValue("duration-sec", 1.0)),
|
||||||
_last_time_sec(0),
|
_last_time_sec(0),
|
||||||
_step(-1)
|
_step(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TimedAnimation::~TimedAnimation ()
|
SGTimedAnimation::~SGTimedAnimation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimedAnimation::update()
|
SGTimedAnimation::update()
|
||||||
{
|
{
|
||||||
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
|
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
|
||||||
_last_time_sec = sim_time_sec;
|
_last_time_sec = sim_time_sec;
|
||||||
@@ -283,12 +283,12 @@ TimedAnimation::update()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of RotateAnimation
|
// Implementation of SGRotateAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RotateAnimation::RotateAnimation( SGPropertyNode *prop_root,
|
SGRotateAnimation::SGRotateAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props )
|
SGPropertyNode_ptr props )
|
||||||
: Animation(props, new ssgTransform),
|
: SGAnimation(props, new ssgTransform),
|
||||||
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
||||||
_offset_deg(props->getDoubleValue("offset-deg", 0.0)),
|
_offset_deg(props->getDoubleValue("offset-deg", 0.0)),
|
||||||
_factor(props->getDoubleValue("factor", 1.0)),
|
_factor(props->getDoubleValue("factor", 1.0)),
|
||||||
@@ -308,13 +308,13 @@ RotateAnimation::RotateAnimation( SGPropertyNode *prop_root,
|
|||||||
sgNormalizeVec3(_axis);
|
sgNormalizeVec3(_axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
RotateAnimation::~RotateAnimation ()
|
SGRotateAnimation::~SGRotateAnimation ()
|
||||||
{
|
{
|
||||||
delete _table;
|
delete _table;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RotateAnimation::update()
|
SGRotateAnimation::update()
|
||||||
{
|
{
|
||||||
if (_table == 0) {
|
if (_table == 0) {
|
||||||
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
|
_position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
|
||||||
@@ -332,12 +332,12 @@ RotateAnimation::update()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of TranslateAnimation
|
// Implementation of SGTranslateAnimation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TranslateAnimation::TranslateAnimation( SGPropertyNode *prop_root,
|
SGTranslateAnimation::SGTranslateAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props )
|
SGPropertyNode_ptr props )
|
||||||
: Animation(props, new ssgTransform),
|
: SGAnimation(props, new ssgTransform),
|
||||||
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
|
||||||
_offset_m(props->getDoubleValue("offset-m", 0.0)),
|
_offset_m(props->getDoubleValue("offset-m", 0.0)),
|
||||||
_factor(props->getDoubleValue("factor", 1.0)),
|
_factor(props->getDoubleValue("factor", 1.0)),
|
||||||
@@ -354,13 +354,13 @@ TranslateAnimation::TranslateAnimation( SGPropertyNode *prop_root,
|
|||||||
sgNormalizeVec3(_axis);
|
sgNormalizeVec3(_axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslateAnimation::~TranslateAnimation ()
|
SGTranslateAnimation::~SGTranslateAnimation ()
|
||||||
{
|
{
|
||||||
delete _table;
|
delete _table;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TranslateAnimation::update()
|
SGTranslateAnimation::update()
|
||||||
{
|
{
|
||||||
if (_table == 0) {
|
if (_table == 0) {
|
||||||
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ SG_USING_STD(vector);
|
|||||||
|
|
||||||
// Don't pull in the headers, since we don't need them here.
|
// Don't pull in the headers, since we don't need them here.
|
||||||
class SGInterpTable;
|
class SGInterpTable;
|
||||||
class FGCondition;
|
class SGCondition;
|
||||||
|
|
||||||
|
|
||||||
// Has anyone done anything *really* stupid, like making min and max macros?
|
// Has anyone done anything *really* stupid, like making min and max macros?
|
||||||
@@ -43,13 +43,13 @@ class FGCondition;
|
|||||||
/**
|
/**
|
||||||
* Abstract base class for all animations.
|
* Abstract base class for all animations.
|
||||||
*/
|
*/
|
||||||
class Animation : public ssgBase
|
class SGAnimation : public ssgBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Animation (SGPropertyNode_ptr props, ssgBranch * branch);
|
SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch);
|
||||||
|
|
||||||
virtual ~Animation ();
|
virtual ~SGAnimation ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SSG branch holding the animation.
|
* Get the SSG branch holding the animation.
|
||||||
@@ -84,48 +84,48 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* A no-op animation.
|
* A no-op animation.
|
||||||
*/
|
*/
|
||||||
class NullAnimation : public Animation
|
class SGNullAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullAnimation (SGPropertyNode_ptr props);
|
SGNullAnimation (SGPropertyNode_ptr props);
|
||||||
virtual ~NullAnimation ();
|
virtual ~SGNullAnimation ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A range, or level-of-detail (LOD) animation.
|
* A range, or level-of-detail (LOD) animation.
|
||||||
*/
|
*/
|
||||||
class RangeAnimation : public Animation
|
class SGRangeAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RangeAnimation (SGPropertyNode_ptr props);
|
SGRangeAnimation (SGPropertyNode_ptr props);
|
||||||
virtual ~RangeAnimation ();
|
virtual ~SGRangeAnimation ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation to turn and face the screen.
|
* Animation to turn and face the screen.
|
||||||
*/
|
*/
|
||||||
class BillboardAnimation : public Animation
|
class SGBillboardAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BillboardAnimation (SGPropertyNode_ptr props);
|
SGBillboardAnimation (SGPropertyNode_ptr props);
|
||||||
virtual ~BillboardAnimation ();
|
virtual ~SGBillboardAnimation ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation to select alternative versions of the same object.
|
* Animation to select alternative versions of the same object.
|
||||||
*/
|
*/
|
||||||
class SelectAnimation : public Animation
|
class SGSelectAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectAnimation( SGPropertyNode *prop_root,
|
SGSelectAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props );
|
SGPropertyNode_ptr props );
|
||||||
virtual ~SelectAnimation ();
|
virtual ~SGSelectAnimation ();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
FGCondition * _condition;
|
SGCondition * _condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -134,13 +134,13 @@ private:
|
|||||||
*
|
*
|
||||||
* This animation rotates at a specific velocity.
|
* This animation rotates at a specific velocity.
|
||||||
*/
|
*/
|
||||||
class SpinAnimation : public Animation
|
class SGSpinAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpinAnimation( SGPropertyNode *prop_root,
|
SGSpinAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props,
|
SGPropertyNode_ptr props,
|
||||||
double sim_time_sec );
|
double sim_time_sec );
|
||||||
virtual ~SpinAnimation ();
|
virtual ~SGSpinAnimation ();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
SGPropertyNode_ptr _prop;
|
SGPropertyNode_ptr _prop;
|
||||||
@@ -156,11 +156,11 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Animation to draw objects for a specific amount of time each.
|
* Animation to draw objects for a specific amount of time each.
|
||||||
*/
|
*/
|
||||||
class TimedAnimation : public Animation
|
class SGTimedAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimedAnimation (SGPropertyNode_ptr props);
|
SGTimedAnimation (SGPropertyNode_ptr props);
|
||||||
virtual ~TimedAnimation ();
|
virtual ~SGTimedAnimation ();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
double _duration_sec;
|
double _duration_sec;
|
||||||
@@ -174,11 +174,11 @@ private:
|
|||||||
*
|
*
|
||||||
* This animation rotates to a specific position.
|
* This animation rotates to a specific position.
|
||||||
*/
|
*/
|
||||||
class RotateAnimation : public Animation
|
class SGRotateAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
|
SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
|
||||||
virtual ~RotateAnimation ();
|
virtual ~SGRotateAnimation ();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
SGPropertyNode_ptr _prop;
|
SGPropertyNode_ptr _prop;
|
||||||
@@ -199,12 +199,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Animation to slide along an axis.
|
* Animation to slide along an axis.
|
||||||
*/
|
*/
|
||||||
class TranslateAnimation : public Animation
|
class SGTranslateAnimation : public SGAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TranslateAnimation( SGPropertyNode *prop_root,
|
SGTranslateAnimation( SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr props );
|
SGPropertyNode_ptr props );
|
||||||
virtual ~TranslateAnimation ();
|
virtual ~SGTranslateAnimation ();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
private:
|
private:
|
||||||
SGPropertyNode_ptr _prop;
|
SGPropertyNode_ptr _prop;
|
||||||
|
|||||||
@@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGSSGLoader.
|
// Implementation of SGssgLoader.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGSSGLoader::FGSSGLoader ()
|
SGssgLoader::SGssgLoader ()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
FGSSGLoader::~FGSSGLoader ()
|
SGssgLoader::~SGssgLoader ()
|
||||||
{
|
{
|
||||||
std::map<string, ssgBase *>::iterator it = _table.begin();
|
std::map<string, ssgBase *>::iterator it = _table.begin();
|
||||||
while (it != _table.end()) {
|
while (it != _table.end()) {
|
||||||
@@ -27,7 +27,7 @@ FGSSGLoader::~FGSSGLoader ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGSSGLoader::flush ()
|
SGssgLoader::flush ()
|
||||||
{
|
{
|
||||||
std::map<string, ssgBase *>::iterator it = _table.begin();
|
std::map<string, ssgBase *>::iterator it = _table.begin();
|
||||||
while (it != _table.end()) {
|
while (it != _table.end()) {
|
||||||
@@ -45,19 +45,19 @@ FGSSGLoader::flush ()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGModelLoader.
|
// Implementation of SGModelLoader.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGModelLoader::FGModelLoader ()
|
SGModelLoader::SGModelLoader ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGModelLoader::~FGModelLoader ()
|
SGModelLoader::~SGModelLoader ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ssgEntity *
|
ssgEntity *
|
||||||
FGModelLoader::load_model( const string &fg_root,
|
SGModelLoader::load_model( const string &fg_root,
|
||||||
const string &path,
|
const string &path,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
@@ -66,7 +66,7 @@ FGModelLoader::load_model( const string &fg_root,
|
|||||||
// avoid duplicates.
|
// avoid duplicates.
|
||||||
std::map<string, ssgBase *>::iterator it = _table.find(path);
|
std::map<string, ssgBase *>::iterator it = _table.find(path);
|
||||||
if (it == _table.end()) {
|
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 = _table.find(path);
|
||||||
it->second->ref(); // add one reference to keep it around
|
it->second->ref(); // add one reference to keep it around
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ SG_USING_STD(string);
|
|||||||
/**
|
/**
|
||||||
* Base class for loading and managing SSG things.
|
* Base class for loading and managing SSG things.
|
||||||
*/
|
*/
|
||||||
class FGSSGLoader
|
class SGssgLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGSSGLoader ();
|
SGssgLoader ();
|
||||||
virtual ~FGSSGLoader ();
|
virtual ~SGssgLoader ();
|
||||||
virtual void flush ();
|
virtual void flush ();
|
||||||
protected:
|
protected:
|
||||||
std::map<string,ssgBase *> _table;
|
std::map<string,ssgBase *> _table;
|
||||||
@@ -35,11 +35,11 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* Class for loading and managing models with XML wrappers.
|
* Class for loading and managing models with XML wrappers.
|
||||||
*/
|
*/
|
||||||
class FGModelLoader : public FGSSGLoader
|
class SGModelLoader : public SGssgLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGModelLoader ();
|
SGModelLoader ();
|
||||||
virtual ~FGModelLoader ();
|
virtual ~SGModelLoader ();
|
||||||
|
|
||||||
virtual ssgEntity *load_model( const string &fg_root,
|
virtual ssgEntity *load_model( const string &fg_root,
|
||||||
const string &path,
|
const string &path,
|
||||||
|
|||||||
@@ -101,11 +101,11 @@ static void MakeTRANS( sgMat4 dst, const double Theta,
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGLocation.
|
// Implementation of SGLocation.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGLocation::FGLocation( void ):
|
SGLocation::SGLocation( void ):
|
||||||
_dirty(true),
|
_dirty(true),
|
||||||
_lon_deg(0),
|
_lon_deg(0),
|
||||||
_lat_deg(0),
|
_lat_deg(0),
|
||||||
@@ -125,26 +125,26 @@ FGLocation::FGLocation( void ):
|
|||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
FGLocation::~FGLocation( void ) {
|
SGLocation::~SGLocation( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGLocation::init ()
|
SGLocation::init ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGLocation::bind ()
|
SGLocation::bind ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGLocation::unbind ()
|
SGLocation::unbind ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
_dirty = true;
|
||||||
_lon_deg = lon_deg;
|
_lon_deg = lon_deg;
|
||||||
@@ -153,7 +153,7 @@ FGLocation::setPosition (double lon_deg, double lat_deg, double alt_ft)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
_dirty = true;
|
||||||
_roll_deg = roll_deg;
|
_roll_deg = roll_deg;
|
||||||
@@ -162,7 +162,7 @@ FGLocation::setOrientation (double roll_deg, double pitch_deg, double heading_de
|
|||||||
}
|
}
|
||||||
|
|
||||||
double *
|
double *
|
||||||
FGLocation::get_absolute_view_pos( const Point3D scenery_center )
|
SGLocation::get_absolute_view_pos( const Point3D scenery_center )
|
||||||
{
|
{
|
||||||
if ( _dirty ) {
|
if ( _dirty ) {
|
||||||
recalc( scenery_center );
|
recalc( scenery_center );
|
||||||
@@ -171,7 +171,7 @@ FGLocation::get_absolute_view_pos( const Point3D scenery_center )
|
|||||||
}
|
}
|
||||||
|
|
||||||
float *
|
float *
|
||||||
FGLocation::getRelativeViewPos( const Point3D scenery_center )
|
SGLocation::getRelativeViewPos( const Point3D scenery_center )
|
||||||
{
|
{
|
||||||
if ( _dirty ) {
|
if ( _dirty ) {
|
||||||
recalc( scenery_center );
|
recalc( scenery_center );
|
||||||
@@ -180,7 +180,7 @@ FGLocation::getRelativeViewPos( const Point3D scenery_center )
|
|||||||
}
|
}
|
||||||
|
|
||||||
float *
|
float *
|
||||||
FGLocation::getZeroElevViewPos( const Point3D scenery_center )
|
SGLocation::getZeroElevViewPos( const Point3D scenery_center )
|
||||||
{
|
{
|
||||||
if ( _dirty ) {
|
if ( _dirty ) {
|
||||||
recalc( scenery_center );
|
recalc( scenery_center );
|
||||||
@@ -193,7 +193,7 @@ FGLocation::getZeroElevViewPos( const Point3D scenery_center )
|
|||||||
// cached data "dirty") on the next "get". It calculates all the outputs
|
// cached data "dirty") on the next "get". It calculates all the outputs
|
||||||
// for viewer.
|
// for viewer.
|
||||||
void
|
void
|
||||||
FGLocation::recalc( const Point3D scenery_center )
|
SGLocation::recalc( const Point3D scenery_center )
|
||||||
{
|
{
|
||||||
|
|
||||||
recalcPosition( _lon_deg, _lat_deg, _alt_ft, scenery_center );
|
recalcPosition( _lon_deg, _lat_deg, _alt_ft, scenery_center );
|
||||||
@@ -231,7 +231,7 @@ FGLocation::recalc( const Point3D scenery_center )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
const Point3D scenery_center ) const
|
||||||
{
|
{
|
||||||
double sea_level_radius_m;
|
double sea_level_radius_m;
|
||||||
@@ -278,6 +278,6 @@ FGLocation::recalcPosition( double lon_deg, double lat_deg, double alt_ft,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGLocation::update (int dt)
|
SGLocation::update (int dt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,16 +37,16 @@
|
|||||||
|
|
||||||
|
|
||||||
// Define a structure containing view information
|
// Define a structure containing view information
|
||||||
class FGLocation
|
class SGLocation
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGLocation( void );
|
SGLocation( void );
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~FGLocation( void );
|
virtual ~SGLocation( void );
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Part 1: standard FGSubsystem implementation.
|
// Part 1: standard FGSubsystem implementation.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ SG_USING_STD(vector);
|
|||||||
static int
|
static int
|
||||||
animation_callback (ssgEntity * entity, int mask)
|
animation_callback (ssgEntity * entity, int mask)
|
||||||
{
|
{
|
||||||
((Animation *)entity->getUserData())->update();
|
((SGAnimation *)entity->getUserData())->update();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ splice_branch (ssgBranch * branch, ssgEntity * child)
|
|||||||
* Make an offset matrix from rotations and position offset.
|
* Make an offset matrix from rotations and position offset.
|
||||||
*/
|
*/
|
||||||
void
|
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 )
|
double x_off, double y_off, double z_off )
|
||||||
{
|
{
|
||||||
sgMat4 rot_matrix;
|
sgMat4 rot_matrix;
|
||||||
@@ -95,33 +95,33 @@ fgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
fgMakeAnimation( ssgBranch * model,
|
sgMakeAnimation( ssgBranch * model,
|
||||||
const char * name,
|
const char * name,
|
||||||
vector<SGPropertyNode_ptr> &name_nodes,
|
vector<SGPropertyNode_ptr> &name_nodes,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr node,
|
SGPropertyNode_ptr node,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
{
|
{
|
||||||
Animation * animation = 0;
|
SGAnimation * animation = 0;
|
||||||
const char * type = node->getStringValue("type", "none");
|
const char * type = node->getStringValue("type", "none");
|
||||||
if (!strcmp("none", type)) {
|
if (!strcmp("none", type)) {
|
||||||
animation = new NullAnimation(node);
|
animation = new SGNullAnimation(node);
|
||||||
} else if (!strcmp("range", type)) {
|
} else if (!strcmp("range", type)) {
|
||||||
animation = new RangeAnimation(node);
|
animation = new SGRangeAnimation(node);
|
||||||
} else if (!strcmp("billboard", type)) {
|
} else if (!strcmp("billboard", type)) {
|
||||||
animation = new BillboardAnimation(node);
|
animation = new SGBillboardAnimation(node);
|
||||||
} else if (!strcmp("select", type)) {
|
} else if (!strcmp("select", type)) {
|
||||||
animation = new SelectAnimation(prop_root, node);
|
animation = new SGSelectAnimation(prop_root, node);
|
||||||
} else if (!strcmp("spin", type)) {
|
} 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)) {
|
} else if (!strcmp("timed", type)) {
|
||||||
animation = new TimedAnimation(node);
|
animation = new SGTimedAnimation(node);
|
||||||
} else if (!strcmp("rotate", type)) {
|
} else if (!strcmp("rotate", type)) {
|
||||||
animation = new RotateAnimation(prop_root, node);
|
animation = new SGRotateAnimation(prop_root, node);
|
||||||
} else if (!strcmp("translate", type)) {
|
} else if (!strcmp("translate", type)) {
|
||||||
animation = new TranslateAnimation(prop_root, node);
|
animation = new SGTranslateAnimation(prop_root, node);
|
||||||
} else {
|
} else {
|
||||||
animation = new NullAnimation(node);
|
animation = new SGNullAnimation(node);
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
|
SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ fgMakeAnimation( ssgBranch * model,
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ssgBranch *
|
ssgBranch *
|
||||||
fgLoad3DModel( const string &fg_root, const string &path,
|
sgLoad3DModel( const string &fg_root, const string &path,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
double sim_time_sec )
|
double sim_time_sec )
|
||||||
{
|
{
|
||||||
@@ -213,7 +213,7 @@ fgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
ssgTransform * alignmainmodel = new ssgTransform;
|
ssgTransform * alignmainmodel = new ssgTransform;
|
||||||
alignmainmodel->addKid(model);
|
alignmainmodel->addKid(model);
|
||||||
sgMat4 res_matrix;
|
sgMat4 res_matrix;
|
||||||
fgMakeOffsetsMatrix(&res_matrix,
|
sgMakeOffsetsMatrix(&res_matrix,
|
||||||
props.getFloatValue("/offsets/heading-deg", 0.0),
|
props.getFloatValue("/offsets/heading-deg", 0.0),
|
||||||
props.getFloatValue("/offsets/roll-deg", 0.0),
|
props.getFloatValue("/offsets/roll-deg", 0.0),
|
||||||
props.getFloatValue("/offsets/pitch-deg", 0.0),
|
props.getFloatValue("/offsets/pitch-deg", 0.0),
|
||||||
@@ -230,7 +230,7 @@ fgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
const char * name = animation_nodes[i]->getStringValue("name", 0);
|
const char * name = animation_nodes[i]->getStringValue("name", 0);
|
||||||
vector<SGPropertyNode_ptr> name_nodes =
|
vector<SGPropertyNode_ptr> name_nodes =
|
||||||
animation_nodes[i]->getChildren("object-name");
|
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);
|
sim_time_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ fgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
SGPropertyNode_ptr node = model_nodes[i];
|
SGPropertyNode_ptr node = model_nodes[i];
|
||||||
ssgTransform * align = new ssgTransform;
|
ssgTransform * align = new ssgTransform;
|
||||||
sgMat4 res_matrix;
|
sgMat4 res_matrix;
|
||||||
fgMakeOffsetsMatrix(&res_matrix,
|
sgMakeOffsetsMatrix(&res_matrix,
|
||||||
node->getFloatValue("offsets/heading-deg", 0.0),
|
node->getFloatValue("offsets/heading-deg", 0.0),
|
||||||
node->getFloatValue("offsets/roll-deg", 0.0),
|
node->getFloatValue("offsets/roll-deg", 0.0),
|
||||||
node->getFloatValue("offsets/pitch-deg", 0.0),
|
node->getFloatValue("offsets/pitch-deg", 0.0),
|
||||||
@@ -249,7 +249,7 @@ fgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
node->getFloatValue("offsets/z-m", 0.0));
|
node->getFloatValue("offsets/z-m", 0.0));
|
||||||
align->setTransform(res_matrix);
|
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 );
|
prop_root, sim_time_sec );
|
||||||
align->addKid(kid);
|
align->addKid(kid);
|
||||||
model->addKid(align);
|
model->addKid(align);
|
||||||
|
|||||||
@@ -41,22 +41,23 @@ SG_USING_STD(vector);
|
|||||||
* Subsystems should not normally invoke this function directly;
|
* Subsystems should not normally invoke this function directly;
|
||||||
* instead, they should use the FGModelLoader declared in loader.hxx.
|
* instead, they should use the FGModelLoader declared in loader.hxx.
|
||||||
*/
|
*/
|
||||||
ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
|
ssgBranch *
|
||||||
SGPropertyNode *prop_root, double sim_time_sec );
|
sgLoad3DModel( const string& fg_root, const string &path,
|
||||||
|
SGPropertyNode *prop_root, double sim_time_sec );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an offset matrix from rotations and position offset.
|
* Make an offset matrix from rotations and position offset.
|
||||||
*/
|
*/
|
||||||
void
|
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 );
|
double x_off, double y_off, double z_off );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the animation
|
* Make the animation
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fgMakeAnimation( ssgBranch * model,
|
sgMakeAnimation( ssgBranch * model,
|
||||||
const char * name,
|
const char * name,
|
||||||
vector<SGPropertyNode_ptr> &name_nodes,
|
vector<SGPropertyNode_ptr> &name_nodes,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ SG_USING_STD(vector);
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGModelPlacement.
|
// Implementation of SGModelPlacement.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGModelPlacement::FGModelPlacement ()
|
SGModelPlacement::SGModelPlacement ()
|
||||||
: _lon_deg(0),
|
: _lon_deg(0),
|
||||||
_lat_deg(0),
|
_lat_deg(0),
|
||||||
_elev_ft(0),
|
_elev_ft(0),
|
||||||
@@ -38,16 +38,16 @@ FGModelPlacement::FGModelPlacement ()
|
|||||||
_heading_deg(0),
|
_heading_deg(0),
|
||||||
_selector(new ssgSelector),
|
_selector(new ssgSelector),
|
||||||
_position(new ssgTransform),
|
_position(new ssgTransform),
|
||||||
_location(new FGLocation)
|
_location(new SGLocation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGModelPlacement::~FGModelPlacement ()
|
SGModelPlacement::~SGModelPlacement ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::init( ssgBranch * model )
|
SGModelPlacement::init( ssgBranch * model )
|
||||||
{
|
{
|
||||||
if (model != 0) {
|
if (model != 0) {
|
||||||
_position->addKid(model);
|
_position->addKid(model);
|
||||||
@@ -57,7 +57,7 @@ FGModelPlacement::init( ssgBranch * model )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::update( const Point3D scenery_center )
|
SGModelPlacement::update( const Point3D scenery_center )
|
||||||
{
|
{
|
||||||
_location->setPosition( _lon_deg, _lat_deg, _elev_ft );
|
_location->setPosition( _lon_deg, _lat_deg, _elev_ft );
|
||||||
_location->setOrientation( _roll_deg, _pitch_deg, _heading_deg );
|
_location->setOrientation( _roll_deg, _pitch_deg, _heading_deg );
|
||||||
@@ -77,37 +77,37 @@ FGModelPlacement::update( const Point3D scenery_center )
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FGModelPlacement::getVisible () const
|
SGModelPlacement::getVisible () const
|
||||||
{
|
{
|
||||||
return (_selector->getSelect() != 0);
|
return (_selector->getSelect() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setVisible (bool visible)
|
SGModelPlacement::setVisible (bool visible)
|
||||||
{
|
{
|
||||||
_selector->select(visible);
|
_selector->select(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setLongitudeDeg (double lon_deg)
|
SGModelPlacement::setLongitudeDeg (double lon_deg)
|
||||||
{
|
{
|
||||||
_lon_deg = lon_deg;
|
_lon_deg = lon_deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setLatitudeDeg (double lat_deg)
|
SGModelPlacement::setLatitudeDeg (double lat_deg)
|
||||||
{
|
{
|
||||||
_lat_deg = lat_deg;
|
_lat_deg = lat_deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setElevationFt (double elev_ft)
|
SGModelPlacement::setElevationFt (double elev_ft)
|
||||||
{
|
{
|
||||||
_elev_ft = elev_ft;
|
_elev_ft = elev_ft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
_lon_deg = lon_deg;
|
||||||
_lat_deg = lat_deg;
|
_lat_deg = lat_deg;
|
||||||
@@ -115,25 +115,25 @@ FGModelPlacement::setPosition (double lon_deg, double lat_deg, double elev_ft)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setRollDeg (double roll_deg)
|
SGModelPlacement::setRollDeg (double roll_deg)
|
||||||
{
|
{
|
||||||
_roll_deg = roll_deg;
|
_roll_deg = roll_deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setPitchDeg (double pitch_deg)
|
SGModelPlacement::setPitchDeg (double pitch_deg)
|
||||||
{
|
{
|
||||||
_pitch_deg = pitch_deg;
|
_pitch_deg = pitch_deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setHeadingDeg (double heading_deg)
|
SGModelPlacement::setHeadingDeg (double heading_deg)
|
||||||
{
|
{
|
||||||
_heading_deg = heading_deg;
|
_heading_deg = heading_deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelPlacement::setOrientation (double roll_deg, double pitch_deg,
|
SGModelPlacement::setOrientation (double roll_deg, double pitch_deg,
|
||||||
double heading_deg)
|
double heading_deg)
|
||||||
{
|
{
|
||||||
_roll_deg = roll_deg;
|
_roll_deg = roll_deg;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ SG_USING_STD(vector);
|
|||||||
|
|
||||||
|
|
||||||
// Don't pull in the headers, since we don't need them here.
|
// 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?
|
// Has anyone done anything *really* stupid, like making min and max macros?
|
||||||
@@ -42,14 +42,14 @@ class FGLocation;
|
|||||||
/**
|
/**
|
||||||
* A wrapper for a model with a definite placement.
|
* A wrapper for a model with a definite placement.
|
||||||
*/
|
*/
|
||||||
class FGModelPlacement
|
class SGModelPlacement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGModelPlacement ();
|
SGModelPlacement ();
|
||||||
virtual ~FGModelPlacement ();
|
virtual ~SGModelPlacement ();
|
||||||
|
|
||||||
virtual void FGModelPlacement::init( ssgBranch * model );
|
virtual void SGModelPlacement::init( ssgBranch * model );
|
||||||
/* virtual void init( const string &fg_root,
|
/* virtual void init( const string &fg_root,
|
||||||
const string &path,
|
const string &path,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
|
virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
|
||||||
|
|
||||||
virtual FGLocation * getFGLocation () { return _location; }
|
virtual SGLocation * getSGLocation () { return _location; }
|
||||||
|
|
||||||
virtual bool getVisible () const;
|
virtual bool getVisible () const;
|
||||||
virtual void setVisible (bool visible);
|
virtual void setVisible (bool visible);
|
||||||
@@ -102,7 +102,7 @@ private:
|
|||||||
ssgTransform * _position;
|
ssgTransform * _position;
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
FGLocation * _location;
|
SGLocation * _location;
|
||||||
|
|
||||||
|
|
||||||
// Addition by Diarmuid Tyson for Multiplayer Support
|
// Addition by Diarmuid Tyson for Multiplayer Support
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ bool SGSky::repaint( sgVec4 sky_color, sgVec4 fog_color,
|
|||||||
stars->repaint( sun_angle, nstars, star_data );
|
stars->repaint( sun_angle, nstars, star_data );
|
||||||
|
|
||||||
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
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 {
|
} else {
|
||||||
// turn off sky
|
// turn off sky
|
||||||
@@ -151,7 +153,9 @@ bool SGSky::reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
|
|||||||
stars->reposition( view_pos, angle );
|
stars->reposition( view_pos, angle );
|
||||||
|
|
||||||
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
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;
|
return true;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ SGSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr,
|
|||||||
_property = root->getNode(node->getStringValue("property", ""), true);
|
_property = root->getNode(node->getStringValue("property", ""), true);
|
||||||
SGPropertyNode *condition = node->getChild("condition");
|
SGPropertyNode *condition = node->getChild("condition");
|
||||||
if (condition != NULL)
|
if (condition != NULL)
|
||||||
_condition = fgReadCondition(root, condition);
|
_condition = sgReadCondition(root, condition);
|
||||||
|
|
||||||
if (!_property && !_condition)
|
if (!_property && !_condition)
|
||||||
SG_LOG(SG_GENERAL, SG_WARN,
|
SG_LOG(SG_GENERAL, SG_WARN,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
SGSoundMgr * _mgr;
|
SGSoundMgr * _mgr;
|
||||||
SGSimpleSound * _sample;
|
SGSimpleSound * _sample;
|
||||||
|
|
||||||
FGCondition * _condition;
|
SGCondition * _condition;
|
||||||
SGPropertyNode * _property;
|
SGPropertyNode * _property;
|
||||||
|
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Condition to signal when queue not empty.
|
* Condition to signal when queue not empty.
|
||||||
*/
|
*/
|
||||||
SGCondition not_empty;
|
SGPthreadCond not_empty;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Prevent copying.
|
// Prevent copying.
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ int gettimeofday(struct timeval* tp, void* tzp) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SGCondition::wait( SGMutex& mutex, unsigned long ms )
|
SGPthreadCond::wait( SGMutex& mutex, unsigned long ms )
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday( &now, 0 );
|
::gettimeofday( &now, 0 );
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ SGThread::cancel()
|
|||||||
*/
|
*/
|
||||||
class SGMutex
|
class SGMutex
|
||||||
{
|
{
|
||||||
friend class SGCondition;
|
friend class SGPthreadCond;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -239,18 +239,18 @@ inline void SGMutex::unlock()
|
|||||||
* A condition variable is always associated with a mutex to avoid race
|
* A condition variable is always associated with a mutex to avoid race
|
||||||
* conditions.
|
* conditions.
|
||||||
*/
|
*/
|
||||||
class SGCondition
|
class SGPthreadCond
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a new condition variable.
|
* Create a new condition variable.
|
||||||
*/
|
*/
|
||||||
SGCondition();
|
SGPthreadCond();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the condition object.
|
* Destroy the condition object.
|
||||||
*/
|
*/
|
||||||
~SGCondition();
|
~SGPthreadCond();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for this condition variable to be signaled.
|
* Wait for this condition variable to be signaled.
|
||||||
@@ -286,8 +286,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Disable copying.
|
// Disable copying.
|
||||||
SGCondition(const SGCondition& );
|
SGPthreadCond(const SGPthreadCond& );
|
||||||
SGCondition& operator=(const SGCondition& );
|
SGPthreadCond& operator=(const SGPthreadCond& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -297,31 +297,31 @@ private:
|
|||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline SGCondition::SGCondition()
|
inline SGPthreadCond::SGPthreadCond()
|
||||||
{
|
{
|
||||||
int status = pthread_cond_init( &cond, 0 );
|
int status = pthread_cond_init( &cond, 0 );
|
||||||
assert( status == 0 );
|
assert( status == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SGCondition::~SGCondition()
|
inline SGPthreadCond::~SGPthreadCond()
|
||||||
{
|
{
|
||||||
int status = pthread_cond_destroy( &cond );
|
int status = pthread_cond_destroy( &cond );
|
||||||
assert( status == 0 );
|
assert( status == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SGCondition::signal()
|
inline void SGPthreadCond::signal()
|
||||||
{
|
{
|
||||||
int status = pthread_cond_signal( &cond );
|
int status = pthread_cond_signal( &cond );
|
||||||
assert( status == 0 );
|
assert( status == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SGCondition::broadcast()
|
inline void SGPthreadCond::broadcast()
|
||||||
{
|
{
|
||||||
int status = pthread_cond_broadcast( &cond );
|
int status = pthread_cond_broadcast( &cond );
|
||||||
assert( status == 0 );
|
assert( status == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SGCondition::wait( SGMutex& mutex )
|
inline void SGPthreadCond::wait( SGMutex& mutex )
|
||||||
{
|
{
|
||||||
int status = pthread_cond_wait( &cond, &mutex.mutex );
|
int status = pthread_cond_wait( &cond, &mutex.mutex );
|
||||||
assert( status == 0 );
|
assert( status == 0 );
|
||||||
|
|||||||
Reference in New Issue
Block a user