Well here is the patch:
Code: Select all
Index: include/ESceneNodeAnimatorTypes.h
===================================================================
--- include/ESceneNodeAnimatorTypes.h (revision 1344)
+++ include/ESceneNodeAnimatorTypes.h (working copy)
@@ -39,6 +39,9 @@
//! Maya camera animator
ESNAT_CAMERA_MAYA,
+
+ //! Scale animator
+ ESNAT_SCALE,
//! Amount of built-in scene node animators
ESNAT_COUNT,
Index: include/ISceneManager.h
===================================================================
--- include/ISceneManager.h (revision 1344)
+++ include/ISceneManager.h (working copy)
@@ -994,6 +994,14 @@
See IReferenceCounted::drop() for more information. */
virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond) = 0;
+ //! Creates a rotation animator, which rotates the attached scene node around itself.
+ /** \param rotationPerSecond: Specifies the speed of the animation
+ \return Returns 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().
+ See IReferenceCounted::drop() for more information. */
+ virtual ISceneNodeAnimator* createScaleAnimator(const core::vector3df& scalePerSecond) = 0;
+
//! Creates a fly circle animator, which lets the attached scene node fly around a center.
/** \param center: Center of the circle.
\param radius: Radius of the circle.
Index: source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp
===================================================================
--- source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp (revision 1344)
+++ source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp (working copy)
@@ -26,6 +26,7 @@
"collisionResponse",
"cameraFPS",
"cameraMaya",
+ "scale",
0
};
@@ -90,6 +91,9 @@
case ESNAT_CAMERA_MAYA:
anim = new CSceneNodeAnimatorCameraMaya(CursorControl);
break;
+ case ESNAT_SCALE:
+ anim = Manager->createScaleAnimator(core::vector3df(2.0f, 2.0f, 2.0f));
+ break;
default:
break;
}
Index: source/Irrlicht/CSceneManager.cpp
===================================================================
--- source/Irrlicht/CSceneManager.cpp (revision 1344)
+++ source/Irrlicht/CSceneManager.cpp (working copy)
@@ -139,6 +139,7 @@
#include "CSceneNodeAnimatorFollowSpline.h"
#include "CSceneNodeAnimatorCameraFPS.h"
#include "CSceneNodeAnimatorCameraMaya.h"
+#include "CSceneNodeAnimatorScale.h"
#include "CDefaultSceneNodeAnimatorFactory.h"
#include "CQuake3ShaderSceneNode.h"
@@ -1379,6 +1380,14 @@
return anim;
}
+//! creates a scale animator, which scales the attach scene node.
+ISceneNodeAnimator* CSceneManager::createScaleAnimator(const core::vector3df& scalePerSecond)
+{
+ ISceneNodeAnimator* anim = new CSceneNodeAnimatorScale(os::Timer::getTime(),
+ scalePerSecond);
+
+ return anim;
+}
//! creates a fly circle animator, which lets the attached scene node fly around a center.
Index: source/Irrlicht/CSceneManager.h
===================================================================
--- source/Irrlicht/CSceneManager.h (revision 1344)
+++ source/Irrlicht/CSceneManager.h (working copy)
@@ -312,6 +312,12 @@
virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime,
const core::array< core::vector3df >& points,
f32 speed = 1.0f, f32 tightness = 0.5f);
+
+ //! Creates a scale animator, which scales the attached scene node.
+ //! \param scalePerSecond: Specifies the speed of the animation
+ //! \return Returns the animator. Attach it to a scene node with ISceneNode::addAnimator()
+ //! and the animator will animate it.
+ virtual ISceneNodeAnimator* createScaleAnimator(const core::vector3df& scalePerSecond);
//! Creates a simple ITriangleSelector, based on a mesh.
Index: source/Irrlicht/CSceneNodeAnimatorScale.cpp
===================================================================
--- source/Irrlicht/CSceneNodeAnimatorScale.cpp (revision 0)
+++ source/Irrlicht/CSceneNodeAnimatorScale.cpp (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2002-2007 Nikolaus Gebhardt
+// This file is part of the "Irrlicht Engine".
+// For conditions of distribution and use, see copyright notice in irrlicht.h
+
+#include "CSceneNodeAnimatorScale.h"
+
+namespace irr
+{
+namespace scene
+{
+
+//! constructor
+CSceneNodeAnimatorScale::CSceneNodeAnimatorScale(u32 time, const core::vector3df& scale)
+: Scale(scale), StartTime(time)
+{
+ #ifdef _DEBUG
+ setDebugName("CSceneNodeAnimatorScale");
+ #endif
+}
+
+//! destructor
+CSceneNodeAnimatorScale::~CSceneNodeAnimatorScale()
+{
+}
+
+//! animates a scene node
+void CSceneNodeAnimatorScale::animateNode(ISceneNode* node, u32 timeMs)
+{
+ if (node)
+ {
+ u32 diffTime = timeMs - StartTime;
+
+ if (diffTime != 0)
+ {
+ core::vector3df NewScale = node->getScale();
+ NewScale += Scale * ((diffTime)/10.0f);
+ node->setScale(NewScale);
+ StartTime = timeMs;
+ }
+ }
+}
+
+//! Writes attributes of the scene node animator.
+void CSceneNodeAnimatorScale::serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options) const
+{
+ out->addVector3d("Scale", Scale);
+}
+
+//! Reads attributes of the scene node animator.
+void CSceneNodeAnimatorScale::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
+{
+ Scale = in->getAttributeAsVector3d("Scale");
+}
+
+} // end namespace scene
+} // end namespace irr
\ No newline at end of file
Index: source/Irrlicht/CSceneNodeAnimatorScale.h
===================================================================
--- source/Irrlicht/CSceneNodeAnimatorScale.h (revision 0)
+++ source/Irrlicht/CSceneNodeAnimatorScale.h (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (C) 2002-2007 Nikolaus Gebhardt
+// This file is part of the "Irrlicht Engine".
+// For conditions of distribution and use, see copyright notice in irrlicht.h
+
+#ifndef __C_SCENE_NODE_ANIMATOR_SCALE_H_INCLUDED__
+#define __C_SCENE_NODE_ANIMATOR_SCALE_H_INCLUDED__
+
+#include "ISceneNode.h"
+
+namespace irr
+{
+namespace scene
+{
+ class CSceneNodeAnimatorScale : public ISceneNodeAnimator
+ {
+ public:
+
+ //! constructor
+ CSceneNodeAnimatorScale(u32 time, const core::vector3df& scale);
+
+ //! destructor
+ virtual ~CSceneNodeAnimatorScale();
+
+ //! animates a scene node
+ virtual void animateNode(ISceneNode* node, u32 timeMs);
+
+ //! Writes attributes of the scene node animator.
+ virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const;
+
+ //! Reads attributes of the scene node animator.
+ virtual void deserializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0);
+
+ //! Returns the type of the scene node animator.
+ virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_SCALE; }
+
+ private:
+
+ core::vector3df Scale;
+ u32 StartTime;
+ };
+
+} // end namespace scene
+} // end namespace irr
+
+#endif
\ No newline at end of file
Code: Select all
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_SCENE_NODE_ANIMATOR_SCALE_H_INCLUDED__
#define __C_SCENE_NODE_ANIMATOR_SCALE_H_INCLUDED__
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
class CSceneNodeAnimatorScale : public ISceneNodeAnimator
{
public:
//! constructor
CSceneNodeAnimatorScale(u32 time, const core::vector3df& scale);
//! destructor
virtual ~CSceneNodeAnimatorScale();
//! animates a scene node
virtual void animateNode(ISceneNode* node, u32 timeMs);
//! Writes attributes of the scene node animator.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const;
//! Reads attributes of the scene node animator.
virtual void deserializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0);
//! Returns the type of the scene node animator.
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_SCALE; }
private:
core::vector3df Scale;
u32 StartTime;
};
} // end namespace scene
} // end namespace irr
#endif
Code: Select all
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CSceneNodeAnimatorScale.h"
namespace irr
{
namespace scene
{
//! constructor
CSceneNodeAnimatorScale::CSceneNodeAnimatorScale(u32 time, const core::vector3df& scale)
: Scale(scale), StartTime(time)
{
#ifdef _DEBUG
setDebugName("CSceneNodeAnimatorScale");
#endif
}
//! destructor
CSceneNodeAnimatorScale::~CSceneNodeAnimatorScale()
{
}
//! animates a scene node
void CSceneNodeAnimatorScale::animateNode(ISceneNode* node, u32 timeMs)
{
if (node)
{
u32 diffTime = timeMs - StartTime;
if (diffTime != 0)
{
core::vector3df NewScale = node->getScale();
NewScale += Scale * ((diffTime)/10.0f);
node->setScale(NewScale);
StartTime = timeMs;
}
}
}
//! Writes attributes of the scene node animator.
void CSceneNodeAnimatorScale::serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options) const
{
out->addVector3d("Scale", Scale);
}
//! Reads attributes of the scene node animator.
void CSceneNodeAnimatorScale::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
Scale = in->getAttributeAsVector3d("Scale");
}
} // end namespace scene
} // end namespace irr
Code: Select all
#include <Irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640, 480));
if (!device)
return 1;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode* node = smgr->addSphereSceneNode(10.0f, 32);
node->setPosition(core::vector3df(0,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
scene::ISceneNodeAnimator* anim = smgr->createScaleAnimator(
core::vector3df(0.01f, 0.01f, 0.01f));
if (anim)
{
node->addAnimator(anim);
anim->drop();
}
anim = smgr->createDeleteAnimator(5000);
if (anim)
{
node->addAnimator(anim);
anim->drop();
}
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
camera->setPosition(core::vector3df(0, 0, -100));
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while (device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Scale shader example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
}
device->drop();
return 0;
}
