+
// animation.hxx - classes to manage model animation.
// Written by David Megginson, started 2002.
//
// Don't pull in the headers, since we don't need them here.
class SGInterpTable;
-class FGCondition;
+class SGCondition;
// Has anyone done anything *really* stupid, like making min and max macros?
/**
* Abstract base class for all animations.
*/
-class Animation : public ssgBase
+class SGAnimation : public ssgBase
{
public:
- Animation (SGPropertyNode_ptr props, ssgBranch * branch);
+ SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch);
- virtual ~Animation ();
+ virtual ~SGAnimation ();
/**
* Get the SSG branch holding the animation.
/**
* A no-op animation.
*/
-class NullAnimation : public Animation
+class SGNullAnimation : public SGAnimation
{
public:
- NullAnimation (SGPropertyNode_ptr props);
- virtual ~NullAnimation ();
+ SGNullAnimation (SGPropertyNode_ptr props);
+ virtual ~SGNullAnimation ();
};
/**
* A range, or level-of-detail (LOD) animation.
*/
-class RangeAnimation : public Animation
+class SGRangeAnimation : public SGAnimation
{
public:
- RangeAnimation (SGPropertyNode_ptr props);
- virtual ~RangeAnimation ();
+ SGRangeAnimation (SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props);
+ virtual ~SGRangeAnimation ();
+ virtual void update();
+private:
+ SGPropertyNode_ptr _min_prop;
+ SGPropertyNode_ptr _max_prop;
+ float _min;
+ float _max;
+ float _min_factor;
+ float _max_factor;
};
/**
* Animation to turn and face the screen.
*/
-class BillboardAnimation : public Animation
+class SGBillboardAnimation : public SGAnimation
{
public:
- BillboardAnimation (SGPropertyNode_ptr props);
- virtual ~BillboardAnimation ();
+ SGBillboardAnimation (SGPropertyNode_ptr props);
+ virtual ~SGBillboardAnimation ();
};
/**
* Animation to select alternative versions of the same object.
*/
-class SelectAnimation : public Animation
+class SGSelectAnimation : public SGAnimation
{
public:
- SelectAnimation( SGPropertyNode *prop_root,
+ SGSelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
- virtual ~SelectAnimation ();
+ virtual ~SGSelectAnimation ();
virtual void update();
private:
- FGCondition * _condition;
+ SGCondition * _condition;
};
*
* This animation rotates at a specific velocity.
*/
-class SpinAnimation : public Animation
+class SGSpinAnimation : public SGAnimation
{
public:
- SpinAnimation( SGPropertyNode *prop_root,
+ SGSpinAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props,
double sim_time_sec );
- virtual ~SpinAnimation ();
+ virtual ~SGSpinAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
/**
* Animation to draw objects for a specific amount of time each.
*/
-class TimedAnimation : public Animation
+class SGTimedAnimation : public SGAnimation
{
public:
- TimedAnimation (SGPropertyNode_ptr props);
- virtual ~TimedAnimation ();
+ SGTimedAnimation (SGPropertyNode_ptr props);
+ virtual ~SGTimedAnimation ();
virtual void update();
private:
double _duration_sec;
*
* This animation rotates to a specific position.
*/
-class RotateAnimation : public Animation
+class SGRotateAnimation : public SGAnimation
{
public:
- RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
- virtual ~RotateAnimation ();
+ SGRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
+ virtual ~SGRotateAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
/**
* Animation to slide along an axis.
*/
-class TranslateAnimation : public Animation
+class SGTranslateAnimation : public SGAnimation
{
public:
- TranslateAnimation( SGPropertyNode *prop_root,
+ SGTranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
- virtual ~TranslateAnimation ();
+ virtual ~SGTranslateAnimation ();
virtual void update();
private:
SGPropertyNode_ptr _prop;
sgVec3 _axis;
};
+/**
+ * Animation to blend an object.
+ */
+class SGBlendAnimation : public SGAnimation
+{
+public:
+ SGBlendAnimation( SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props );
+ virtual ~SGBlendAnimation ();
+ virtual void update();
+private:
+ SGPropertyNode_ptr _prop;
+ SGInterpTable * _table;
+ double _prev_value;
+ double _offset;
+ double _factor;
+ bool _has_min;
+ double _min;
+ bool _has_max;
+ double _max;
+};
+
+/**
+ * Animation to scale an object.
+ */
+class SGScaleAnimation : public SGAnimation
+{
+public:
+ SGScaleAnimation( SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props );
+ virtual ~SGScaleAnimation ();
+ virtual void update();
+private:
+ SGPropertyNode_ptr _prop;
+ double _x_factor;
+ double _y_factor;
+ double _z_factor;
+ double _x_offset;
+ double _y_offset;
+ double _z_offset;
+ SGInterpTable * _table;
+ bool _has_min_x;
+ bool _has_min_y;
+ bool _has_min_z;
+ double _min_x;
+ double _min_y;
+ double _min_z;
+ bool _has_max_x;
+ bool _has_max_y;
+ bool _has_max_z;
+ double _max_x;
+ double _max_y;
+ double _max_z;
+ double _x_scale;
+ double _y_scale;
+ double _z_scale;
+ sgMat4 _matrix;
+};
+
+/**
+ * Animation to rotate texture mappings around a center point.
+ *
+ * This animation rotates to a specific position.
+ */
+class SGTexRotateAnimation : public SGAnimation
+{
+public:
+ SGTexRotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props );
+ virtual ~SGTexRotateAnimation ();
+ virtual void update();
+private:
+ SGPropertyNode_ptr _prop;
+ double _offset_deg;
+ double _factor;
+ SGInterpTable * _table;
+ bool _has_min;
+ double _min_deg;
+ bool _has_max;
+ double _max_deg;
+ double _position_deg;
+ sgMat4 _matrix;
+ sgVec3 _center;
+ sgVec3 _axis;
+};
+
+
+/**
+ * Animation to slide texture mappings along an axis.
+ */
+class SGTexTranslateAnimation : public SGAnimation
+{
+public:
+ SGTexTranslateAnimation( SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props );
+ virtual ~SGTexTranslateAnimation ();
+ virtual void update();
+private:
+ SGPropertyNode_ptr _prop;
+ double _offset;
+ double _factor;
+ double _step;
+ double _scroll;
+ SGInterpTable * _table;
+ bool _has_min;
+ double _min;
+ bool _has_max;
+ double _max;
+ double _position;
+ sgMat4 _matrix;
+ sgVec3 _axis;
+};
+
+
+
+/**
+ * Classes for handling multiple types of Texture translations on one object
+ */
+
+class SGTexMultipleAnimation : public SGAnimation
+{
+public:
+ SGTexMultipleAnimation( SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props );
+ virtual ~SGTexMultipleAnimation ();
+ virtual void update();
+private:
+ class TexTransform
+ {
+ public:
+ SGPropertyNode_ptr prop;
+ int subtype; // 0=translation, 1=rotation
+ double offset;
+ double factor;
+ double step;
+ double scroll;
+ SGInterpTable * table;
+ bool has_min;
+ double min;
+ bool has_max;
+ double max;
+ double position;
+ sgMat4 matrix;
+ sgVec3 center;
+ sgVec3 axis;
+ };
+ SGPropertyNode_ptr _prop;
+ TexTransform* _transform;
+ int _num_transforms;
+};
+
+
+/**
+ * An animation to enable the alpha test
+ */
+class SGAlphaTestAnimation : public SGAnimation
+{
+public:
+ SGAlphaTestAnimation (SGPropertyNode *prop_root,
+ SGPropertyNode_ptr props);
+ virtual ~SGAlphaTestAnimation ();
+ virtual void update();
+private:
+ void setAlphaClampToBranch(ssgBranch *b, float clamp);
+ bool _done;
+ float _alpha_clamp;
+};
+
#endif // _SG_ANIMATION_HXX