]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/animation.cxx
- better error message when submodel loading failed
[simgear.git] / simgear / scene / model / animation.cxx
index a20df8d92df3e6d54a79015b3c0f48915f320e79..5dddc5bd23f567dacef0b97eefc44fd3a4c5f43a 100644 (file)
@@ -3,6 +3,9 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
 
 #include <string.h>             // for strcmp()
 #include <math.h>
@@ -179,7 +182,8 @@ double SGAnimation::sim_time_sec = 0.0;
 SGPersonalityBranch *SGAnimation::current_object = 0;
 
 SGAnimation::SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch)
-    : _branch(branch)
+    : _branch(branch),
+    animation_type(0)
 {
     _branch->setName(props->getStringValue("name", 0));
     if ( props->getBoolValue( "enable-hot", true ) ) {
@@ -771,7 +775,7 @@ SGTranslateAnimation::update()
 {
   if (_condition == 0 || _condition->test()) {
     if (_table == 0) {
-      _position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
+      _position_m = (_prop->getDoubleValue() * _factor) + _offset_m;
       if (_has_min && _position_m < _min_m)
         _position_m = _min_m;
       if (_has_max && _position_m > _max_m)
@@ -1119,6 +1123,7 @@ void SGAlphaTestAnimation::setAlphaClampToBranch(ssgBranch *b, float clamp)
 SGMaterialAnimation::SGMaterialAnimation( SGPropertyNode *prop_root,
         SGPropertyNode_ptr props, const SGPath &texture_path)
     : SGAnimation(props, new ssgBranch),
+    _last_condition(false),
     _prop_root(prop_root),
     _prop_base(""),
     _texture_base(texture_path),
@@ -1188,6 +1193,8 @@ SGMaterialAnimation::SGMaterialAnimation( SGPropertyNode *prop_root,
     _thresh_prop = n ? _prop_root->getNode(path(n->getStringValue()), true) : 0;
     n = props->getChild("texture-prop");
     _tex_prop = n ? _prop_root->getNode(path(n->getStringValue()), true) : 0;
+
+    _static_update = _update;
 }
 
 void SGMaterialAnimation::initColorGroup(SGPropertyNode_ptr group, ColorSpec *col, int flag)
@@ -1226,8 +1233,15 @@ void SGMaterialAnimation::init()
 
 int SGMaterialAnimation::update()
 {
-    if (_condition && !_condition->test())
-        return 2;
+    if (_condition) {
+        bool cond = _condition->test();
+        if (cond && !_last_condition)
+            _update |= _static_update;
+
+        _last_condition = cond;
+        if (!cond)
+            return 2;
+    }
 
     if (_read & DIFFUSE)
         updateColorGroup(&_diff, DIFFUSE);
@@ -1501,4 +1515,39 @@ void SGDistScaleAnimation::distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m )
   sgPreMultMat4( r, transform );
 }
 
+////////////////////////////////////////////////////////////////////////
+// Implementation of SGShadowAnimation
+////////////////////////////////////////////////////////////////////////
+
+SGShadowAnimation::SGShadowAnimation ( SGPropertyNode *prop_root,
+                   SGPropertyNode_ptr props )
+  : SGAnimation(props, new ssgBranch),
+    _condition(0),
+       _condition_value(true)
+{
+       animation_type = 1;
+       SGPropertyNode_ptr node = props->getChild("condition");
+       if (node != 0) {
+               _condition = sgReadCondition(prop_root, node);
+               _condition_value = false;
+       }
+}
+
+SGShadowAnimation::~SGShadowAnimation ()
+{
+       delete _condition;
+}
+
+int
+SGShadowAnimation::update()
+{
+       if (_condition)
+               _condition_value = _condition->test();
+       return 2;
+}
+
+bool SGShadowAnimation::get_condition_value(void) {
+       return _condition_value;
+}
+
 // end of animation.cxx