📄 d3dx9math.h
字号:
#ifdef __cplusplus
}
#endif
//--------------------------
// 4D Matrix
//--------------------------
// inline
D3DXMATRIX* D3DXMatrixIdentity
( D3DXMATRIX *pOut );
BOOL D3DXMatrixIsIdentity
( CONST D3DXMATRIX *pM );
// non-inline
#ifdef __cplusplus
extern "C" {
#endif
FLOAT WINAPI D3DXMatrixDeterminant
( CONST D3DXMATRIX *pM );
HRESULT WINAPI D3DXMatrixDecompose
( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation,
D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM );
D3DXMATRIX* WINAPI D3DXMatrixTranspose
( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM );
// Matrix multiplication. The result represents the transformation M2
// followed by the transformation M1. (Out = M1 * M2)
D3DXMATRIX* WINAPI D3DXMatrixMultiply
( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );
// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose
( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );
// Calculate inverse of matrix. Inversion my fail, in which case NULL will
// be returned. The determinant of pM is also returned it pfDeterminant
// is non-NULL.
D3DXMATRIX* WINAPI D3DXMatrixInverse
( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM );
// Build a matrix which scales by (sx, sy, sz)
D3DXMATRIX* WINAPI D3DXMatrixScaling
( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz );
// Build a matrix which translates by (x, y, z)
D3DXMATRIX* WINAPI D3DXMatrixTranslation
( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z );
// Build a matrix which rotates around the X axis
D3DXMATRIX* WINAPI D3DXMatrixRotationX
( D3DXMATRIX *pOut, FLOAT Angle );
// Build a matrix which rotates around the Y axis
D3DXMATRIX* WINAPI D3DXMatrixRotationY
( D3DXMATRIX *pOut, FLOAT Angle );
// Build a matrix which rotates around the Z axis
D3DXMATRIX* WINAPI D3DXMatrixRotationZ
( D3DXMATRIX *pOut, FLOAT Angle );
// Build a matrix which rotates around an arbitrary axis
D3DXMATRIX* WINAPI D3DXMatrixRotationAxis
( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );
// Build a matrix from a quaternion
D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion
( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ);
// Yaw around the Y axis, a pitch around the X axis,
// and a roll around the Z axis.
D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll
( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );
// Build transformation matrix. NULL arguments are treated as identity.
// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
D3DXMATRIX* WINAPI D3DXMatrixTransformation
( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter,
CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling,
CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation,
CONST D3DXVECTOR3 *pTranslation);
// Build 2D transformation matrix in XY plane. NULL arguments are treated as identity.
// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
D3DXMATRIX* WINAPI D3DXMatrixTransformation2D
( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter,
FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling,
CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation,
CONST D3DXVECTOR2* pTranslation);
// Build affine transformation matrix. NULL arguments are treated as identity.
// Mout = Ms * Mrc-1 * Mr * Mrc * Mt
D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation
( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter,
CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation);
// Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity.
// Mout = Ms * Mrc-1 * Mr * Mrc * Mt
D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D
( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter,
FLOAT Rotation, CONST D3DXVECTOR2* pTranslation);
// Build a lookat matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixLookAtRH
( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
CONST D3DXVECTOR3 *pUp );
// Build a lookat matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixLookAtLH
( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
CONST D3DXVECTOR3 *pUp );
// Build a perspective projection matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH
( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
// Build a perspective projection matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH
( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
// Build a perspective projection matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH
( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );
// Build a perspective projection matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH
( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );
// Build a perspective projection matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH
( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
FLOAT zf );
// Build a perspective projection matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH
( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
FLOAT zf );
// Build an ortho projection matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixOrthoRH
( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
// Build an ortho projection matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixOrthoLH
( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
// Build an ortho projection matrix. (right-handed)
D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH
( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
FLOAT zf );
// Build an ortho projection matrix. (left-handed)
D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH
( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
FLOAT zf );
// Build a matrix which flattens geometry into a plane, as if casting
// a shadow from a light.
D3DXMATRIX* WINAPI D3DXMatrixShadow
( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight,
CONST D3DXPLANE *pPlane );
// Build a matrix which reflects the coordinate system about a plane
D3DXMATRIX* WINAPI D3DXMatrixReflect
( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane );
#ifdef __cplusplus
}
#endif
//--------------------------
// Quaternion
//--------------------------
// inline
FLOAT D3DXQuaternionLength
( CONST D3DXQUATERNION *pQ );
// Length squared, or "norm"
FLOAT D3DXQuaternionLengthSq
( CONST D3DXQUATERNION *pQ );
FLOAT D3DXQuaternionDot
( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 );
// (0, 0, 0, 1)
D3DXQUATERNION* D3DXQuaternionIdentity
( D3DXQUATERNION *pOut );
BOOL D3DXQuaternionIsIdentity
( CONST D3DXQUATERNION *pQ );
// (-x, -y, -z, w)
D3DXQUATERNION* D3DXQuaternionConjugate
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
// non-inline
#ifdef __cplusplus
extern "C" {
#endif
// Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
void WINAPI D3DXQuaternionToAxisAngle
( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle );
// Build a quaternion from a rotation matrix.
D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix
( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM);
// Rotation about arbitrary axis.
D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis
( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );
// Yaw around the Y axis, a pitch around the X axis,
// and a roll around the Z axis.
D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll
( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );
// Quaternion multiplication. The result represents the rotation Q2
// followed by the rotation Q1. (Out = Q2 * Q1)
D3DXQUATERNION* WINAPI D3DXQuaternionMultiply
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
CONST D3DXQUATERNION *pQ2 );
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
// Conjugate and re-norm
D3DXQUATERNION* WINAPI D3DXQuaternionInverse
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
// Expects unit quaternions.
// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
D3DXQUATERNION* WINAPI D3DXQuaternionLn
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
// Expects pure quaternions. (w == 0) w is ignored in calculation.
// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
D3DXQUATERNION* WINAPI D3DXQuaternionExp
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1).
// Expects unit quaternions.
D3DXQUATERNION* WINAPI D3DXQuaternionSlerp
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
CONST D3DXQUATERNION *pQ2, FLOAT t );
// Spherical quadrangle interpolation.
// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
D3DXQUATERNION* WINAPI D3DXQuaternionSquad
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB,
CONST D3DXQUATERNION *pC, FLOAT t );
// Setup control points for spherical quadrangle interpolation
// from Q1 to Q2. The control points are chosen in such a way
// to ensure the continuity of tangents with adjacent segments.
void WINAPI D3DXQuaternionSquadSetup
( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut,
CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1,
CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 );
// Barycentric interpolation.
// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3,
FLOAT f, FLOAT g );
#ifdef __cplusplus
}
#endif
//--------------------------
// Plane
//--------------------------
// inline
// ax + by + cz + dw
FLOAT D3DXPlaneDot
( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV);
// ax + by + cz + d
FLOAT D3DXPlaneDotCoord
( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV);
// ax + by + cz
FLOAT D3DXPlaneDotNormal
( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV);
D3DXPLANE* D3DXPlaneScale
(D3DXPLANE *pOut, CONST D3DXPLANE *pP, FLOAT s);
// non-inline
#ifdef __cplusplus
extern "C" {
#endif
// Normalize plane (so that |a,b,c| == 1)
D3DXPLANE* WINAPI D3DXPlaneNormalize
( D3DXPLANE *pOut, CONST D3DXPLANE *pP);
// Find the intersection between a plane and a line. If the line is
// parallel to the plane, NULL is returned.
D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine
( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1,
CONST D3DXVECTOR3 *pV2);
// Construct a plane from a point and a normal
D3DXPLANE* WINAPI D3DXPlaneFromPointNormal
( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal);
// Construct a plane from 3 points
D3DXPLANE* WINAPI D3DXPlaneFromPoints
( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
CONST D3DXVECTOR3 *pV3);
// Transform a plane by a matrix. The vector (a,b,c) must be normal.
// M should be the inverse transpose of the transformation desired.
D3DXPLANE* WINAPI D3DXPlaneTransform
( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM );
// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal.
// M should be the inverse transpose of the transformation desired.
D3DXPLANE* WINAPI D3DXPlaneTransformArray
( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n );
#ifdef __cplusplus
}
#endif
//--------------------------
// Color
//--------------------------
// inline
// (1-r, 1-g, 1-b, a)
D3DXCOLOR* D3DXColorNegative
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC);
D3DXCOLOR* D3DXColorAdd
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
D3DXCOLOR* D3DXColorSubtract
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
D3DXCOLOR* D3DXColorScale
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s);
// (r1*r2, g1*g2, b1*b2, a1*a2)
D3DXCOLOR* D3DXColorModulate
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
// Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
D3DXCOLOR* D3DXColorLerp
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s);
// non-inline
#ifdef __cplusplus
extern "C" {
#endif
// Interpolate r,g,b between desaturated color and color.
// DesaturatedColor + s(Color - DesaturatedColor)
D3DXCOLOR* WINAPI D3DXColorAdjustSaturation
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s);
// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey)
D3DXCOLOR* WINAPI D3DXColorAdjustContrast
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c);
#ifdef __cplusplus
}
#endif
//--------------------------
// Misc
//--------------------------
#ifdef __cplusplus
extern "C" {
#endif
// Calculate Fresnel term given the cosine of theta (likely obtained by
// taking the dot of two normals), and the refraction index of the material.
FLOAT WINAPI D3DXFresnelTerm
(FLOAT CosTheta, FLOAT RefractionIndex);
#ifdef __cplusplus
}
#endif
//===========================================================================
//
// Matrix Stack
//
//===========================================================================
typedef interface ID3DXMatrixStack ID3DXMatrixStack;
typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK;
// {C7885BA7-F990-4fe7-922D-8515E477DD85}
DEFINE_GUID(IID_ID3DXMatrixStack,
0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85);
#undef INTERFACE
#define INTERFACE ID3DXMatrixStack
DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown)
{
//
// IUnknown methods
//
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
//
// ID3DXMatrixStack methods
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -