#ifndef SG_PROPERTY_INTERPOLATION_MGR_HXX_
#define SG_PROPERTY_INTERPOLATION_MGR_HXX_
+#include "PropertyInterpolator.hxx"
+
+#include <simgear/math/sg_types.hxx>
+#include <simgear/misc/make_new.hxx>
+#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
-#include <simgear/props/PropertyInterpolator.hxx>
#include <list>
public SGSubsystem
{
public:
- typedef PropertyInterpolator*
- (*InterpolatorFactory)(const SGPropertyNode* target);
+ typedef PropertyInterpolator* (*InterpolatorFactory)();
PropertyInterpolationMgr();
* @param duration Duration if the animation (in seconds)
* @param easing Type of easing ("linear", "swing", etc.)
*/
- PropertyInterpolatorRef
+ PropertyInterpolator*
createInterpolator( const std::string& type,
- const SGPropertyNode* target,
- double duration = 1.0,
- const std::string& easing = "swing" );
+ const SGPropertyNode& target,
+ double duration,
+ const std::string& easing );
/**
- * Add animation of the given property from current its current value to
- * the target value of the interpolator.
+ * Add animation of the given property from its current value to the
+ * target value of the interpolator. If no interpolator is given any
+ * existing animation of the given property is aborted.
*
* @param prop Property to be interpolated
* @param interp Interpolator used for interpolation
*/
- void interpolate( SGPropertyNode* prop,
- PropertyInterpolatorRef interp );
+ bool interpolate( SGPropertyNode* prop,
+ PropertyInterpolatorRef interp = 0 );
+
+ bool interpolate( SGPropertyNode* prop,
+ const std::string& type,
+ const SGPropertyNode& target,
+ double duration,
+ const std::string& easing );
+
+ bool interpolate( SGPropertyNode* prop,
+ const std::string& type,
+ const PropertyList& values,
+ const double_list& deltas,
+ const std::string& easing );
/**
* Register factory for interpolation type.
template<class T>
void addInterpolatorFactory(const std::string& type)
{
- addInterpolatorFactory(type, &PropertyInterpolator::create<T>);
+ addInterpolatorFactory
+ (
+ type,
+ &simgear::make_new_derived<PropertyInterpolator, T>
+ );
}
/**
*/
void addEasingFunction(const std::string& type, easing_func_t func);
+ /**
+ * Set property containing real time delta (not sim time)
+ *
+ * TODO better pass both deltas to all update methods...
+ */
+ void setRealtimeProperty(SGPropertyNode* node);
+
protected:
typedef std::map<std::string, InterpolatorFactory> InterpolatorFactoryMap;
InterpolatorFactoryMap _interpolator_factories;
EasingFunctionMap _easing_functions;
InterpolatorList _interpolators;
+
+ SGPropertyNode_ptr _rt_prop;
};
} // namespace simgear