D3DXMAMATRIXLOKATLH function
Create the observation matrix of the left hand coordinate system.
definition:
D3DXMAMATRIX * WINAPI D3DXMATRIXLOOKATLH
D3DXMAMATRIX * POUT,
Const d3dxvector3 * peye,
Const D3DxVector3 * Pat,
Const D3DxVector3 * Pup
);
parameter:
pout
[IN, OUT] points to the matrix of returning results of the D3DXMatrix structure.
peye
[in] Point all the eyes of the D3DxVector3 structure all in position vectors. This value will be used to translate.
PAT
[in] Points the camera to observe the target position vector to the camera of the D3DxVector3 structure.
PUP
[in] Points to the current world coordinate system of D3DXVECTOR3 structure. Usually used in [0, 1, 0].
return value:
Point to the left hand coordinate system observation matrix of the D3DXMAMATRIX structure.
Description:
The return value is the same as the parameter Pout returned. By this way, the D3DXMatrixLookatLH function can be a parameter of other functions.
This function calculates the returned matrix with the following formula:
ZAXIS = NORMAL (at - eye)
XAXIS = Normal (Cross (Up, ZAXIS))
Yaxis = Cross (ZAXIS, XAXIS)
Xaxis.x yaxis.x zaxis.x 0
Xaxis.y yaxis.y zaxis.y 0
Xaxis.z yaxis.z zaxis.z 0
-dot (Xaxis, Eye) -dot (Yaxis, Eye) -dot (ZAXIS, EYE) 1
Function information:
HEADER
D3DX9Math.h
Import Library
D3DX9.LIB
Minimum operation systems
WINDOWS 98
related functions:
D3DXMAMATRIXLOKATRH
Instructions: One camera has some properties in the above pictures: 1. Observer: Position 2, target point: The camera is facing a place 3, observe the scope: conical shape projection range The angle size, the unit is an extension. 4, visible nearest distance and farthest distance: The scope of the observation in the middle of these two is visible area. 5, aspect ratio: the width and high proportion of the show, generally 1.
After understanding the principle of the camera, let's see how it sets it in D3D. There are two matrices to set up the camera, one is a viewing matrix, one is a shooting matrix, the program explains everything. The first is to set the observation matrix of the camera:
m_veyept = d3dxvector3 (0.0F, 3.0F, -5.0F); // View point coordinate m_vlookatpt = d3dxvector3 (0.0F, 0.0F, 0.0F); // Target point coordinate m_vupvec = d3dxvector3 (0.0F, 1.0F, 0.0F ); // The current direction of the world is usually (0, 1, 0)
/ / Establish a viewing matrix D3DXMAMATRIXLOKATLH (& M_MatView, & M_VeyEPT, & M_VLOOKATPT, & M_VEYEPT, & M_VLOOKATPT, & M_VEYEPT, & M_VLOOKATPT, & M_VUPVEC) based on the three values given above;
// Set the matrix of D3D PD3DDEVICE-> SetTransform (D3DTS_VIEW, & M_MATIW);