Controlling the camera

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
genzm
Posts: 6
Joined: Sun Mar 24, 2013 4:42 pm

Controlling the camera

Post by genzm »

Hy, I'm trying to write my own camera controllers. (more as an exercise than really with a purpose).
Because I know there is cameraFPS node available, but just to try things out.

So suppose I've written code that caluculates a position vector and a rotation vector.
How would I set these for the IcameraSceneNode?

This is how I did it:

Code: Select all

    check_keyboard_input(delta);
    check_mouse_input(delta);
 
    core::vector3df v = camera->getPosition();  v += dvector;         // dvector is difference with previous position
    camera->setPosition(v);
    camera->setRotation((*rotation)*180/core::PI);                    // rotation is in radials, so needs convert to degrees
    v += ((*rotation)* 180)/core::PI;
    camera->setTarget(v);                                             // target point is a random point in the direction of the rotation
 
So I would assume that this gives me somewhat decent results, but the camera flickers all the time from directions and rotations. I really can't figure out why this doesn't work. Is this the right way to set rotation of a camera?

Thanks
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Controlling the camera

Post by hendu »

Don't set both target and rotation, changing one changes the other by default IIRC.
Post Reply