From 6b71800829d201584d2369985f3bf95743e62ad2 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 13 Apr 2002 12:10:20 +0000 Subject: [PATCH] Add and document a "range" (level-of-detail) animation for individual objects and a range for the model as a whole. --- src/Model/model.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++-- src/Model/model.hxx | 15 +++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/Model/model.cxx b/src/Model/model.cxx index 1119de043..ce9a5e7b1 100644 --- a/src/Model/model.cxx +++ b/src/Model/model.cxx @@ -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 ssgTransform * align = new ssgTransform; - align->addKid(_model); + align->addKid(lod); sgMat4 rot_matrix; sgMat4 off_matrix; sgMat4 res_matrix; @@ -217,7 +226,6 @@ FG3DModel::init (const string &path) _selector->addKid(_position); _selector->clrTraversalMaskBits(SSGTRAV_HOT); - // Set up a location class _location = (FGLocation *) new FGLocation; @@ -318,6 +326,8 @@ FG3DModel::make_animation (const char * object_name, const char * type = node->getStringValue("type"); if (!strcmp("none", type)) { animation = new NullAnimation(); + } else if (!strcmp("range", type)) { + animation = new RangeAnimation(); } else if (!strcmp("select", type)) { animation = new SelectAnimation(); } 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 diff --git a/src/Model/model.hxx b/src/Model/model.hxx index fa85b592f..ce4112ba9 100644 --- a/src/Model/model.hxx +++ b/src/Model/model.hxx @@ -139,6 +139,21 @@ private: 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. -- 2.39.5