D3D练习---动态铁轨

这个demo中演示了如何动态设置Camera

struct  camera
{
    D3DXMATRIX view_matrix;
    D3DXVECTOR3 eye_vector;
    D3DXVECTOR3 lookat_vector;
    D3DXVECTOR3 up_vector;

    D3DXMATRIX 
&  getMatrix()
    {
        D3DXMatrixLookAtLH(
& view_matrix, & eye_vector,
                                       
& lookat_vector,
                                       
& up_vector);
        
return  view_matrix;
    }
};

const   float  CAMERA_SPEED  =   0.01f ;
camera  g_camera;

g_camera.eye_vector.z 
+=  CAMERA_SPEED;
g_d3d_device
-> SetTransform(D3DTS_VIEW, & g_camera.getMatrix());

效果图:

D3D练习---动态铁轨_第1张图片

Source Code and Executable:

http://www.cppblog.com/Files/sandy/fly.rar


你可能感兴趣的:(D3D练习---动态铁轨)