Camera rotation is always up?

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
Delee
Posts: 18
Joined: Sat Apr 14, 2007 8:36 am

Camera rotation is always up?

Post by Delee »

Hi everyone. I have a simple camera attached to an object within the game. I use the following to create the camera.

Code: Select all

cameraNode =  sceneManager -> addCameraSceneNode(oNode, vector3df(0, 0, 0), vector3df(0, 0, 0), -1);
No matter what values I set for the camera rotation, the camera always looks up at the ceiling. My object is an tall egg.

Can anyone please tell me how to make the camera face forward through the object?
My thanks in advance. :)
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

you can use:

Code: Select all

 cameraNode->setTarget(lookAtTarget);
link to irrlicht doc:
http://irrlicht.sourceforge.net/docu/cl ... e.html#a20
Delee
Posts: 18
Joined: Sat Apr 14, 2007 8:36 am

Post by Delee »

Hi, thanks for the help!

I did some testing and it appears that changes caused by Newton are messing the camera up. Right at the beginning, the camera is set correctly to display just above and behind the character.

Code: Select all

cameraNode =  sceneManager -> addCameraSceneNode(oNode, vector3df(40, 60, 0), vector3df(0, 0, 0), -1);
Then, as soon as Newton begins modifying the object, the camera rotations all change and it starts to look at the ceiling. I use the following code to modify the object.

Code: Select all

matrix4 mat;
memcpy(mat.pointer(), matrix, sizeof(float) * 16);

ISceneNode *shape = ((SShape*) NewtonBodyGetUserData(body)) -> node;

if (shape) {
	shape -> setPosition(mat.getTranslation());
	shape -> setRotation(mat.getRotationDegrees());
}
Now, I thought that when you attached a camera to a node and set the default positioning and rotation, it would begin to mimic the node. You rotate the node, the camera rotates with it. True, the camera currently moves to the position of the node, but the Y axis rotation is horribly wrong. Reversing the rotation doesn't help. The mesh itself is not being rotated along the Y axis.

Perhaps I am making some assumptions that are incorrect. Any help is appreciated. :)
Delee
Posts: 18
Joined: Sat Apr 14, 2007 8:36 am

Post by Delee »

Oh and also, even if following my modification of the object's rotation, I set the camera rotation to 0 on all points, it still ends up looking at the ceiling.
Post Reply