Camera won't rotate [solved]

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
Apoptyzm
Posts: 19
Joined: Tue Sep 23, 2008 7:53 pm

Camera won't rotate [solved]

Post by Apoptyzm »

Hi,
I have weird thing...
I want my camera to follow a sphere for example, but it points one point all the time and it wont change ;x

Code: Select all

//I initialized Camera
Camera = irrScene->addCameraSceneNode(0,vector3df(0,0,0),vector3df(0,0,0),-1);

//later I've set it up

camerapos= vector3df(0,1.5,-5);
Camera->setParent(BodyNode);
Camera->setPosition( camerapos );
Camera->setRotation(vector3df(0,0,0) );

//and it points global(0,0,0) all the time not relatively to parent sphere.

//so on every frame I tried to point the camera to look at the point where the sphere looks

camerapos = conv::btV2irrV( trans.getBasis()[2]*57.2957795);
Camera->setRotation(camerapos);//camerapos is good and it differs at every frame (from circa -50 to 50)
vector3df v = Camera->getRotation();
//but "v" is messed up.. i get smtg like 1.000e+008 etc

any clue
Last edited by Apoptyzm on Mon Oct 20, 2008 3:19 pm, edited 1 time in total.
fennec
Posts: 55
Joined: Fri Oct 10, 2008 7:23 am

Post by fennec »

Regular cameras don't respond to rotations. They look at a target.

Instead use:

Camera->setTarget(objectToLookAt->getAbsolutePosition());

The objectToLookAt might simply be an empty node child of the sphere.

If fact, objectToLookAt might even be child of the camera, so that when you rotate the camera, the target moves.
Apoptyzm
Posts: 19
Joined: Tue Sep 23, 2008 7:53 pm

Post by Apoptyzm »

thanx for reply.

I thought that normal camera's dont have setTarget, but i've found that my pointer was an IsceneNode, not CameraNode ... doh

still I wonder why i cant rotate it with setRotation..
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

fennec wrote:Regular cameras don't respond to rotations. They look at a target.
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

fennec (posts 14) wrote:[Pearls of wisdom]
Crikey, we've got a live one here. Nicely answered.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply