6 #ifdef COMPILE_PHANTOM_DEVICE
8 namespace vreckoDP_PHANToM {
13 class FadeForceFilter :
public PHANToMFilter {
15 FadeForceFilter(
const char* abName =
"FadeFilter");
17 virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *parameters);
18 virtual void postInitialize(
void);
20 virtual void apply(PHANToMSTATE &pState, osg::Vec3 &force, osg::Vec3 &torque);
24 double defaultFadeTimeInSecs;
25 bool bFadeInFromStart;
35 double fadeTimeInSecs;
36 osg::Timer_t fadeTimeInTicks;
37 osg::Timer_t fadeStart;
40 void startFade(
bool bFadeIn,
double newFadeTimeInSecs = -1);
45 inline float currentFadeFactor(osg::Timer_t currentTick) {
46 checkFadingForEnd(currentTick);
48 if (fadeState == Normal)
50 if (fadeState == Lowered)
53 if (fadeState == FadingIn)
54 return (
float)(currentTick - fadeStart) / (
float)fadeTimeInTicks;
57 return 1.0f - ((float)(currentTick - fadeStart) / (float)fadeTimeInTicks);
60 inline void checkFadingForEnd(osg::Timer_t currentTick) {
61 if ((fadeState == Normal) || (fadeState == Lowered))
64 if (currentTick > fadeStart + fadeTimeInTicks) {
66 if (fadeState == FadingIn)