home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Include / d3dxmath.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  32.7 KB  |  1,093 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4. //
  5. //  File:       d3dxmath.h
  6. //  Content:    D3DX math types and functions
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9.  
  10. #ifndef __D3DXMATH_H__
  11. #define __D3DXMATH_H__
  12.  
  13. #include <d3d.h>
  14. #include <math.h>
  15. #include <limits.h>
  16. #include "d3dxerr.h"
  17.  
  18. #ifndef D3DXINLINE
  19. #ifdef __cplusplus
  20. #define D3DXINLINE inline
  21. #else
  22. #define D3DXINLINE _inline
  23. #endif
  24. #endif
  25.  
  26. #if _MSC_VER >= 1200
  27. #pragma warning(push)
  28. #endif
  29. #pragma warning(disable:4201) // anonymous unions warning
  30.  
  31.  
  32.  
  33. typedef struct ID3DXMatrixStack *LPD3DXMATRIXSTACK;
  34.  
  35. // {E3357330-CC5E-11d2-A434-00A0C90629A8}
  36. DEFINE_GUID( IID_ID3DXMatrixStack,
  37.              0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
  38.  
  39.  
  40. //===========================================================================
  41. //
  42. // General purpose utilities
  43. //
  44. //===========================================================================
  45. #define D3DX_PI    ((float)  3.141592654f)
  46. #define D3DX_1BYPI ((float)  0.318309886f)
  47.  
  48. #define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
  49. #define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
  50.  
  51.  
  52.  
  53. //===========================================================================
  54. //
  55. // Vectors
  56. //
  57. //===========================================================================
  58.  
  59. //--------------------------
  60. // 2D Vector
  61. //--------------------------
  62. typedef struct D3DXVECTOR2
  63. {
  64. #ifdef __cplusplus
  65. public:
  66.     D3DXVECTOR2() {};
  67.     D3DXVECTOR2( const float * );
  68.     D3DXVECTOR2( float x, float y );
  69.  
  70.     // casting
  71.     operator float* ();
  72.     operator const float* () const;
  73.  
  74.     // assignment operators
  75.     D3DXVECTOR2& operator += ( const D3DXVECTOR2& );
  76.     D3DXVECTOR2& operator -= ( const D3DXVECTOR2& );
  77.     D3DXVECTOR2& operator *= ( float );
  78.     D3DXVECTOR2& operator /= ( float );
  79.  
  80.     // unary operators
  81.     D3DXVECTOR2 operator + () const;
  82.     D3DXVECTOR2 operator - () const;
  83.  
  84.     // binary operators
  85.     D3DXVECTOR2 operator + ( const D3DXVECTOR2& ) const;
  86.     D3DXVECTOR2 operator - ( const D3DXVECTOR2& ) const;
  87.     D3DXVECTOR2 operator * ( float ) const;
  88.     D3DXVECTOR2 operator / ( float ) const;
  89.  
  90.     friend D3DXVECTOR2 operator * ( float, const D3DXVECTOR2& );
  91.  
  92.     BOOL operator == ( const D3DXVECTOR2& ) const;
  93.     BOOL operator != ( const D3DXVECTOR2& ) const;
  94.  
  95.  
  96. public:
  97. #endif //__cplusplus
  98.     float x, y;
  99. } D3DXVECTOR2, *LPD3DXVECTOR2;
  100.  
  101.  
  102. //--------------------------
  103. // 3D Vector
  104. //--------------------------
  105. typedef struct D3DXVECTOR3
  106. {
  107. #ifdef __cplusplus
  108. public:
  109.     D3DXVECTOR3() {};
  110.     D3DXVECTOR3( const float * );
  111.     D3DXVECTOR3( const D3DVECTOR& );
  112.     D3DXVECTOR3( float x, float y, float z );
  113.  
  114.     // casting
  115.     operator float* ();
  116.     operator const float* () const;
  117.  
  118.     operator D3DVECTOR* ();
  119.     operator const D3DVECTOR* () const;
  120.  
  121.     operator D3DVECTOR& ();
  122.     operator const D3DVECTOR& () const;
  123.  
  124.     // assignment operators
  125.     D3DXVECTOR3& operator += ( const D3DXVECTOR3& );
  126.     D3DXVECTOR3& operator -= ( const D3DXVECTOR3& );
  127.     D3DXVECTOR3& operator *= ( float );
  128.     D3DXVECTOR3& operator /= ( float );
  129.  
  130.     // unary operators
  131.     D3DXVECTOR3 operator + () const;
  132.     D3DXVECTOR3 operator - () const;
  133.  
  134.     // binary operators
  135.     D3DXVECTOR3 operator + ( const D3DXVECTOR3& ) const;
  136.     D3DXVECTOR3 operator - ( const D3DXVECTOR3& ) const;
  137.     D3DXVECTOR3 operator * ( float ) const;
  138.     D3DXVECTOR3 operator / ( float ) const;
  139.  
  140.     friend D3DXVECTOR3 operator * ( float, const struct D3DXVECTOR3& );
  141.  
  142.     BOOL operator == ( const D3DXVECTOR3& ) const;
  143.     BOOL operator != ( const D3DXVECTOR3& ) const;
  144.  
  145. public:
  146. #endif //__cplusplus
  147.     float x, y, z;
  148. } D3DXVECTOR3, *LPD3DXVECTOR3;
  149.  
  150.  
  151. //--------------------------
  152. // 4D Vector
  153. //--------------------------
  154. typedef struct D3DXVECTOR4
  155. {
  156. #ifdef __cplusplus
  157. public:
  158.     D3DXVECTOR4() {};
  159.     D3DXVECTOR4( const float* );
  160.     D3DXVECTOR4( float x, float y, float z, float w );
  161.  
  162.     // casting
  163.     operator float* ();
  164.     operator const float* () const;
  165.  
  166.     // assignment operators
  167.     D3DXVECTOR4& operator += ( const D3DXVECTOR4& );
  168.     D3DXVECTOR4& operator -= ( const D3DXVECTOR4& );
  169.     D3DXVECTOR4& operator *= ( float );
  170.     D3DXVECTOR4& operator /= ( float );
  171.  
  172.     // unary operators
  173.     D3DXVECTOR4 operator + () const;
  174.     D3DXVECTOR4 operator - () const;
  175.  
  176.     // binary operators
  177.     D3DXVECTOR4 operator + ( const D3DXVECTOR4& ) const;
  178.     D3DXVECTOR4 operator - ( const D3DXVECTOR4& ) const;
  179.     D3DXVECTOR4 operator * ( float ) const;
  180.     D3DXVECTOR4 operator / ( float ) const;
  181.  
  182.     friend D3DXVECTOR4 operator * ( float, const D3DXVECTOR4& );
  183.  
  184.     BOOL operator == ( const D3DXVECTOR4& ) const;
  185.     BOOL operator != ( const D3DXVECTOR4& ) const;
  186.  
  187. public:
  188. #endif //__cplusplus
  189.     float x, y, z, w;
  190. } D3DXVECTOR4, *LPD3DXVECTOR4;
  191.  
  192.  
  193. //===========================================================================
  194. //
  195. // Matrices
  196. //
  197. //===========================================================================
  198. typedef struct D3DXMATRIX
  199. {
  200. #ifdef __cplusplus
  201. public:
  202.     D3DXMATRIX() {};
  203.     D3DXMATRIX( const float * );
  204.     D3DXMATRIX( const D3DMATRIX& );
  205.     D3DXMATRIX( float m00, float m01, float m02, float m03,
  206.                 float m10, float m11, float m12, float m13,
  207.                 float m20, float m21, float m22, float m23,
  208.                 float m30, float m31, float m32, float m33 );
  209.  
  210.  
  211.     // access grants
  212.     float& operator () ( UINT iRow, UINT iCol );
  213.     float  operator () ( UINT iRow, UINT iCol ) const;
  214.  
  215.     // casting operators
  216.     operator float* ();
  217.     operator const float* () const;
  218.  
  219.     operator D3DMATRIX* ();
  220.     operator const D3DMATRIX* () const;
  221.  
  222.     operator D3DMATRIX& ();
  223.     operator const D3DMATRIX& () const;
  224.  
  225.     // assignment operators
  226.     D3DXMATRIX& operator *= ( const D3DXMATRIX& );
  227.     D3DXMATRIX& operator += ( const D3DXMATRIX& );
  228.     D3DXMATRIX& operator -= ( const D3DXMATRIX& );
  229.     D3DXMATRIX& operator *= ( float );
  230.     D3DXMATRIX& operator /= ( float );
  231.  
  232.     // unary operators
  233.     D3DXMATRIX operator + () const;
  234.     D3DXMATRIX operator - () const;
  235.  
  236.     // binary operators
  237.     D3DXMATRIX operator * ( const D3DXMATRIX& ) const;
  238.     D3DXMATRIX operator + ( const D3DXMATRIX& ) const;
  239.     D3DXMATRIX operator - ( const D3DXMATRIX& ) const;
  240.     D3DXMATRIX operator * ( float ) const;
  241.     D3DXMATRIX operator / ( float ) const;
  242.  
  243.     friend D3DXMATRIX operator * ( float, const D3DXMATRIX& );
  244.  
  245.     BOOL operator == ( const D3DXMATRIX& ) const;
  246.     BOOL operator != ( const D3DXMATRIX& ) const;
  247.  
  248.  
  249. #endif //__cplusplus
  250.  
  251.     union
  252.     {
  253.         float m[4][4];
  254. #ifdef __cplusplus
  255.         struct
  256.         {
  257.             float m00, m01, m02, m03;
  258.             float m10, m11, m12, m13;
  259.             float m20, m21, m22, m23;
  260.             float m30, m31, m32, m33;
  261.         };
  262. #endif //__cplusplus
  263.     };
  264. } D3DXMATRIX, *LPD3DXMATRIX;
  265.  
  266.  
  267. //===========================================================================
  268. //
  269. //    Quaternions
  270. //
  271. //===========================================================================
  272. typedef struct D3DXQUATERNION
  273. {
  274. #ifdef __cplusplus
  275. public:
  276.     D3DXQUATERNION() {}
  277.     D3DXQUATERNION( const float * );
  278.     D3DXQUATERNION( float x, float y, float z, float w );
  279.  
  280.     // casting
  281.     operator float* ();
  282.     operator const float* () const;
  283.  
  284.     // assignment operators
  285.     D3DXQUATERNION& operator += ( const D3DXQUATERNION& );
  286.     D3DXQUATERNION& operator -= ( const D3DXQUATERNION& );
  287.     D3DXQUATERNION& operator *= ( const D3DXQUATERNION& );
  288.     D3DXQUATERNION& operator *= ( float );
  289.     D3DXQUATERNION& operator /= ( float );
  290.  
  291.     // unary operators
  292.     D3DXQUATERNION  operator + () const;
  293.     D3DXQUATERNION  operator - () const;
  294.  
  295.     // binary operators
  296.     D3DXQUATERNION operator + ( const D3DXQUATERNION& ) const;
  297.     D3DXQUATERNION operator - ( const D3DXQUATERNION& ) const;
  298.     D3DXQUATERNION operator * ( const D3DXQUATERNION& ) const;
  299.     D3DXQUATERNION operator * ( float ) const;
  300.     D3DXQUATERNION operator / ( float ) const;
  301.  
  302.     friend D3DXQUATERNION operator * (float, const D3DXQUATERNION& );
  303.  
  304.     BOOL operator == ( const D3DXQUATERNION& ) const;
  305.     BOOL operator != ( const D3DXQUATERNION& ) const;
  306.  
  307. #endif //__cplusplus
  308.     float x, y, z, w;
  309. } D3DXQUATERNION, *LPD3DXQUATERNION;
  310.  
  311.  
  312. //===========================================================================
  313. //
  314. // Planes
  315. //
  316. //===========================================================================
  317. typedef struct D3DXPLANE
  318. {
  319. #ifdef __cplusplus
  320. public:
  321.     D3DXPLANE() {}
  322.     D3DXPLANE( const float* );
  323.     D3DXPLANE( float a, float b, float c, float d );
  324.  
  325.     // casting
  326.     operator float* ();
  327.     operator const float* () const;
  328.  
  329.     // unary operators
  330.     D3DXPLANE operator + () const;
  331.     D3DXPLANE operator - () const;
  332.  
  333.     // binary operators
  334.     BOOL operator == ( const D3DXPLANE& ) const;
  335.     BOOL operator != ( const D3DXPLANE& ) const;
  336.  
  337. #endif //__cplusplus
  338.     float a, b, c, d;
  339. } D3DXPLANE, *LPD3DXPLANE;
  340.  
  341.  
  342. //===========================================================================
  343. //
  344. // Colors
  345. //
  346. //===========================================================================
  347.  
  348. typedef struct D3DXCOLOR
  349. {
  350. #ifdef __cplusplus
  351. public:
  352.     D3DXCOLOR() {}
  353.     D3DXCOLOR( DWORD argb );
  354.     D3DXCOLOR( const float * );
  355.     D3DXCOLOR( const D3DCOLORVALUE& );
  356.     D3DXCOLOR( float r, float g, float b, float a );
  357.  
  358.     // casting
  359.     operator DWORD () const;
  360.  
  361.     operator float* ();
  362.     operator const float* () const;
  363.  
  364.     operator D3DCOLORVALUE* ();
  365.     operator const D3DCOLORVALUE* () const;
  366.  
  367.     operator D3DCOLORVALUE& ();
  368.     operator const D3DCOLORVALUE& () const;
  369.  
  370.     // assignment operators
  371.     D3DXCOLOR& operator += ( const D3DXCOLOR& );
  372.     D3DXCOLOR& operator -= ( const D3DXCOLOR& );
  373.     D3DXCOLOR& operator *= ( float );
  374.     D3DXCOLOR& operator /= ( float );
  375.  
  376.     // unary operators
  377.     D3DXCOLOR operator + () const;
  378.     D3DXCOLOR operator - () const;
  379.  
  380.     // binary operators
  381.     D3DXCOLOR operator + ( const D3DXCOLOR& ) const;
  382.     D3DXCOLOR operator - ( const D3DXCOLOR& ) const;
  383.     D3DXCOLOR operator * ( float ) const;
  384.     D3DXCOLOR operator / ( float ) const;
  385.  
  386.     friend D3DXCOLOR operator * (float, const D3DXCOLOR& );
  387.  
  388.     BOOL operator == ( const D3DXCOLOR& ) const;
  389.     BOOL operator != ( const D3DXCOLOR& ) const;
  390.  
  391. #endif //__cplusplus
  392.     FLOAT r, g, b, a;
  393. } D3DXCOLOR, *LPD3DXCOLOR;
  394.  
  395.  
  396.  
  397. //===========================================================================
  398. //
  399. // D3DX math functions:
  400. //
  401. // NOTE:
  402. //  * All these functions can take the same object as in and out parameters.
  403. //
  404. //  * Out parameters are typically also returned as return values, so that
  405. //    the output of one function may be used as a parameter to another.
  406. //
  407. //===========================================================================
  408.  
  409. //--------------------------
  410. // 2D Vector
  411. //--------------------------
  412.  
  413. // inline
  414.  
  415. float D3DXVec2Length
  416.     ( const D3DXVECTOR2 *pV );
  417.  
  418. float D3DXVec2LengthSq
  419.     ( const D3DXVECTOR2 *pV );
  420.  
  421. float D3DXVec2Dot
  422.     ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  423.  
  424. // Z component of ((x1,y1,0) cross (x2,y2,0))
  425. float D3DXVec2CCW
  426.     ( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  427.  
  428. D3DXVECTOR2* D3DXVec2Add
  429.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  430.  
  431. D3DXVECTOR2* D3DXVec2Subtract
  432.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  433.  
  434. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  435. D3DXVECTOR2* D3DXVec2Minimize
  436.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  437.  
  438. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  439. D3DXVECTOR2* D3DXVec2Maximize
  440.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );
  441.  
  442. D3DXVECTOR2* D3DXVec2Scale
  443.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, float s );
  444.  
  445. // Linear interpolation. V1 + s(V2-V1)
  446. D3DXVECTOR2* D3DXVec2Lerp
  447.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2,
  448.       float s );
  449.  
  450. // non-inline
  451. #ifdef __cplusplus
  452. extern "C" {
  453. #endif
  454.  
  455. D3DXVECTOR2* WINAPI D3DXVec2Normalize
  456.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV );
  457.  
  458. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  459. // and position V2, tangent T2 (when s == 1).
  460. D3DXVECTOR2* WINAPI D3DXVec2Hermite
  461.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pT1,
  462.       const D3DXVECTOR2 *pV2, const D3DXVECTOR2 *pT2, float s );
  463.  
  464. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  465. D3DXVECTOR2* WINAPI D3DXVec2BaryCentric
  466.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2,
  467.       D3DXVECTOR2 *pV3, float f, float g);
  468.  
  469. // Transform (x, y, 0, 1) by matrix.
  470. D3DXVECTOR4* WINAPI D3DXVec2Transform
  471.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );
  472.  
  473. // Transform (x, y, 0, 1) by matrix, project result back into w=1.
  474. D3DXVECTOR2* WINAPI D3DXVec2TransformCoord
  475.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );
  476.  
  477. // Transform (x, y, 0, 0) by matrix.
  478. D3DXVECTOR2* WINAPI D3DXVec2TransformNormal
  479.     ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );
  480.  
  481. #ifdef __cplusplus
  482. }
  483. #endif
  484.  
  485.  
  486. //--------------------------
  487. // 3D Vector
  488. //--------------------------
  489.  
  490. // inline
  491.  
  492. float D3DXVec3Length
  493.     ( const D3DXVECTOR3 *pV );
  494.  
  495. float D3DXVec3LengthSq
  496.     ( const D3DXVECTOR3 *pV );
  497.  
  498. float D3DXVec3Dot
  499.     ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  500.  
  501. D3DXVECTOR3* D3DXVec3Cross
  502.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  503.  
  504. D3DXVECTOR3* D3DXVec3Add
  505.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  506.  
  507. D3DXVECTOR3* D3DXVec3Subtract
  508.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  509.  
  510. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  511. D3DXVECTOR3* D3DXVec3Minimize
  512.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  513.  
  514. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  515. D3DXVECTOR3* D3DXVec3Maximize
  516.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );
  517.  
  518. D3DXVECTOR3* D3DXVec3Scale
  519.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, float s);
  520.  
  521. // Linear interpolation. V1 + s(V2-V1)
  522. D3DXVECTOR3* D3DXVec3Lerp
  523.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
  524.       float s );
  525.  
  526. // non-inline
  527. #ifdef __cplusplus
  528. extern "C" {
  529. #endif
  530.  
  531. D3DXVECTOR3* WINAPI D3DXVec3Normalize
  532.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV );
  533.  
  534. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  535. // and position V2, tangent T2 (when s == 1).
  536. D3DXVECTOR3* WINAPI D3DXVec3Hermite
  537.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pT1,
  538.       const D3DXVECTOR3 *pV2, const D3DXVECTOR3 *pT2, float s );
  539.  
  540. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  541. D3DXVECTOR3* WINAPI D3DXVec3BaryCentric
  542.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
  543.       const D3DXVECTOR3 *pV3, float f, float g);
  544.  
  545. // Transform (x, y, z, 1) by matrix.
  546. D3DXVECTOR4* WINAPI D3DXVec3Transform
  547.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );
  548.  
  549. // Transform (x, y, z, 1) by matrix, project result back into w=1.
  550. D3DXVECTOR3* WINAPI D3DXVec3TransformCoord
  551.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );
  552.  
  553. // Transform (x, y, z, 0) by matrix.
  554. D3DXVECTOR3* WINAPI D3DXVec3TransformNormal
  555.     ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );
  556.  
  557. #ifdef __cplusplus
  558. }
  559. #endif
  560.  
  561.  
  562.  
  563. //--------------------------
  564. // 4D Vector
  565. //--------------------------
  566.  
  567. // inline
  568.  
  569. float D3DXVec4Length
  570.     ( const D3DXVECTOR4 *pV );
  571.  
  572. float D3DXVec4LengthSq
  573.     ( const D3DXVECTOR4 *pV );
  574.  
  575. float D3DXVec4Dot
  576.     ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 );
  577.  
  578. D3DXVECTOR4* D3DXVec4Add
  579.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);
  580.  
  581. D3DXVECTOR4* D3DXVec4Subtract
  582.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);
  583.  
  584. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  585. D3DXVECTOR4* D3DXVec4Minimize
  586.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);
  587.  
  588. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  589. D3DXVECTOR4* D3DXVec4Maximize
  590.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);
  591.  
  592. D3DXVECTOR4* D3DXVec4Scale
  593.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, float s);
  594.  
  595. // Linear interpolation. V1 + s(V2-V1)
  596. D3DXVECTOR4* D3DXVec4Lerp
  597.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
  598.       float s );
  599.  
  600. // non-inline
  601. #ifdef __cplusplus
  602. extern "C" {
  603. #endif
  604.  
  605. // Cross-product in 4 dimensions.
  606. D3DXVECTOR4* WINAPI D3DXVec4Cross
  607.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
  608.       const D3DXVECTOR4 *pV3);
  609.  
  610. D3DXVECTOR4* WINAPI D3DXVec4Normalize
  611.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV );
  612.  
  613. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  614. // and position V2, tangent T2 (when s == 1).
  615. D3DXVECTOR4* WINAPI D3DXVec4Hermite
  616.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pT1,
  617.       const D3DXVECTOR4 *pV2, const D3DXVECTOR4 *pT2, float s );
  618.  
  619. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  620. D3DXVECTOR4* WINAPI D3DXVec4BaryCentric
  621.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
  622.       const D3DXVECTOR4 *pV3, float f, float g);
  623.  
  624. // Transform vector by matrix.
  625. D3DXVECTOR4* WINAPI D3DXVec4Transform
  626.     ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, const D3DXMATRIX *pM );
  627.  
  628. #ifdef __cplusplus
  629. }
  630. #endif
  631.  
  632.  
  633. //--------------------------
  634. // 4D Matrix
  635. //--------------------------
  636.  
  637. // inline
  638.  
  639. D3DXMATRIX* D3DXMatrixIdentity
  640.     ( D3DXMATRIX *pOut );
  641.  
  642. BOOL D3DXMatrixIsIdentity
  643.     ( const D3DXMATRIX *pM );
  644.  
  645.  
  646. // non-inline
  647. #ifdef __cplusplus
  648. extern "C" {
  649. #endif
  650.  
  651. float WINAPI D3DXMatrixfDeterminant
  652.     ( const D3DXMATRIX *pM );
  653.  
  654. // Matrix multiplication.  The result represents the transformation M2 
  655. // followed by the transformation M1.  (Out = M1 * M2)
  656. D3DXMATRIX* WINAPI D3DXMatrixMultiply
  657.     ( D3DXMATRIX *pOut, const D3DXMATRIX *pM1, const D3DXMATRIX *pM2 );
  658.  
  659. D3DXMATRIX* WINAPI D3DXMatrixTranspose
  660.     ( D3DXMATRIX *pOut, const D3DXMATRIX *pM );
  661.  
  662. // Calculate inverse of matrix.  Inversion my fail, in which case NULL will
  663. // be returned.  The determinant of pM is also returned it pfDeterminant
  664. // is non-NULL.
  665. D3DXMATRIX* WINAPI D3DXMatrixInverse
  666.     ( D3DXMATRIX *pOut, float *pfDeterminant, const D3DXMATRIX *pM );
  667.  
  668. // Build a matrix which scales by (sx, sy, sz)
  669. D3DXMATRIX* WINAPI D3DXMatrixScaling
  670.     ( D3DXMATRIX *pOut, float sx, float sy, float sz );
  671.  
  672. // Build a matrix which translates by (x, y, z)
  673. D3DXMATRIX* WINAPI D3DXMatrixTranslation
  674.     ( D3DXMATRIX *pOut, float x, float y, float z );
  675.  
  676. // Build a matrix which rotates around the X axis
  677. D3DXMATRIX* WINAPI D3DXMatrixRotationX
  678.     ( D3DXMATRIX *pOut, float angle );
  679.  
  680. // Build a matrix which rotates around the Y axis
  681. D3DXMATRIX* WINAPI D3DXMatrixRotationY
  682.     ( D3DXMATRIX *pOut, float angle );
  683.  
  684. // Build a matrix which rotates around the Z axis
  685. D3DXMATRIX* WINAPI D3DXMatrixRotationZ
  686.     ( D3DXMATRIX *pOut, float angle );
  687.  
  688. // Build a matrix which rotates around an arbitrary axis
  689. D3DXMATRIX* WINAPI D3DXMatrixRotationAxis
  690.     ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pV, float angle );
  691.  
  692. // Build a matrix from a quaternion
  693. D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion
  694.     ( D3DXMATRIX *pOut, const D3DXQUATERNION *pQ);
  695.  
  696. // Yaw around the Y axis, a pitch around the X axis,
  697. // and a roll around the Z axis.
  698. D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll
  699.     ( D3DXMATRIX *pOut, float yaw, float pitch, float roll );
  700.  
  701.  
  702. // Build transformation matrix.  NULL arguments are treated as identity.
  703. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
  704. D3DXMATRIX* WINAPI D3DXMatrixTransformation
  705.     ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pScalingCenter,
  706.       const D3DXQUATERNION *pScalingRotation, const D3DXVECTOR3 *pScaling,
  707.       const D3DXVECTOR3 *pRotationCenter, const D3DXQUATERNION *pRotation,
  708.       const D3DXVECTOR3 *pTranslation);
  709.  
  710. // Build affine transformation matrix.  NULL arguments are treated as identity.
  711. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt
  712. D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation
  713.     ( D3DXMATRIX *pOut, float Scaling, const D3DXVECTOR3 *pRotationCenter,
  714.       const D3DXQUATERNION *pRotation, const D3DXVECTOR3 *pTranslation);
  715.  
  716. // Build a lookat matrix. (right-handed)
  717. D3DXMATRIX* WINAPI D3DXMatrixLookAt
  718.     ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt,
  719.       const D3DXVECTOR3 *pUp );
  720.  
  721. // Build a lookat matrix. (left-handed)
  722. D3DXMATRIX* WINAPI D3DXMatrixLookAtLH
  723.     ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt,
  724.       const D3DXVECTOR3 *pUp );
  725.  
  726. // Build a perspective projection matrix. (right-handed)
  727. D3DXMATRIX* WINAPI D3DXMatrixPerspective
  728.     ( D3DXMATRIX *pOut, float w, float h, float zn, float zf );
  729.  
  730. // Build a perspective projection matrix. (left-handed)
  731. D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH
  732.     ( D3DXMATRIX *pOut, float w, float h, float zn, float zf );
  733.  
  734. // Build a perspective projection matrix. (right-handed)
  735. D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFov
  736.     ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf );
  737.  
  738. // Build a perspective projection matrix. (left-handed)
  739. D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH
  740.     ( D3DXMATRIX *pOut, float fovy, float aspect, float zn, float zf );
  741.  
  742. // Build a perspective projection matrix. (right-handed)
  743. D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenter
  744.     ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn,
  745.       float zf );
  746.  
  747. // Build a perspective projection matrix. (left-handed)
  748. D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH
  749.     ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn,
  750.       float zf );
  751.  
  752. // Build an ortho projection matrix. (right-handed)
  753. D3DXMATRIX* WINAPI D3DXMatrixOrtho
  754.     ( D3DXMATRIX *pOut, float w, float h, float zn, float zf );
  755.  
  756. // Build an ortho projection matrix. (left-handed)
  757. D3DXMATRIX* WINAPI D3DXMatrixOrthoLH
  758.     ( D3DXMATRIX *pOut, float w, float h, float zn, float zf );
  759.  
  760. // Build an ortho projection matrix. (right-handed)
  761. D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenter
  762.     ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn,
  763.       float zf );
  764.  
  765. // Build an ortho projection matrix. (left-handed)
  766. D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH
  767.     ( D3DXMATRIX *pOut, float l, float r, float b, float t, float zn,
  768.       float zf );
  769.  
  770. // Build a matrix which flattens geometry into a plane, as if casting
  771. // a shadow from a light.
  772. D3DXMATRIX* WINAPI D3DXMatrixShadow
  773.     ( D3DXMATRIX *pOut, const D3DXVECTOR4 *pLight,
  774.       const D3DXPLANE *pPlane );
  775.  
  776. // Build a matrix which reflects the coordinate system about a plane
  777. D3DXMATRIX* WINAPI D3DXMatrixReflect
  778.     ( D3DXMATRIX *pOut, const D3DXPLANE *pPlane );
  779.  
  780. #ifdef __cplusplus
  781. }
  782. #endif
  783.  
  784.  
  785. //--------------------------
  786. // Quaternion
  787. //--------------------------
  788.  
  789. // inline
  790.  
  791. float D3DXQuaternionLength
  792.     ( const D3DXQUATERNION *pQ );
  793.  
  794. // Length squared, or "norm"
  795. float D3DXQuaternionLengthSq
  796.     ( const D3DXQUATERNION *pQ );
  797.  
  798. float D3DXQuaternionDot
  799.     ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 );
  800.  
  801. // (0, 0, 0, 1)
  802. D3DXQUATERNION* D3DXQuaternionIdentity
  803.     ( D3DXQUATERNION *pOut );
  804.  
  805. BOOL D3DXQuaternionIsIdentity
  806.     ( const D3DXQUATERNION *pQ );
  807.  
  808. // (-x, -y, -z, w)
  809. D3DXQUATERNION* D3DXQuaternionConjugate
  810.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
  811.  
  812.  
  813. // non-inline
  814. #ifdef __cplusplus
  815. extern "C" {
  816. #endif
  817.  
  818. // Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
  819. void WINAPI D3DXQuaternionToAxisAngle
  820.     ( const D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, float *pAngle );
  821.  
  822. // Build a quaternion from a rotation matrix.
  823. D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix
  824.     ( D3DXQUATERNION *pOut, const D3DXMATRIX *pM);
  825.  
  826. // Rotation about arbitrary axis.
  827. D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis
  828.     ( D3DXQUATERNION *pOut, const D3DXVECTOR3 *pV, float angle );
  829.  
  830. // Yaw around the Y axis, a pitch around the X axis,
  831. // and a roll around the Z axis.
  832. D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll
  833.     ( D3DXQUATERNION *pOut, float yaw, float pitch, float roll );
  834.  
  835. // Quaternion multiplication.  The result represents the rotation Q2 
  836. // followed by the rotation Q1.  (Out = Q2 * Q1)
  837. D3DXQUATERNION* WINAPI D3DXQuaternionMultiply
  838.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
  839.       const D3DXQUATERNION *pQ2 );
  840.  
  841. D3DXQUATERNION* WINAPI D3DXQuaternionNormalize
  842.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
  843.  
  844. // Conjugate and re-norm
  845. D3DXQUATERNION* WINAPI D3DXQuaternionInverse
  846.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
  847.  
  848. // Expects unit quaternions.
  849. // if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
  850. D3DXQUATERNION* WINAPI D3DXQuaternionLn
  851.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
  852.  
  853. // Expects pure quaternions. (w == 0)  w is ignored in calculation.
  854. // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
  855. D3DXQUATERNION* WINAPI D3DXQuaternionExp
  856.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
  857.  
  858. // Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1).
  859. // Expects unit quaternions.
  860. D3DXQUATERNION* WINAPI D3DXQuaternionSlerp
  861.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
  862.       const D3DXQUATERNION *pQ2, float t );
  863.  
  864. // Spherical quadrangle interpolation.
  865. // Slerp(Slerp(Q1, Q4, t), Slerp(Q2, Q3, t), 2t(1-t))
  866. D3DXQUATERNION* WINAPI D3DXQuaternionSquad
  867.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
  868.       const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3,
  869.       const D3DXQUATERNION *pQ4, float t );
  870.  
  871. // Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
  872. D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric
  873.     ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
  874.       const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3,
  875.       float f, float g );
  876.  
  877. #ifdef __cplusplus
  878. }
  879. #endif
  880.  
  881.  
  882. //--------------------------
  883. // Plane
  884. //--------------------------
  885.  
  886. // inline
  887.  
  888. // ax + by + cz + dw
  889. float D3DXPlaneDot
  890.     ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV);
  891.  
  892. // ax + by + cz + d
  893. float D3DXPlaneDotCoord
  894.     ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV);
  895.  
  896. // ax + by + cz
  897. float D3DXPlaneDotNormal
  898.     ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV);
  899.  
  900. // non-inline
  901. #ifdef __cplusplus
  902. extern "C" {
  903. #endif
  904.  
  905. // Normalize plane (so that |a,b,c| == 1)
  906. D3DXPLANE* WINAPI D3DXPlaneNormalize
  907.     ( D3DXPLANE *pOut, const D3DXPLANE *pP);
  908.  
  909. // Find the intersection between a plane and a line.  If the line is
  910. // parallel to the plane, NULL is returned.
  911. D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine
  912.     ( D3DXVECTOR3 *pOut, const D3DXPLANE *pP, const D3DXVECTOR3 *pV1,
  913.       const D3DXVECTOR3 *pV2);
  914.  
  915. // Construct a plane from a point and a normal
  916. D3DXPLANE* WINAPI D3DXPlaneFromPointNormal
  917.     ( D3DXPLANE *pOut, const D3DXVECTOR3 *pPoint, const D3DXVECTOR3 *pNormal);
  918.  
  919. // Construct a plane from 3 points
  920. D3DXPLANE* WINAPI D3DXPlaneFromPoints
  921.     ( D3DXPLANE *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
  922.       const D3DXVECTOR3 *pV3);
  923.  
  924. // Transform a plane by a matrix.  The vector (a,b,c) must be normal.
  925. // M must be an affine transform.
  926. D3DXPLANE* WINAPI D3DXPlaneTransform
  927.     ( D3DXPLANE *pOut, const D3DXPLANE *pP, const D3DXMATRIX *pM );
  928.  
  929. #ifdef __cplusplus
  930. }
  931. #endif
  932.  
  933.  
  934. //--------------------------
  935. // Color
  936. //--------------------------
  937.  
  938. // inline
  939.  
  940. // (1-r, 1-g, 1-b, a)
  941. D3DXCOLOR* D3DXColorNegative
  942.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC);
  943.  
  944. D3DXCOLOR* D3DXColorAdd
  945.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);
  946.  
  947. D3DXCOLOR* D3DXColorSubtract
  948.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);
  949.  
  950. D3DXCOLOR* D3DXColorScale
  951.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s);
  952.  
  953. // (r1*r2, g1*g2, b1*b2, a1*a2)
  954. D3DXCOLOR* D3DXColorModulate
  955.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);
  956.  
  957. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  958. D3DXCOLOR* D3DXColorLerp
  959.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, float s);
  960.  
  961. // non-inline
  962. #ifdef __cplusplus
  963. extern "C" {
  964. #endif
  965.  
  966. // Interpolate r,g,b between desaturated color and color.
  967. // DesaturatedColor + s(Color - DesaturatedColor)
  968. D3DXCOLOR* WINAPI D3DXColorAdjustSaturation
  969.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float s);
  970.  
  971. // Interpolate r,g,b between 50% grey and color.  Grey + s(Color - Grey)
  972. D3DXCOLOR* WINAPI D3DXColorAdjustContrast
  973.     (D3DXCOLOR *pOut, const D3DXCOLOR *pC, float c);
  974.  
  975. #ifdef __cplusplus
  976. }
  977. #endif
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984. //===========================================================================
  985. //
  986. //    Matrix Stack
  987. //
  988. //===========================================================================
  989.  
  990. DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown)
  991. {
  992.     //
  993.     // IUnknown methods
  994.     //
  995.     STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  996.     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  997.     STDMETHOD_(ULONG,Release)(THIS) PURE;
  998.  
  999.     //
  1000.     // ID3DXMatrixStack methods
  1001.     //
  1002.  
  1003.     // Pops the top of the stack, returns the current top
  1004.     // *after* popping the top.
  1005.     STDMETHOD(Pop)(THIS) PURE;
  1006.  
  1007.     // Pushes the stack by one, duplicating the current matrix.
  1008.     STDMETHOD(Push)(THIS) PURE;
  1009.  
  1010.     // Loads identity in the current matrix.
  1011.     STDMETHOD(LoadIdentity)(THIS) PURE;
  1012.  
  1013.     // Loads the given matrix into the current matrix
  1014.     STDMETHOD(LoadMatrix)(THIS_ const D3DXMATRIX* pM ) PURE;
  1015.  
  1016.     // Right-Multiplies the given matrix to the current matrix.
  1017.     // (transformation is about the current world origin)
  1018.     STDMETHOD(MultMatrix)(THIS_ const D3DXMATRIX* pM ) PURE;
  1019.  
  1020.     // Left-Multiplies the given matrix to the current matrix
  1021.     // (transformation is about the local origin of the object)
  1022.     STDMETHOD(MultMatrixLocal)(THIS_ const D3DXMATRIX* pM ) PURE;
  1023.  
  1024.     // Right multiply the current matrix with the computed rotation
  1025.     // matrix, counterclockwise about the given axis with the given angle.
  1026.     // (rotation is about the current world origin)
  1027.     STDMETHOD(RotateAxis)
  1028.         (THIS_ const D3DXVECTOR3* pV, float angle) PURE;
  1029.  
  1030.     // Left multiply the current matrix with the computed rotation
  1031.     // matrix, counterclockwise about the given axis with the given angle.
  1032.     // (rotation is about the local origin of the object)
  1033.     STDMETHOD(RotateAxisLocal)
  1034.         (THIS_ const D3DXVECTOR3* pV, float angle) PURE;
  1035.  
  1036.     // Right multiply the current matrix with the computed rotation
  1037.     // matrix. All angles are counterclockwise. (rotation is about the
  1038.     // current world origin)
  1039.  
  1040.     // The rotation is composed of a yaw around the Y axis, a pitch around
  1041.     // the X axis, and a roll around the Z axis.
  1042.     STDMETHOD(RotateYawPitchRoll)
  1043.         (THIS_ float yaw, float pitch, float roll) PURE;
  1044.  
  1045.     // Left multiply the current matrix with the computed rotation
  1046.     // matrix. All angles are counterclockwise. (rotation is about the
  1047.     // local origin of the object)
  1048.  
  1049.     // The rotation is composed of a yaw around the Y axis, a pitch around
  1050.     // the X axis, and a roll around the Z axis.
  1051.     STDMETHOD(RotateYawPitchRollLocal)
  1052.         (THIS_ float yaw, float pitch, float roll) PURE;
  1053.  
  1054.     // Right multiply the current matrix with the computed scale
  1055.     // matrix. (transformation is about the current world origin)
  1056.     STDMETHOD(Scale)(THIS_ float x, float y, float z) PURE;
  1057.  
  1058.     // Left multiply the current matrix with the computed scale
  1059.     // matrix. (transformation is about the local origin of the object)
  1060.     STDMETHOD(ScaleLocal)(THIS_ float x, float y, float z) PURE;
  1061.  
  1062.     // Right multiply the current matrix with the computed translation
  1063.     // matrix. (transformation is about the current world origin)
  1064.     STDMETHOD(Translate)(THIS_ float x, float y, float z ) PURE;
  1065.  
  1066.     // Left multiply the current matrix with the computed translation
  1067.     // matrix. (transformation is about the local origin of the object)
  1068.     STDMETHOD(TranslateLocal)(THIS_ float x, float y, float z) PURE;
  1069.  
  1070.     // Obtain the current matrix at the top of the stack
  1071.     STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE;
  1072. };
  1073.  
  1074. #ifdef __cplusplus
  1075. extern "C" {
  1076. #endif
  1077.  
  1078. HRESULT WINAPI D3DXCreateMatrixStack( DWORD flags, LPD3DXMATRIXSTACK *ppStack );
  1079.  
  1080. #ifdef __cplusplus
  1081. }
  1082. #endif
  1083.  
  1084. #include "d3dxmath.inl"
  1085.  
  1086. #if _MSC_VER >= 1200
  1087. #pragma warning(pop)
  1088. #else
  1089. #pragma warning(default:4201)
  1090. #endif
  1091.  
  1092. #endif // __D3DXMATH_H__
  1093.