   Moving camera and moving object problems
  Hi all, After a 7 year gap I am back on 3d programming and I have run into a problem i can't seem to solve. I am making a bike game. If i move just the bike everything is smooth.If i move just the camera everything is smooth.If i move the bike and have the camera follow or the bike judders/displaces, the terrain and other static objects are still smooth. I am using Directx 9 and visual studio 2008 on Windows 7. In an attempt to identify the cause of the problem i have removed much of the code dealing with movement and left myself with code that simply moves the bike to the right, the camera matches the location of the bike, but 10 units back. When not moving the bike it is perfectly central, but when i move the bike (pressing right arrow) it jumps to the right of the screen and when i release the key it returns to the center. My code is almost identical to what i used to do in directx 8 and i never had any problems. void drawFrame(){//Time based movementlastTime=currTime;currTime=GetTickCount()*0.001f;timeElapsed=currTime-lastTime;//temp bike controlif(KEYDOWN(VK_UP)){bike.vLoc.x++;}D3DXMATRIX matWorld, matScale, matTrans;D3DXMATRIX matTemp, matRotateX, matRotateY, matRotateZ;D3DXMATRIX matLocal;vLook.x=bike.vLoc.x;vLook.y=bike.vLoc.y;vLook.z=bike.vLoc.z;//match position + 10 unitsvCam.x = bike.vLoc.x;vCam.y = bike.vLoc.y;vCam.z = bike.vLoc.z-10;D3DXMatrixScaling(&matScale, bike.vScl.x, bike.vScl.y, bike.vScl.z);D3DXMatrixTranslation(&matWorld, bike.vLoc.x, bike.vLoc.y, bike.vLoc.z);D3DXMatrixRotationY( &matRotateY, -bike.vR.x );D3DXMatrixRotationX( &matRotateX, -bike.vR.y );D3DXMatrixRotationZ( &matRotateZ, -bike.vR.z );D3DXMatrixMultiply( &matWorld, &matWorld, &matScale);D3DXMatrixMultiply( &matTemp, &matRotateX, &matRotateY );D3DXMatrixMultiply( &matTemp, &matRotateZ, &matTemp );D3DXMatrixMultiply( &matWorld, &matTemp, &matWorld ); bike.setMatLocal(matWorld);bike.render(g_pd3dDevice);D3DXMatrixScaling(&matScale, checkPoint.vScl.x, checkPoint.vScl.y, checkPoint.vScl.z);D3DXMatrixTranslation(&matWorld, checkPoint.vLoc.x, checkPoint.vLoc.y, checkPoint.vLoc.z);D3DXMatrixRotationY( &matRotateY, -checkPoint.vR.x );D3DXMatrixRotationX( &matRotateX, -checkPoint.vR.y );D3DXMatrixRotationZ( &matRotateZ, -checkPoint.vR.z );D3DXMatrixMultiply( &matWorld, &matWorld, &matScale);D3DXMatrixMultiply( &matTemp, &matRotateX, &matRotateY );D3DXMatrixMultiply( &matTemp, &matRotateZ, &matTemp );D3DXMatrixMultiply( &matWorld, &matTemp, &matWorld ); checkPoint.setMatLocal(matWorld);checkPoint.render(g_pd3dDevice);/*View */D3DXMATRIX matView;    D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( vCam.x, vCam.y, vCam.z),&D3DXVECTOR3( vLook.x, vLook.y, vLook.z ),&D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );    g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );//Projection    D3DXMATRIX matProj;    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100000.0f );    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); I am really hoping someone can spot something i have overlooked. Any help will be much appreciated, thank you   
  You should try to create your view matrices right after you changed the Location of the camera, and before you render the bike. When you not do so, the rendered image will still use the camera location of your last frame...Hope that helps :)   ;  :)Thank you. I moved the render bike call to after View and before projection and it seems to have solved it. I wonder why i never noticed this before???Thanks again   ;  One more thing:You don't need to recalculate the Proj matrix every frame. Just do it, when you window gets resized :)   ;  Thanks. I have changed that bit code too now. :)