view matrix

Started by
1 comment, last by nish 22 years, 9 months ago
hi guys , can anyone tell me how to use the view matrix to get camera movement. when i am compiling the following code only one frame is showing . the code is below other necessary functions are there THANKS TO ANYONE WHO ANSWERS IN ADVANCE VOID Render() { g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); D3DLIGHT8 light; ZeroMemory( &light, sizeof(D3DLIGHT8) ); light.Type = D3DLIGHT_POINT; light.Diffuse.r = 1.0f; light.Diffuse.g = 0.0f; light.Diffuse.b = 0.2f; light.Position.x = 0.0f; light.Position.y = 1.0f; light.Position.z = -80.0f; light.Range = 1000.0f; g_pd3dDevice->SetLight( 0, &light ); g_pd3dDevice->LightEnable( 0, TRUE); D3DXMATRIX matView, matProj; D3DXVECTOR3 eyepoint,lookat; D3DXVECTOR3 upvect(0.0f,1.0f,0); eyepoint.x = 0.0f; eyepoint.y = 25.0f; lookat.x = 0.0f; lookat.y = 25.0f; g_pd3dDevice->BeginScene(); for(int m = 0;m<345;m++) { eyepoint.z = 5.0f+m; lookat.z =-100.0f; D3DXMatrixLookAtLH( &matView,&eyepoint,&lookat,&upvect); g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 10000.0f ); g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); for( DWORD i=0; iSetMaterial( &g_pMeshMaterials ); g_pd3dDevice->SetTexture( 0, g_pMeshTextures ); g_pMesh->DrawSubset( i ); } g_pd3dDevice->EndScene(); } g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); } </i>
Advertisement
Shouldn''t the g_pd3dDevice->BeginScene() be in the loop
for every frame you need to have a beginscene and a endscene
the beginscene is outside the loop scope and because of that you can''t see all the frames, only the first one

Katana
Katana
hi

even when i keep the begin scene in the loop only one frame is getting displayed. updated code is here



for(int m = 0;m<345;m++)
{
g_pd3dDevice->BeginScene();

eyepoint.z = 5.0f+m;
lookat.z =-100.0f;

D3DXMatrixLookAtLH( &matView,&eyepoint,&lookat,&upvect);
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 10000.0f );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );



for( DWORD i=0; i {

g_pd3dDevice->SetMaterial( &g_pMeshMaterials );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures );<br> <br> <br> g_pMesh->DrawSubset( i );<br> }<br> <br> <br> g_pd3dDevice->EndScene();<br> <br> }<br> g_pd3dDevice->Present( NULL, NULL, NULL, NULL );<br>}<br> </i>

This topic is closed to new replies.

Advertisement