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.
weeix
Posts: 23 Joined: Fri Jul 09, 2010 5:07 am
Post
by weeix » Wed Aug 18, 2010 6:52 am
I'm trying to create a function that can move a node to any specific position.
Code: Select all
typedef struct
{
scene::ISceneNode* node;
core::vector3df current, destination, speed;
}movement;
irr::core::array<movement*> movementList;
void addMovement(scene::ISceneNode* node, core::vector3df& absoluteDestination) // This function runs as an event
{
movement* movementInfo = new movement();
movementInfo->node = node;
movementInfo->current = core::vector3df(0,0,0);
movementInfo->destination = absoluteDestination - node->getAbsolutePosition();
movementInfo->speed = movementInfo->destination / 1000;
movementList.push_back(movementInfo);
}
void updateMovement() // This function runs in every game loop
{
for( u32 i = 0; i < movementList.size(); i++ )
{
movementList[i]->node->setPosition(
movementList[i]->node->getPosition() + movementList[i]->speed);
movementList[i]->current += movementList[i]->speed;
if(fabs(movementList[i]->destination.X - movementList[i]->current.X) < 1)
movementList.erase(i);
}
}
but.. it doesn't work. I give up. [white flag]
Last edited by
weeix on Wed Aug 18, 2010 6:55 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821 Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!
Post
by BlindSide » Wed Aug 18, 2010 6:53 am
Look at the code for FlyStraightAnimator produced from ISceneManager::createFlyStraightAnimator.
ShadowMapping for Irrlicht!:
Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
weeix
Posts: 23 Joined: Fri Jul 09, 2010 5:07 am
Post
by weeix » Wed Aug 18, 2010 7:24 am
BlindSide wrote: Look at the code for FlyStraightAnimator produced from ISceneManager::createFlyStraightAnimator.
I took a look in ISceneManager.h and only found this
Code: Select all
virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint,
const core::vector3df& endPoint, u32 timeForWay, bool loop=false, bool pingpong = false) = 0;
(I'm trying to integrate your "ease in/ease out"
method with the function.)
Lonesome Ducky
Competition winner
Posts: 1123 Joined: Sun Jun 10, 2007 11:14 pm
Post
by Lonesome Ducky » Wed Aug 18, 2010 7:57 am
I think he meant to find it in the irrlicht source, so you could see the code. Anyway, I don't see anything fundamentally wrong with your code. Have you tried to see if speed actually has a value that isn't 0,0,0? And also, be sure to use a frameDeltaTime value for movement if you plan on keeping frame rate independence.