FollowSplineAnimator get on which point of trajectory is it?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

FollowSplineAnimator get on which point of trajectory is it?

Post by Georgian »

heelp please people ,
I am using a follow spline animator
core::array<core::vector3df> PositionPoints;


PositionPoints.push_back(core::vector3df(x11,y11,z11));
PositionPoints.push_back(core::vector3df(x21,y21,z21));
PositionPoints.push_back(core::vector3df(x31,y31,z31));

ISceneNodeAnimator* sa;
sa= smgr->createFollowSplineAnimator(device->getTimer()->getTime(),PositionPoints,0.2);


i have managed to make it stop on last point (by cheking area around it)
but can i get info on where the camera is at the moment? for example heading from (x11,y11,z11) to (x21,y21,z21) or should i do it manuall (i dont want to there are a lot of points )


-----
if its not possible at least tell me how to do something every 5 seconds :)
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

with device->getTimer()->getTime() get current time and store it in variable named lets say 'before', then wait until current time is equal to before + 5, execure your actions and set 'before' to current time.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

what about something like this

Code: Select all

vector3df CamPos = Camera->getPosition();
s32 Index=-1;
f32 ShortestDistSQInv=0;
u32 PointCount=PositionPoints.size();
for(s32 i=0;i<PointCount;i++)
{
    f32 DistInv;
    DistInv=1.f / PositionPoints[i].getDistanceFromSQ(CamPos);
    if(Dist > ShortestDistSQInv)
    {
        Index=i;
        ShortestDistSQInv=DistInv;
    }
}

if(Index!=-1)
{
    //The closest point is PositionPoins[i], doesn't care if it's the next or prev point, just closest.
}
else
{
    //Your code doesn't contain any points :)
}
If you just want the pos of the cam, do Camera->getPosition()
If you don't have anything nice to say, don't say anything at all.
mrAlmond
Posts: 15
Joined: Fri Nov 23, 2007 9:47 am

Post by mrAlmond »

I reopen this thread because I really need to know the current position of the spline animator...I'm not moving the camera so I don't need to know its position, I'm just moving meshes...please help!
Thank you.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

So use node->getPosition()..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

mrAlmond wrote:I reopen this thread because I really need to know the current position of the spline animator...I'm not moving the camera so I don't need to know its position, I'm just moving meshes...please help!
What a peculiar question. I'd like to think that it's not as simple as node->getPosition() / node->getAbsolutePosition(); for (one of?) the node(s) that the animator is applied to.

Are you perhaps saying that you've created an animator but that it's not attached to any node?

If so, then the easiest way to get the position would be to just attach it to an empty scene node, created with ISceneManager::addEmptySceneNode(), then retrieve that node's position.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply