1 |
//////////////////////////////////////////////////////////////////////////////
|
2 |
//
|
3 |
// Copyright (C) 1998 Microsoft Corporation. All Rights Reserved.
|
4 |
//
|
5 |
// File: d3dx8math.inl
|
6 |
// Content: D3DX math inline functions
|
7 |
//
|
8 |
//////////////////////////////////////////////////////////////////////////////
|
9 |
|
10 |
#ifndef __D3DX8MATH_INL__
|
11 |
#define __D3DX8MATH_INL__
|
12 |
|
13 |
|
14 |
//===========================================================================
|
15 |
//
|
16 |
// Inline Class Methods
|
17 |
//
|
18 |
//===========================================================================
|
19 |
|
20 |
#ifdef __cplusplus
|
21 |
|
22 |
//--------------------------
|
23 |
// 2D Vector
|
24 |
//--------------------------
|
25 |
|
26 |
D3DXINLINE
|
27 |
D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf )
|
28 |
{
|
29 |
#ifdef D3DX_DEBUG
|
30 |
if(!pf)
|
31 |
return;
|
32 |
#endif
|
33 |
|
34 |
x = pf[0];
|
35 |
y = pf[1];
|
36 |
}
|
37 |
|
38 |
D3DXINLINE
|
39 |
D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy )
|
40 |
{
|
41 |
x = fx;
|
42 |
y = fy;
|
43 |
}
|
44 |
|
45 |
// casting
|
46 |
D3DXINLINE
|
47 |
D3DXVECTOR2::operator FLOAT* ()
|
48 |
{
|
49 |
return (FLOAT *) &x;
|
50 |
}
|
51 |
|
52 |
D3DXINLINE
|
53 |
D3DXVECTOR2::operator CONST FLOAT* () const
|
54 |
{
|
55 |
return (CONST FLOAT *) &x;
|
56 |
}
|
57 |
|
58 |
// assignment operators
|
59 |
D3DXINLINE D3DXVECTOR2&
|
60 |
D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v )
|
61 |
{
|
62 |
x += v.x;
|
63 |
y += v.y;
|
64 |
return *this;
|
65 |
}
|
66 |
|
67 |
D3DXINLINE D3DXVECTOR2&
|
68 |
D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v )
|
69 |
{
|
70 |
x -= v.x;
|
71 |
y -= v.y;
|
72 |
return *this;
|
73 |
}
|
74 |
|
75 |
D3DXINLINE D3DXVECTOR2&
|
76 |
D3DXVECTOR2::operator *= ( FLOAT f )
|
77 |
{
|
78 |
x *= f;
|
79 |
y *= f;
|
80 |
return *this;
|
81 |
}
|
82 |
|
83 |
D3DXINLINE D3DXVECTOR2&
|
84 |
D3DXVECTOR2::operator /= ( FLOAT f )
|
85 |
{
|
86 |
FLOAT fInv = 1.0f / f;
|
87 |
x *= fInv;
|
88 |
y *= fInv;
|
89 |
return *this;
|
90 |
}
|
91 |
|
92 |
// unary operators
|
93 |
D3DXINLINE D3DXVECTOR2
|
94 |
D3DXVECTOR2::operator + () const
|
95 |
{
|
96 |
return *this;
|
97 |
}
|
98 |
|
99 |
D3DXINLINE D3DXVECTOR2
|
100 |
D3DXVECTOR2::operator - () const
|
101 |
{
|
102 |
return D3DXVECTOR2(-x, -y);
|
103 |
}
|
104 |
|
105 |
// binary operators
|
106 |
D3DXINLINE D3DXVECTOR2
|
107 |
D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const
|
108 |
{
|
109 |
return D3DXVECTOR2(x + v.x, y + v.y);
|
110 |
}
|
111 |
|
112 |
D3DXINLINE D3DXVECTOR2
|
113 |
D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const
|
114 |
{
|
115 |
return D3DXVECTOR2(x - v.x, y - v.y);
|
116 |
}
|
117 |
|
118 |
D3DXINLINE D3DXVECTOR2
|
119 |
D3DXVECTOR2::operator * ( FLOAT f ) const
|
120 |
{
|
121 |
return D3DXVECTOR2(x * f, y * f);
|
122 |
}
|
123 |
|
124 |
D3DXINLINE D3DXVECTOR2
|
125 |
D3DXVECTOR2::operator / ( FLOAT f ) const
|
126 |
{
|
127 |
FLOAT fInv = 1.0f / f;
|
128 |
return D3DXVECTOR2(x * fInv, y * fInv);
|
129 |
}
|
130 |
|
131 |
|
132 |
D3DXINLINE D3DXVECTOR2
|
133 |
operator * ( FLOAT f, CONST D3DXVECTOR2& v )
|
134 |
{
|
135 |
return D3DXVECTOR2(f * v.x, f * v.y);
|
136 |
}
|
137 |
|
138 |
D3DXINLINE BOOL
|
139 |
D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const
|
140 |
{
|
141 |
return x == v.x && y == v.y;
|
142 |
}
|
143 |
|
144 |
D3DXINLINE BOOL
|
145 |
D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const
|
146 |
{
|
147 |
return x != v.x || y != v.y;
|
148 |
}
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
//--------------------------
|
154 |
// 3D Vector
|
155 |
//--------------------------
|
156 |
D3DXINLINE
|
157 |
D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf )
|
158 |
{
|
159 |
#ifdef D3DX_DEBUG
|
160 |
if(!pf)
|
161 |
return;
|
162 |
#endif
|
163 |
|
164 |
x = pf[0];
|
165 |
y = pf[1];
|
166 |
z = pf[2];
|
167 |
}
|
168 |
|
169 |
D3DXINLINE
|
170 |
D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v )
|
171 |
{
|
172 |
x = v.x;
|
173 |
y = v.y;
|
174 |
z = v.z;
|
175 |
}
|
176 |
|
177 |
D3DXINLINE
|
178 |
D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz )
|
179 |
{
|
180 |
x = fx;
|
181 |
y = fy;
|
182 |
z = fz;
|
183 |
}
|
184 |
|
185 |
|
186 |
// casting
|
187 |
D3DXINLINE
|
188 |
D3DXVECTOR3::operator FLOAT* ()
|
189 |
{
|
190 |
return (FLOAT *) &x;
|
191 |
}
|
192 |
|
193 |
D3DXINLINE
|
194 |
D3DXVECTOR3::operator CONST FLOAT* () const
|
195 |
{
|
196 |
return (CONST FLOAT *) &x;
|
197 |
}
|
198 |
|
199 |
|
200 |
// assignment operators
|
201 |
D3DXINLINE D3DXVECTOR3&
|
202 |
D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v )
|
203 |
{
|
204 |
x += v.x;
|
205 |
y += v.y;
|
206 |
z += v.z;
|
207 |
return *this;
|
208 |
}
|
209 |
|
210 |
D3DXINLINE D3DXVECTOR3&
|
211 |
D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v )
|
212 |
{
|
213 |
x -= v.x;
|
214 |
y -= v.y;
|
215 |
z -= v.z;
|
216 |
return *this;
|
217 |
}
|
218 |
|
219 |
D3DXINLINE D3DXVECTOR3&
|
220 |
D3DXVECTOR3::operator *= ( FLOAT f )
|
221 |
{
|
222 |
x *= f;
|
223 |
y *= f;
|
224 |
z *= f;
|
225 |
return *this;
|
226 |
}
|
227 |
|
228 |
D3DXINLINE D3DXVECTOR3&
|
229 |
D3DXVECTOR3::operator /= ( FLOAT f )
|
230 |
{
|
231 |
FLOAT fInv = 1.0f / f;
|
232 |
x *= fInv;
|
233 |
y *= fInv;
|
234 |
z *= fInv;
|
235 |
return *this;
|
236 |
}
|
237 |
|
238 |
|
239 |
// unary operators
|
240 |
D3DXINLINE D3DXVECTOR3
|
241 |
D3DXVECTOR3::operator + () const
|
242 |
{
|
243 |
return *this;
|
244 |
}
|
245 |
|
246 |
D3DXINLINE D3DXVECTOR3
|
247 |
D3DXVECTOR3::operator - () const
|
248 |
{
|
249 |
return D3DXVECTOR3(-x, -y, -z);
|
250 |
}
|
251 |
|
252 |
|
253 |
// binary operators
|
254 |
D3DXINLINE D3DXVECTOR3
|
255 |
D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const
|
256 |
{
|
257 |
return D3DXVECTOR3(x + v.x, y + v.y, z + v.z);
|
258 |
}
|
259 |
|
260 |
D3DXINLINE D3DXVECTOR3
|
261 |
D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const
|
262 |
{
|
263 |
return D3DXVECTOR3(x - v.x, y - v.y, z - v.z);
|
264 |
}
|
265 |
|
266 |
D3DXINLINE D3DXVECTOR3
|
267 |
D3DXVECTOR3::operator * ( FLOAT f ) const
|
268 |
{
|
269 |
return D3DXVECTOR3(x * f, y * f, z * f);
|
270 |
}
|
271 |
|
272 |
D3DXINLINE D3DXVECTOR3
|
273 |
D3DXVECTOR3::operator / ( FLOAT f ) const
|
274 |
{
|
275 |
FLOAT fInv = 1.0f / f;
|
276 |
return D3DXVECTOR3(x * fInv, y * fInv, z * fInv);
|
277 |
}
|
278 |
|
279 |
|
280 |
D3DXINLINE D3DXVECTOR3
|
281 |
operator * ( FLOAT f, CONST struct D3DXVECTOR3& v )
|
282 |
{
|
283 |
return D3DXVECTOR3(f * v.x, f * v.y, f * v.z);
|
284 |
}
|
285 |
|
286 |
|
287 |
D3DXINLINE BOOL
|
288 |
D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const
|
289 |
{
|
290 |
return x == v.x && y == v.y && z == v.z;
|
291 |
}
|
292 |
|
293 |
D3DXINLINE BOOL
|
294 |
D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const
|
295 |
{
|
296 |
return x != v.x || y != v.y || z != v.z;
|
297 |
}
|
298 |
|
299 |
|
300 |
|
301 |
//--------------------------
|
302 |
// 4D Vector
|
303 |
//--------------------------
|
304 |
D3DXINLINE
|
305 |
D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf )
|
306 |
{
|
307 |
#ifdef D3DX_DEBUG
|
308 |
if(!pf)
|
309 |
return;
|
310 |
#endif
|
311 |
|
312 |
x = pf[0];
|
313 |
y = pf[1];
|
314 |
z = pf[2];
|
315 |
w = pf[3];
|
316 |
}
|
317 |
|
318 |
D3DXINLINE
|
319 |
D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw )
|
320 |
{
|
321 |
x = fx;
|
322 |
y = fy;
|
323 |
z = fz;
|
324 |
w = fw;
|
325 |
}
|
326 |
|
327 |
|
328 |
// casting
|
329 |
D3DXINLINE
|
330 |
D3DXVECTOR4::operator FLOAT* ()
|
331 |
{
|
332 |
return (FLOAT *) &x;
|
333 |
}
|
334 |
|
335 |
D3DXINLINE
|
336 |
D3DXVECTOR4::operator CONST FLOAT* () const
|
337 |
{
|
338 |
return (CONST FLOAT *) &x;
|
339 |
}
|
340 |
|
341 |
|
342 |
// assignment operators
|
343 |
D3DXINLINE D3DXVECTOR4&
|
344 |
D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v )
|
345 |
{
|
346 |
x += v.x;
|
347 |
y += v.y;
|
348 |
z += v.z;
|
349 |
w += v.w;
|
350 |
return *this;
|
351 |
}
|
352 |
|
353 |
D3DXINLINE D3DXVECTOR4&
|
354 |
D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v )
|
355 |
{
|
356 |
x -= v.x;
|
357 |
y -= v.y;
|
358 |
z -= v.z;
|
359 |
w -= v.w;
|
360 |
return *this;
|
361 |
}
|
362 |
|
363 |
D3DXINLINE D3DXVECTOR4&
|
364 |
D3DXVECTOR4::operator *= ( FLOAT f )
|
365 |
{
|
366 |
x *= f;
|
367 |
y *= f;
|
368 |
z *= f;
|
369 |
w *= f;
|
370 |
return *this;
|
371 |
}
|
372 |
|
373 |
D3DXINLINE D3DXVECTOR4&
|
374 |
D3DXVECTOR4::operator /= ( FLOAT f )
|
375 |
{
|
376 |
FLOAT fInv = 1.0f / f;
|
377 |
x *= fInv;
|
378 |
y *= fInv;
|
379 |
z *= fInv;
|
380 |
w *= fInv;
|
381 |
return *this;
|
382 |
}
|
383 |
|
384 |
|
385 |
// unary operators
|
386 |
D3DXINLINE D3DXVECTOR4
|
387 |
D3DXVECTOR4::operator + () const
|
388 |
{
|
389 |
return *this;
|
390 |
}
|
391 |
|
392 |
D3DXINLINE D3DXVECTOR4
|
393 |
D3DXVECTOR4::operator - () const
|
394 |
{
|
395 |
return D3DXVECTOR4(-x, -y, -z, -w);
|
396 |
}
|
397 |
|
398 |
|
399 |
// binary operators
|
400 |
D3DXINLINE D3DXVECTOR4
|
401 |
D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const
|
402 |
{
|
403 |
return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w);
|
404 |
}
|
405 |
|
406 |
D3DXINLINE D3DXVECTOR4
|
407 |
D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const
|
408 |
{
|
409 |
return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w);
|
410 |
}
|
411 |
|
412 |
D3DXINLINE D3DXVECTOR4
|
413 |
D3DXVECTOR4::operator * ( FLOAT f ) const
|
414 |
{
|
415 |
return D3DXVECTOR4(x * f, y * f, z * f, w * f);
|
416 |
}
|
417 |
|
418 |
D3DXINLINE D3DXVECTOR4
|
419 |
D3DXVECTOR4::operator / ( FLOAT f ) const
|
420 |
{
|
421 |
FLOAT fInv = 1.0f / f;
|
422 |
return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv);
|
423 |
}
|
424 |
|
425 |
|
426 |
D3DXINLINE D3DXVECTOR4
|
427 |
operator * ( FLOAT f, CONST D3DXVECTOR4& v )
|
428 |
{
|
429 |
return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w);
|
430 |
}
|
431 |
|
432 |
|
433 |
D3DXINLINE BOOL
|
434 |
D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const
|
435 |
{
|
436 |
return x == v.x && y == v.y && z == v.z && w == v.w;
|
437 |
}
|
438 |
|
439 |
D3DXINLINE BOOL
|
440 |
D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const
|
441 |
{
|
442 |
return x != v.x || y != v.y || z != v.z || w != v.w;
|
443 |
}
|
444 |
|
445 |
|
446 |
//--------------------------
|
447 |
// Matrix
|
448 |
//--------------------------
|
449 |
D3DXINLINE
|
450 |
D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf )
|
451 |
{
|
452 |
#ifdef D3DX_DEBUG
|
453 |
if(!pf)
|
454 |
return;
|
455 |
#endif
|
456 |
|
457 |
memcpy(&_11, pf, sizeof(D3DXMATRIX));
|
458 |
}
|
459 |
|
460 |
D3DXINLINE
|
461 |
D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat )
|
462 |
{
|
463 |
memcpy(&_11, &mat, sizeof(D3DXMATRIX));
|
464 |
}
|
465 |
|
466 |
D3DXINLINE
|
467 |
D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14,
|
468 |
FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24,
|
469 |
FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34,
|
470 |
FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 )
|
471 |
{
|
472 |
_11 = f11; _12 = f12; _13 = f13; _14 = f14;
|
473 |
_21 = f21; _22 = f22; _23 = f23; _24 = f24;
|
474 |
_31 = f31; _32 = f32; _33 = f33; _34 = f34;
|
475 |
_41 = f41; _42 = f42; _43 = f43; _44 = f44;
|
476 |
}
|
477 |
|
478 |
|
479 |
|
480 |
// access grants
|
481 |
D3DXINLINE FLOAT&
|
482 |
D3DXMATRIX::operator () ( UINT iRow, UINT iCol )
|
483 |
{
|
484 |
return m[iRow][iCol];
|
485 |
}
|
486 |
|
487 |
D3DXINLINE FLOAT
|
488 |
D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const
|
489 |
{
|
490 |
return m[iRow][iCol];
|
491 |
}
|
492 |
|
493 |
|
494 |
// casting operators
|
495 |
D3DXINLINE
|
496 |
D3DXMATRIX::operator FLOAT* ()
|
497 |
{
|
498 |
return (FLOAT *) &_11;
|
499 |
}
|
500 |
|
501 |
D3DXINLINE
|
502 |
D3DXMATRIX::operator CONST FLOAT* () const
|
503 |
{
|
504 |
return (CONST FLOAT *) &_11;
|
505 |
}
|
506 |
|
507 |
|
508 |
// assignment operators
|
509 |
D3DXINLINE D3DXMATRIX&
|
510 |
D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat )
|
511 |
{
|
512 |
D3DXMatrixMultiply(this, this, &mat);
|
513 |
return *this;
|
514 |
}
|
515 |
|
516 |
D3DXINLINE D3DXMATRIX&
|
517 |
D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat )
|
518 |
{
|
519 |
_11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14;
|
520 |
_21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24;
|
521 |
_31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34;
|
522 |
_41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44;
|
523 |
return *this;
|
524 |
}
|
525 |
|
526 |
D3DXINLINE D3DXMATRIX&
|
527 |
D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat )
|
528 |
{
|
529 |
_11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14;
|
530 |
_21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24;
|
531 |
_31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34;
|
532 |
_41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44;
|
533 |
return *this;
|
534 |
}
|
535 |
|
536 |
D3DXINLINE D3DXMATRIX&
|
537 |
D3DXMATRIX::operator *= ( FLOAT f )
|
538 |
{
|
539 |
_11 *= f; _12 *= f; _13 *= f; _14 *= f;
|
540 |
_21 *= f; _22 *= f; _23 *= f; _24 *= f;
|
541 |
_31 *= f; _32 *= f; _33 *= f; _34 *= f;
|
542 |
_41 *= f; _42 *= f; _43 *= f; _44 *= f;
|
543 |
return *this;
|
544 |
}
|
545 |
|
546 |
D3DXINLINE D3DXMATRIX&
|
547 |
D3DXMATRIX::operator /= ( FLOAT f )
|
548 |
{
|
549 |
FLOAT fInv = 1.0f / f;
|
550 |
_11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv;
|
551 |
_21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv;
|
552 |
_31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv;
|
553 |
_41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv;
|
554 |
return *this;
|
555 |
}
|
556 |
|
557 |
|
558 |
// unary operators
|
559 |
D3DXINLINE D3DXMATRIX
|
560 |
D3DXMATRIX::operator + () const
|
561 |
{
|
562 |
return *this;
|
563 |
}
|
564 |
|
565 |
D3DXINLINE D3DXMATRIX
|
566 |
D3DXMATRIX::operator - () const
|
567 |
{
|
568 |
return D3DXMATRIX(-_11, -_12, -_13, -_14,
|
569 |
-_21, -_22, -_23, -_24,
|
570 |
-_31, -_32, -_33, -_34,
|
571 |
-_41, -_42, -_43, -_44);
|
572 |
}
|
573 |
|
574 |
|
575 |
// binary operators
|
576 |
D3DXINLINE D3DXMATRIX
|
577 |
D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const
|
578 |
{
|
579 |
D3DXMATRIX matT;
|
580 |
D3DXMatrixMultiply(&matT, this, &mat);
|
581 |
return matT;
|
582 |
}
|
583 |
|
584 |
D3DXINLINE D3DXMATRIX
|
585 |
D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const
|
586 |
{
|
587 |
return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14,
|
588 |
_21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24,
|
589 |
_31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34,
|
590 |
_41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44);
|
591 |
}
|
592 |
|
593 |
D3DXINLINE D3DXMATRIX
|
594 |
D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const
|
595 |
{
|
596 |
return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14,
|
597 |
_21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24,
|
598 |
_31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34,
|
599 |
_41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44);
|
600 |
}
|
601 |
|
602 |
D3DXINLINE D3DXMATRIX
|
603 |
D3DXMATRIX::operator * ( FLOAT f ) const
|
604 |
{
|
605 |
return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f,
|
606 |
_21 * f, _22 * f, _23 * f, _24 * f,
|
607 |
_31 * f, _32 * f, _33 * f, _34 * f,
|
608 |
_41 * f, _42 * f, _43 * f, _44 * f);
|
609 |
}
|
610 |
|
611 |
D3DXINLINE D3DXMATRIX
|
612 |
D3DXMATRIX::operator / ( FLOAT f ) const
|
613 |
{
|
614 |
FLOAT fInv = 1.0f / f;
|
615 |
return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv,
|
616 |
_21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv,
|
617 |
_31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv,
|
618 |
_41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv);
|
619 |
}
|
620 |
|
621 |
|
622 |
D3DXINLINE D3DXMATRIX
|
623 |
operator * ( FLOAT f, CONST D3DXMATRIX& mat )
|
624 |
{
|
625 |
return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14,
|
626 |
f * mat._21, f * mat._22, f * mat._23, f * mat._24,
|
627 |
f * mat._31, f * mat._32, f * mat._33, f * mat._34,
|
628 |
f * mat._41, f * mat._42, f * mat._43, f * mat._44);
|
629 |
}
|
630 |
|
631 |
|
632 |
D3DXINLINE BOOL
|
633 |
D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const
|
634 |
{
|
635 |
return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX));
|
636 |
}
|
637 |
|
638 |
D3DXINLINE BOOL
|
639 |
D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const
|
640 |
{
|
641 |
return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX));
|
642 |
}
|
643 |
|
644 |
|
645 |
|
646 |
//--------------------------
|
647 |
// Quaternion
|
648 |
//--------------------------
|
649 |
|
650 |
D3DXINLINE
|
651 |
D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf )
|
652 |
{
|
653 |
#ifdef D3DX_DEBUG
|
654 |
if(!pf)
|
655 |
return;
|
656 |
#endif
|
657 |
|
658 |
x = pf[0];
|
659 |
y = pf[1];
|
660 |
z = pf[2];
|
661 |
w = pf[3];
|
662 |
}
|
663 |
|
664 |
D3DXINLINE
|
665 |
D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw )
|
666 |
{
|
667 |
x = fx;
|
668 |
y = fy;
|
669 |
z = fz;
|
670 |
w = fw;
|
671 |
}
|
672 |
|
673 |
|
674 |
// casting
|
675 |
D3DXINLINE
|
676 |
D3DXQUATERNION::operator FLOAT* ()
|
677 |
{
|
678 |
return (FLOAT *) &x;
|
679 |
}
|
680 |
|
681 |
D3DXINLINE
|
682 |
D3DXQUATERNION::operator CONST FLOAT* () const
|
683 |
{
|
684 |
return (CONST FLOAT *) &x;
|
685 |
}
|
686 |
|
687 |
|
688 |
// assignment operators
|
689 |
D3DXINLINE D3DXQUATERNION&
|
690 |
D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q )
|
691 |
{
|
692 |
x += q.x;
|
693 |
y += q.y;
|
694 |
z += q.z;
|
695 |
w += q.w;
|
696 |
return *this;
|
697 |
}
|
698 |
|
699 |
D3DXINLINE D3DXQUATERNION&
|
700 |
D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q )
|
701 |
{
|
702 |
x -= q.x;
|
703 |
y -= q.y;
|
704 |
z -= q.z;
|
705 |
w -= q.w;
|
706 |
return *this;
|
707 |
}
|
708 |
|
709 |
D3DXINLINE D3DXQUATERNION&
|
710 |
D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q )
|
711 |
{
|
712 |
D3DXQuaternionMultiply(this, this, &q);
|
713 |
return *this;
|
714 |
}
|
715 |
|
716 |
D3DXINLINE D3DXQUATERNION&
|
717 |
D3DXQUATERNION::operator *= ( FLOAT f )
|
718 |
{
|
719 |
x *= f;
|
720 |
y *= f;
|
721 |
z *= f;
|
722 |
w *= f;
|
723 |
return *this;
|
724 |
}
|
725 |
|
726 |
D3DXINLINE D3DXQUATERNION&
|
727 |
D3DXQUATERNION::operator /= ( FLOAT f )
|
728 |
{
|
729 |
FLOAT fInv = 1.0f / f;
|
730 |
x *= fInv;
|
731 |
y *= fInv;
|
732 |
z *= fInv;
|
733 |
w *= fInv;
|
734 |
return *this;
|
735 |
}
|
736 |
|
737 |
|
738 |
// unary operators
|
739 |
D3DXINLINE D3DXQUATERNION
|
740 |
D3DXQUATERNION::operator + () const
|
741 |
{
|
742 |
return *this;
|
743 |
}
|
744 |
|
745 |
D3DXINLINE D3DXQUATERNION
|
746 |
D3DXQUATERNION::operator - () const
|
747 |
{
|
748 |
return D3DXQUATERNION(-x, -y, -z, -w);
|
749 |
}
|
750 |
|
751 |
|
752 |
// binary operators
|
753 |
D3DXINLINE D3DXQUATERNION
|
754 |
D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const
|
755 |
{
|
756 |
return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w);
|
757 |
}
|
758 |
|
759 |
D3DXINLINE D3DXQUATERNION
|
760 |
D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const
|
761 |
{
|
762 |
return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w);
|
763 |
}
|
764 |
|
765 |
D3DXINLINE D3DXQUATERNION
|
766 |
D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const
|
767 |
{
|
768 |
D3DXQUATERNION qT;
|
769 |
D3DXQuaternionMultiply(&qT, this, &q);
|
770 |
return qT;
|
771 |
}
|
772 |
|
773 |
D3DXINLINE D3DXQUATERNION
|
774 |
D3DXQUATERNION::operator * ( FLOAT f ) const
|
775 |
{
|
776 |
return D3DXQUATERNION(x * f, y * f, z * f, w * f);
|
777 |
}
|
778 |
|
779 |
D3DXINLINE D3DXQUATERNION
|
780 |
D3DXQUATERNION::operator / ( FLOAT f ) const
|
781 |
{
|
782 |
FLOAT fInv = 1.0f / f;
|
783 |
return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv);
|
784 |
}
|
785 |
|
786 |
|
787 |
D3DXINLINE D3DXQUATERNION
|
788 |
operator * (FLOAT f, CONST D3DXQUATERNION& q )
|
789 |
{
|
790 |
return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w);
|
791 |
}
|
792 |
|
793 |
|
794 |
D3DXINLINE BOOL
|
795 |
D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const
|
796 |
{
|
797 |
return x == q.x && y == q.y && z == q.z && w == q.w;
|
798 |
}
|
799 |
|
800 |
D3DXINLINE BOOL
|
801 |
D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const
|
802 |
{
|
803 |
return x != q.x || y != q.y || z != q.z || w != q.w;
|
804 |
}
|
805 |
|
806 |
|
807 |
|
808 |
//--------------------------
|
809 |
// Plane
|
810 |
//--------------------------
|
811 |
|
812 |
D3DXINLINE
|
813 |
D3DXPLANE::D3DXPLANE( CONST FLOAT* pf )
|
814 |
{
|
815 |
#ifdef D3DX_DEBUG
|
816 |
if(!pf)
|
817 |
return;
|
818 |
#endif
|
819 |
|
820 |
a = pf[0];
|
821 |
b = pf[1];
|
822 |
c = pf[2];
|
823 |
d = pf[3];
|
824 |
}
|
825 |
|
826 |
D3DXINLINE
|
827 |
D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd )
|
828 |
{
|
829 |
a = fa;
|
830 |
b = fb;
|
831 |
c = fc;
|
832 |
d = fd;
|
833 |
}
|
834 |
|
835 |
|
836 |
// casting
|
837 |
D3DXINLINE
|
838 |
D3DXPLANE::operator FLOAT* ()
|
839 |
{
|
840 |
return (FLOAT *) &a;
|
841 |
}
|
842 |
|
843 |
D3DXINLINE
|
844 |
D3DXPLANE::operator CONST FLOAT* () const
|
845 |
{
|
846 |
return (CONST FLOAT *) &a;
|
847 |
}
|
848 |
|
849 |
|
850 |
// unary operators
|
851 |
D3DXINLINE D3DXPLANE
|
852 |
D3DXPLANE::operator + () const
|
853 |
{
|
854 |
return *this;
|
855 |
}
|
856 |
|
857 |
D3DXINLINE D3DXPLANE
|
858 |
D3DXPLANE::operator - () const
|
859 |
{
|
860 |
return D3DXPLANE(-a, -b, -c, -d);
|
861 |
}
|
862 |
|
863 |
|
864 |
// binary operators
|
865 |
D3DXINLINE BOOL
|
866 |
D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const
|
867 |
{
|
868 |
return a == p.a && b == p.b && c == p.c && d == p.d;
|
869 |
}
|
870 |
|
871 |
D3DXINLINE BOOL
|
872 |
D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const
|
873 |
{
|
874 |
return a != p.a || b != p.b || c != p.c || d != p.d;
|
875 |
}
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
//--------------------------
|
881 |
// Color
|
882 |
//--------------------------
|
883 |
|
884 |
D3DXINLINE
|
885 |
D3DXCOLOR::D3DXCOLOR( DWORD dw )
|
886 |
{
|
887 |
CONST FLOAT f = 1.0f / 255.0f;
|
888 |
r = f * (FLOAT) (unsigned char) (dw >> 16);
|
889 |
g = f * (FLOAT) (unsigned char) (dw >> 8);
|
890 |
b = f * (FLOAT) (unsigned char) (dw >> 0);
|
891 |
a = f * (FLOAT) (unsigned char) (dw >> 24);
|
892 |
}
|
893 |
|
894 |
D3DXINLINE
|
895 |
D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf )
|
896 |
{
|
897 |
#ifdef D3DX_DEBUG
|
898 |
if(!pf)
|
899 |
return;
|
900 |
#endif
|
901 |
|
902 |
r = pf[0];
|
903 |
g = pf[1];
|
904 |
b = pf[2];
|
905 |
a = pf[3];
|
906 |
}
|
907 |
|
908 |
D3DXINLINE
|
909 |
D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c )
|
910 |
{
|
911 |
r = c.r;
|
912 |
g = c.g;
|
913 |
b = c.b;
|
914 |
a = c.a;
|
915 |
}
|
916 |
|
917 |
D3DXINLINE
|
918 |
D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa )
|
919 |
{
|
920 |
r = fr;
|
921 |
g = fg;
|
922 |
b = fb;
|
923 |
a = fa;
|
924 |
}
|
925 |
|
926 |
|
927 |
// casting
|
928 |
D3DXINLINE
|
929 |
D3DXCOLOR::operator DWORD () const
|
930 |
{
|
931 |
DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f);
|
932 |
DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f);
|
933 |
DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f);
|
934 |
DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f);
|
935 |
|
936 |
return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB;
|
937 |
}
|
938 |
|
939 |
|
940 |
D3DXINLINE
|
941 |
D3DXCOLOR::operator FLOAT * ()
|
942 |
{
|
943 |
return (FLOAT *) &r;
|
944 |
}
|
945 |
|
946 |
D3DXINLINE
|
947 |
D3DXCOLOR::operator CONST FLOAT * () const
|
948 |
{
|
949 |
return (CONST FLOAT *) &r;
|
950 |
}
|
951 |
|
952 |
|
953 |
D3DXINLINE
|
954 |
D3DXCOLOR::operator D3DCOLORVALUE * ()
|
955 |
{
|
956 |
return (D3DCOLORVALUE *) &r;
|
957 |
}
|
958 |
|
959 |
D3DXINLINE
|
960 |
D3DXCOLOR::operator CONST D3DCOLORVALUE * () const
|
961 |
{
|
962 |
return (CONST D3DCOLORVALUE *) &r;
|
963 |
}
|
964 |
|
965 |
|
966 |
D3DXINLINE
|
967 |
D3DXCOLOR::operator D3DCOLORVALUE& ()
|
968 |
{
|
969 |
return *((D3DCOLORVALUE *) &r);
|
970 |
}
|
971 |
|
972 |
D3DXINLINE
|
973 |
D3DXCOLOR::operator CONST D3DCOLORVALUE& () const
|
974 |
{
|
975 |
return *((CONST D3DCOLORVALUE *) &r);
|
976 |
}
|
977 |
|
978 |
|
979 |
// assignment operators
|
980 |
D3DXINLINE D3DXCOLOR&
|
981 |
D3DXCOLOR::operator += ( CONST D3DXCOLOR& c )
|
982 |
{
|
983 |
r += c.r;
|
984 |
g += c.g;
|
985 |
b += c.b;
|
986 |
a += c.a;
|
987 |
return *this;
|
988 |
}
|
989 |
|
990 |
D3DXINLINE D3DXCOLOR&
|
991 |
D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c )
|
992 |
{
|
993 |
r -= c.r;
|
994 |
g -= c.g;
|
995 |
b -= c.b;
|
996 |
a -= c.a;
|
997 |
return *this;
|
998 |
}
|
999 |
|
1000 |
D3DXINLINE D3DXCOLOR&
|
1001 |
D3DXCOLOR::operator *= ( FLOAT f )
|
1002 |
{
|
1003 |
r *= f;
|
1004 |
g *= f;
|
1005 |
b *= f;
|
1006 |
a *= f;
|
1007 |
return *this;
|
1008 |
}
|
1009 |
|
1010 |
D3DXINLINE D3DXCOLOR&
|
1011 |
D3DXCOLOR::operator /= ( FLOAT f )
|
1012 |
{
|
1013 |
FLOAT fInv = 1.0f / f;
|
1014 |
r *= fInv;
|
1015 |
g *= fInv;
|
1016 |
b *= fInv;
|
1017 |
a *= fInv;
|
1018 |
return *this;
|
1019 |
}
|
1020 |
|
1021 |
|
1022 |
// unary operators
|
1023 |
D3DXINLINE D3DXCOLOR
|
1024 |
D3DXCOLOR::operator + () const
|
1025 |
{
|
1026 |
return *this;
|
1027 |
}
|
1028 |
|
1029 |
D3DXINLINE D3DXCOLOR
|
1030 |
D3DXCOLOR::operator - () const
|
1031 |
{
|
1032 |
return D3DXCOLOR(-r, -g, -b, -a);
|
1033 |
}
|
1034 |
|
1035 |
|
1036 |
// binary operators
|
1037 |
D3DXINLINE D3DXCOLOR
|
1038 |
D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const
|
1039 |
{
|
1040 |
return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a);
|
1041 |
}
|
1042 |
|
1043 |
D3DXINLINE D3DXCOLOR
|
1044 |
D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const
|
1045 |
{
|
1046 |
return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a);
|
1047 |
}
|
1048 |
|
1049 |
D3DXINLINE D3DXCOLOR
|
1050 |
D3DXCOLOR::operator * ( FLOAT f ) const
|
1051 |
{
|
1052 |
return D3DXCOLOR(r * f, g * f, b * f, a * f);
|
1053 |
}
|
1054 |
|
1055 |
D3DXINLINE D3DXCOLOR
|
1056 |
D3DXCOLOR::operator / ( FLOAT f ) const
|
1057 |
{
|
1058 |
FLOAT fInv = 1.0f / f;
|
1059 |
return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv);
|
1060 |
}
|
1061 |
|
1062 |
|
1063 |
D3DXINLINE D3DXCOLOR
|
1064 |
operator * (FLOAT f, CONST D3DXCOLOR& c )
|
1065 |
{
|
1066 |
return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a);
|
1067 |
}
|
1068 |
|
1069 |
|
1070 |
D3DXINLINE BOOL
|
1071 |
D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const
|
1072 |
{
|
1073 |
return r == c.r && g == c.g && b == c.b && a == c.a;
|
1074 |
}
|
1075 |
|
1076 |
D3DXINLINE BOOL
|
1077 |
D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const
|
1078 |
{
|
1079 |
return r != c.r || g != c.g || b != c.b || a != c.a;
|
1080 |
}
|
1081 |
|
1082 |
|
1083 |
#endif //__cplusplus
|
1084 |
|
1085 |
|
1086 |
|
1087 |
//===========================================================================
|
1088 |
//
|
1089 |
// Inline functions
|
1090 |
//
|
1091 |
//===========================================================================
|
1092 |
|
1093 |
|
1094 |
//--------------------------
|
1095 |
// 2D Vector
|
1096 |
//--------------------------
|
1097 |
|
1098 |
D3DXINLINE FLOAT D3DXVec2Length
|
1099 |
( CONST D3DXVECTOR2 *pV )
|
1100 |
{
|
1101 |
#ifdef D3DX_DEBUG
|
1102 |
if(!pV)
|
1103 |
return 0.0f;
|
1104 |
#endif
|
1105 |
|
1106 |
#ifdef __cplusplus
|
1107 |
return sqrtf(pV->x * pV->x + pV->y * pV->y);
|
1108 |
#else
|
1109 |
return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y);
|
1110 |
#endif
|
1111 |
}
|
1112 |
|
1113 |
D3DXINLINE FLOAT D3DXVec2LengthSq
|
1114 |
( CONST D3DXVECTOR2 *pV )
|
1115 |
{
|
1116 |
#ifdef D3DX_DEBUG
|
1117 |
if(!pV)
|
1118 |
return 0.0f;
|
1119 |
#endif
|
1120 |
|
1121 |
return pV->x * pV->x + pV->y * pV->y;
|
1122 |
}
|
1123 |
|
1124 |
D3DXINLINE FLOAT D3DXVec2Dot
|
1125 |
( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1126 |
{
|
1127 |
#ifdef D3DX_DEBUG
|
1128 |
if(!pV1 || !pV2)
|
1129 |
return 0.0f;
|
1130 |
#endif
|
1131 |
|
1132 |
return pV1->x * pV2->x + pV1->y * pV2->y;
|
1133 |
}
|
1134 |
|
1135 |
D3DXINLINE FLOAT D3DXVec2CCW
|
1136 |
( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1137 |
{
|
1138 |
#ifdef D3DX_DEBUG
|
1139 |
if(!pV1 || !pV2)
|
1140 |
return 0.0f;
|
1141 |
#endif
|
1142 |
|
1143 |
return pV1->x * pV2->y - pV1->y * pV2->x;
|
1144 |
}
|
1145 |
|
1146 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Add
|
1147 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1148 |
{
|
1149 |
#ifdef D3DX_DEBUG
|
1150 |
if(!pOut || !pV1 || !pV2)
|
1151 |
return NULL;
|
1152 |
#endif
|
1153 |
|
1154 |
pOut->x = pV1->x + pV2->x;
|
1155 |
pOut->y = pV1->y + pV2->y;
|
1156 |
return pOut;
|
1157 |
}
|
1158 |
|
1159 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract
|
1160 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1161 |
{
|
1162 |
#ifdef D3DX_DEBUG
|
1163 |
if(!pOut || !pV1 || !pV2)
|
1164 |
return NULL;
|
1165 |
#endif
|
1166 |
|
1167 |
pOut->x = pV1->x - pV2->x;
|
1168 |
pOut->y = pV1->y - pV2->y;
|
1169 |
return pOut;
|
1170 |
}
|
1171 |
|
1172 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize
|
1173 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1174 |
{
|
1175 |
#ifdef D3DX_DEBUG
|
1176 |
if(!pOut || !pV1 || !pV2)
|
1177 |
return NULL;
|
1178 |
#endif
|
1179 |
|
1180 |
pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x;
|
1181 |
pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y;
|
1182 |
return pOut;
|
1183 |
}
|
1184 |
|
1185 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize
|
1186 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 )
|
1187 |
{
|
1188 |
#ifdef D3DX_DEBUG
|
1189 |
if(!pOut || !pV1 || !pV2)
|
1190 |
return NULL;
|
1191 |
#endif
|
1192 |
|
1193 |
pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x;
|
1194 |
pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y;
|
1195 |
return pOut;
|
1196 |
}
|
1197 |
|
1198 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Scale
|
1199 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s )
|
1200 |
{
|
1201 |
#ifdef D3DX_DEBUG
|
1202 |
if(!pOut || !pV)
|
1203 |
return NULL;
|
1204 |
#endif
|
1205 |
|
1206 |
pOut->x = pV->x * s;
|
1207 |
pOut->y = pV->y * s;
|
1208 |
return pOut;
|
1209 |
}
|
1210 |
|
1211 |
D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp
|
1212 |
( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2,
|
1213 |
FLOAT s )
|
1214 |
{
|
1215 |
#ifdef D3DX_DEBUG
|
1216 |
if(!pOut || !pV1 || !pV2)
|
1217 |
return NULL;
|
1218 |
#endif
|
1219 |
|
1220 |
pOut->x = pV1->x + s * (pV2->x - pV1->x);
|
1221 |
pOut->y = pV1->y + s * (pV2->y - pV1->y);
|
1222 |
return pOut;
|
1223 |
}
|
1224 |
|
1225 |
|
1226 |
//--------------------------
|
1227 |
// 3D Vector
|
1228 |
//--------------------------
|
1229 |
|
1230 |
D3DXINLINE FLOAT D3DXVec3Length
|
1231 |
( CONST D3DXVECTOR3 *pV )
|
1232 |
{
|
1233 |
#ifdef D3DX_DEBUG
|
1234 |
if(!pV)
|
1235 |
return 0.0f;
|
1236 |
#endif
|
1237 |
|
1238 |
#ifdef __cplusplus
|
1239 |
return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z);
|
1240 |
#else
|
1241 |
return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z);
|
1242 |
#endif
|
1243 |
}
|
1244 |
|
1245 |
D3DXINLINE FLOAT D3DXVec3LengthSq
|
1246 |
( CONST D3DXVECTOR3 *pV )
|
1247 |
{
|
1248 |
#ifdef D3DX_DEBUG
|
1249 |
if(!pV)
|
1250 |
return 0.0f;
|
1251 |
#endif
|
1252 |
|
1253 |
return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z;
|
1254 |
}
|
1255 |
|
1256 |
D3DXINLINE FLOAT D3DXVec3Dot
|
1257 |
( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1258 |
{
|
1259 |
#ifdef D3DX_DEBUG
|
1260 |
if(!pV1 || !pV2)
|
1261 |
return 0.0f;
|
1262 |
#endif
|
1263 |
|
1264 |
return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z;
|
1265 |
}
|
1266 |
|
1267 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Cross
|
1268 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1269 |
{
|
1270 |
D3DXVECTOR3 v;
|
1271 |
|
1272 |
#ifdef D3DX_DEBUG
|
1273 |
if(!pOut || !pV1 || !pV2)
|
1274 |
return NULL;
|
1275 |
#endif
|
1276 |
|
1277 |
v.x = pV1->y * pV2->z - pV1->z * pV2->y;
|
1278 |
v.y = pV1->z * pV2->x - pV1->x * pV2->z;
|
1279 |
v.z = pV1->x * pV2->y - pV1->y * pV2->x;
|
1280 |
|
1281 |
*pOut = v;
|
1282 |
return pOut;
|
1283 |
}
|
1284 |
|
1285 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Add
|
1286 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1287 |
{
|
1288 |
#ifdef D3DX_DEBUG
|
1289 |
if(!pOut || !pV1 || !pV2)
|
1290 |
return NULL;
|
1291 |
#endif
|
1292 |
|
1293 |
pOut->x = pV1->x + pV2->x;
|
1294 |
pOut->y = pV1->y + pV2->y;
|
1295 |
pOut->z = pV1->z + pV2->z;
|
1296 |
return pOut;
|
1297 |
}
|
1298 |
|
1299 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract
|
1300 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1301 |
{
|
1302 |
#ifdef D3DX_DEBUG
|
1303 |
if(!pOut || !pV1 || !pV2)
|
1304 |
return NULL;
|
1305 |
#endif
|
1306 |
|
1307 |
pOut->x = pV1->x - pV2->x;
|
1308 |
pOut->y = pV1->y - pV2->y;
|
1309 |
pOut->z = pV1->z - pV2->z;
|
1310 |
return pOut;
|
1311 |
}
|
1312 |
|
1313 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize
|
1314 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1315 |
{
|
1316 |
#ifdef D3DX_DEBUG
|
1317 |
if(!pOut || !pV1 || !pV2)
|
1318 |
return NULL;
|
1319 |
#endif
|
1320 |
|
1321 |
pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x;
|
1322 |
pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y;
|
1323 |
pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z;
|
1324 |
return pOut;
|
1325 |
}
|
1326 |
|
1327 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize
|
1328 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 )
|
1329 |
{
|
1330 |
#ifdef D3DX_DEBUG
|
1331 |
if(!pOut || !pV1 || !pV2)
|
1332 |
return NULL;
|
1333 |
#endif
|
1334 |
|
1335 |
pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x;
|
1336 |
pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y;
|
1337 |
pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z;
|
1338 |
return pOut;
|
1339 |
}
|
1340 |
|
1341 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Scale
|
1342 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s)
|
1343 |
{
|
1344 |
#ifdef D3DX_DEBUG
|
1345 |
if(!pOut || !pV)
|
1346 |
return NULL;
|
1347 |
#endif
|
1348 |
|
1349 |
pOut->x = pV->x * s;
|
1350 |
pOut->y = pV->y * s;
|
1351 |
pOut->z = pV->z * s;
|
1352 |
return pOut;
|
1353 |
}
|
1354 |
|
1355 |
D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp
|
1356 |
( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
|
1357 |
FLOAT s )
|
1358 |
{
|
1359 |
#ifdef D3DX_DEBUG
|
1360 |
if(!pOut || !pV1 || !pV2)
|
1361 |
return NULL;
|
1362 |
#endif
|
1363 |
|
1364 |
pOut->x = pV1->x + s * (pV2->x - pV1->x);
|
1365 |
pOut->y = pV1->y + s * (pV2->y - pV1->y);
|
1366 |
pOut->z = pV1->z + s * (pV2->z - pV1->z);
|
1367 |
return pOut;
|
1368 |
}
|
1369 |
|
1370 |
|
1371 |
//--------------------------
|
1372 |
// 4D Vector
|
1373 |
//--------------------------
|
1374 |
|
1375 |
D3DXINLINE FLOAT D3DXVec4Length
|
1376 |
( CONST D3DXVECTOR4 *pV )
|
1377 |
{
|
1378 |
#ifdef D3DX_DEBUG
|
1379 |
if(!pV)
|
1380 |
return 0.0f;
|
1381 |
#endif
|
1382 |
|
1383 |
#ifdef __cplusplus
|
1384 |
return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w);
|
1385 |
#else
|
1386 |
return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w);
|
1387 |
#endif
|
1388 |
}
|
1389 |
|
1390 |
D3DXINLINE FLOAT D3DXVec4LengthSq
|
1391 |
( CONST D3DXVECTOR4 *pV )
|
1392 |
{
|
1393 |
#ifdef D3DX_DEBUG
|
1394 |
if(!pV)
|
1395 |
return 0.0f;
|
1396 |
#endif
|
1397 |
|
1398 |
return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w;
|
1399 |
}
|
1400 |
|
1401 |
D3DXINLINE FLOAT D3DXVec4Dot
|
1402 |
( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 )
|
1403 |
{
|
1404 |
#ifdef D3DX_DEBUG
|
1405 |
if(!pV1 || !pV2)
|
1406 |
return 0.0f;
|
1407 |
#endif
|
1408 |
|
1409 |
return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w;
|
1410 |
}
|
1411 |
|
1412 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Add
|
1413 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2)
|
1414 |
{
|
1415 |
#ifdef D3DX_DEBUG
|
1416 |
if(!pOut || !pV1 || !pV2)
|
1417 |
return NULL;
|
1418 |
#endif
|
1419 |
|
1420 |
pOut->x = pV1->x + pV2->x;
|
1421 |
pOut->y = pV1->y + pV2->y;
|
1422 |
pOut->z = pV1->z + pV2->z;
|
1423 |
pOut->w = pV1->w + pV2->w;
|
1424 |
return pOut;
|
1425 |
}
|
1426 |
|
1427 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract
|
1428 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2)
|
1429 |
{
|
1430 |
#ifdef D3DX_DEBUG
|
1431 |
if(!pOut || !pV1 || !pV2)
|
1432 |
return NULL;
|
1433 |
#endif
|
1434 |
|
1435 |
pOut->x = pV1->x - pV2->x;
|
1436 |
pOut->y = pV1->y - pV2->y;
|
1437 |
pOut->z = pV1->z - pV2->z;
|
1438 |
pOut->w = pV1->w - pV2->w;
|
1439 |
return pOut;
|
1440 |
}
|
1441 |
|
1442 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize
|
1443 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2)
|
1444 |
{
|
1445 |
#ifdef D3DX_DEBUG
|
1446 |
if(!pOut || !pV1 || !pV2)
|
1447 |
return NULL;
|
1448 |
#endif
|
1449 |
|
1450 |
pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x;
|
1451 |
pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y;
|
1452 |
pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z;
|
1453 |
pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w;
|
1454 |
return pOut;
|
1455 |
}
|
1456 |
|
1457 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize
|
1458 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2)
|
1459 |
{
|
1460 |
#ifdef D3DX_DEBUG
|
1461 |
if(!pOut || !pV1 || !pV2)
|
1462 |
return NULL;
|
1463 |
#endif
|
1464 |
|
1465 |
pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x;
|
1466 |
pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y;
|
1467 |
pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z;
|
1468 |
pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w;
|
1469 |
return pOut;
|
1470 |
}
|
1471 |
|
1472 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Scale
|
1473 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s)
|
1474 |
{
|
1475 |
#ifdef D3DX_DEBUG
|
1476 |
if(!pOut || !pV)
|
1477 |
return NULL;
|
1478 |
#endif
|
1479 |
|
1480 |
pOut->x = pV->x * s;
|
1481 |
pOut->y = pV->y * s;
|
1482 |
pOut->z = pV->z * s;
|
1483 |
pOut->w = pV->w * s;
|
1484 |
return pOut;
|
1485 |
}
|
1486 |
|
1487 |
D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp
|
1488 |
( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
|
1489 |
FLOAT s )
|
1490 |
{
|
1491 |
#ifdef D3DX_DEBUG
|
1492 |
if(!pOut || !pV1 || !pV2)
|
1493 |
return NULL;
|
1494 |
#endif
|
1495 |
|
1496 |
pOut->x = pV1->x + s * (pV2->x - pV1->x);
|
1497 |
pOut->y = pV1->y + s * (pV2->y - pV1->y);
|
1498 |
pOut->z = pV1->z + s * (pV2->z - pV1->z);
|
1499 |
pOut->w = pV1->w + s * (pV2->w - pV1->w);
|
1500 |
return pOut;
|
1501 |
}
|
1502 |
|
1503 |
|
1504 |
//--------------------------
|
1505 |
// 4D Matrix
|
1506 |
//--------------------------
|
1507 |
|
1508 |
D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity
|
1509 |
( D3DXMATRIX *pOut )
|
1510 |
{
|
1511 |
#ifdef D3DX_DEBUG
|
1512 |
if(!pOut)
|
1513 |
return NULL;
|
1514 |
#endif
|
1515 |
|
1516 |
pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] =
|
1517 |
pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] =
|
1518 |
pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] =
|
1519 |
pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f;
|
1520 |
|
1521 |
pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f;
|
1522 |
return pOut;
|
1523 |
}
|
1524 |
|
1525 |
|
1526 |
D3DXINLINE BOOL D3DXMatrixIsIdentity
|
1527 |
( CONST D3DXMATRIX *pM )
|
1528 |
{
|
1529 |
#ifdef D3DX_DEBUG
|
1530 |
if(!pM)
|
1531 |
return FALSE;
|
1532 |
#endif
|
1533 |
|
1534 |
return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f &&
|
1535 |
pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f &&
|
1536 |
pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f &&
|
1537 |
pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f;
|
1538 |
}
|
1539 |
|
1540 |
|
1541 |
//--------------------------
|
1542 |
// Quaternion
|
1543 |
//--------------------------
|
1544 |
|
1545 |
D3DXINLINE FLOAT D3DXQuaternionLength
|
1546 |
( CONST D3DXQUATERNION *pQ )
|
1547 |
{
|
1548 |
#ifdef D3DX_DEBUG
|
1549 |
if(!pQ)
|
1550 |
return 0.0f;
|
1551 |
#endif
|
1552 |
|
1553 |
#ifdef __cplusplus
|
1554 |
return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w);
|
1555 |
#else
|
1556 |
return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w);
|
1557 |
#endif
|
1558 |
}
|
1559 |
|
1560 |
D3DXINLINE FLOAT D3DXQuaternionLengthSq
|
1561 |
( CONST D3DXQUATERNION *pQ )
|
1562 |
{
|
1563 |
#ifdef D3DX_DEBUG
|
1564 |
if(!pQ)
|
1565 |
return 0.0f;
|
1566 |
#endif
|
1567 |
|
1568 |
return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w;
|
1569 |
}
|
1570 |
|
1571 |
D3DXINLINE FLOAT D3DXQuaternionDot
|
1572 |
( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 )
|
1573 |
{
|
1574 |
#ifdef D3DX_DEBUG
|
1575 |
if(!pQ1 || !pQ2)
|
1576 |
return 0.0f;
|
1577 |
#endif
|
1578 |
|
1579 |
return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w;
|
1580 |
}
|
1581 |
|
1582 |
|
1583 |
D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity
|
1584 |
( D3DXQUATERNION *pOut )
|
1585 |
{
|
1586 |
#ifdef D3DX_DEBUG
|
1587 |
if(!pOut)
|
1588 |
return NULL;
|
1589 |
#endif
|
1590 |
|
1591 |
pOut->x = pOut->y = pOut->z = 0.0f;
|
1592 |
pOut->w = 1.0f;
|
1593 |
return pOut;
|
1594 |
}
|
1595 |
|
1596 |
D3DXINLINE BOOL D3DXQuaternionIsIdentity
|
1597 |
( CONST D3DXQUATERNION *pQ )
|
1598 |
{
|
1599 |
#ifdef D3DX_DEBUG
|
1600 |
if(!pQ)
|
1601 |
return FALSE;
|
1602 |
#endif
|
1603 |
|
1604 |
return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f;
|
1605 |
}
|
1606 |
|
1607 |
|
1608 |
D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate
|
1609 |
( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ )
|
1610 |
{
|
1611 |
#ifdef D3DX_DEBUG
|
1612 |
if(!pOut || !pQ)
|
1613 |
return NULL;
|
1614 |
#endif
|
1615 |
|
1616 |
pOut->x = -pQ->x;
|
1617 |
pOut->y = -pQ->y;
|
1618 |
pOut->z = -pQ->z;
|
1619 |
pOut->w = pQ->w;
|
1620 |
return pOut;
|
1621 |
}
|
1622 |
|
1623 |
|
1624 |
//--------------------------
|
1625 |
// Plane
|
1626 |
//--------------------------
|
1627 |
|
1628 |
D3DXINLINE FLOAT D3DXPlaneDot
|
1629 |
( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV)
|
1630 |
{
|
1631 |
#ifdef D3DX_DEBUG
|
1632 |
if(!pP || !pV)
|
1633 |
return 0.0f;
|
1634 |
#endif
|
1635 |
|
1636 |
return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w;
|
1637 |
}
|
1638 |
|
1639 |
D3DXINLINE FLOAT D3DXPlaneDotCoord
|
1640 |
( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV)
|
1641 |
{
|
1642 |
#ifdef D3DX_DEBUG
|
1643 |
if(!pP || !pV)
|
1644 |
return 0.0f;
|
1645 |
#endif
|
1646 |
|
1647 |
return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d;
|
1648 |
}
|
1649 |
|
1650 |
D3DXINLINE FLOAT D3DXPlaneDotNormal
|
1651 |
( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV)
|
1652 |
{
|
1653 |
#ifdef D3DX_DEBUG
|
1654 |
if(!pP || !pV)
|
1655 |
return 0.0f;
|
1656 |
#endif
|
1657 |
|
1658 |
return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z;
|
1659 |
}
|
1660 |
|
1661 |
|
1662 |
//--------------------------
|
1663 |
// Color
|
1664 |
//--------------------------
|
1665 |
|
1666 |
D3DXINLINE D3DXCOLOR* D3DXColorNegative
|
1667 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC)
|
1668 |
{
|
1669 |
#ifdef D3DX_DEBUG
|
1670 |
if(!pOut || !pC)
|
1671 |
return NULL;
|
1672 |
#endif
|
1673 |
|
1674 |
pOut->r = 1.0f - pC->r;
|
1675 |
pOut->g = 1.0f - pC->g;
|
1676 |
pOut->b = 1.0f - pC->b;
|
1677 |
pOut->a = pC->a;
|
1678 |
return pOut;
|
1679 |
}
|
1680 |
|
1681 |
D3DXINLINE D3DXCOLOR* D3DXColorAdd
|
1682 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
|
1683 |
{
|
1684 |
#ifdef D3DX_DEBUG
|
1685 |
if(!pOut || !pC1 || !pC2)
|
1686 |
return NULL;
|
1687 |
#endif
|
1688 |
|
1689 |
pOut->r = pC1->r + pC2->r;
|
1690 |
pOut->g = pC1->g + pC2->g;
|
1691 |
pOut->b = pC1->b + pC2->b;
|
1692 |
pOut->a = pC1->a + pC2->a;
|
1693 |
return pOut;
|
1694 |
}
|
1695 |
|
1696 |
D3DXINLINE D3DXCOLOR* D3DXColorSubtract
|
1697 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
|
1698 |
{
|
1699 |
#ifdef D3DX_DEBUG
|
1700 |
if(!pOut || !pC1 || !pC2)
|
1701 |
return NULL;
|
1702 |
#endif
|
1703 |
|
1704 |
pOut->r = pC1->r - pC2->r;
|
1705 |
pOut->g = pC1->g - pC2->g;
|
1706 |
pOut->b = pC1->b - pC2->b;
|
1707 |
pOut->a = pC1->a - pC2->a;
|
1708 |
return pOut;
|
1709 |
}
|
1710 |
|
1711 |
D3DXINLINE D3DXCOLOR* D3DXColorScale
|
1712 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s)
|
1713 |
{
|
1714 |
#ifdef D3DX_DEBUG
|
1715 |
if(!pOut || !pC)
|
1716 |
return NULL;
|
1717 |
#endif
|
1718 |
|
1719 |
pOut->r = pC->r * s;
|
1720 |
pOut->g = pC->g * s;
|
1721 |
pOut->b = pC->b * s;
|
1722 |
pOut->a = pC->a * s;
|
1723 |
return pOut;
|
1724 |
}
|
1725 |
|
1726 |
D3DXINLINE D3DXCOLOR* D3DXColorModulate
|
1727 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
|
1728 |
{
|
1729 |
#ifdef D3DX_DEBUG
|
1730 |
if(!pOut || !pC1 || !pC2)
|
1731 |
return NULL;
|
1732 |
#endif
|
1733 |
|
1734 |
pOut->r = pC1->r * pC2->r;
|
1735 |
pOut->g = pC1->g * pC2->g;
|
1736 |
pOut->b = pC1->b * pC2->b;
|
1737 |
pOut->a = pC1->a * pC2->a;
|
1738 |
return pOut;
|
1739 |
}
|
1740 |
|
1741 |
D3DXINLINE D3DXCOLOR* D3DXColorLerp
|
1742 |
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s)
|
1743 |
{
|
1744 |
#ifdef D3DX_DEBUG
|
1745 |
if(!pOut || !pC1 || !pC2)
|
1746 |
return NULL;
|
1747 |
#endif
|
1748 |
|
1749 |
pOut->r = pC1->r + s * (pC2->r - pC1->r);
|
1750 |
pOut->g = pC1->g + s * (pC2->g - pC1->g);
|
1751 |
pOut->b = pC1->b + s * (pC2->b - pC1->b);
|
1752 |
pOut->a = pC1->a + s * (pC2->a - pC1->a);
|
1753 |
return pOut;
|
1754 |
}
|
1755 |
|
1756 |
|
1757 |
#endif // __D3DX8MATH_INL__
|