]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/animation.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / model / animation.hxx
index 7828dbc320210daa9d0f65365b1e7903c9c3d359..048d991f513a9ce31b0e341b48d673f59d5c9511 100644 (file)
 # error This library requires C++
 #endif
 
-#include <vector>
-#include <map>
-
-#include <osg/Vec3>
-#include <osg/Vec4>
-
 #include <osg/ref_ptr>
-#include <osg/AlphaFunc>
 #include <osg/Group>
-#include <osg/Material>
 #include <osg/Node>
-#include <osg/NodeCallback>
 #include <osg/NodeVisitor>
-#include <osg/StateSet>
 #include <osg/Texture2D>
-#include <osg/TexMat>
-
-#include <simgear/props/props.hxx>
-#include <simgear/misc/sg_path.hxx>
+#include <osgDB/ReaderWriter>
 
-#include <simgear/math/interpolater.hxx>
-#include <simgear/scene/model/persparam.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
-
-
-SG_USING_STD(vector);
-SG_USING_STD(map);
-
-// Don't pull in the headers, since we don't need them here.
-class SGInterpTable;
-class SGCondition;
+#include <simgear/props/props.hxx>
+#include <simgear/props/condition.hxx>
+#include <simgear/structure/SGExpression.hxx>
 
 // Has anyone done anything *really* stupid, like making min and max macros?
 #ifdef min
@@ -51,30 +31,24 @@ class SGCondition;
 #undef max
 #endif
 
+SGExpressiond*
+read_value(const SGPropertyNode* configNode, SGPropertyNode* modelRoot,
+           const char* unit, double defMin, double defMax);
 
-\f
-//////////////////////////////////////////////////////////////////////
-// Helper classes, FIXME: factor out
-//////////////////////////////////////////////////////////////////////
-
-class SGDoubleValue : public SGReferenced {
-public:
-  virtual ~SGDoubleValue() {}
-  virtual double getValue() const = 0;
-};
-
-\f
-//////////////////////////////////////////////////////////////////////
-// Base class for animation installers
-//////////////////////////////////////////////////////////////////////
+SGVec3d readTranslateAxis(const SGPropertyNode* configNode);
 
+/**
+ * Base class for animation installers
+ */
 class SGAnimation : protected osg::NodeVisitor {
 public:
   SGAnimation(const SGPropertyNode* configNode, SGPropertyNode* modelRoot);
   virtual ~SGAnimation();
 
   static bool animate(osg::Node* node, const SGPropertyNode* configNode,
-                      SGPropertyNode* modelRoot);
+                      SGPropertyNode* modelRoot,
+                      const osgDB::Options* options,
+                      const std::string &path, int i);
 
 protected:
   void apply(osg::Node* node);
@@ -84,6 +58,23 @@ protected:
 
   virtual void apply(osg::Group& group);
 
+  /**
+   * Read a 3d vector from the configuration property node.
+   *
+   * Reads values from @a name/[xyz]@a prefix and defaults to the according
+   * value of @a def for each value which is not set.
+   *
+   * @param name    Name of the root node containing all coordinates
+   * @param suffix  Suffix appended to each child node (x,y,z)
+   * @param def     Vector containing default values
+   */
+  SGVec3d readVec3( const std::string& name,
+                    const std::string& suffix = "",
+                    const SGVec3d& def = SGVec3d::zeros() ) const;
+  void readRotationCenterAndAxis(SGVec3d& center, SGVec3d& axis) const;
+
+  SGExpressiond* readOffsetValue(const char* tag_name) const;
+
   void removeMode(osg::Node& node, osg::StateAttribute::GLMode mode);
   void removeAttribute(osg::Node& node, osg::StateAttribute::Type type);
   void removeTextureMode(osg::Node& node, unsigned unit,
@@ -103,6 +94,7 @@ protected:
 
   const SGCondition* getCondition() const;
 
+  std::list<std::string> _objectNames;
 private:
   void installInGroup(const std::string& name, osg::Group& group,
                       osg::ref_ptr<osg::Group>& animationGroup);
@@ -118,13 +110,12 @@ private:
   std::string _name;
   SGSharedPtr<SGPropertyNode const> _configNode;
   SGPropertyNode* _modelRoot;
-  std::list<std::string> _objectNames;
+  
   std::list<osg::ref_ptr<osg::Node> > _installedAnimations;
   bool _enableHOT;
-  bool _disableShadow;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Null animation installer
 //////////////////////////////////////////////////////////////////////
@@ -135,7 +126,7 @@ public:
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Translate animation installer
 //////////////////////////////////////////////////////////////////////
@@ -147,14 +138,13 @@ public:
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
 private:
   class UpdateCallback;
-  class Transform;
   SGSharedPtr<const SGCondition> _condition;
-  SGSharedPtr<const SGDoubleValue> _animationValue;
+  SGSharedPtr<const SGExpressiond> _animationValue;
   SGVec3d _axis;
   double _initialValue;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Rotate/Spin animation installer
 //////////////////////////////////////////////////////////////////////
@@ -165,18 +155,15 @@ public:
                     SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
 private:
-  class UpdateCallback;
-  class SpinUpdateCallback;
-  class Transform;
   SGSharedPtr<const SGCondition> _condition;
-  SGSharedPtr<const SGDoubleValue> _animationValue;
+  SGSharedPtr<const SGExpressiond> _animationValue;
   SGVec3d _axis;
   SGVec3d _center;
   double _initialValue;
   bool _isSpin;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Scale animation installer
 //////////////////////////////////////////////////////////////////////
@@ -188,14 +175,13 @@ public:
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
 private:
   class UpdateCallback;
-  class Transform;
   SGSharedPtr<const SGCondition> _condition;
-  SGSharedPtr<const SGDoubleValue> _animationValue[3];
+  SGSharedPtr<const SGExpressiond> _animationValue[3];
   SGVec3d _initialValue;
   SGVec3d _center;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // dist scale animation installer
 //////////////////////////////////////////////////////////////////////
@@ -205,11 +191,10 @@ public:
   SGDistScaleAnimation(const SGPropertyNode* configNode,
                        SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
   class Transform;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // dist scale animation installer
 //////////////////////////////////////////////////////////////////////
@@ -219,11 +204,11 @@ public:
   SGFlashAnimation(const SGPropertyNode* configNode,
                    SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
+public:
   class Transform;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // dist scale animation installer
 //////////////////////////////////////////////////////////////////////
@@ -233,11 +218,10 @@ public:
   SGBillboardAnimation(const SGPropertyNode* configNode,
                        SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
   class Transform;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Range animation installer
 //////////////////////////////////////////////////////////////////////
@@ -250,12 +234,12 @@ public:
 private:
   class UpdateCallback;
   SGSharedPtr<const SGCondition> _condition;
-  SGSharedPtr<const SGDoubleValue> _minAnimationValue;
-  SGSharedPtr<const SGDoubleValue> _maxAnimationValue;
+  SGSharedPtr<const SGExpressiond> _minAnimationValue;
+  SGSharedPtr<const SGExpressiond> _maxAnimationValue;
   SGVec2d _initialValue;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Select animation installer
 //////////////////////////////////////////////////////////////////////
@@ -265,11 +249,9 @@ public:
   SGSelectAnimation(const SGPropertyNode* configNode,
                     SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
-  class UpdateCallback;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Alpha test animation installer
 //////////////////////////////////////////////////////////////////////
@@ -281,7 +263,7 @@ public:
   virtual void install(osg::Node& node);
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Blend animation installer
 //////////////////////////////////////////////////////////////////////
@@ -295,10 +277,10 @@ public:
 private:
   class BlendVisitor;
   class UpdateCallback;
-  SGSharedPtr<SGDoubleValue> _animationValue;
+  SGSharedPtr<SGExpressiond> _animationValue;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Timed animation installer
 //////////////////////////////////////////////////////////////////////
@@ -312,7 +294,7 @@ private:
   class UpdateCallback;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Shadow animation installer
 //////////////////////////////////////////////////////////////////////
@@ -326,7 +308,7 @@ private:
   class UpdateCallback;
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // TextureTransform animation
 //////////////////////////////////////////////////////////////////////
@@ -347,7 +329,7 @@ private:
                        UpdateCallback* updateCallback);
 };
 
-\f
+
 //////////////////////////////////////////////////////////////////////
 // Shader animation
 //////////////////////////////////////////////////////////////////////
@@ -355,24 +337,43 @@ private:
 class SGShaderAnimation : public SGAnimation {
 public:
   SGShaderAnimation(const SGPropertyNode* configNode,
-                    SGPropertyNode* modelRoot);
+                    SGPropertyNode* modelRoot,
+                    const osgDB::Options* options);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
 private:
   class UpdateCallback;
+  osg::ref_ptr<osg::Texture2D> _effect_texture;
 };
 
-\f
 //////////////////////////////////////////////////////////////////////
-// Pick animation
+// Light animation
 //////////////////////////////////////////////////////////////////////
 
-class SGPickAnimation : public SGAnimation {
+class SGLightAnimation : public SGAnimation {
 public:
-  SGPickAnimation(const SGPropertyNode* configNode,
-                  SGPropertyNode* modelRoot);
+  SGLightAnimation(const SGPropertyNode* configNode,
+                   SGPropertyNode* modelRoot,
+                   const osgDB::Options* options,
+                   const std::string &path, int i);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
+  virtual void install(osg::Node& node);
 private:
-  class PickCallback;
+  std::string _light_type;
+  SGVec3d _position;
+  SGVec3d _direction;
+  SGVec4d _ambient;
+  SGVec4d _diffuse;
+  SGVec4d _specular;
+  SGVec3d _attenuation;
+  double _exponent;
+  double _cutoff;
+  double _near;
+  double _far;
+  std::string _key;
+  class UpdateCallback;
+  friend class UpdateCallback;
+  SGSharedPtr<SGExpressiond> _animationValue;
+  osg::ref_ptr<const osgDB::Options> _options;
 };
 
 #endif // _SG_ANIMATION_HXX