XMMatrixLookAtLH

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);




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章