Irrlicth has a scale animator?
Irrlicth has a scale animator?
There is something like:
scenemanager->createScaleAnimator(...) that makes my object bigger or smaller while time is passing?
I've searched in scenemanager documentation but i haven't found it.
If I need to create it can you gave me some advice? Where I can start?
Thanks
Tranen
scenemanager->createScaleAnimator(...) that makes my object bigger or smaller while time is passing?
I've searched in scenemanager documentation but i haven't found it.
If I need to create it can you gave me some advice? Where I can start?
Thanks
Tranen
Last edited by Tranen on Sun Mar 28, 2010 4:25 pm, edited 2 times in total.
-
- Posts: 237
- Joined: Mon Jan 16, 2006 1:18 pm
- Location: Odessa,Russian Federation
Pseudo
Code: Select all
f32 TimeDelta=Irrtime-lastTime;TimeDelta/=100;
Node->setScale(vector3df(1.0f*TimeDelta,1.0f*TimeDelta,1.0f*TimeDelta)); lastTime=Irrtime;
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
My boids do it like this:
Code: Select all
void BoidSceneNode::OnAnimate(u32 timeMs)
{
if (this->firstUpdate)
{
this->lastAnimationTime = timeMs;
this->firstUpdate = false;
}
const f32 elapsed = (timeMs - this->lastAnimationTime)*0.001;
this->lastAnimationTime = timeMs;
if (this->perching) //if on ground
{
if (this->forward)
{
this->RelativeScale += irr::core::vector3df(1.0f, 1.0f, 1.0f)*elapsed;
if (this->RelativeScale.X > 2.0f)
this->forward = false;
}
else
{
this->RelativeScale -= irr::core::vector3df(1.0f, 1.0f, 1.0f)*elapsed;
if (this->RelativeScale.X < 1.0f)
this->forward = true;
}
}
ISceneNode::OnAnimate(timeMs);
}
"Whoops..."
Code: Select all
class CScaleAnimator : public irr::scene::ISceneNodeAnimator
{
public:
CScaleAnimator(irr::core::vector3df scalePerSec)
{
LastTime = 0;
}
void animateNode(irr::scene::ISceneNode* node, irr::u32 timeMs)
{
if (LastTime == 0)
LastTime = timeMs;
irr::f32 diff = (timeMs-LastTime) / 1000.0f;
node->setScale(node->getScale()+ScalePerSec*diff);
LastTime = timeMs;
}
irr::scene::ISceneNodeAnimator* createClone(irr::scene::ISceneNode* node, irr::scene::ISceneManager* newManager=0)
{
return new CScaleAnimator(ScalePerSec);
}
protected:
irr::u32 LastTime;
irr::core::vector3df ScalePerSec;
};
Last edited by sudi on Tue Mar 23, 2010 7:45 pm, edited 1 time in total.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
-
- Posts: 237
- Joined: Mon Jan 16, 2006 1:18 pm
- Location: Odessa,Russian Federation
Random )) I got question....
What is a reason you use "this" like
I do not understand.... ))
What is a reason you use "this" like
Code: Select all
this->forward
'this' is a pointer to the current class object instance. It isn't required to access members within the class like that person did, though it can be used like in the way that person did it. Probably for improved understanding when reading it (so you know where that variable or function is located that is being called).
The 'this' pointer is useful in that it allows a class to 'delete' itself. Irrlicht's reference counter (IUnknown) does this explicitly.
The 'this' pointer is useful in that it allows a class to 'delete' itself. Irrlicht's reference counter (IUnknown) does this explicitly.
-
- Posts: 237
- Joined: Mon Jan 16, 2006 1:18 pm
- Location: Odessa,Russian Federation
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Hi, i'm trying to use Sudi code, here is what I do:
before the render loop.
Nothing happens it seems that the animatedNode function is never called by the engine, so what else I must do? I need to register in some way this animator with the engine?
Thanks!
Tranen
Code: Select all
IMeshSceneNode* s = smgr->addSphereSceneNode(10);
s->setPosition(core::vector3df(0,0,0));
CScaleAnimator sa(core::vector3df(4,4,4));
s->addAnimator(&sa);
Nothing happens it seems that the animatedNode function is never called by the engine, so what else I must do? I need to register in some way this animator with the engine?
Thanks!
Tranen
Sorry I see that with this works:
Since I don't have launched a create* function a I don't need to drop the object right?
Thanks
Code: Select all
CScaleAnimator* sa2 = new CScaleAnimator(core::vector3df(4,4,4));
s->addAnimator(sa2);
Thanks
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am