Camera rotation

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
unclejoe
Posts: 10
Joined: Fri Mar 28, 2008 2:27 pm
Location: Europe

Camera rotation

Post by unclejoe »

Hi folks,
I'm trying to rotate the camera with the up-key, using the following code in my event receiver:

Code: Select all

case KEY_UP:
  cam->setRotation (cam->getRotation () + core::vector3df (0, 5, 0) );
  break;
but the camera simply won't rotate. What am I doing wrong?
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

as far as I see: the ICameraSceneNode class has to setRotation(). If you want to rotate your camera, you have to get a node pointing to that class and then, if the camera eg. has been created with addICameraSceneNode rotate the camera by using the setTarget(thistarget) method, where thistarget is a vector3df type that holds the absolute positions of the point the camera should look at. (so if the cam is at ->setPosition(vector3df(0,0,0)) and you say setTarget(vector3df(0,1,0)) the cam will look up.
If you want to have constant rotation you have to constantly change the target (eg in the progs main loop).
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

floppyfreak wrote:as far as I see: the ICameraSceneNode class has to setRotation(). If you want to rotate your camera, you have to get a node pointing to that class and then, if the camera eg. has been created with addICameraSceneNode rotate the camera by using the setTarget(thistarget) method, where thistarget is a vector3df type that holds the absolute positions of the point the camera should look at. (so if the cam is at ->setPosition(vector3df(0,0,0)) and you say setTarget(vector3df(0,1,0)) the cam will look up.
If you want to have constant rotation you have to constantly change the target (eg in the progs main loop).
unclejoe: What he's trying to say in simpler words is that the camera's rotation is decided by its target (vector).

Code: Select all

case KEY_UP:
    cam->setTarget(cam->getTarget() + vector3df(0.f, 5.f, 0.f));
  //cam->setRotation (cam->getRotation () + core::vector3df (0, 5, 0) );
  break;
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
unclejoe
Posts: 10
Joined: Fri Mar 28, 2008 2:27 pm
Location: Europe

Post by unclejoe »

M'kay, so i should change the target the camera is looking at. i just thought i could rotate it, cause the camera class is inherited from ISceneNode, but clearly the function setRotation () doesn't do poop...

LOL, this forum automaticly changes the word sh*it into poop!!!!!
Post Reply