Add an optional startPosition parameter to createFlyCircleAnimator() to allow specifying a start position on the circle. New unit test added. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2105 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7c6f04fdc5
commit
e464ba11f4
|
@ -1,5 +1,7 @@
|
|||
Changes in version 1.6
|
||||
|
||||
- Added an startPosition parameter to createFlyCircleAnimator() to allow starting the animator at any position on the circle.
|
||||
|
||||
- Many uses of dimension2d<s32> changed to dimension2d<u32>, including IImage, ITexture and screen dimensions. You will have to change (at least) createDevice() calls to use dimension2d<u32>
|
||||
|
||||
- Added IFileSystem::createMemoryWriteFile() to allow creation of an IWriteFile interface that uses an application supplied memory buffer.
|
||||
|
|
|
@ -1039,6 +1039,8 @@ namespace scene
|
|||
\param radius: Radius of the circle.
|
||||
\param speed: The orbital speed, in radians per millisecond.
|
||||
\param direction: Specifies the upvector used for alignment of the mesh.
|
||||
\param startPosition: The position on the circle where the animator will
|
||||
begin. Value is in multiples of a circle, i.e. 0.5 is half way around.
|
||||
\return The animator. Attach it to a scene node with ISceneNode::addAnimator()
|
||||
and the animator will animate it.
|
||||
If you no longer need the animator, you should call ISceneNodeAnimator::drop().
|
||||
|
@ -1046,7 +1048,8 @@ namespace scene
|
|||
virtual ISceneNodeAnimator* createFlyCircleAnimator(
|
||||
const core::vector3df& center=core::vector3df(0.f,0.f,0.f),
|
||||
f32 radius=100.f, f32 speed=0.001f,
|
||||
const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f)) = 0;
|
||||
const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f),
|
||||
f32 startPosition = 0.f) = 0;
|
||||
|
||||
//! Creates a fly straight animator, which lets the attached scene node fly or move along a line between two points.
|
||||
/** \param startPoint: Start point of the line.
|
||||
|
|
|
@ -1521,10 +1521,14 @@ ISceneNodeAnimator* CSceneManager::createRotationAnimator(const core::vector3df&
|
|||
//! creates a fly circle animator, which lets the attached scene node fly around a center.
|
||||
ISceneNodeAnimator* CSceneManager::createFlyCircleAnimator(
|
||||
const core::vector3df& center, f32 radius, f32 speed,
|
||||
const core::vector3df& direction)
|
||||
const core::vector3df& direction,
|
||||
f32 startPosition)
|
||||
{
|
||||
const f32 orbitDurationMs = (core::DEGTORAD * 360.f) / speed;
|
||||
u32 effectiveTime = os::Timer::getTime() + (u32)(orbitDurationMs * startPosition);
|
||||
|
||||
ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyCircle(
|
||||
os::Timer::getTime(), center,
|
||||
effectiveTime, center,
|
||||
radius, speed, direction);
|
||||
return anim;
|
||||
}
|
||||
|
|
|
@ -281,13 +281,17 @@ namespace scene
|
|||
//! creates a fly circle animator
|
||||
/** Lets the attached scene node fly around a center.
|
||||
\param center Center relative to node origin
|
||||
\param speed rotation speed
|
||||
\return Animator. Attach it to a scene node with ISceneNode::addAnimator()
|
||||
and the animator will animate it. */
|
||||
\param speed: The orbital speed, in radians per millisecond.
|
||||
\param direction: Specifies the upvector used for alignment of the mesh.
|
||||
\param startPosition: The position on the circle where the animator will
|
||||
begin. Value is in multiples of a circle, i.e. 0.5 is half way around.
|
||||
\return The animator. Attach it to a scene node with ISceneNode::addAnimator()
|
||||
*/
|
||||
virtual ISceneNodeAnimator* createFlyCircleAnimator(
|
||||
const core::vector3df& center=core::vector3df(0.f, 0.f, 0.f),
|
||||
f32 radius=100.f, f32 speed=0.001f,
|
||||
const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f));
|
||||
const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f),
|
||||
f32 startPosition = 0.f);
|
||||
|
||||
//! Creates a fly straight animator, which lets the attached scene node
|
||||
//! fly or move along a line between two points.
|
||||
|
|
|
@ -38,9 +38,15 @@ void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs)
|
|||
if ( 0 == node )
|
||||
return;
|
||||
|
||||
const f32 t = (timeMs-StartTime) * Speed;
|
||||
f32 time;
|
||||
|
||||
node->setPosition(Center + Radius * ((VecU*cosf(t)) + (VecV*sinf(t))));
|
||||
// Check for the condition where the StartTime is in the future.
|
||||
if(StartTime > timeMs)
|
||||
time = ((s32)timeMs - (s32)StartTime) * Speed;
|
||||
else
|
||||
time = (timeMs-StartTime) * Speed;
|
||||
|
||||
node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time))));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright (C) 2008-2009 Colin MacDonald
|
||||
// No rights reserved: this software is in the public domain.
|
||||
|
||||
#include "testUtils.h"
|
||||
#include "irrlicht.h"
|
||||
|
||||
using namespace irr;
|
||||
using namespace core;
|
||||
using namespace scene;
|
||||
using namespace video;
|
||||
|
||||
/** Tests the offset capability of the fly circle animator */
|
||||
bool flyCircleAnimator(void)
|
||||
{
|
||||
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
|
||||
core::dimension2du(160,120), 32);
|
||||
if (!device)
|
||||
return false;
|
||||
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
ISceneManager* smgr = device->getSceneManager();
|
||||
|
||||
const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f };
|
||||
|
||||
for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i)
|
||||
{
|
||||
IBillboardSceneNode * node = smgr->addBillboardSceneNode();
|
||||
// Have the animator rotate around the Z axis plane, rather than the default Y axis
|
||||
ISceneNodeAnimator * animator =
|
||||
smgr->createFlyCircleAnimator(vector3df(0, 0, 0), 30.f,
|
||||
0.001f, vector3df(0, 0, 1),
|
||||
(offsetDegrees[i] / 360.f));
|
||||
if(!node || !animator)
|
||||
return false;
|
||||
|
||||
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
|
||||
node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp"));
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
|
||||
node->addAnimator(animator);
|
||||
animator->drop();
|
||||
}
|
||||
|
||||
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0));
|
||||
|
||||
bool result = false;
|
||||
|
||||
// Don't do device->run() since I need the time to remain at 0.
|
||||
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
|
||||
{
|
||||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100);
|
||||
}
|
||||
|
||||
device->drop();
|
||||
|
||||
return result;
|
||||
}
|
|
@ -87,6 +87,7 @@ int main(int argumentCount, char * arguments[])
|
|||
TEST(sceneNodeAnimator);
|
||||
TEST(vectorPositionDimension2d);
|
||||
TEST(writeImageToFile);
|
||||
TEST(flyCircleAnimator);
|
||||
|
||||
const unsigned int numberOfTests = tests.size();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -1,2 +1,2 @@
|
|||
Test suite pass at GMT Mon Jan 19 13:42:16 2009
|
||||
Test suite pass at GMT Tue Jan 20 12:53:02 2009
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<Unit filename="drawRectOutline.cpp" />
|
||||
<Unit filename="exports.cpp" />
|
||||
<Unit filename="fast_atof.cpp" />
|
||||
<Unit filename="flyCircleAnimator.cpp" />
|
||||
<Unit filename="guiDisabledMenu.cpp" />
|
||||
<Unit filename="irrCoreEquals.cpp" />
|
||||
<Unit filename="line2dIntersectWith.cpp" />
|
||||
|
|
|
@ -205,6 +205,10 @@
|
|||
RelativePath=".\fast_atof.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\flyCircleAnimator.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\guiDisabledMenu.cpp"
|
||||
>
|
||||
|
|
|
@ -203,6 +203,10 @@
|
|||
RelativePath=".\fast_atof.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\flyCircleAnimator.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\guiDisabledMenu.cpp"
|
||||
>
|
||||
|
|
|
@ -40,7 +40,7 @@ bool testWithDriver(video::E_DRIVER_TYPE driverType)
|
|||
smgr->drawAll();
|
||||
driver->endScene();
|
||||
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAlphaChannelRef.png", 99.88);
|
||||
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAlphaChannelRef.png", 99.88f);
|
||||
|
||||
device->drop();
|
||||
|
||||
|
|
Loading…
Reference in New Issue