/[cvs]/api/include/d3dxmath.h
ViewVC logotype

Annotation of /api/include/d3dxmath.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Jul 1 20:47:59 2001 UTC (22 years, 10 months ago) by bearsoft
Branch point for: lazy, MAIN
File MIME type: text/plain
Initial revision

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

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26