]> git.mxchange.org Git - flightgear.git/commitdiff
Add and document a "range" (level-of-detail) animation for individual
authordavid <david>
Sat, 13 Apr 2002 12:10:20 +0000 (12:10 +0000)
committerdavid <david>
Sat, 13 Apr 2002 12:10:20 +0000 (12:10 +0000)
objects and a range for the model as a whole.

src/Model/model.cxx
src/Model/model.hxx

index 1119de04336d316452db843856b885580d2c39b4..ce9a5e7b166bb340a0b1d4a147001e338b7aae3d 100644 (file)
@@ -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)
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// 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)
+{
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FG3DModel::SelectAnimation
index fa85b592fbb6090cf8cb941a5ca4868c7e7429ce..ce4112ba959732e0357406f379bee8a658218365 100644 (file)
@@ -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.