]> git.mxchange.org Git - simgear.git/commitdiff
Add <expression> to animations
authorTorsten Dreyer <Torsten@t3r.de>
Fri, 7 Jan 2011 21:43:46 +0000 (22:43 +0100)
committerTorsten Dreyer <Torsten@t3r.de>
Fri, 7 Jan 2011 21:43:46 +0000 (22:43 +0100)
Allow complex animation expressions

Example: translate along the y-axis following a sin
function.
<animation>
  <type>translate</type>
  <axis>
    <y>1</y>
  </axis>
  <expression>
    <sin>
      <product>
        <property>/some/position-norm</property>
        <value>6.28</value>
      </product>
    </sin>
  </expression>
</animation>

simgear/scene/model/animation.cxx

index a6734c1e6c35af922a67c9b688270bb0136fba46..dae46ea283f2ff8947aad812f0cd7095685900ea 100644 (file)
@@ -206,6 +206,10 @@ SGExpressiond*
 read_value(const SGPropertyNode* configNode, SGPropertyNode* modelRoot,
            const char* unit, double defMin, double defMax)
 {
+  const SGPropertyNode * expression = configNode->getNode( "expression" );
+  if( expression != NULL )
+    return SGReadDoubleExpression( modelRoot, expression->getChild(0) );
+
   SGExpression<double>* value = 0;
 
   std::string inputPropertyName = configNode->getStringValue("property", "");