Camera problem in irrlicht 1.7

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
raveneyes
Posts: 11
Joined: Wed Sep 03, 2008 5:49 am

Camera problem in irrlicht 1.7

Post by raveneyes »

I downloaded irrlicht 1.7 on a windows box and compiled it using visual studio 2008, i ran the exmples and everything is working fine. However, i want to control the camera object with my own key event listener.
So i set up a normal camera (assuming that scmgr is my scene manager object) and in the main loop i'm rotating the camera on the x axis if user presses the up key. However, the camera seems not to rotate as the view is still the same. Debugging the application shows that the rotation member of the camera is increasing but with no effect in the scene. Can someone shed some light on this matter, your help is appreciated.

Here's the code snippet (omitting some blocks for brevity):

camera = scmgr->AddCameraSceneNode();
camera->setPosition( 0, 320, 0 );
camera->setTarget( 0, 0, 0 );

...

main loop:
while( device->run() )
{
...
if( myreceiver.UpKeyDown() )
{
camera->setRotation( camera->getRotation().X + 1, camera->getRotation().Y, camera->getRotation().Z );
}
...
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You're changing the rotation, not the target. By default, the two things are separated. You can bind both together, though, if you really need this. Otherwise just update the target instead of the rotation.
raveneyes
Posts: 11
Joined: Wed Sep 03, 2008 5:49 am

Post by raveneyes »

Can I disable the option making the camera point to a target because i don't need it in my project and I only need to rotate it on its axis. I've already tried omitting the setTarget and still it seems that the camera is always pointing to a fixed point.
raveneyes
Posts: 11
Joined: Wed Sep 03, 2008 5:49 am

Post by raveneyes »

To elaborate my problem further, i want to rotate the camera on the axis that is pointing toward a given target, so if the camera is a top view cam and you're seeing 4 quadrants on the screen

1 | 2
------
3 | 4

i want to make a 180 degree rotation in a way that the view will be

4 | 3
------
2 | 1

One of the ways i know mathematically is to apply a rotational transform on the Up vector of the camera. But doing that, is also not yielding any results.
CuteAlien
Admin
Posts: 10021
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

As hybrid mentioned - you can bind target and rotation together. Use yourCamera->bindTargetAndRotation(true) to do that.
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
raveneyes
Posts: 11
Joined: Wed Sep 03, 2008 5:49 am

Post by raveneyes »

Thank you for your help, the bindTargetAndRotation solved my problem.
Post Reply