Add the ability to set three levels of detail for static scenery using the property tree

This commit is contained in:
ehofman
2003-09-28 08:38:48 +00:00
parent 81b9ec50b0
commit 431e78cf09
3 changed files with 51 additions and 8 deletions

View File

@@ -97,7 +97,7 @@ set_scale (sgMat4 &matrix, double x, double y, double z)
static void
change_alpha( ssgBase *_branch, float _blend )
{
unsigned int i;
int i;
for (i = 0; i < ((ssgBranch *)_branch)->getNumKids(); i++)
change_alpha( ((ssgBranch *)_branch)->getKid(i), _blend );
@@ -214,19 +214,55 @@ SGNullAnimation::~SGNullAnimation ()
// Implementation of SGRangeAnimation
////////////////////////////////////////////////////////////////////////
SGRangeAnimation::SGRangeAnimation (SGPropertyNode_ptr props)
: SGAnimation(props, new ssgRangeSelector)
SGRangeAnimation::SGRangeAnimation (SGPropertyNode *prop_root,
SGPropertyNode_ptr props)
: SGAnimation(props, new ssgRangeSelector),
_min(0.0), _max(0.0)
{
float ranges[] = { props->getFloatValue("min-m", 0),
props->getFloatValue("max-m", 5000) };
float ranges[2];
SGPropertyNode_ptr node = props->getChild( "min-property" );
if (node != 0) {
_min_prop = (SGPropertyNode *)prop_root->getNode(node->getStringValue(), true);
ranges[0] = _min_prop->getFloatValue();
} else {
ranges[0] = _min = props->getFloatValue("min-m", 0);
}
node = props->getChild( "max-property" );
if (node != 0) {
_max_prop = (SGPropertyNode *)prop_root->getNode(node->getStringValue(), true);
ranges[1] = _max_prop->getFloatValue();
} else {
ranges[1] = _max = props->getFloatValue("max-m", 0);
}
((ssgRangeSelector *)_branch)->setRanges(ranges, 2);
}
SGRangeAnimation::~SGRangeAnimation ()
{
}
void
SGRangeAnimation::update()
{
float ranges[2];
bool upd = false;
if (_min_prop != 0) {
ranges[0] = _min_prop->getFloatValue();
upd = true;
} else {
ranges[0] = _min;
}
if (_max_prop != 0) {
ranges[1] = _max_prop->getFloatValue();
upd = true;
} else {
ranges[1] = _max;
}
if (upd)
((ssgRangeSelector *)_branch)->setRanges(ranges, 2);
}
////////////////////////////////////////////////////////////////////////

View File

@@ -99,8 +99,15 @@ public:
class SGRangeAnimation : public SGAnimation
{
public:
SGRangeAnimation (SGPropertyNode_ptr props);
SGRangeAnimation (SGPropertyNode *prop_root,
SGPropertyNode_ptr props);
virtual ~SGRangeAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _min_prop;
SGPropertyNode_ptr _max_prop;
float _min;
float _max;
};

View File

@@ -107,7 +107,7 @@ sgMakeAnimation( ssgBranch * model,
if (!strcmp("none", type)) {
animation = new SGNullAnimation(node);
} else if (!strcmp("range", type)) {
animation = new SGRangeAnimation(node);
animation = new SGRangeAnimation(prop_root, node);
} else if (!strcmp("billboard", type)) {
animation = new SGBillboardAnimation(node);
} else if (!strcmp("select", type)) {