Sorry to bump this again, but I suppose it's important for anyone in the future with this problem. After some time, I noticed problems with my last solution. Turns out the code above doesn't work frame by frame as I once thought. So, I made a new solution. I created a variable and had it check itself like so:
Code: Select all
int check = 0;
...
while(g_device->run() && g_driver)
{
if (g_device->isWindowActive())
{
check = (check == 10) ? 0 : check + 1;
Basically, this variable increments itself by 1 every frame until 10, at which point it resets itself to zero. Further along in my loop I put:
Code: Select all
if(World.running && check == 5) {
g_cam->updateAbsolutePosition();
g_cam_current_pos = g_cam->getAbsolutePosition();
printf("Updating current pos...\n");
}
if(World.running && check == 10) {
g_cam_last_pos = g_cam_current_pos;
printf("Updating last pos...\n");
}
This means that it stores the camera position when check is equal to 5, then it waits 5 frames, stores the last position, waits another 5 frames and stores the current position again. Then in my Event Receiver, I did the following:
Code: Select all
case KEY_KEY_W:
if(check == 6)
printf("Old (%.2f, %.2f, %.2f)\nNew (%.2f, %.2f, %.2f)\n",
g_cam_last_pos.X, g_cam_last_pos.Y, g_cam_last_pos.Z,
g_cam_current_pos.X, g_cam_current_pos.Y, g_cam_current_pos.Z);
This successfully got me the right positions 5 frames apart. Hopefully I can now close the chapter on this giant time waster of a problem and get on with my game.