Page 1 of 1

2 camera problem

Posted: Sun May 08, 2005 1:43 pm
by esmanical
I'm having problem with this demo I'm working on. I have 2 cameras, one is :

camera2 = sm->addCameraSceneNodeFPS(0, 100.0f, 600.0f, -1, keyMap, 8 );

and the other one is:
camera = smgr->addCameraSceneNode(BackNode,core::vector3df(0, 100, 0), core::vector3df(0, 0, -1));

During the game camera is folowing my character, and when I press ENTER I want to take a free look around.So when I press ENTER this function is called:

void CDemo::switchcamera()
{
freelook = (!freelook);
freelook ? smgr->setActiveCamera(camera2) : smgr->setActiveCamera(camera);
if(freelook)
{
camera2->setPosition(camera->getAbsolutePosition());
camera2->setTarget(camera->getTarget());

}
}

The point is that when switching camera I want to have the same look with my freelook camera (camera2), but its not like that. After switching camera 2 position is ok (same as camera position), but it looks somewhere up, not in my character. I cant solve this problem, anyone?

Posted: Sun May 08, 2005 11:42 pm
by bitplane
just a guess, but perhaps 'camera' has no target as 'camera2' is now the active camera.

Posted: Tue May 10, 2005 1:21 pm
by esmanical
No, I changed the code like this:

camera2->setTarget(EmptyNode->getAbsolutePosition());

and this EmptyNode is actually where my camera is looking at, and its allways there so... sthank you, Anyone?