i am writing a game where the camera (instance of ICameraSceneNode*) is looking down on the game board. I attached the camera movement to the mouse but instead of the camera's view angle being constant (the camera's direction is!) it shakes and jitters. The effect is more noticable when the camera moves faster. I tried to pin down the problem, but it even occurs in the following code:
Code: Select all
m_lookAt = vector3df(0.0, sin(0.008*g_gameTime)*10.0, 0.0);
m_cam->setTarget(m_lookAt);
m_cam->setPosition(m_lookAt + vector3df(0.0, 0.0, -25.0));
m_cam->setUpVector(vector3df(0.0, 1.0, 0.0));
I changed the HelloWorld example (actually just changed 5 lines or so) to demonstrate the problem. the main.cpp can be found here: main.cpp and a windows exe here: HelloWorld.exe
Ok, i found a way to get rid of the effect, however i still don't know the source of the problem. In the changed helloworld demo i replaced
Code: Select all
while(device->run())
{
float y = sin(device->getTimer()->getTime()*0.008)*10.0;
cam->setPosition(vector3df(0.0, y, -40.0));
cam->setTarget(vector3df(0.0, y, 0.0));
Code: Select all
float y = 0.0;
float prevY = 0.0;
while(device->run())
{
prevY = y;
y = sin(device->getTimer()->getTime()*0.008)*10.0;
cam->setPosition(vector3df(0.0, y, -40.0));
cam->setTarget(vector3df(0.0, prevY, 0.0));
btw: to make the effect more visible (i suppose at 200fps or so it's hard to see) you can insert a Sleep(100)/usleep(100) in the main-loop. Which is what i did in the changed helloworld example.