]> git.mxchange.org Git - flightgear.git/commitdiff
Added rotation animations, and a factor parameter for scaling.
authordavid <david>
Tue, 26 Feb 2002 14:30:04 +0000 (14:30 +0000)
committerdavid <david>
Tue, 26 Feb 2002 14:30:04 +0000 (14:30 +0000)
src/Main/model.cxx
src/Main/model.hxx

index cd2866bb07322f48447b063e5b27b12241c30107..d1b4233f497bb59d731bbea392a988e3647ee1da 100644 (file)
@@ -182,6 +182,13 @@ FGAircraftModel::read_animation (const SGPropertyNode * node)
   if (type_name == "spin") {
     SG_LOG(SG_INPUT, SG_INFO, "Reading spin animation");
     animation.type = Animation::Spin;
+  } else if (type_name == "rotate") {
+    SG_LOG(SG_INPUT, SG_INFO, "Reading rotate animation");
+    animation.type = Animation::Rotate;
+  } else if (type_name == "none") {
+    SG_LOG(SG_INPUT, SG_INFO, "Reading disabled animation");
+    animation.type = Animation::None;
+    return animation;
   } else {
     animation.type = Animation::None;
     SG_LOG(SG_INPUT, SG_ALERT, "Unknown animation type " << type_name);
@@ -213,6 +220,9 @@ FGAircraftModel::read_animation (const SGPropertyNode * node)
   animation.prop =
     fgGetNode(node->getStringValue("property", "/null"), true);
 
+  animation.position = node->getFloatValue("initial-position", 0);
+  animation.factor = node->getFloatValue("factor", 1);
+
                                // Get the center and axis
   animation.center_x = node->getFloatValue("center/x-m", 0);
   animation.center_y = node->getFloatValue("center/y-m", 0);
@@ -231,7 +241,8 @@ FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
   case Animation::None:
     return;
   case Animation::Spin: {
-    float velocity_rpms = animation.prop->getDoubleValue() / 60000.0;
+    float velocity_rpms = animation.prop->getDoubleValue()
+      * animation.factor / 60000.0;
     animation.position += (elapsed_ms * velocity_rpms * 360);
     while (animation.position >= 360)
       animation.position -= 360;
@@ -248,6 +259,21 @@ FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
     animation.transform->setTransform(animation.matrix);
     return;
   }
+  case Animation::Rotate: {
+    animation.position = animation.prop->getFloatValue() * animation.factor;
+    sgMakeTransMat4(animation.matrix, -animation.center_x,
+                   -animation.center_y, -animation.center_z);
+    sgVec3 axis;
+    sgSetVec3(axis, animation.axis_x, animation.axis_y, animation.axis_z);
+    sgMat4 tmp;
+    sgMakeRotMat4(tmp, animation.position, axis);
+    sgPostMultMat4(animation.matrix, tmp);
+    sgMakeTransMat4(tmp, animation.center_x,
+                   animation.center_y, animation.center_z);
+    sgPostMultMat4(animation.matrix, tmp);
+    animation.transform->setTransform(animation.matrix);
+    return;
+  }
   default:
     return;
   }
index c68bcc75d56fa151e091173b8ea8c2401ecf8184..651462a3e6bfd6c8826381802d44e51073c8e792 100644 (file)
@@ -38,13 +38,15 @@ private:
   {
     enum Type {
       None,
-      Spin
+      Spin,
+      Rotate
     };
     string name;
     Type type;
     ssgTransform * transform;
     sgMat4 matrix;
     SGPropertyNode * prop;
+    float factor;
     float position;
     float center_x;
     float center_y;