diff -Naurw Irrlicht/CSceneManager.cpp Irrlicht/CSceneManager.cpp --- Irrlicht/CSceneManager.cpp 2005-09-27 15:50:08.000000000 +0200 +++ Irrlicht/CSceneManager.cpp 2005-10-27 17:00:52.000000000 +0200 @@ -832,9 +832,9 @@ //! Creates a fly straight animator, which lets the attached scene node //! fly or move along a line between two points. ISceneNodeAnimatorFlyStraight* CSceneManager::createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop) + const core::vector3df& endPoint, u32 timeForWay, bool loop, bool animateToStartOnLoop ) { - return new CSceneNodeAnimatorFlyStraight(startPoint, endPoint, timeForWay, loop, os::Timer::getTime()); + return new CSceneNodeAnimatorFlyStraight(startPoint, endPoint, timeForWay, loop, animateToStartOnLoop, os::Timer::getTime()); } diff -Naurw Irrlicht/CSceneManager.h Irrlicht/CSceneManager.h --- Irrlicht/CSceneManager.h 2005-09-27 15:46:54.000000000 +0200 +++ Irrlicht/CSceneManager.h 2005-11-23 23:23:16.000000000 +0100 @@ -245,7 +259,7 @@ //! Creates a fly straight animator, which lets the attached scene node //! fly or move along a line between two points. virtual ISceneNodeAnimatorFlyStraight* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false); + const core::vector3df& endPoint, u32 timeForWay, bool loop=false, bool animateToStartOnLoop=true); //! Creates a texture animator, which switches the textures of the target scene //! node based on a list of textures. diff -Naurw Irrlicht/CSceneNodeAnimatorFlyStraight.cpp Irrlicht/CSceneNodeAnimatorFlyStraight.cpp --- Irrlicht/CSceneNodeAnimatorFlyStraight.cpp 2005-08-20 22:17:52.000000000 +0200 +++ Irrlicht/CSceneNodeAnimatorFlyStraight.cpp 2005-10-03 15:07:08.000000000 +0200 @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h #include "CSceneNodeAnimatorFlyStraight.h" +#include "os.h" namespace irr { @@ -13,8 +14,9 @@ //! constructor CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, const core::vector3df& endPoint, u32 timeForWay, - bool loop, u32 now) -: Start(startPoint), End(endPoint), StartTime(now), TimeForWay(timeForWay), Loop(loop) + bool loop, bool animateToStartOnLoop, u32 now) +: Start(startPoint), End(endPoint), StartTime(now), TimeForWay(timeForWay), Loop(loop), CallbacksCalled(false) +, AnimateToStartOnLoop( animateToStartOnLoop ), Direction(1), FirstTime(true) { #ifdef _DEBUG setDebugName("CSceneNodeAnimatorFlyStraight"); @@ -44,18 +46,74 @@ if (!node) return; - u32 t = (timeMs-StartTime); + if( FirstTime ) + { + StartTime = timeMs; + LastTime = timeMs; + node->setPosition( Start ); + FirstTime = false; + return; + } + + if( LastTime - StartTime >= TimeForWay ) + { + if( Loop ) + { + // In loop mode, we call the callbacks, everytime half the loop is finished, otherwise, if the + // node has been animated from the start to the end, or when it gets back to the start from the end + for( u32 i=0; isetPosition( Start ); + } + } + else + { + if( !CallbacksCalled ) + { + for( u32 i=0; isetPosition( End ); + CallbacksCalled = true; + } + } + } + else + { + u32 delta = (timeMs - LastTime); + core::vector3df pos = node->getPosition(); - if (!Loop && t >= TimeForWay) - pos = End; + if( Direction > 0 ) + { + //pos += Vector * (f32)fmod((f32)t, (f32)TimeForWay) * TimeFactor; + pos += Vector * ( delta * TimeFactor ); + } else - pos += Vector * (f32)fmod((f32)t, (f32)TimeForWay) * TimeFactor; + { + //pos -= Vector * (f32)fmod((f32)t, (f32)TimeForWay) * TimeFactor; + pos -= Vector * ( delta * TimeFactor ); + } node->setPosition(pos); + LastTime = timeMs; + } } - } // end namespace scene diff -Naurw Irrlicht/CSceneNodeAnimatorFlyStraight.h Irrlicht/CSceneNodeAnimatorFlyStraight.h --- Irrlicht/CSceneNodeAnimatorFlyStraight.h 2005-09-27 15:57:32.000000000 +0200 +++ Irrlicht/CSceneNodeAnimatorFlyStraight.h 2005-10-03 15:06:12.000000000 +0200 @@ -19,7 +19,7 @@ //! constructor CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, const core::vector3df& endPoint, u32 timeForWay, - bool loop, u32 now); + bool loop, bool animateToStartOnLoop, u32 now); //! destructor virtual ~CSceneNodeAnimatorFlyStraight(); @@ -91,7 +91,13 @@ u32 StartTime; u32 EndTime; u32 TimeForWay; + u32 LastTime; bool Loop; + bool AnimateToStartOnLoop; + bool FirstTime; + c8 Direction; + + bool CallbacksCalled; }; diff -Naurw Irrlicht/include/ISceneManager.h Irrlicht/include/ISceneManager.h --- Irrlicht/include/ISceneManager.h 2005-09-27 15:46:10.000000000 +0200 +++ Irrlicht/include/ISceneManager.h 2005-11-23 23:22:50.000000000 +0100 @@ -843,7 +901,7 @@ If you no longer need the animator, you should call ISceneNodeAnimator::drop(). See IUnknown::drop() for more information. */ virtual ISceneNodeAnimatorFlyStraight* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false) = 0; + const core::vector3df& endPoint, u32 timeForWay, bool loop=false, bool animateToStartOnLoop=true ) = 0; //! Creates a texture animator, which switches the textures of the target scene node based on a list of textures. /** \param textures: List of textures to use.