XMMatrixLookAtLH

来源:互联网 发布:java程序员培训 编辑:程序博客网 时间:2024/05/02 01:35

The XNA Math library provides the following function for computing the view matrix based on the just described process: XMMATRIX XMMatrixLookAtLH( // Outputs resulting view matrix V FXMVECTOR EyePosition, // Input camera position Q FXMVECTOR FocusPosition, // Input target point T FXMVECTOR UpDirection); // Input world up vector j Usually the world’s y-axis corresponds to the “up” direction, so the “up” vector is almost always j = (0,1,0). As an example, suppose we want to position the camera at the point (5, 3, −10) relative to the world space, and have the camera look at the origin of the world (0, 0, 0). We can build the view matrix by writing: 

XMVECTOR pos = XMVectorSet(5, 3, -10, 1.0f);

 XMVECTOR target = XMVectorZero(); 

XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);

 XMMATRIX V = XMMatrixLookAtLH(pos, target, up);




原创粉丝点击