]> git.mxchange.org Git - flightgear.git/commitdiff
Correct offset-deg in a rotate animation so that it is added after the
authordavid <david>
Wed, 13 Nov 2002 16:45:21 +0000 (16:45 +0000)
committerdavid <david>
Wed, 13 Nov 2002 16:45:21 +0000 (16:45 +0000)
factor (otherwise, it's not in degrees).

Allow 2D panel inclusions to be named (and further animated).

src/Model/model.cxx

index 895923bf9648da906cd103a856d84e40c10876d9..fd1ea0095558d402a4c27d7e0e9f2c744e6bed0c 100644 (file)
@@ -179,7 +179,7 @@ make_animation (ssgBranch * model,
                 SGPropertyNode_ptr node)
 {
   Animation * animation = 0;
-  const char * type = node->getStringValue("type");
+  const char * type = node->getStringValue("type", "none");
   if (!strcmp("none", type)) {
     animation = new NullAnimation(node);
   } else if (!strcmp("range", type)) {
@@ -295,9 +295,19 @@ fgLoad3DModel (const string &path)
                       props.getFloatValue("/offsets/z-m", 0.0));
   align->setTransform(res_matrix);
 
+                                // Load panels
+  unsigned int i;
+  vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
+  for (i = 0; i < panel_nodes.size(); i++) {
+    SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
+    FGPanelNode * panel = new FGPanelNode(panel_nodes[i]);
+    if (panel_nodes[i]->hasValue("name"))
+        panel->setName((char *)panel_nodes[i]->getStringValue("name"));
+    model->addKid(panel);
+  }
+
                                 // Load animations
   vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
-  unsigned int i;
   for (i = 0; i < animation_nodes.size(); i++) {
     const char * name = animation_nodes[i]->getStringValue("name", 0);
     vector<SGPropertyNode_ptr> name_nodes =
@@ -305,14 +315,6 @@ fgLoad3DModel (const string &path)
     make_animation(model, name, name_nodes, animation_nodes[i]);
   }
 
-                                // Load panels
-  vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
-  for (i = 0; i < panel_nodes.size(); i++) {
-    printf("Reading a panel in model.cxx\n");
-    FGPanelNode * panel = new FGPanelNode(panel_nodes[i]);
-    model->addKid(panel);
-  }
-
                                 // Load sub-models
   vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
   for (i = 0; i < model_nodes.size(); i++) {
@@ -550,7 +552,7 @@ void
 RotateAnimation::update ()
 {
   if (_table == 0) {
-    _position_deg = (_prop->getDoubleValue() + _offset_deg) * _factor;
+   _position_deg = _prop->getDoubleValue() * _factor + _offset_deg;
    if (_has_min && _position_deg < _min_deg)
      _position_deg = _min_deg;
    if (_has_max && _position_deg > _max_deg)