Sign in to follow this  

onFrameMove and jerky camera

This topic is 2139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody,

I have a problem, I use DXUT and at times when I move my camera, it's jerky.
I use these callback :
[code]DXUTSetCallbackFrameMove (OnFrameMove, scene);
DXUTSetCallbackD3D11FrameRender (OnFrameRender, scene);[/code]
[code]void WINAPI OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ) {
Scene &s = *static_cast<Scene*>(pUserContext);
// if the camera move
if(s.pCamera.getMove()){
s.pCamera.frameMove(fElapsedTime); // update the position
s.pCamera.render(); // compute the matrix
s.pCamera.renderReflection(s.pWaterPlane->getHeight()); // compute the matrix of reflection
}

//move the water
s.pShaderWater.setWaterMove(s.pShaderWater.getWaterMove() + 0.0001f);
if(s.pShaderWater.getWaterMove() > 1.0f)
{
s.pShaderWater.setWaterMove(s.pShaderWater.getWaterMove()- 1.0f);
}
};[/code]

The message callback :
[code]LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam,bool *pbNoFurtherProcessing,void *pUserContext)
{
Scene &s = *static_cast<Scene*>(pUserContext);
switch( msg ) {
case WM_KEYDOWN:{
switch(wParam) {
case VK_UP : s.pCamera.setMoveForward(true);break;
case VK_DOWN : s.pCamera.setMoveBackward(true);break;
case VK_LEFT: s.pCamera.setMoveLeft(true);break;
case VK_RIGHT : s.pCamera.setMoveRight(true);break;
case 'A': s.pCamera.setMoveUp(true);break;
case 'Z' : s.pCamera.setMoveDown(true);break;
}
}
break;
case WM_KEYUP:{
switch(wParam) {
case VK_UP : s.pCamera.setMoveForward(false);break;
case VK_DOWN : s.pCamera.setMoveBackward(false);break;
case VK_LEFT: s.pCamera.setMoveLeft(false);break;
case VK_RIGHT : s.pCamera.setMoveRight(false);break;
case 'A': s.pCamera.setMoveUp(false);break;
case 'Z' : s.pCamera.setMoveDown(false);break;
}
}
break
}
return 0;
}[/code]

And the move function :

[code]void Camera::MoveForward(float p_time){
if(m_moveForward)
m_position.z+=m_speed * p_time;
}[/code]

and in my function onFrameRender , i draw the differents objects of my scene one by one.

in 7 sec my camera jumps:
[media]http://www.youtube.com/watch?v=rmQme0yjpTs&feature=youtu.be[/media]

An idea of this problem?

Share this post


Link to post
Share on other sites
Sign in to follow this