[Fixed]Animate Moving Camera Node

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
remark
Posts: 14
Joined: Wed May 28, 2014 5:02 am

[Fixed]Animate Moving Camera Node

Post by remark »

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.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animate Moving Camera Node

Post by CuteAlien »

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
remark
Posts: 14
Joined: Wed May 28, 2014 5:02 am

Re: Animate Moving Camera Node

Post by remark »

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 :

Code: Select all

...error: crosses initialization of 'irr::scene::ISceneNodeAnimator* anim'|
for this code fragment inside a gui button:

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;
edit #2: fixed code with brackets around the case, works great now, thanks!
Post Reply