Creating new camera vs. moving 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
Caspian
Posts: 15
Joined: Sun Mar 18, 2007 2:38 am

Creating new camera vs. moving camera

Post by Caspian »

When I move the camera, I use these commands:

Code: Select all

camera->setTarget(core::vector3df(1,2,3));
camera->setPosition(core::vector3df(0,0,0));
The camera's target updates just as it should. However, y and z components are off by about 0.5. I'm focusing on some very small objects (of size 0.06 and 0.017), so this offset is very important to me.

Oddly enough, when I create a new camera like this:

Code: Select all

smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(1,2,3));
the camera is positioned exactly the way I want it. Why is this? It's probably a bad idea to create a new camera every time I want it to move... but what am I doing wrong with changing the position of the camera?

Any help would be appreciated!

EDIT: If I do this:

Code: Select all

smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(1,2,3));
camera->setTarget(core::vector3df(1,2,3));
camera->setPosition(core::vector3df(0,0,0));
the camera is positioned properly. However, I'm wasting system resources by continually creating new cameras, so I'd like to reposition the camera without having to create a new one. Thanks!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

If you create a new camera you can remove the old one...

But did you try cam->updateAbsolutePosition() after positioning it ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Caspian
Posts: 15
Joined: Sun Mar 18, 2007 2:38 am

Post by Caspian »

Thanks! Calling the updateAbsolutePosition does the trick. I had thought that I was setting the absolute position...

It works great now :D.
Post Reply