]> git.mxchange.org Git - flightgear.git/commitdiff
Added min/max parameters to clamp range of movement. These are
authordavid <david>
Sat, 2 Mar 2002 16:07:42 +0000 (16:07 +0000)
committerdavid <david>
Sat, 2 Mar 2002 16:07:42 +0000 (16:07 +0000)
actually very powerful when combined with factor and offset -- for
example, on the C310 model the nose wheel can now retract completely
before the doors start closing.

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

index 3cf6c3031f66be2e4cff90caf1c00bb3cf9264f1..32237ee4a68d55aef7d9a869c85a18b815539071 100644 (file)
@@ -231,6 +231,18 @@ FGAircraftModel::read_animation (const string &object_name,
 
   animation.position = node->getFloatValue("initial-position", 0);
   animation.offset = node->getFloatValue("offset", 0);
+  if (node->hasValue("min")) {
+    animation.has_min = true;
+    animation.min = node->getFloatValue("min");
+  } else {
+    animation.has_min = false;
+  }
+  if (node->hasValue("max")) {
+    animation.has_max = true;
+    animation.max = node->getFloatValue("max");
+  } else {
+    animation.has_max = false;
+  }
   animation.factor = node->getFloatValue("factor", 1);
 
                                // Get the center and axis
@@ -238,7 +250,7 @@ FGAircraftModel::read_animation (const string &object_name,
   animation.center[1] = node->getFloatValue("center/y-m", 0);
   animation.center[2] = node->getFloatValue("center/z-m", 0);
   animation.axis[0] = node->getFloatValue("axis/x", 0);
-  animation.axis[1] = node->getFloatValue("axis/y", 1);
+  animation.axis[1] = node->getFloatValue("axis/y", 0);
   animation.axis[2] = node->getFloatValue("axis/z", 0);
 
   sgNormalizeVec3(animation.axis);
@@ -264,6 +276,10 @@ FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
     animation.position = ((animation.prop->getFloatValue()
                           + animation.offset)
                          * animation.factor);
+    if (animation.has_min && animation.position < animation.min)
+      animation.position = animation.min;
+    if (animation.has_max && animation.position > animation.max)
+      animation.position = animation.max;
     animation.setRotation();
     return;
   }
index 685c37d0e6d75aae1b3cc5ec83f401546c3f2c2d..ac23895c516ea2368399caa9b147337066914b61 100644 (file)
@@ -49,6 +49,10 @@ private:
     float factor;
     float offset;
     float position;
+    bool has_min;
+    float min;
+    bool has_max;
+    float max;
     sgVec3 center;
     sgVec3 axis;
     void setRotation ();