[Fixed]Animate Moving Camera Node
[Fixed]Animate Moving Camera Node
Hi, I am trying to have the camera node (not fps), be animated to show movement along a certain distance once a certain button/action is performed, but I cant think of any good way to do it, any suggestions would be great, thanks in advance!
Last edited by remark on Wed May 28, 2014 8:49 pm, edited 1 time in total.
Re: Animate Moving Camera Node
The camera is derived from ISceneNode so you can use the setPosition function from that. Also ensure to update the target where the camera looks at with setTarget.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Animate Moving Camera Node
That doesnt really help for "showing" the motion, as that is what I have been doing, however, you reminded me that I can use functions that the node is derived from, I thus found ISceneNodeAnimator, and createFlyStraghtAnimator, however, the fly straight animator uses constant points, is there a way to change the start and end point on the fly as I advance the camera?
Edit: I think I kinda got it working, but I keep getting the error :
for this code fragment inside a gui button:
edit #2: fixed code with brackets around the case, works great now, thanks!
Edit: I think I kinda got it working, but I keep getting the error :
Code: Select all
...error: crosses initialization of 'irr::scene::ISceneNodeAnimator* anim'|
Code: Select all
case GUI_ID_Forward_Arrow_X:
Context.camera ->bindTargetAndRotation(true);
x = 0;
z = 0;
y = Context.camera->getRotation().Y;
if ((y == 0) or (y == 360))
z = 10;
else if (y == 90)
x = 10;
else if (y == 180)
z = -10;
else if (y == 270)
x = -10;
x = Context.camera->getPosition().X + x;
z = Context.camera->getPosition().Z + z;
scene::ISceneNodeAnimator *anim = Context.smgr->createFlyStraightAnimator(core::vector3df(Context.camera->getPosition()),core::vector3df(x,-1,z), 500, false);
Context.camera->addAnimator(anim);
anim->drop();
Context.camera ->setPosition(core::vector3df(x,-1,z));
return true;