Posted on 2007-05-05 07:55 
小明 阅读(1949) 
评论(1)  编辑 收藏 引用  所属分类: 
Game Development 
			 
			
		 
		这个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());
效果图:

Source Code and Executable:
http://www.cppblog.com/Files/sandy/fly.rar