Separate the UVController function out and make it generic

Also fix a timing bug in it.
actorid
Chris Robinson 12 years ago
parent 6b151be3f4
commit ca289a317c

@ -66,6 +66,36 @@ namespace NifOgre
{
// FIXME: Should not be here.
class DefaultFunction : public Ogre::ControllerFunction<Ogre::Real>
{
private:
float mFrequency;
float mPhase;
float mStartTime;
float mStopTime;
public:
DefaultFunction(const Nif::Controller *ctrl)
: Ogre::ControllerFunction<Ogre::Real>(false)
, mFrequency(ctrl->frequency)
, mPhase(ctrl->phase)
, mStartTime(ctrl->timeStart)
, mStopTime(ctrl->timeStop)
{
mDeltaCount = mPhase;
while(mDeltaCount < mStartTime)
mDeltaCount += (mStopTime-mStartTime);
}
virtual Ogre::Real calculate(Ogre::Real value)
{
mDeltaCount += value*mFrequency;
mDeltaCount = std::fmod(mDeltaCount - mStartTime,
mStopTime - mStartTime) + mStartTime;
return mDeltaCount;
}
};
class VisController
{
public:
@ -208,35 +238,7 @@ public:
}
};
class Function : public Ogre::ControllerFunction<Ogre::Real>
{
private:
float mFrequency;
float mPhase;
float mStartTime;
float mStopTime;
public:
Function(const Nif::NiUVController *ctrl)
: Ogre::ControllerFunction<Ogre::Real>(false)
, mFrequency(ctrl->frequency)
, mPhase(ctrl->phase)
, mStartTime(ctrl->timeStart)
, mStopTime(ctrl->timeStop)
{
mDeltaCount = mPhase;
while(mDeltaCount < mStartTime)
mDeltaCount += (mStopTime-mStartTime);
}
virtual Ogre::Real calculate(Ogre::Real value)
{
mDeltaCount += value;
mDeltaCount = std::fmod(mDeltaCount+(value*mFrequency) - mStartTime,
mStopTime - mStartTime) + mStartTime;
return mDeltaCount;
}
};
typedef DefaultFunction Function;
};

Loading…
Cancel
Save