Page 1 of 1

Camera rotation is always up?

Posted: Tue Apr 17, 2007 2:48 am
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. :)

Posted: Tue Apr 17, 2007 3:18 am
by JonLT
you can use:

Code: Select all

 cameraNode->setTarget(lookAtTarget);
link to irrlicht doc:
http://irrlicht.sourceforge.net/docu/cl ... e.html#a20

Posted: Tue Apr 17, 2007 4:32 am
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. :)

Posted: Tue Apr 17, 2007 5:11 am
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.