im trying to create a simple camera class that can move around and rotate. and it is working but not when im multiplying its movements by timeDelta.
timeDelta is calculated every frame like so:
int d3d::mainLoop( bool (*ptr_display)(float timeDelta) )
{
MSG msg;
::ZeroMemory(&msg, sizeof(MSG));
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT)
{
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
ptr_display(timeDelta);
lastTime = currTime;
}
}
return 0;
}
and in my display method i am checking input and moving the camera
if(::GetAsyncKeyState('W') & 0x8000f)
cam->translate(0,0,1.0f*timeDelta);
if(::GetAsyncKeyState('S') & 0x8000f)
cam->translate(0,0,-1.0f*timeDelta);
if(::GetAsyncKeyState('D') & 0x8000f)
cam->translate(1.0f*timeDelta,0,0);
if(::GetAsyncKeyState('A') & 0x8000f)
cam->translate(-1.0f*timeDelta,0,0);
it all works if i dont multiply by timeDelta...the movement is very smooth...but it wouldnt be timebased....but i dont know why the timeDelta is making it run choppy
thanks