I modified tutorial 18 SplitScreen to show you a problem that I can't solve:
I want to make sure that a camera moves as a fps camera is connected to, so i modified the example:
to connect camera[2] (normal camera) to camera[3] (fps camera) I added:
Code: Select all
camera[2]->bindTargetAndRotation(true);
Code: Select all
camera[0] = smgr->addCameraSceneNode(0, vector3df(50,0,0), vector3df(0,0,0));
//Top
camera[1] = smgr->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
//Left
camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0));
camera[2]->bindTargetAndRotation(true);
//User-controlled
camera[3] = smgr->addCameraSceneNodeFPS();
// don't start at sydney's position
if (camera[3])
camera[3]->setPosition(core::vector3df(-50,0,-50));
Code: Select all
camera[2]->setPosition(camera[3]->getPosition() + core::vector3df(0,300,0));
camera[2]->setRotation(camera[3]->getRotation());
here is the loop:
Code: Select all
while(device->run())
{
//Set the viewpoint to the whole screen and begin scene
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
driver->beginScene(true,true,SColor(255,100,100,100));
//If SplitScreen is used
if (SplitScreen)
{
//Activate camera1
smgr->setActiveCamera(camera[0]);
//Set viewpoint to the first quarter (left top)
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera2
smgr->setActiveCamera(camera[1]);
//Set viewpoint to the second quarter (right top)
driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera3
camera[2]->setPosition(camera[3]->getPosition() + core::vector3df(0,300,0));
camera[2]->setRotation(camera[3]->getRotation());
smgr->setActiveCamera(camera[2]);
//Set viewpoint to the third quarter (left bottom)
driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
//Draw scene
smgr->drawAll();
//Set viewport the last quarter (right bottom)
driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
}
//Activate camera4
smgr->setActiveCamera(camera[3]);
//Draw scene
smgr->drawAll();
driver->endScene();
https://youtu.be/55onpDY11UE
The problem is if i move only the mouse there is no problem, when I use arrow keys the camera moves in wrong ways.
I don't understand where is my mistake.
Can anybody help me?