Add and document a "range" (level-of-detail) animation for individual
objects and a range for the model as a whole.
This commit is contained in:
parent
fa5a707128
commit
6b71800829
2 changed files with 60 additions and 2 deletions
|
@ -193,9 +193,18 @@ FG3DModel::init (const string &path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up the range selector node
|
||||||
|
float ranges[2];
|
||||||
|
ssgRangeSelector * lod = new ssgRangeSelector;
|
||||||
|
lod->addKid(_model);
|
||||||
|
ranges[0] = props.getFloatValue("range/min-m", 0);
|
||||||
|
ranges[1] = props.getFloatValue("range/max-m", 5000);
|
||||||
|
lod->setRanges(ranges, 2);
|
||||||
|
|
||||||
|
|
||||||
// Set up the alignment node
|
// Set up the alignment node
|
||||||
ssgTransform * align = new ssgTransform;
|
ssgTransform * align = new ssgTransform;
|
||||||
align->addKid(_model);
|
align->addKid(lod);
|
||||||
sgMat4 rot_matrix;
|
sgMat4 rot_matrix;
|
||||||
sgMat4 off_matrix;
|
sgMat4 off_matrix;
|
||||||
sgMat4 res_matrix;
|
sgMat4 res_matrix;
|
||||||
|
@ -217,7 +226,6 @@ FG3DModel::init (const string &path)
|
||||||
_selector->addKid(_position);
|
_selector->addKid(_position);
|
||||||
_selector->clrTraversalMaskBits(SSGTRAV_HOT);
|
_selector->clrTraversalMaskBits(SSGTRAV_HOT);
|
||||||
|
|
||||||
|
|
||||||
// Set up a location class
|
// Set up a location class
|
||||||
_location = (FGLocation *) new FGLocation;
|
_location = (FGLocation *) new FGLocation;
|
||||||
|
|
||||||
|
@ -318,6 +326,8 @@ FG3DModel::make_animation (const char * object_name,
|
||||||
const char * type = node->getStringValue("type");
|
const char * type = node->getStringValue("type");
|
||||||
if (!strcmp("none", type)) {
|
if (!strcmp("none", type)) {
|
||||||
animation = new NullAnimation();
|
animation = new NullAnimation();
|
||||||
|
} else if (!strcmp("range", type)) {
|
||||||
|
animation = new RangeAnimation();
|
||||||
} else if (!strcmp("select", type)) {
|
} else if (!strcmp("select", type)) {
|
||||||
animation = new SelectAnimation();
|
animation = new SelectAnimation();
|
||||||
} else if (!strcmp("spin", type)) {
|
} else if (!strcmp("spin", type)) {
|
||||||
|
@ -387,6 +397,39 @@ FG3DModel::NullAnimation::update (int dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Implementation of FG3DModel::RangeAnimation
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FG3DModel::RangeAnimation::RangeAnimation ()
|
||||||
|
: _branch(new ssgRangeSelector)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FG3DModel::RangeAnimation::~RangeAnimation ()
|
||||||
|
{
|
||||||
|
_branch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FG3DModel::RangeAnimation::init (ssgEntity * object,
|
||||||
|
SGPropertyNode * props)
|
||||||
|
{
|
||||||
|
float ranges[2];
|
||||||
|
splice_branch(_branch, object);
|
||||||
|
_branch->setName(props->getStringValue("name", 0));
|
||||||
|
ranges[0] = props->getFloatValue("min-m", 0);
|
||||||
|
ranges[1] = props->getFloatValue("max-m", 5000);
|
||||||
|
_branch->setRanges(ranges, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FG3DModel::RangeAnimation::update (int dt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FG3DModel::SelectAnimation
|
// Implementation of FG3DModel::SelectAnimation
|
||||||
|
|
|
@ -139,6 +139,21 @@ private:
|
||||||
ssgBranch * _branch;
|
ssgBranch * _branch;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A range, or level-of-detail (LOD) animation.
|
||||||
|
*/
|
||||||
|
class RangeAnimation : public Animation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RangeAnimation ();
|
||||||
|
virtual ~RangeAnimation ();
|
||||||
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
|
virtual void update (int dt);
|
||||||
|
private:
|
||||||
|
ssgRangeSelector * _branch;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation to select alternative versions of the same object.
|
* Animation to select alternative versions of the same object.
|
||||||
|
|
Loading…
Add table
Reference in a new issue