This cam will move above the scene when you get close to the screen borders. call this function from your main loop.
Oh and since this is my first post here after lurking the forums for a while, Hello all
Code: Select all
void CGame::updateCamera()
{
// make the camera look to a fixed point (45 degrees down)
// in front of it, so it wont stay locked on the old target.
vector3df cpos = pCamera->getPosition();
cpos.Z += 2;
cpos.Y -= 2;
pCamera->setTarget(cpos);
// get the cursor positions
int x = pDevice->getCursorControl()->getPosition().X;
int y = pDevice->getCursorControl()->getPosition().Y;
// make the move distance the same for different frame rates
int fps = pDriver->getFPS();
float dist;
if (fps > 1)
dist = 200.0f / fps;
else
dist = 1.0f;
if (x > (screenSize.X - 50))
{
cpos = pCamera->getPosition();
cpos.X += dist;
pCamera->setPosition(cpos);
}
else if (x < 50)
{
cpos = pCamera->getPosition();
cpos.X -= dist;
pCamera->setPosition(cpos);
}
if (y < 50)
{
cpos = pCamera->getPosition();
cpos.Z += dist;
pCamera->setPosition(cpos);
}
else if (y > (screenSize.Y - 50))
{
cpos = pCamera->getPosition();
cpos.Z -= dist;
pCamera->setPosition(cpos);
}
}