]> git.mxchange.org Git - flightgear.git/commitdiff
Added select animation type (using a condition), and allow all
authordavid <david>
Mon, 1 Apr 2002 14:00:08 +0000 (14:00 +0000)
committerdavid <david>
Mon, 1 Apr 2002 14:00:08 +0000 (14:00 +0000)
animations to be named.

src/Main/model.cxx
src/Main/model.hxx

index 2cee54884f1820019973675f4013422e8ce1d7a7..461c5a8e42c5a722c7290fb832777a4e377f0545 100644 (file)
@@ -32,6 +32,9 @@ FGAircraftModel current_model;        // FIXME: add to globals
 // Static utility functions.
 ////////////////////////////////////////////////////////////////////////
 
+/**
+ * Locate a named SSG node in a branch.
+ */
 static ssgEntity *
 find_named_node (ssgEntity * node, const char * name)
 {
@@ -296,6 +299,8 @@ FGAircraftModel::make_animation (const char * object_name,
   const char * type = node->getStringValue("type");
   if (!strcmp("none", type)) {
     animation = new NullAnimation();
+  } else if (!strcmp("select", type)) {
+    animation = new SelectAnimation();
   } else if (!strcmp("spin", type)) {
     animation = new SpinAnimation();
   } else if (!strcmp("rotate", type)) {
@@ -340,17 +345,21 @@ FGAircraftModel::Animation::~Animation ()
 ////////////////////////////////////////////////////////////////////////
 
 FGAircraftModel::NullAnimation::NullAnimation ()
+  : _branch(new ssgBranch)
 {
 }
 
 FGAircraftModel::NullAnimation::~NullAnimation ()
 {
+  _branch = 0;
 }
 
 void
 FGAircraftModel::NullAnimation::init (ssgEntity * object,
-                                     SGPropertyNode * node)
+                                     SGPropertyNode * props)
 {
+  splice_branch(_branch, object);
+  _branch->setName(props->getStringValue("name", 0));
 }
 
 void
@@ -359,6 +368,45 @@ FGAircraftModel::NullAnimation::update (int dt)
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGAircraftModel::SelectAnimation
+////////////////////////////////////////////////////////////////////////
+
+FGAircraftModel::SelectAnimation::SelectAnimation ()
+  : _condition(0),
+    _selector(new ssgSelector)
+{
+}
+
+FGAircraftModel::SelectAnimation::~SelectAnimation ()
+{
+  delete _condition;
+  _selector = 0;
+}
+
+void
+FGAircraftModel::SelectAnimation::init (ssgEntity * object,
+                                     SGPropertyNode * props)
+{
+  splice_branch(_selector, object);
+  _selector->setName(props->getStringValue("name", 0));
+  SGPropertyNode * node = props->getChild("condition");
+  if (node != 0) {
+    _condition = fgReadCondition(node);
+  }
+}
+
+void
+FGAircraftModel::SelectAnimation::update (int dt)
+{
+  if (_condition != 0 && _condition->test()) 
+    _selector->select(0xffff);
+  else
+    _selector->select(0x0000);
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGAircraftModel::SpinAnimation
@@ -383,6 +431,7 @@ FGAircraftModel::SpinAnimation::init (ssgEntity * object,
 {
                                // Splice in the new transform node
   splice_branch(_transform, object);
+  _transform->setName(props->getStringValue("name", 0));
   _prop = fgGetNode(props->getStringValue("property", "/null"), true);
   _factor = props->getDoubleValue("factor", 1.0);
   _position_deg = props->getDoubleValue("starting-position-deg", 0);
@@ -438,6 +487,7 @@ FGAircraftModel::RotateAnimation::init (ssgEntity * object,
 {
                                // Splice in the new transform node
   splice_branch(_transform, object);
+  _transform->setName(props->getStringValue("name", 0));
   _prop = fgGetNode(props->getStringValue("property", "/null"), true);
   _offset_deg = props->getDoubleValue("offset-deg", 0.0);
   _factor = props->getDoubleValue("factor", 1.0);
@@ -501,6 +551,7 @@ FGAircraftModel::TranslateAnimation::init (ssgEntity * object,
 {
                                // Splice in the new transform node
   splice_branch(_transform, object);
+  _transform->setName(props->getStringValue("name", 0));
   _prop = fgGetNode(props->getStringValue("property", "/null"), true);
   _offset_m = props->getDoubleValue("offset-m", 0.0);
   _factor = props->getDoubleValue("factor", 1.0);
@@ -533,7 +584,3 @@ FGAircraftModel::TranslateAnimation::update (int dt)
 
 
 // end of model.cxx
-
-
-
-
index 9ed6340724db93f0b3be9966f05e969f8b9bdac5..439f6eef1de78740459072d473100d669200100f 100644 (file)
@@ -98,6 +98,24 @@ private:
     virtual ~NullAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
     virtual void update (int dt);
+  private:
+    ssgBranch * _branch;
+  };
+
+
+  /**
+   * Animation to select alternative versions of the same object.
+   */
+  class SelectAnimation : public Animation
+  {
+  public:
+    SelectAnimation ();
+    virtual ~SelectAnimation ();
+    virtual void init (ssgEntity * object, SGPropertyNode * props);
+    virtual void update (int dt);
+  private:
+    FGCondition * _condition;
+    ssgSelector * _selector;
   };