2 * Copyright 2008 David Adam
3 * Copyright 2008 Luis Busquets
4 * Copyright 2008 Philip Nilsson
5 * Copyright 2008 Henri Verbeet
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
26 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
36 if (abs(x
- y
) > ulps
)
42 static BOOL
compare_vec2(const D3DXVECTOR2
*v1
, const D3DXVECTOR2
*v2
, unsigned int ulps
)
44 return compare_float(v1
->x
, v2
->x
, ulps
) && compare_float(v1
->y
, v2
->y
, ulps
);
47 static BOOL
compare_vec3(const D3DXVECTOR3
*v1
, const D3DXVECTOR3
*v2
, unsigned int ulps
)
49 return compare_float(v1
->x
, v2
->x
, ulps
)
50 && compare_float(v1
->y
, v2
->y
, ulps
)
51 && compare_float(v1
->z
, v2
->z
, ulps
);
54 static BOOL
compare_vec4(const D3DXVECTOR4
*v1
, const D3DXVECTOR4
*v2
, unsigned int ulps
)
56 return compare_float(v1
->x
, v2
->x
, ulps
)
57 && compare_float(v1
->y
, v2
->y
, ulps
)
58 && compare_float(v1
->z
, v2
->z
, ulps
)
59 && compare_float(v1
->w
, v2
->w
, ulps
);
62 static BOOL
compare_color(const D3DXCOLOR
*c1
, const D3DXCOLOR
*c2
, unsigned int ulps
)
64 return compare_float(c1
->r
, c2
->r
, ulps
)
65 && compare_float(c1
->g
, c2
->g
, ulps
)
66 && compare_float(c1
->b
, c2
->b
, ulps
)
67 && compare_float(c1
->a
, c2
->a
, ulps
);
70 static BOOL
compare_plane(const D3DXPLANE
*p1
, const D3DXPLANE
*p2
, unsigned int ulps
)
72 return compare_float(p1
->a
, p2
->a
, ulps
)
73 && compare_float(p1
->b
, p2
->b
, ulps
)
74 && compare_float(p1
->c
, p2
->c
, ulps
)
75 && compare_float(p1
->d
, p2
->d
, ulps
);
78 static BOOL
compare_quaternion(const D3DXQUATERNION
*q1
, const D3DXQUATERNION
*q2
, unsigned int ulps
)
80 return compare_float(q1
->x
, q2
->x
, ulps
)
81 && compare_float(q1
->y
, q2
->y
, ulps
)
82 && compare_float(q1
->z
, q2
->z
, ulps
)
83 && compare_float(q1
->w
, q2
->w
, ulps
);
86 static BOOL
compare_matrix(const D3DXMATRIX
*m1
, const D3DXMATRIX
*m2
, unsigned int ulps
)
90 for (i
= 0; i
< 4; ++i
)
92 for (j
= 0; j
< 4; ++j
)
94 if (!compare_float(U(*m1
).m
[i
][j
], U(*m2
).m
[i
][j
], ulps
))
102 #define expect_vec2(expected, vector, ulps) expect_vec2_(__LINE__, expected, vector, ulps)
103 static void expect_vec2_(unsigned int line
, const D3DXVECTOR2
*expected
, const D3DXVECTOR2
*vector
, unsigned int ulps
)
105 BOOL equal
= compare_vec2(expected
, vector
, ulps
);
106 ok_(__FILE__
, line
)(equal
,
107 "Got unexpected vector {%.8e, %.8e}, expected {%.8e, %.8e}.\n",
108 vector
->x
, vector
->y
, expected
->x
, expected
->y
);
111 #define expect_vec3(expected, vector, ulps) expect_vec3_(__LINE__, expected, vector, ulps)
112 static void expect_vec3_(unsigned int line
, const D3DXVECTOR3
*expected
, const D3DXVECTOR3
*vector
, unsigned int ulps
)
114 BOOL equal
= compare_vec3(expected
, vector
, ulps
);
115 ok_(__FILE__
, line
)(equal
,
116 "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
117 vector
->x
, vector
->y
, vector
->z
, expected
->x
, expected
->y
, expected
->z
);
120 #define expect_vec4(expected, vector, ulps) expect_vec4_(__LINE__, expected, vector, ulps)
121 static void expect_vec4_(unsigned int line
, const D3DXVECTOR4
*expected
, const D3DXVECTOR4
*vector
, unsigned int ulps
)
123 BOOL equal
= compare_vec4(expected
, vector
, ulps
);
124 ok_(__FILE__
, line
)(equal
,
125 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
126 vector
->x
, vector
->y
, vector
->z
, vector
->w
, expected
->x
, expected
->y
, expected
->z
, expected
->w
);
129 #define expect_color(expected, color, ulps) expect_color_(__LINE__, expected, color, ulps)
130 static void expect_color_(unsigned int line
, const D3DXCOLOR
*expected
, const D3DXCOLOR
*color
, unsigned int ulps
)
132 BOOL equal
= compare_color(expected
, color
, ulps
);
133 ok_(__FILE__
, line
)(equal
,
134 "Got unexpected color {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
135 color
->r
, color
->g
, color
->b
, color
->a
, expected
->r
, expected
->g
, expected
->b
, expected
->a
);
138 #define expect_plane(expected, plane, ulps) expect_plane_(__LINE__, expected, plane, ulps)
139 static void expect_plane_(unsigned int line
, const D3DXPLANE
*expected
, const D3DXPLANE
*plane
, unsigned int ulps
)
141 BOOL equal
= compare_plane(expected
, plane
, ulps
);
142 ok_(__FILE__
, line
)(equal
,
143 "Got unexpected plane {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
144 plane
->a
, plane
->b
, plane
->c
, plane
->d
, expected
->a
, expected
->b
, expected
->c
, expected
->d
);
147 #define expect_quaternion(expected, quaternion, ulps) expect_quaternion_(__LINE__, expected, quaternion, ulps)
148 static void expect_quaternion_(unsigned int line
, const D3DXQUATERNION
*expected
,
149 const D3DXQUATERNION
*quaternion
, unsigned int ulps
)
151 BOOL equal
= compare_quaternion(expected
, quaternion
, ulps
);
152 ok_(__FILE__
, line
)(equal
,
153 "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
154 quaternion
->x
, quaternion
->y
, quaternion
->z
, quaternion
->w
,
155 expected
->x
, expected
->y
, expected
->z
, expected
->w
);
158 #define expect_matrix(expected, matrix, ulps) expect_matrix_(__LINE__, expected, matrix, ulps)
159 static void expect_matrix_(unsigned int line
, const D3DXMATRIX
*expected
, const D3DXMATRIX
*matrix
, unsigned int ulps
)
161 BOOL equal
= compare_matrix(expected
, matrix
, ulps
);
162 ok_(__FILE__
, line
)(equal
,
163 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
164 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
165 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
166 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
167 U(*matrix
).m
[0][0], U(*matrix
).m
[0][1], U(*matrix
).m
[0][2], U(*matrix
).m
[0][3],
168 U(*matrix
).m
[1][0], U(*matrix
).m
[1][1], U(*matrix
).m
[1][2], U(*matrix
).m
[1][3],
169 U(*matrix
).m
[2][0], U(*matrix
).m
[2][1], U(*matrix
).m
[2][2], U(*matrix
).m
[2][3],
170 U(*matrix
).m
[3][0], U(*matrix
).m
[3][1], U(*matrix
).m
[3][2], U(*matrix
).m
[3][3],
171 U(*expected
).m
[0][0], U(*expected
).m
[0][1], U(*expected
).m
[0][2], U(*expected
).m
[0][3],
172 U(*expected
).m
[1][0], U(*expected
).m
[1][1], U(*expected
).m
[1][2], U(*expected
).m
[1][3],
173 U(*expected
).m
[2][0], U(*expected
).m
[2][1], U(*expected
).m
[2][2], U(*expected
).m
[2][3],
174 U(*expected
).m
[3][0], U(*expected
).m
[3][1], U(*expected
).m
[3][2], U(*expected
).m
[3][3]);
177 #define expect_vec4_array(count, expected, vector, ulps) expect_vec4_array_(__LINE__, count, expected, vector, ulps)
178 static void expect_vec4_array_(unsigned int line
, unsigned int count
, const D3DXVECTOR4
*expected
,
179 const D3DXVECTOR4
*vector
, unsigned int ulps
)
184 for (i
= 0; i
< count
; ++i
)
186 equal
= compare_vec4(&expected
[i
], &vector
[i
], ulps
);
187 ok_(__FILE__
, line
)(equal
,
188 "Got unexpected vector {%.8e, %.8e, %.8e, %.8e} at index %u, expected {%.8e, %.8e, %.8e, %.8e}.\n",
189 vector
[i
].x
, vector
[i
].y
, vector
[i
].z
, vector
[i
].w
, i
,
190 expected
[i
].x
, expected
[i
].y
, expected
[i
].z
, expected
[i
].w
);
196 static void set_matrix(D3DXMATRIX
* mat
,
197 float m00
, float m01
, float m02
, float m03
,
198 float m10
, float m11
, float m12
, float m13
,
199 float m20
, float m21
, float m22
, float m23
,
200 float m30
, float m31
, float m32
, float m33
)
202 U(mat
)->m
[0][0] = m00
; U(mat
)->m
[0][1] = m01
; U(mat
)->m
[0][2] = m02
; U(mat
)->m
[0][3] = m03
;
203 U(mat
)->m
[1][0] = m10
; U(mat
)->m
[1][1] = m11
; U(mat
)->m
[1][2] = m12
; U(mat
)->m
[1][3] = m13
;
204 U(mat
)->m
[2][0] = m20
; U(mat
)->m
[2][1] = m21
; U(mat
)->m
[2][2] = m22
; U(mat
)->m
[2][3] = m23
;
205 U(mat
)->m
[3][0] = m30
; U(mat
)->m
[3][1] = m31
; U(mat
)->m
[3][2] = m32
; U(mat
)->m
[3][3] = m33
;
208 static void D3DXColorTest(void)
210 D3DXCOLOR color
, color1
, color2
, expected
, got
;
211 LPD3DXCOLOR funcpointer
;
214 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
215 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
216 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
220 /*_______________D3DXColorAdd________________*/
221 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
; expected
.a
= 0.93f
;
222 D3DXColorAdd(&got
,&color1
,&color2
);
223 expect_color(&expected
, &got
, 1);
224 /* Test the NULL case */
225 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
226 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
227 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
228 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
229 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
230 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
232 /*_______________D3DXColorAdjustContrast______*/
233 expected
.r
= 0.41f
; expected
.g
= 0.575f
; expected
.b
= 0.473f
; expected
.a
= 0.93f
;
234 D3DXColorAdjustContrast(&got
,&color
,scale
);
235 expect_color(&expected
, &got
, 0);
237 /*_______________D3DXColorAdjustSaturation______*/
238 expected
.r
= 0.486028f
; expected
.g
= 0.651028f
; expected
.b
= 0.549028f
; expected
.a
= 0.93f
;
239 D3DXColorAdjustSaturation(&got
,&color
,scale
);
240 expect_color(&expected
, &got
, 16);
242 /*_______________D3DXColorLerp________________*/
243 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
244 D3DXColorLerp(&got
,&color
,&color1
,scale
);
245 expect_color(&expected
, &got
, 0);
246 /* Test the NULL case */
247 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
248 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
249 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
250 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
251 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
252 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
254 /*_______________D3DXColorModulate________________*/
255 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
256 D3DXColorModulate(&got
,&color1
,&color2
);
257 expect_color(&expected
, &got
, 0);
258 /* Test the NULL case */
259 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
260 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
261 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
262 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
263 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
264 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
266 /*_______________D3DXColorNegative________________*/
267 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
268 D3DXColorNegative(&got
,&color
);
269 expect_color(&expected
, &got
, 1);
270 /* Test the greater than 1 case */
271 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
272 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
273 D3DXColorNegative(&got
,&color1
);
274 expect_color(&expected
, &got
, 1);
275 /* Test the negative case */
276 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
277 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
278 D3DXColorNegative(&got
,&color1
);
279 expect_color(&expected
, &got
, 1);
280 /* Test the NULL case */
281 funcpointer
= D3DXColorNegative(&got
,NULL
);
282 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
283 funcpointer
= D3DXColorNegative(NULL
,NULL
);
284 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
286 /*_______________D3DXColorScale________________*/
287 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
288 D3DXColorScale(&got
,&color
,scale
);
289 expect_color(&expected
, &got
, 1);
290 /* Test the NULL case */
291 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
292 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
293 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
294 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
296 /*_______________D3DXColorSubtract_______________*/
297 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
; expected
.a
= 0.82f
;
298 D3DXColorSubtract(&got
,&color
,&color2
);
299 expect_color(&expected
, &got
, 1);
300 /* Test the NULL case */
301 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
302 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
303 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
304 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
305 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
306 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
309 static void D3DXFresnelTest(void)
314 fresnel
= D3DXFresnelTerm(0.5f
, 1.5f
);
315 equal
= compare_float(fresnel
, 8.91867128e-02f
, 1);
316 ok(equal
, "Got unexpected Fresnel term %.8e.\n", fresnel
);
319 static void D3DXMatrixTest(void)
321 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
322 BOOL expected
, got
, equal
;
323 float angle
, determinant
;
326 D3DXVECTOR3 at
, axis
, eye
, last
;
330 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
331 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
332 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
333 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
334 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
335 U(mat
).m
[3][3] = -40.0f
;
337 U(mat2
).m
[0][0] = 1.0f
; U(mat2
).m
[1][0] = 2.0f
; U(mat2
).m
[2][0] = 3.0f
;
338 U(mat2
).m
[3][0] = 4.0f
; U(mat2
).m
[0][1] = 5.0f
; U(mat2
).m
[1][1] = 6.0f
;
339 U(mat2
).m
[2][1] = 7.0f
; U(mat2
).m
[3][1] = 8.0f
; U(mat2
).m
[0][2] = -8.0f
;
340 U(mat2
).m
[1][2] = -7.0f
; U(mat2
).m
[2][2] = -6.0f
; U(mat2
).m
[3][2] = -5.0f
;
341 U(mat2
).m
[0][3] = -4.0f
; U(mat2
).m
[1][3] = -3.0f
; U(mat2
).m
[2][3] = -2.0f
;
342 U(mat2
).m
[3][3] = -1.0f
;
344 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
346 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
347 r
.x
= 0.87f
; r
.y
= 0.65f
; r
.z
=0.43f
; r
.w
= 0.21f
;
349 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
350 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
351 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
352 last
.x
= 9.7f
; last
.y
= -8.6; last
.z
= 1.3f
;
354 light
.x
= 9.6f
; light
.y
= 8.5f
; light
.z
= 7.4; light
.w
= 6.3;
356 angle
= D3DX_PI
/3.0f
;
358 /*____________D3DXMatrixAffineTransformation______*/
359 set_matrix(&expectedmat
,
360 -459.239990f
, -576.719971f
, -263.440002f
, 0.0f
,
361 519.760010f
, -352.440002f
, -277.679993f
, 0.0f
,
362 363.119995f
, -121.040001f
, -117.479996f
, 0.0f
,
363 -1239.0f
, 667.0f
, 567.0f
, 1.0f
);
364 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, &axis
);
365 expect_matrix(&expectedmat
, &gotmat
, 0);
367 /* Test the NULL case */
368 U(expectedmat
).m
[3][0] = 1.0f
; U(expectedmat
).m
[3][1] = -3.0f
; U(expectedmat
).m
[3][2] = 7.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
369 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, &axis
);
370 expect_matrix(&expectedmat
, &gotmat
, 0);
372 U(expectedmat
).m
[3][0] = -1240.0f
; U(expectedmat
).m
[3][1] = 670.0f
; U(expectedmat
).m
[3][2] = 560.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
373 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, NULL
);
374 expect_matrix(&expectedmat
, &gotmat
, 0);
376 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
377 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, NULL
);
378 expect_matrix(&expectedmat
, &gotmat
, 0);
380 set_matrix(&expectedmat
,
381 3.56f
, 0.0f
, 0.0f
, 0.0f
,
382 0.0f
, 3.56f
, 0.0f
, 0.0f
,
383 0.0f
, 0.0f
, 3.56f
, 0.0f
,
384 1.0f
, -3.0f
, 7.0f
, 1.0f
);
385 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, &axis
);
386 expect_matrix(&expectedmat
, &gotmat
, 0);
388 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, &axis
);
389 expect_matrix(&expectedmat
, &gotmat
, 0);
391 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 0.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
392 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, NULL
);
393 expect_matrix(&expectedmat
, &gotmat
, 0);
395 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, NULL
);
396 expect_matrix(&expectedmat
, &gotmat
, 0);
398 /*____________D3DXMatrixfDeterminant_____________*/
399 determinant
= D3DXMatrixDeterminant(&mat
);
400 equal
= compare_float(determinant
, -147888.0f
, 0);
401 ok(equal
, "Got unexpected determinant %.8e.\n", determinant
);
403 /*____________D3DXMatrixInverse______________*/
404 set_matrix(&expectedmat
,
405 16067.0f
/73944.0f
, -10165.0f
/147888.0f
, -2729.0f
/147888.0f
, -1631.0f
/49296.0f
,
406 -565.0f
/36972.0f
, 2723.0f
/73944.0f
, -1073.0f
/73944.0f
, 289.0f
/24648.0f
,
407 -389.0f
/2054.0f
, 337.0f
/4108.0f
, 181.0f
/4108.0f
, 317.0f
/4108.0f
,
408 163.0f
/5688.0f
, -101.0f
/11376.0f
, -73.0f
/11376.0f
, -127.0f
/3792.0f
);
409 D3DXMatrixInverse(&gotmat
, &determinant
, &mat
);
410 expect_matrix(&expectedmat
, &gotmat
, 1);
411 equal
= compare_float(determinant
, -147888.0f
, 0);
412 ok(equal
, "Got unexpected determinant %.8e.\n", determinant
);
414 ret
= D3DXMatrixInverse(&gotmat
, &determinant
, &mat2
);
415 ok(!ret
, "Unexpected return value %p.\n", ret
);
416 expect_matrix(&expectedmat
, &gotmat
, 1);
417 ok(compare_float(determinant
, 5.0f
, 0), "Unexpected determinant %.8e.\n", determinant
);
419 /*____________D3DXMatrixIsIdentity______________*/
421 memset(&mat3
, 0, sizeof(mat3
));
422 got
= D3DXMatrixIsIdentity(&mat3
);
423 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
424 D3DXMatrixIdentity(&mat3
);
426 got
= D3DXMatrixIsIdentity(&mat3
);
427 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
428 U(mat3
).m
[0][0] = 0.000009f
;
430 got
= D3DXMatrixIsIdentity(&mat3
);
431 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
432 /* Test the NULL case */
434 got
= D3DXMatrixIsIdentity(NULL
);
435 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
437 /*____________D3DXMatrixLookAtLH_______________*/
438 set_matrix(&expectedmat
,
439 -0.82246518f
, -0.40948939f
, -0.39480308f
, 0.0f
,
440 -0.55585691f
, 0.43128574f
, 0.71064550f
, 0.0f
,
441 -0.12072885f
, 0.80393475f
, -0.58233452f
, 0.0f
,
442 4.4946337f
, 0.80971903f
, 10.060076f
, 1.0f
);
443 D3DXMatrixLookAtLH(&gotmat
, &eye
, &at
, &axis
);
444 expect_matrix(&expectedmat
, &gotmat
, 32);
446 /*____________D3DXMatrixLookAtRH_______________*/
447 set_matrix(&expectedmat
,
448 0.82246518f
, -0.40948939f
, 0.39480308f
, 0.0f
,
449 0.55585691f
, 0.43128574f
, -0.71064550f
, 0.0f
,
450 0.12072885f
, 0.80393475f
, 0.58233452f
, 0.0f
,
451 -4.4946337f
, 0.80971903f
, -10.060076f
, 1.0f
);
452 D3DXMatrixLookAtRH(&gotmat
, &eye
, &at
, &axis
);
453 expect_matrix(&expectedmat
, &gotmat
, 32);
455 /*____________D3DXMatrixMultiply______________*/
456 set_matrix(&expectedmat
,
457 73.0f
, 193.0f
, -197.0f
, -77.0f
,
458 231.0f
, 551.0f
, -489.0f
, -169.0f
,
459 239.0f
, 523.0f
, -400.0f
, -116.0f
,
460 -164.0f
, -320.0f
, 187.0f
, 31.0f
);
461 D3DXMatrixMultiply(&gotmat
, &mat
, &mat2
);
462 expect_matrix(&expectedmat
, &gotmat
, 0);
464 /*____________D3DXMatrixMultiplyTranspose____*/
465 set_matrix(&expectedmat
,
466 73.0f
, 231.0f
, 239.0f
, -164.0f
,
467 193.0f
, 551.0f
, 523.0f
, -320.0f
,
468 -197.0f
, -489.0f
, -400.0f
, 187.0f
,
469 -77.0f
, -169.0f
, -116.0f
, 31.0f
);
470 D3DXMatrixMultiplyTranspose(&gotmat
, &mat
, &mat2
);
471 expect_matrix(&expectedmat
, &gotmat
, 0);
473 /*____________D3DXMatrixOrthoLH_______________*/
474 set_matrix(&expectedmat
,
475 0.8f
, 0.0f
, 0.0f
, 0.0f
,
476 0.0f
, 0.27027027f
, 0.0f
, 0.0f
,
477 0.0f
, 0.0f
, -0.15151515f
, 0.0f
,
478 0.0f
, 0.0f
, -0.48484848f
, 1.0f
);
479 D3DXMatrixOrthoLH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
480 expect_matrix(&expectedmat
, &gotmat
, 16);
482 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
483 set_matrix(&expectedmat
,
484 3.6363636f
, 0.0f
, 0.0f
, 0.0f
,
485 0.0f
, 0.18018018f
, 0.0f
, 0.0f
,
486 0.0f
, 0.0f
, -0.045662100f
, 0.0f
,
487 -1.7272727f
, -0.56756757f
, 0.42465753f
, 1.0f
);
488 D3DXMatrixOrthoOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
489 expect_matrix(&expectedmat
, &gotmat
, 32);
491 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
492 set_matrix(&expectedmat
,
493 3.6363636f
, 0.0f
, 0.0f
, 0.0f
,
494 0.0f
, 0.18018018f
, 0.0f
, 0.0f
,
495 0.0f
, 0.0f
, 0.045662100f
, 0.0f
,
496 -1.7272727f
, -0.56756757f
, 0.42465753f
, 1.0f
);
497 D3DXMatrixOrthoOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
498 expect_matrix(&expectedmat
, &gotmat
, 32);
500 /*____________D3DXMatrixOrthoRH_______________*/
501 set_matrix(&expectedmat
,
502 0.8f
, 0.0f
, 0.0f
, 0.0f
,
503 0.0f
, 0.27027027f
, 0.0f
, 0.0f
,
504 0.0f
, 0.0f
, 0.15151515f
, 0.0f
,
505 0.0f
, 0.0f
, -0.48484848f
, 1.0f
);
506 D3DXMatrixOrthoRH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
507 expect_matrix(&expectedmat
, &gotmat
, 16);
509 /*____________D3DXMatrixPerspectiveFovLH_______________*/
510 set_matrix(&expectedmat
,
511 13.288858f
, 0.0f
, 0.0f
, 0.0f
,
512 0.0f
, 9.9666444f
, 0.0f
, 0.0f
,
513 0.0f
, 0.0f
, 0.78378378f
, 1.0f
,
514 0.0f
, 0.0f
, 1.8810811f
, 0.0f
);
515 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
516 expect_matrix(&expectedmat
, &gotmat
, 4);
518 /*____________D3DXMatrixPerspectiveFovRH_______________*/
519 set_matrix(&expectedmat
,
520 13.288858f
, 0.0f
, 0.0f
, 0.0f
,
521 0.0f
, 9.9666444f
, 0.0f
, 0.0f
,
522 0.0f
, 0.0f
, -0.78378378f
, -1.0f
,
523 0.0f
, 0.0f
, 1.8810811f
, 0.0f
);
524 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
525 expect_matrix(&expectedmat
, &gotmat
, 4);
527 /*____________D3DXMatrixPerspectiveLH_______________*/
528 set_matrix(&expectedmat
,
529 -24.0f
, 0.0f
, 0.0f
, 0.0f
,
530 0.0f
, -6.4f
, 0.0f
, 0.0f
,
531 0.0f
, 0.0f
, 0.78378378f
, 1.0f
,
532 0.0f
, 0.0f
, 1.8810811f
, 0.0f
);
533 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
534 expect_matrix(&expectedmat
, &gotmat
, 4);
536 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
537 set_matrix(&expectedmat
,
538 11.636364f
, 0.0f
, 0.0f
, 0.0f
,
539 0.0f
, 0.57657658f
, 0.0f
, 0.0f
,
540 -1.7272727f
, -0.56756757f
, 0.84079602f
, 1.0f
,
541 0.0f
, 0.0f
, -2.6905473f
, 0.0f
);
542 D3DXMatrixPerspectiveOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
543 expect_matrix(&expectedmat
, &gotmat
, 8);
545 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
546 set_matrix(&expectedmat
,
547 11.636364f
, 0.0f
, 0.0f
, 0.0f
,
548 0.0f
, 0.57657658f
, 0.0f
, 0.0f
,
549 1.7272727f
, 0.56756757f
, -0.84079602f
, -1.0f
,
550 0.0f
, 0.0f
, -2.6905473f
, 0.0f
);
551 D3DXMatrixPerspectiveOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
552 expect_matrix(&expectedmat
, &gotmat
, 8);
554 /*____________D3DXMatrixPerspectiveRH_______________*/
555 set_matrix(&expectedmat
,
556 -24.0f
, -0.0f
, 0.0f
, 0.0f
,
557 0.0f
, -6.4f
, 0.0f
, 0.0f
,
558 0.0f
, 0.0f
, -0.78378378f
, -1.0f
,
559 0.0f
, 0.0f
, 1.8810811f
, 0.0f
);
560 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
561 expect_matrix(&expectedmat
, &gotmat
, 4);
563 /*____________D3DXMatrixReflect______________*/
564 set_matrix(&expectedmat
,
565 0.30769235f
, -0.23076922f
, 0.92307687f
, 0.0f
,
566 -0.23076922, 0.92307693f
, 0.30769232f
, 0.0f
,
567 0.92307687f
, 0.30769232f
, -0.23076922f
, 0.0f
,
568 1.6153846f
, 0.53846157f
, -2.1538463f
, 1.0f
);
569 D3DXMatrixReflect(&gotmat
, &plane
);
570 expect_matrix(&expectedmat
, &gotmat
, 32);
572 /*____________D3DXMatrixRotationAxis_____*/
573 set_matrix(&expectedmat
,
574 0.50847453f
, 0.76380461f
, 0.39756277f
, 0.0f
,
575 -0.81465209f
, 0.57627118f
, -0.065219201f
, 0.0f
,
576 -0.27891868f
, -0.29071301f
, 0.91525424f
, 0.0f
,
577 0.0f
, 0.0f
, 0.0f
, 1.0f
);
578 D3DXMatrixRotationAxis(&gotmat
, &axis
, angle
);
579 expect_matrix(&expectedmat
, &gotmat
, 32);
581 /*____________D3DXMatrixRotationQuaternion______________*/
582 set_matrix(&expectedmat
,
583 -129.0f
, -162.0f
, -74.0f
, 0.0f
,
584 146.0f
, -99.0f
, -78.0f
, 0.0f
,
585 102.0f
, -34.0f
, -33.0f
, 0.0f
,
586 0.0f
, 0.0f
, 0.0f
, 1.0f
);
587 D3DXMatrixRotationQuaternion(&gotmat
, &q
);
588 expect_matrix(&expectedmat
, &gotmat
, 0);
590 /*____________D3DXMatrixRotationX______________*/
591 set_matrix(&expectedmat
,
592 1.0f
, 0.0f
, 0.0f
, 0.0f
,
593 0.0f
, 0.5f
, sqrt(3.0f
)/2.0f
, 0.0f
,
594 0.0f
, -sqrt(3.0f
)/2.0f
, 0.5f
, 0.0f
,
595 0.0f
, 0.0f
, 0.0f
, 1.0f
);
596 D3DXMatrixRotationX(&gotmat
, angle
);
597 expect_matrix(&expectedmat
, &gotmat
, 1);
599 /*____________D3DXMatrixRotationY______________*/
600 set_matrix(&expectedmat
,
601 0.5f
, 0.0f
, -sqrt(3.0f
)/2.0f
, 0.0f
,
602 0.0f
, 1.0f
, 0.0f
, 0.0f
,
603 sqrt(3.0f
)/2.0f
, 0.0f
, 0.5f
, 0.0f
,
604 0.0f
, 0.0f
, 0.0f
, 1.0f
);
605 D3DXMatrixRotationY(&gotmat
, angle
);
606 expect_matrix(&expectedmat
, &gotmat
, 1);
608 /*____________D3DXMatrixRotationYawPitchRoll____*/
609 set_matrix(&expectedmat
,
610 0.88877726f
, 0.091874748f
, -0.44903678f
, 0.0f
,
611 0.35171318f
, 0.49148652f
, 0.79670501f
, 0.0f
,
612 0.29389259f
, -0.86602545f
, 0.40450847f
, 0.0f
,
613 0.0f
, 0.0f
, 0.0f
, 1.0f
);
614 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
* angle
/ 5.0f
, angle
, 3.0f
* angle
/ 17.0f
);
615 expect_matrix(&expectedmat
, &gotmat
, 64);
617 /*____________D3DXMatrixRotationZ______________*/
618 set_matrix(&expectedmat
,
619 0.5f
, sqrt(3.0f
)/2.0f
, 0.0f
, 0.0f
,
620 -sqrt(3.0f
)/2.0f
, 0.5f
, 0.0f
, 0.0f
,
621 0.0f
, 0.0f
, 1.0f
, 0.0f
,
622 0.0f
, 0.0f
, 0.0f
, 1.0f
);
623 D3DXMatrixRotationZ(&gotmat
, angle
);
624 expect_matrix(&expectedmat
, &gotmat
, 1);
626 /*____________D3DXMatrixScaling______________*/
627 set_matrix(&expectedmat
,
628 0.69f
, 0.0f
, 0.0f
, 0.0f
,
629 0.0f
, 0.53f
, 0.0f
, 0.0f
,
630 0.0f
, 0.0f
, 4.11f
, 0.0f
,
631 0.0f
, 0.0f
, 0.0f
, 1.0f
);
632 D3DXMatrixScaling(&gotmat
, 0.69f
, 0.53f
, 4.11f
);
633 expect_matrix(&expectedmat
, &gotmat
, 0);
635 /*____________D3DXMatrixShadow______________*/
636 set_matrix(&expectedmat
,
637 12.786773f
, 5.0009613f
, 4.3537784f
, 3.7065949f
,
638 1.8827150f
, 8.8056154f
, 1.4512594f
, 1.2355317f
,
639 -7.5308599f
, -6.6679487f
, 1.3335901f
, -4.9421268f
,
640 -13.179006f
, -11.668910f
, -10.158816f
, -1.5100943f
);
641 D3DXMatrixShadow(&gotmat
, &light
, &plane
);
642 expect_matrix(&expectedmat
, &gotmat
, 8);
644 /*____________D3DXMatrixTransformation______________*/
645 set_matrix(&expectedmat
,
646 1.0f
, 0.0f
, 0.0f
, 0.0f
,
647 0.0f
, 1.0f
, 0.0f
, 0.0f
,
648 0.0f
, 0.0f
, 1.0f
, 0.0f
,
649 0.0f
, 0.0f
, 0.0f
, 1.0f
);
650 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
651 expect_matrix(&expectedmat
, &gotmat
, 0);
653 set_matrix(&expectedmat
,
654 1.0f
, 0.0f
, 0.0f
, 0.0f
,
655 0.0f
, 1.0f
, 0.0f
, 0.0f
,
656 0.0f
, 0.0f
, 1.0f
, 0.0f
,
657 9.7f
, -8.6f
, 1.3f
, 1.0f
);
658 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, NULL
, NULL
, &last
);
659 expect_matrix(&expectedmat
, &gotmat
, 0);
661 set_matrix(&expectedmat
,
662 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
663 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
664 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
665 0.0f
, 0.0f
, 0.0f
, 1.0f
);
666 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, NULL
, &r
, NULL
);
667 expect_matrix(&expectedmat
, &gotmat
, 8);
669 set_matrix(&expectedmat
,
670 1.0f
, 0.0f
, 0.0f
, 0.0f
,
671 0.0f
, 1.0f
, 0.0f
, 0.0f
,
672 0.0f
, 0.0f
, 1.0f
, 0.0f
,
673 0.0f
, 0.0f
, 0.0f
, 1.0f
);
674 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, &eye
, NULL
, NULL
);
675 expect_matrix(&expectedmat
, &gotmat
, 0);
677 set_matrix(&expectedmat
,
678 1.0f
, 0.0f
, 0.0f
, 0.0f
,
679 0.0f
, -3.0f
, 0.0f
, 0.0f
,
680 0.0f
, 0.0f
, 7.0f
, 0.0f
,
681 0.0f
, 0.0f
, 0.0f
, 1.0f
);
682 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, NULL
, NULL
, NULL
);
683 expect_matrix(&expectedmat
, &gotmat
, 0);
685 set_matrix(&expectedmat
,
686 1.0f
, 0.0f
, 0.0f
, 0.0f
,
687 0.0f
, 1.0f
, 0.0f
, 0.0f
,
688 0.0f
, 0.0f
, 1.0f
, 0.0f
,
689 0.0f
, 0.0f
, 0.0f
, 1.0f
);
690 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, NULL
, NULL
, NULL
);
691 expect_matrix(&expectedmat
, &gotmat
, 0);
693 set_matrix(&expectedmat
,
694 1.0f
, 0.0f
, 0.0f
, 0.0f
,
695 0.0f
, 1.0f
, 0.0f
, 0.0f
,
696 0.0f
, 0.0f
, 1.0f
, 0.0f
,
697 0.0f
, 0.0f
, 0.0f
, 1.0f
);
698 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, NULL
, NULL
, NULL
);
699 expect_matrix(&expectedmat
, &gotmat
, 0);
701 set_matrix(&expectedmat
,
702 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
703 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
704 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
705 9.7f
, -8.6f
, 1.3f
, 1.0f
);
706 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, NULL
, &r
, &last
);
707 expect_matrix(&expectedmat
, &gotmat
, 8);
709 set_matrix(&expectedmat
,
710 1.0f
, 0.0f
, 0.0f
, 0.0f
,
711 0.0f
, 1.0f
, 0.0f
, 0.0f
,
712 0.0f
, 0.0f
, 1.0f
, 0.0f
,
713 9.7f
, -8.6f
, 1.3f
, 1.0f
);
714 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, &eye
, NULL
, &last
);
715 expect_matrix(&expectedmat
, &gotmat
, 0);
717 set_matrix(&expectedmat
,
718 1.0f
, 0.0f
, 0.0f
, 0.0f
,
719 0.0f
, -3.0f
, 0.0f
, 0.0f
,
720 0.0f
, 0.0f
, 7.0f
, 0.0f
,
721 9.7f
, -8.6f
, 1.3f
, 1.0f
);
722 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, NULL
, NULL
, &last
);
723 expect_matrix(&expectedmat
, &gotmat
, 0);
725 set_matrix(&expectedmat
,
726 1.0f
, 0.0f
, 0.0f
, 0.0f
,
727 0.0f
, 1.0f
, 0.0f
, 0.0f
,
728 0.0f
, 0.0f
, 1.0f
, 0.0f
,
729 9.7f
, -8.6f
, 1.3f
, 1.0f
);
730 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, NULL
, NULL
, &last
);
731 expect_matrix(&expectedmat
, &gotmat
, 0);
733 set_matrix(&expectedmat
,
734 1.0f
, 0.0f
, 0.0f
, 0.0f
,
735 0.0f
, 1.0f
, 0.0f
, 0.0f
,
736 0.0f
, 0.0f
, 1.0f
, 0.0f
,
737 9.7f
, -8.6f
, 1.3f
, 1.0f
);
738 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, NULL
, NULL
, &last
);
739 expect_matrix(&expectedmat
, &gotmat
, 0);
741 set_matrix(&expectedmat
,
742 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
743 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
744 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
745 8.5985f
, -21.024f
, 14.383499, 1.0f
);
746 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, &eye
, &r
, NULL
);
747 expect_matrix(&expectedmat
, &gotmat
, 8);
749 set_matrix(&expectedmat
,
750 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
751 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
752 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
753 0.0f
, 0.0f
, 0.0f
, 1.0f
);
754 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, NULL
, &r
, NULL
);
755 expect_matrix(&expectedmat
, &gotmat
, 8);
757 set_matrix(&expectedmat
,
758 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
759 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
760 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
761 0.0f
, 0.0f
, 0.0f
, 1.0f
);
762 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, NULL
, &r
, NULL
);
763 expect_matrix(&expectedmat
, &gotmat
, 8);
765 set_matrix(&expectedmat
,
766 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
767 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
768 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
769 0.0f
, 0.0f
, 0.0f
, 1.0f
);
770 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, NULL
, &r
, NULL
);
771 expect_matrix(&expectedmat
, &gotmat
, 8);
773 set_matrix(&expectedmat
,
774 1.0f
, 0.0f
, 0.0f
, 0.0f
,
775 0.0f
, -3.0f
, 0.0f
, 0.0f
,
776 0.0f
, 0.0f
, 7.0f
, 0.0f
,
777 0.0f
, 0.0f
, 0.0f
, 1.0f
);
778 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, &eye
, NULL
, NULL
);
779 expect_matrix(&expectedmat
, &gotmat
, 0);
781 set_matrix(&expectedmat
,
782 1.0f
, 0.0f
, 0.0f
, 0.0f
,
783 0.0f
, 1.0f
, 0.0f
, 0.0f
,
784 0.0f
, 0.0f
, 1.0f
, 0.0f
,
785 0.0f
, 0.0f
, 0.0f
, 1.0f
);
786 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, &eye
, NULL
, NULL
);
787 expect_matrix(&expectedmat
, &gotmat
, 0);
789 set_matrix(&expectedmat
,
790 1.0f
, 0.0f
, 0.0f
, 0.0f
,
791 0.0f
, 1.0f
, 0.0f
, 0.0f
,
792 0.0f
, 0.0f
, 1.0f
, 0.0f
,
793 0.0f
, 0.0f
, 0.0f
, 1.0f
);
794 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, &eye
, NULL
, NULL
);
795 expect_matrix(&expectedmat
, &gotmat
, 0);
797 set_matrix(&expectedmat
,
798 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
799 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
800 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
801 0.0f
, 0.0f
, 0.0f
, 1.0f
);
802 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
803 expect_matrix(&expectedmat
, &gotmat
, 0);
805 set_matrix(&expectedmat
,
806 1.0f
, 0.0f
, 0.0f
, 0.0f
,
807 0.0f
, -3.0f
, 0.0f
, 0.0f
,
808 0.0f
, 0.0f
, 7.0f
, 0.0f
,
809 0.0f
, 52.0f
, 54.0f
, 1.0f
);
810 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, NULL
, NULL
, NULL
);
811 expect_matrix(&expectedmat
, &gotmat
, 0);
813 set_matrix(&expectedmat
,
814 1.0f
, 0.0f
, 0.0f
, 0.0f
,
815 0.0f
, 1.0f
, 0.0f
, 0.0f
,
816 0.0f
, 0.0f
, 1.0f
, 0.0f
,
817 0.0f
, 0.0f
, 0.0f
, 1.0f
);
818 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, NULL
, NULL
, NULL
);
819 expect_matrix(&expectedmat
, &gotmat
, 0);
821 set_matrix(&expectedmat
,
822 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
823 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
824 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
825 18.2985f
, -29.624001f
, 15.683499f
, 1.0f
);
826 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, NULL
, &eye
, &r
, &last
);
827 expect_matrix(&expectedmat
, &gotmat
, 8);
829 set_matrix(&expectedmat
,
830 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
831 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
832 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
833 9.7f
, -8.6f
, 1.3f
, 1.0f
);
834 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, NULL
, &r
, &last
);
835 expect_matrix(&expectedmat
, &gotmat
, 8);
837 set_matrix(&expectedmat
,
838 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
839 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
840 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
841 9.7f
, -8.6f
, 1.3f
, 1.0f
);
842 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, NULL
, &r
, &last
);
843 expect_matrix(&expectedmat
, &gotmat
, 8);
845 set_matrix(&expectedmat
,
846 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
847 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
848 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
849 9.7f
, -8.6f
, 1.3f
, 1.0f
);
850 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, NULL
, &r
, &last
);
851 expect_matrix(&expectedmat
, &gotmat
, 8);
853 set_matrix(&expectedmat
,
854 1.0f
, 0.0f
, 0.0f
, 0.0f
,
855 0.0f
, -3.0f
, 0.0f
, 0.0f
,
856 0.0f
, 0.0f
, 7.0f
, 0.0f
,
857 9.7f
, -8.6f
, 1.3f
, 1.0f
);
858 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, &eye
, NULL
, &last
);
859 expect_matrix(&expectedmat
, &gotmat
, 0);
861 set_matrix(&expectedmat
,
862 1.0f
, 0.0f
, 0.0f
, 0.0f
,
863 0.0f
, 1.0f
, 0.0f
, 0.0f
,
864 0.0f
, 0.0f
, 1.0f
, 0.0f
,
865 9.7f
, -8.6f
, 1.3f
, 1.0f
);
866 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, &eye
, NULL
, &last
);
867 expect_matrix(&expectedmat
, &gotmat
, 0);
869 set_matrix(&expectedmat
,
870 1.0f
, 0.0f
, 0.0f
, 0.0f
,
871 0.0f
, 1.0f
, 0.0f
, 0.0f
,
872 0.0f
, 0.0f
, 1.0f
, 0.0f
,
873 9.7f
, -8.6f
, 1.3f
, 1.0f
);
874 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, &eye
, NULL
, &last
);
875 expect_matrix(&expectedmat
, &gotmat
, 0);
877 set_matrix(&expectedmat
,
878 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
879 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
880 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
881 9.7f
, -8.6f
, 1.3f
, 1.0f
);
882 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, &last
);
883 expect_matrix(&expectedmat
, &gotmat
, 0);
885 set_matrix(&expectedmat
,
886 1.0f
, 0.0f
, 0.0f
, 0.0f
,
887 0.0f
, -3.0f
, 0.0f
, 0.0f
,
888 0.0f
, 0.0f
, 7.0f
, 0.0f
,
889 9.7f
, 43.400002f
, 55.299999f
, 1.0f
);
890 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, NULL
, NULL
, &last
);
891 expect_matrix(&expectedmat
, &gotmat
, 0);
893 set_matrix(&expectedmat
,
894 1.0f
, 0.0f
, 0.0f
, 0.0f
,
895 0.0f
, 1.0f
, 0.0f
, 0.0f
,
896 0.0f
, 0.0f
, 1.0f
, 0.0f
,
897 9.7f
, -8.6f
, 1.3f
, 1.0f
);
898 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, NULL
, NULL
, &last
);
899 expect_matrix(&expectedmat
, &gotmat
, 0);
901 set_matrix(&expectedmat
,
902 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
903 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
904 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
905 8.5985f
, -21.024f
, 14.383499, 1.0f
);
906 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, &eye
, &r
, NULL
);
907 expect_matrix(&expectedmat
, &gotmat
, 8);
909 set_matrix(&expectedmat
,
910 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
911 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
912 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
913 8.5985f
, -21.024f
, 14.383499, 1.0f
);
914 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, &eye
, &r
, NULL
);
915 expect_matrix(&expectedmat
, &gotmat
, 8);
917 set_matrix(&expectedmat
,
918 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
919 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
920 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
921 8.5985f
, -21.024f
, 14.383499, 1.0f
);
922 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, &eye
, &r
, NULL
);
923 expect_matrix(&expectedmat
, &gotmat
, 8);
925 set_matrix(&expectedmat
,
926 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
927 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
928 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
929 0.0f
, 0.0f
, 0.0f
, 1.0f
);
930 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, &r
, NULL
);
931 expect_matrix(&expectedmat
, &gotmat
, 32);
933 set_matrix(&expectedmat
,
934 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
935 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
936 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
937 104.565598f
, -35.492798f
, -25.306400f
, 1.0f
);
938 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, NULL
, &r
, NULL
);
939 expect_matrix(&expectedmat
, &gotmat
, 8);
941 set_matrix(&expectedmat
,
942 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
943 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
944 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
945 0.0f
, 0.0f
, 0.0f
, 1.0f
);
946 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, NULL
, &r
, NULL
);
947 expect_matrix(&expectedmat
, &gotmat
, 8);
949 set_matrix(&expectedmat
,
950 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
951 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
952 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
953 0.0f
, 0.0f
, 0.0f
, 1.0f
);
954 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, &eye
, NULL
, NULL
);
955 expect_matrix(&expectedmat
, &gotmat
, 0);
957 set_matrix(&expectedmat
,
958 1.0f
, 0.0f
, 0.0f
, 0.0f
,
959 0.0f
, -3.0f
, 0.0f
, 0.0f
,
960 0.0f
, 0.0f
, 7.0f
, 0.0f
,
961 0.0f
, 52.0f
, 54.0f
, 1.0f
);
962 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, &eye
, NULL
, NULL
);
963 expect_matrix(&expectedmat
, &gotmat
, 0);
965 set_matrix(&expectedmat
,
966 1.0f
, 0.0f
, 0.0f
, 0.0f
,
967 0.0f
, 1.0f
, 0.0f
, 0.0f
,
968 0.0f
, 0.0f
, 1.0f
, 0.0f
,
969 0.0f
, 0.0f
, 0.0f
, 1.0f
);
970 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, &eye
, NULL
, NULL
);
971 expect_matrix(&expectedmat
, &gotmat
, 0);
973 set_matrix(&expectedmat
,
974 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
975 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
976 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
977 -287420.0f
, -14064.0f
, 37122.0f
, 1.0f
);
978 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, NULL
, NULL
, NULL
);
979 expect_matrix(&expectedmat
, &gotmat
, 0);
981 set_matrix(&expectedmat
,
982 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
983 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
984 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
985 18.2985f
, -29.624001f
, 15.683499f
, 1.0f
);
986 D3DXMatrixTransformation(&gotmat
, NULL
, NULL
, &axis
, &eye
, &r
, &last
);
987 expect_matrix(&expectedmat
, &gotmat
, 8);
989 set_matrix(&expectedmat
,
990 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
991 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
992 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
993 18.2985f
, -29.624001f
, 15.683499f
, 1.0f
);
994 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, NULL
, &eye
, &r
, &last
);
995 expect_matrix(&expectedmat
, &gotmat
, 8);
997 set_matrix(&expectedmat
,
998 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
999 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
1000 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
1001 18.2985f
, -29.624001f
, 15.683499f
, 1.0f
);
1002 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, NULL
, &eye
, &r
, &last
);
1003 expect_matrix(&expectedmat
, &gotmat
, 8);
1005 set_matrix(&expectedmat
,
1006 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1007 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1008 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1009 9.7f
, -8.6f
, 1.3f
, 1.0f
);
1010 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, &r
, &last
);
1011 expect_matrix(&expectedmat
, &gotmat
, 32);
1013 set_matrix(&expectedmat
,
1014 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
1015 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
1016 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
1017 114.265594f
, -44.092796f
, -24.006401f
, 1.0f
);
1018 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, NULL
, &r
, &last
);
1019 expect_matrix(&expectedmat
, &gotmat
, 8);
1021 set_matrix(&expectedmat
,
1022 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
1023 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
1024 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
1025 9.7f
, -8.6f
, 1.3f
, 1.0f
);
1026 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, NULL
, &r
, &last
);
1027 expect_matrix(&expectedmat
, &gotmat
, 8);
1029 set_matrix(&expectedmat
,
1030 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
1031 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
1032 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
1033 9.7f
, -8.6f
, 1.3f
, 1.0f
);
1034 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, &eye
, NULL
, &last
);
1035 expect_matrix(&expectedmat
, &gotmat
, 0);
1037 set_matrix(&expectedmat
,
1038 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1039 0.0f
, -3.0f
, 0.0f
, 0.0f
,
1040 0.0f
, 0.0f
, 7.0f
, 0.0f
,
1041 9.7f
, 43.400002f
, 55.299999f
, 1.0f
);
1042 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, &eye
, NULL
, &last
);
1043 expect_matrix(&expectedmat
, &gotmat
, 0);
1045 set_matrix(&expectedmat
,
1046 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1047 0.0f
, 1.0f
, 0.0f
, 0.0f
,
1048 0.0f
, 0.0f
, 1.0f
, 0.0f
,
1049 9.7f
, -8.6f
, 1.3f
, 1.0f
);
1050 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, &eye
, NULL
, &last
);
1051 expect_matrix(&expectedmat
, &gotmat
, 0);
1053 set_matrix(&expectedmat
,
1054 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
1055 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
1056 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
1057 -287410.3125f
, -14072.599609f
, 37123.300781f
, 1.0f
);
1058 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, NULL
, NULL
, &last
);
1059 expect_matrix(&expectedmat
, &gotmat
, 0);
1061 set_matrix(&expectedmat
,
1062 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1063 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1064 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1065 8.598499f
, -21.024f
, 14.383499f
, 1.0f
);
1066 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, &eye
, &r
, NULL
);
1067 expect_matrix(&expectedmat
, &gotmat
, 32);
1069 set_matrix(&expectedmat
,
1070 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
1071 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
1072 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
1073 113.164093f
, -56.5168f
, -10.922897f
, 1.0f
);
1074 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, &eye
, &r
, NULL
);
1075 expect_matrix(&expectedmat
, &gotmat
, 8);
1077 set_matrix(&expectedmat
,
1078 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
1079 0.9504f
, -0.8836f
, 0.9244f
, 0.0f
,
1080 1.0212f
, 0.1936f
, -1.3588f
, 0.0f
,
1081 8.5985f
, -21.024f
, 14.383499, 1.0f
);
1082 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, &eye
, &r
, NULL
);
1083 expect_matrix(&expectedmat
, &gotmat
, 8);
1085 set_matrix(&expectedmat
,
1086 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1087 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1088 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1089 86280.34375f
, -357366.3125f
, -200024.125f
, 1.0f
);
1090 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, NULL
, &r
, NULL
);
1091 expect_matrix(&expectedmat
, &gotmat
, 32);
1093 set_matrix(&expectedmat
,
1094 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
1095 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
1096 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
1097 -287410.3125f
, -14064.0f
, 37122.0f
, 1.0f
);
1098 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, &eye
, NULL
, NULL
);
1099 expect_matrix(&expectedmat
, &gotmat
, 512);
1101 set_matrix(&expectedmat
,
1102 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1103 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1104 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1105 86280.34375f
, -357366.3125f
, -200009.75f
, 1.0f
);
1106 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, &eye
, &r
, NULL
);
1107 expect_matrix(&expectedmat
, &gotmat
, 2048);
1109 set_matrix(&expectedmat
,
1110 25521.0f
, 39984.0f
, 20148.0f
, 0.0f
,
1111 39984.0f
, 4933.0f
, -3324.0f
, 0.0f
,
1112 20148.0f
, -3324.0f
, -5153.0f
, 0.0f
,
1113 -287410.3125f
, -14072.599609f
, 37123.300781f
, 1.0f
);
1114 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, &eye
, NULL
, &last
);
1115 expect_matrix(&expectedmat
, &gotmat
, 0);
1117 set_matrix(&expectedmat
,
1118 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1119 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1120 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1121 86290.046875f
, -357374.90625f
, -200022.828125f
, 1.0f
);
1122 D3DXMatrixTransformation(&gotmat
, &at
, &q
, &axis
, NULL
, &r
, &last
);
1123 expect_matrix(&expectedmat
, &gotmat
, 32);
1125 set_matrix(&expectedmat
,
1126 -0.21480007f
, 1.3116000f
, 0.47520003f
, 0.0f
,
1127 0.95040143f
, -0.88360137f
, 0.92439979f
, 0.0f
,
1128 1.0212044f
, 0.19359307f
, -1.3588026f
, 0.0f
,
1129 18.298532f
, -29.624001f
, 15.683499f
, 1.0f
);
1130 D3DXMatrixTransformation(&gotmat
, &at
, &q
, NULL
, &eye
, &r
, &last
);
1131 expect_matrix(&expectedmat
, &gotmat
, 512);
1133 set_matrix(&expectedmat
,
1134 -0.2148f
, 1.3116f
, 0.4752f
, 0.0f
,
1135 -2.8512f
, 2.6508f
, -2.7732f
, 0.0f
,
1136 7.148399f
, 1.3552f
, -9.5116f
, 0.0f
,
1137 122.86409f
, -65.116798f
, -9.622897f
, 1.0f
);
1138 D3DXMatrixTransformation(&gotmat
, &at
, NULL
, &axis
, &eye
, &r
, &last
);
1139 expect_matrix(&expectedmat
, &gotmat
, 8);
1141 set_matrix(&expectedmat
,
1142 53094.015625f
, 2044.133789f
, 21711.687500f
, 0.0f
,
1143 -7294.705078f
, 47440.683594f
, 28077.113281, 0.0f
,
1144 -12749.161133f
, 28365.580078f
, 13503.520508f
, 0.0f
,
1145 18.2985f
, -29.624001f
, 15.683499f
, 1.0f
);
1146 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, &eye
, &r
, &last
);
1147 expect_matrix(&expectedmat
, &gotmat
, 32);
1149 q
.x
= 1.0f
; q
.y
= 1.0f
; q
.z
= 1.0f
; q
.w
= 1.0f
;
1150 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 2.0f
;
1152 set_matrix(&expectedmat
,
1153 41.0f
, -12.0f
, -24.0f
, 0.0f
,
1154 -12.0f
, 25.0f
, -12.0f
, 0.0f
,
1155 -24.0f
, -12.0f
, 34.0f
, 0.0f
,
1156 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1157 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1158 expect_matrix(&expectedmat
, &gotmat
, 0);
1160 q
.x
= 1.0f
; q
.y
= 1.0f
; q
.z
= 1.0f
; q
.w
= 1.0f
;
1161 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 3.0f
;
1163 set_matrix(&expectedmat
,
1164 57.0f
, -12.0f
, -36.0f
, 0.0f
,
1165 -12.0f
, 25.0f
, -12.0f
, 0.0f
,
1166 -36.0f
, -12.0f
, 43.0f
, 0.0f
,
1167 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1168 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1169 expect_matrix(&expectedmat
, &gotmat
, 0);
1171 q
.x
= 1.0f
; q
.y
= 1.0f
; q
.z
= 1.0f
; q
.w
= 0.0f
;
1172 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 3.0f
;
1174 set_matrix(&expectedmat
,
1175 25.0f
, 0.0f
, -20.0f
, 0.0f
,
1176 0.0f
, 25.0f
, -20.0f
, 0.0f
,
1177 -20.0f
, -20.0f
, 35.0f
, 0.0f
,
1178 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1179 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1180 expect_matrix(&expectedmat
, &gotmat
, 0);
1182 q
.x
= 1.0f
; q
.y
= 1.0f
; q
.z
= 0.0f
; q
.w
= 0.0f
;
1183 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 3.0f
;
1185 set_matrix(&expectedmat
,
1186 5.0f
, -4.0f
, 0.0f
, 0.0f
,
1187 -4.0f
, 5.0f
, 0.0f
, 0.0f
,
1188 0.0f
, 0.0f
, 27.0f
, 0.0f
,
1189 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1190 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1191 expect_matrix(&expectedmat
, &gotmat
, 0);
1193 q
.x
= 1.0f
; q
.y
= 0.0f
; q
.z
= 0.0f
; q
.w
= 0.0f
;
1194 axis
.x
= 5.0f
; axis
.y
= 2.0f
; axis
.z
= 1.0f
;
1196 set_matrix(&expectedmat
,
1197 5.0f
, 0.0f
, 0.0f
, 0.0f
,
1198 0.0f
, 2.0f
, 0.0f
, 0.0f
,
1199 0.0f
, 0.0f
, 1.0f
, 0.0f
,
1200 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1201 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1202 expect_matrix(&expectedmat
, &gotmat
, 0);
1204 q
.x
= 1.0f
; q
.y
= 0.0f
; q
.z
= 0.0f
; q
.w
= 0.0f
;
1205 axis
.x
= 1.0f
; axis
.y
= 4.0f
; axis
.z
= 1.0f
;
1207 set_matrix(&expectedmat
,
1208 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1209 0.0f
, 4.0f
, 0.0f
, 0.0f
,
1210 0.0f
, 0.0f
, 1.0f
, 0.0f
,
1211 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1212 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1213 expect_matrix(&expectedmat
, &gotmat
, 0);
1215 q
.x
= 0.0f
; q
.y
= 1.0f
; q
.z
= 0.0f
; q
.w
= 0.0f
;
1216 axis
.x
= 1.0f
; axis
.y
= 4.0f
; axis
.z
= 1.0f
;
1218 set_matrix(&expectedmat
,
1219 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1220 0.0f
, 4.0f
, 0.0f
, 0.0f
,
1221 0.0f
, 0.0f
, 1.0f
, 0.0f
,
1222 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1223 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1224 expect_matrix(&expectedmat
, &gotmat
, 0);
1226 q
.x
= 1.0f
; q
.y
= 0.0f
; q
.z
= 0.0f
; q
.w
= 1.0f
;
1227 axis
.x
= 1.0f
; axis
.y
= 4.0f
; axis
.z
= 1.0f
;
1229 set_matrix(&expectedmat
,
1230 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1231 0.0f
, 8.0f
, -6.0f
, 0.0f
,
1232 0.0f
, -6.0f
, 17.0f
, 0.0f
,
1233 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1234 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1235 expect_matrix(&expectedmat
, &gotmat
, 0);
1237 q
.x
= 1.0f
; q
.y
= 0.0f
; q
.z
= 0.0f
; q
.w
= 1.0f
;
1238 axis
.x
= 0.0f
; axis
.y
= 4.0f
; axis
.z
= 0.0f
;
1240 set_matrix(&expectedmat
,
1241 0.0f
, 0.0f
, 0.0f
, 0.0f
,
1242 0.0f
, 4.0f
, -8.0f
, 0.0f
,
1243 0.0f
, -8.0f
, 16.0f
, 0.0f
,
1244 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1245 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1246 expect_matrix(&expectedmat
, &gotmat
, 0);
1248 q
.x
= 0.0f
; q
.y
= 1.0f
; q
.z
= 0.0f
; q
.w
= 1.0f
;
1249 axis
.x
= 1.0f
; axis
.y
= 4.0f
; axis
.z
= 1.0f
;
1251 set_matrix(&expectedmat
,
1252 5.0f
, 0.0f
, 0.0f
, 0.0f
,
1253 0.0f
, 4.0f
, 0.0f
, 0.0f
,
1254 0.0f
, 0.0f
, 5.0f
, 0.0f
,
1255 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1256 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1257 expect_matrix(&expectedmat
, &gotmat
, 0);
1259 q
.x
= 1.0f
; q
.y
= 0.0f
; q
.z
= 0.0f
; q
.w
= 0.0f
;
1260 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 3.0f
;
1262 set_matrix(&expectedmat
,
1263 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1264 0.0f
, 1.0f
, 0.0f
, 0.0f
,
1265 0.0f
, 0.0f
, 3.0f
, 0.0f
,
1266 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1267 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1268 expect_matrix(&expectedmat
, &gotmat
, 0);
1270 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1271 axis
.x
= 3.0f
; axis
.y
= 3.0f
; axis
.z
= 3.0f
;
1273 set_matrix(&expectedmat
,
1274 3796587.0f
, -1377948.0f
, -1589940.0f
, 0.0f
,
1275 -1377948.0f
, 3334059.0f
, -1879020.0f
, 0.0f
,
1276 -1589940.0f
, -1879020.0f
, 2794443.0f
, 0.0f
,
1277 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1278 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1279 expect_matrix(&expectedmat
, &gotmat
, 0);
1281 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1282 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 1.0f
;
1284 set_matrix(&expectedmat
,
1285 1265529.0f
, -459316.0f
, -529980.0f
, 0.0f
,
1286 -459316.0f
, 1111353.0f
, -626340.0f
, 0.0f
,
1287 -529980.0f
, -626340.0f
, 931481.0f
, 0.0f
,
1288 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1289 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1290 expect_matrix(&expectedmat
, &gotmat
, 0);
1292 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1293 axis
.x
= 1.0f
; axis
.y
= 1.0f
; axis
.z
= 3.0f
;
1295 set_matrix(&expectedmat
,
1296 2457497.0f
, -434612.0f
, -1423956.0f
, 0.0f
,
1297 -434612.0f
, 1111865.0f
, -644868.0f
, 0.0f
,
1298 -1423956.0f
, -644868.0f
, 1601963.0f
, 0.0f
,
1299 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1300 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1301 expect_matrix(&expectedmat
, &gotmat
, 0);
1303 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1304 axis
.x
= 0.0f
; axis
.y
= 0.0f
; axis
.z
= 3.0f
;
1306 set_matrix(&expectedmat
,
1307 1787952.0f
, 37056.0f
, -1340964.0f
, 0.0f
,
1308 37056.0f
, 768.0f
, -27792.0f
, 0.0f
,
1309 -1340964.0f
, -27792.0f
, 1005723.0f
, 0.0f
,
1310 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1311 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1312 expect_matrix(&expectedmat
, &gotmat
, 0);
1314 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1315 axis
.x
= 0.0f
; axis
.y
= 0.0f
; axis
.z
= 1.0f
;
1317 set_matrix(&expectedmat
,
1318 595984.0f
, 12352.0f
, -446988.0f
, 0.0f
,
1319 12352.0f
, 256.0f
, -9264.0f
, 0.0f
,
1320 -446988.0f
, -9264.0f
, 335241.0f
, 0.0f
,
1321 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1322 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1323 expect_matrix(&expectedmat
, &gotmat
, 0);
1325 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1326 axis
.x
= 0.0f
; axis
.y
= 3.0f
; axis
.z
= 0.0f
;
1328 set_matrix(&expectedmat
,
1329 150528.0f
, 464352.0f
, -513408.0f
, 0.0f
,
1330 464352.0f
, 1432443.0f
, -1583772.0f
, 0.0f
,
1331 -513408.0f
, -1583772.0f
, 1751088.0f
, 0.0f
,
1332 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1333 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1334 expect_matrix(&expectedmat
, &gotmat
, 0);
1336 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1337 axis
.x
= 0.0f
; axis
.y
= 1.0f
; axis
.z
= 0.0f
;
1339 set_matrix(&expectedmat
,
1340 50176.0f
, 154784.0f
, -171136.0f
, 0.0f
,
1341 154784.0f
, 477481.0f
, -527924.0f
, 0.0f
,
1342 -171136.0f
, -527924.0f
, 583696.0f
, 0.0f
,
1343 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1344 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1345 expect_matrix(&expectedmat
, &gotmat
, 0);
1347 q
.x
= 11.0f
; q
.y
= 13.0f
; q
.z
= 15.0f
; q
.w
= 17.0f
;
1348 axis
.x
= 1.0f
; axis
.y
= 0.0f
; axis
.z
= 0.0f
;
1350 set_matrix(&expectedmat
,
1351 619369.0f
, -626452.0f
, 88144.0f
, 0.0f
,
1352 -626452.0f
, 633616.0f
, -89152.0f
, 0.0f
,
1353 88144.0f
, -89152, 12544.0f
, 0.0f
,
1354 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1355 D3DXMatrixTransformation(&gotmat
, NULL
, &q
, &axis
, NULL
, NULL
, NULL
);
1356 expect_matrix(&expectedmat
, &gotmat
, 0);
1358 /*____________D3DXMatrixTranslation______________*/
1359 set_matrix(&expectedmat
,
1360 1.0f
, 0.0f
, 0.0f
, 0.0f
,
1361 0.0f
, 1.0f
, 0.0f
, 0.0f
,
1362 0.0f
, 0.0f
, 1.0f
, 0.0f
,
1363 0.69f
, 0.53f
, 4.11f
, 1.0f
);
1364 D3DXMatrixTranslation(&gotmat
, 0.69f
, 0.53f
, 4.11f
);
1365 expect_matrix(&expectedmat
, &gotmat
, 0);
1367 /*____________D3DXMatrixTranspose______________*/
1368 set_matrix(&expectedmat
,
1369 10.0f
, 11.0f
, 19.0f
, 2.0f
,
1370 5.0f
, 20.0f
, -21.0f
, 3.0f
,
1371 7.0f
, 16.0f
, 30.f
, -4.0f
,
1372 8.0f
, 33.0f
, 43.0f
, -40.0f
);
1373 D3DXMatrixTranspose(&gotmat
, &mat
);
1374 expect_matrix(&expectedmat
, &gotmat
, 0);
1377 static void D3DXPlaneTest(void)
1380 D3DXPLANE expectedplane
, gotplane
, nulplane
, plane
;
1381 D3DXVECTOR3 expectedvec
, gotvec
, vec1
, vec2
, vec3
;
1382 LPD3DXVECTOR3 funcpointer
;
1384 FLOAT expected
, got
;
1386 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1387 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1388 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1389 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1390 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
1391 U(mat
).m
[3][3] = -40.0f
;
1393 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
1395 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
1397 /*_______________D3DXPlaneDot________________*/
1399 got
= D3DXPlaneDot(&plane
, &vec
);
1400 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1402 got
= D3DXPlaneDot(NULL
, &vec
);
1403 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1405 got
= D3DXPlaneDot(NULL
, NULL
);
1406 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1408 /*_______________D3DXPlaneDotCoord________________*/
1410 got
= D3DXPlaneDotCoord(&plane
, &vec
);
1411 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1413 got
= D3DXPlaneDotCoord(NULL
, &vec
);
1414 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1416 got
= D3DXPlaneDotCoord(NULL
, NULL
);
1417 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1419 /*_______________D3DXPlaneDotNormal______________*/
1421 got
= D3DXPlaneDotNormal(&plane
, &vec
);
1422 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1424 got
= D3DXPlaneDotNormal(NULL
, &vec
);
1425 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1427 got
= D3DXPlaneDotNormal(NULL
, NULL
);
1428 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
1430 /*_______________D3DXPlaneFromPointNormal_______*/
1431 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
1432 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
1433 expectedplane
.a
= 17.0f
; expectedplane
.b
= 31.0f
; expectedplane
.c
= 24.0f
; expectedplane
.d
= -950.0f
;
1434 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, &vec2
);
1435 expect_plane(&expectedplane
, &gotplane
, 0);
1436 gotplane
.a
= vec2
.x
; gotplane
.b
= vec2
.y
; gotplane
.c
= vec2
.z
;
1437 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, (D3DXVECTOR3
*)&gotplane
);
1438 expect_plane(&expectedplane
, &gotplane
, 0);
1439 gotplane
.a
= vec1
.x
; gotplane
.b
= vec1
.y
; gotplane
.c
= vec1
.z
;
1440 expectedplane
.d
= -1826.0f
;
1441 D3DXPlaneFromPointNormal(&gotplane
, (D3DXVECTOR3
*)&gotplane
, &vec2
);
1442 expect_plane(&expectedplane
, &gotplane
, 0);
1444 /*_______________D3DXPlaneFromPoints_______*/
1445 vec1
.x
= 1.0f
; vec1
.y
= 2.0f
; vec1
.z
= 3.0f
;
1446 vec2
.x
= 1.0f
; vec2
.y
= -6.0f
; vec2
.z
= -5.0f
;
1447 vec3
.x
= 83.0f
; vec3
.y
= 74.0f
; vec3
.z
= 65.0f
;
1448 expectedplane
.a
= 0.085914f
; expectedplane
.b
= -0.704492f
; expectedplane
.c
= 0.704492f
; expectedplane
.d
= -0.790406f
;
1449 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
1450 expect_plane(&expectedplane
, &gotplane
, 64);
1452 /*_______________D3DXPlaneIntersectLine___________*/
1453 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
1454 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
1455 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
1456 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
1457 expect_vec3(&expectedvec
, &gotvec
, 1);
1458 /* Test a parallel line */
1459 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
1460 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
1461 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
1462 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
1463 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1465 /*_______________D3DXPlaneNormalize______________*/
1466 expectedplane
.a
= -3.0f
/sqrt(26.0f
); expectedplane
.b
= -1.0f
/sqrt(26.0f
); expectedplane
.c
= 4.0f
/sqrt(26.0f
); expectedplane
.d
= 7.0/sqrt(26.0f
);
1467 D3DXPlaneNormalize(&gotplane
, &plane
);
1468 expect_plane(&expectedplane
, &gotplane
, 2);
1469 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
; nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
1470 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
1471 D3DXPlaneNormalize(&gotplane
, &nulplane
);
1472 expect_plane(&expectedplane
, &gotplane
, 0);
1474 /*_______________D3DXPlaneTransform____________*/
1475 expectedplane
.a
= 49.0f
; expectedplane
.b
= -98.0f
; expectedplane
.c
= 55.0f
; expectedplane
.d
= -165.0f
;
1476 D3DXPlaneTransform(&gotplane
,&plane
,&mat
);
1477 expect_plane(&expectedplane
, &gotplane
, 0);
1480 static void D3DXQuaternionTest(void)
1483 D3DXQUATERNION expectedquat
, gotquat
, Nq
, Nq1
, nul
, smallq
, smallr
, q
, r
, s
, t
, u
;
1484 BOOL expectedbool
, gotbool
, equal
;
1485 float angle
, got
, scale
, scale2
;
1486 LPD3DXQUATERNION funcpointer
;
1487 D3DXVECTOR3 axis
, expectedvec
;
1489 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
1490 q
.x
= 1.0f
; q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
1491 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
1492 t
.x
= -1111.0f
; t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
1493 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
1494 smallq
.x
= 0.1f
; smallq
.y
= 0.2f
; smallq
.z
= 0.3f
; smallq
.w
= 0.4f
;
1495 smallr
.x
= 0.5f
; smallr
.y
= 0.6f
; smallr
.z
= 0.7f
; smallr
.w
= 0.8f
;
1500 /*_______________D3DXQuaternionBaryCentric________________________*/
1501 expectedquat
.x
= -867.444458; expectedquat
.y
= 87.851111f
; expectedquat
.z
= -9.937778f
; expectedquat
.w
= 3.235555f
;
1502 D3DXQuaternionBaryCentric(&gotquat
,&q
,&r
,&t
,scale
,scale2
);
1503 expect_quaternion(&expectedquat
, &gotquat
, 1);
1505 /*_______________D3DXQuaternionConjugate________________*/
1506 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
1507 D3DXQuaternionConjugate(&gotquat
,&q
);
1508 expect_quaternion(&expectedquat
, &gotquat
, 0);
1509 /* Test the NULL case */
1510 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
1511 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1512 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
1513 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1515 /*_______________D3DXQuaternionDot______________________*/
1516 got
= D3DXQuaternionDot(&q
,&r
);
1517 equal
= compare_float(got
, 55.0f
, 0);
1518 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1519 /* Tests the case NULL */
1520 got
= D3DXQuaternionDot(NULL
,&r
);
1521 equal
= compare_float(got
, 0.0f
, 0);
1522 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1523 got
= D3DXQuaternionDot(NULL
,NULL
);
1524 equal
= compare_float(got
, 0.0f
, 0);
1525 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1527 /*_______________D3DXQuaternionExp______________________________*/
1528 expectedquat
.x
= -0.216382f
; expectedquat
.y
= -0.432764f
; expectedquat
.z
= -0.8655270f
; expectedquat
.w
= -0.129449f
;
1529 D3DXQuaternionExp(&gotquat
,&q
);
1530 expect_quaternion(&expectedquat
, &gotquat
, 16);
1531 /* Test the null quaternion */
1532 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
1533 D3DXQuaternionExp(&gotquat
,&nul
);
1534 expect_quaternion(&expectedquat
, &gotquat
, 0);
1535 /* Test the case where the norm of the quaternion is <1 */
1536 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
1537 expectedquat
.x
= 0.195366; expectedquat
.y
= 0.097683f
; expectedquat
.z
= 0.293049f
; expectedquat
.w
= 0.930813f
;
1538 D3DXQuaternionExp(&gotquat
,&Nq1
);
1539 expect_quaternion(&expectedquat
, &gotquat
, 8);
1541 /*_______________D3DXQuaternionIdentity________________*/
1542 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
1543 D3DXQuaternionIdentity(&gotquat
);
1544 expect_quaternion(&expectedquat
, &gotquat
, 0);
1545 /* Test the NULL case */
1546 funcpointer
= D3DXQuaternionIdentity(NULL
);
1547 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1549 /*_______________D3DXQuaternionInverse________________________*/
1550 expectedquat
.x
= -1.0f
/121.0f
; expectedquat
.y
= -2.0f
/121.0f
; expectedquat
.z
= -4.0f
/121.0f
; expectedquat
.w
= 10.0f
/121.0f
;
1551 D3DXQuaternionInverse(&gotquat
,&q
);
1552 expect_quaternion(&expectedquat
, &gotquat
, 0);
1554 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 10.0f
;
1555 D3DXQuaternionInverse(&gotquat
,&gotquat
);
1556 expect_quaternion(&expectedquat
, &gotquat
, 1);
1559 /*_______________D3DXQuaternionIsIdentity________________*/
1560 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
1561 expectedbool
= TRUE
;
1562 gotbool
= D3DXQuaternionIsIdentity(&s
);
1563 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
1564 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
1565 expectedbool
= FALSE
;
1566 gotbool
= D3DXQuaternionIsIdentity(&q
);
1567 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
1568 /* Test the NULL case */
1569 gotbool
= D3DXQuaternionIsIdentity(NULL
);
1570 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
1572 /*_______________D3DXQuaternionLength__________________________*/
1573 got
= D3DXQuaternionLength(&q
);
1574 equal
= compare_float(got
, 11.0f
, 0);
1575 ok(equal
, "Got unexpected length %.8e.\n", got
);
1576 /* Tests the case NULL. */
1577 got
= D3DXQuaternionLength(NULL
);
1578 equal
= compare_float(got
, 0.0f
, 0);
1579 ok(equal
, "Got unexpected length %.8e.\n", got
);
1581 /*_______________D3DXQuaternionLengthSq________________________*/
1582 got
= D3DXQuaternionLengthSq(&q
);
1583 equal
= compare_float(got
, 121.0f
, 0);
1584 ok(equal
, "Got unexpected length %.8e.\n", got
);
1585 /* Tests the case NULL */
1586 got
= D3DXQuaternionLengthSq(NULL
);
1587 equal
= compare_float(got
, 0.0f
, 0);
1588 ok(equal
, "Got unexpected length %.8e.\n", got
);
1590 /*_______________D3DXQuaternionLn______________________________*/
1591 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 0.0f
;
1592 D3DXQuaternionLn(&gotquat
,&q
);
1593 expect_quaternion(&expectedquat
, &gotquat
, 0);
1594 expectedquat
.x
= -3.0f
; expectedquat
.y
= 4.0f
; expectedquat
.z
= -5.0f
; expectedquat
.w
= 0.0f
;
1595 D3DXQuaternionLn(&gotquat
,&r
);
1596 expect_quaternion(&expectedquat
, &gotquat
, 0);
1597 Nq
.x
= 1.0f
/11.0f
; Nq
.y
= 2.0f
/11.0f
; Nq
.z
= 4.0f
/11.0f
; Nq
.w
=10.0f
/11.0f
;
1598 expectedquat
.x
= 0.093768f
; expectedquat
.y
= 0.187536f
; expectedquat
.z
= 0.375073f
; expectedquat
.w
= 0.0f
;
1599 D3DXQuaternionLn(&gotquat
,&Nq
);
1600 expect_quaternion(&expectedquat
, &gotquat
, 32);
1601 Nq
.x
= 0.0f
; Nq
.y
= 0.0f
; Nq
.z
= 0.0f
; Nq
.w
= 1.0f
;
1602 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1603 D3DXQuaternionLn(&gotquat
,&Nq
);
1604 expect_quaternion(&expectedquat
, &gotquat
, 0);
1605 Nq
.x
= 5.4f
; Nq
.y
= 1.2f
; Nq
.z
= -0.3f
; Nq
.w
= -0.3f
;
1606 expectedquat
.x
= 10.616652f
; expectedquat
.y
= 2.359256f
; expectedquat
.z
= -0.589814f
; expectedquat
.w
= 0.0f
;
1607 D3DXQuaternionLn(&gotquat
,&Nq
);
1608 expect_quaternion(&expectedquat
, &gotquat
, 1);
1609 /* Test the case where the norm of the quaternion is <1 */
1610 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
1611 expectedquat
.x
= 0.206945f
; expectedquat
.y
= 0.103473f
; expectedquat
.z
= 0.310418f
; expectedquat
.w
= 0.0f
;
1612 D3DXQuaternionLn(&gotquat
,&Nq1
);
1613 expect_quaternion(&expectedquat
, &gotquat
, 64);
1614 /* Test the case where the real part of the quaternion is -1.0f */
1615 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= -1.0f
;
1616 expectedquat
.x
= 0.2f
; expectedquat
.y
= 0.1f
; expectedquat
.z
= 0.3f
; expectedquat
.w
= 0.0f
;
1617 D3DXQuaternionLn(&gotquat
,&Nq1
);
1618 expect_quaternion(&expectedquat
, &gotquat
, 0);
1620 /*_______________D3DXQuaternionMultiply________________________*/
1621 expectedquat
.x
= 3.0f
; expectedquat
.y
= 61.0f
; expectedquat
.z
= -32.0f
; expectedquat
.w
= 85.0f
;
1622 D3DXQuaternionMultiply(&gotquat
,&q
,&r
);
1623 expect_quaternion(&expectedquat
, &gotquat
, 0);
1625 /*_______________D3DXQuaternionNormalize________________________*/
1626 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
1627 D3DXQuaternionNormalize(&gotquat
,&q
);
1628 expect_quaternion(&expectedquat
, &gotquat
, 1);
1630 /*_______________D3DXQuaternionRotationAxis___________________*/
1631 axis
.x
= 2.0f
; axis
.y
= 7.0; axis
.z
= 13.0f
;
1632 angle
= D3DX_PI
/3.0f
;
1633 expectedquat
.x
= 0.067116; expectedquat
.y
= 0.234905f
; expectedquat
.z
= 0.436251f
; expectedquat
.w
= 0.866025f
;
1634 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
1635 expect_quaternion(&expectedquat
, &gotquat
, 64);
1636 /* Test the nul quaternion */
1637 axis
.x
= 0.0f
; axis
.y
= 0.0; axis
.z
= 0.0f
;
1638 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.866025f
;
1639 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
1640 expect_quaternion(&expectedquat
, &gotquat
, 8);
1642 /*_______________D3DXQuaternionRotationMatrix___________________*/
1643 /* test when the trace is >0 */
1644 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1645 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1646 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1647 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1648 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
1649 U(mat
).m
[3][3] = 48.0f
;
1650 expectedquat
.x
= 2.368682f
; expectedquat
.y
= 0.768221f
; expectedquat
.z
= -0.384111f
; expectedquat
.w
= 3.905125f
;
1651 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1652 expect_quaternion(&expectedquat
, &gotquat
, 16);
1653 /* test the case when the greater element is (2,2) */
1654 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1655 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1656 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1657 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1658 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = -60.0f
; U(mat
).m
[2][2] = 40.0f
;
1659 U(mat
).m
[3][3] = 48.0f
;
1660 expectedquat
.x
= 1.233905f
; expectedquat
.y
= -0.237290f
; expectedquat
.z
= 5.267827f
; expectedquat
.w
= -0.284747f
;
1661 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1662 expect_quaternion(&expectedquat
, &gotquat
, 64);
1663 /* test the case when the greater element is (1,1) */
1664 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1665 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1666 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1667 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1668 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 60.0f
; U(mat
).m
[2][2] = -80.0f
;
1669 U(mat
).m
[3][3] = 48.0f
;
1670 expectedquat
.x
= 0.651031f
; expectedquat
.y
= 6.144103f
; expectedquat
.z
= -0.203447f
; expectedquat
.w
= 0.488273f
;
1671 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1672 expect_quaternion(&expectedquat
, &gotquat
, 8);
1673 /* test the case when the trace is near 0 in a matrix which is not a rotation */
1674 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1675 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1676 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1677 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1678 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.9f
;
1679 U(mat
).m
[3][3] = 48.0f
;
1680 expectedquat
.x
= 1.709495f
; expectedquat
.y
= 2.339872f
; expectedquat
.z
= -0.534217f
; expectedquat
.w
= 1.282122f
;
1681 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1682 expect_quaternion(&expectedquat
, &gotquat
, 8);
1683 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
1684 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1685 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1686 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1687 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1688 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.51f
;
1689 U(mat
).m
[3][3] = 48.0f
;
1690 expectedquat
.x
= 1.724923f
; expectedquat
.y
= 2.318944f
; expectedquat
.z
= -0.539039f
; expectedquat
.w
= 1.293692f
;
1691 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1692 expect_quaternion(&expectedquat
, &gotquat
, 8);
1693 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
1694 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1695 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1696 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1697 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1698 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.49f
;
1699 U(mat
).m
[3][3] = 48.0f
;
1700 expectedquat
.x
= 1.725726f
; expectedquat
.y
= 2.317865f
; expectedquat
.z
= -0.539289f
; expectedquat
.w
= 1.294294f
;
1701 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1702 expect_quaternion(&expectedquat
, &gotquat
, 8);
1703 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
1704 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1705 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1706 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1707 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1708 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.01f
;
1709 U(mat
).m
[3][3] = 48.0f
;
1710 expectedquat
.x
= 1.745328f
; expectedquat
.y
= 2.291833f
; expectedquat
.z
= -0.545415f
; expectedquat
.w
= 1.308996f
;
1711 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1712 expect_quaternion(&expectedquat
, &gotquat
, 4);
1713 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
1714 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1715 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1716 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1717 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1718 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.0f
;
1719 U(mat
).m
[3][3] = 48.0f
;
1720 expectedquat
.x
= 1.745743f
; expectedquat
.y
= 2.291288f
; expectedquat
.z
= -0.545545f
; expectedquat
.w
= 1.309307f
;
1721 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1722 expect_quaternion(&expectedquat
, &gotquat
, 8);
1723 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
1724 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1725 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1726 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1727 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1728 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.01f
;
1729 U(mat
).m
[3][3] = 48.0f
;
1730 expectedquat
.x
= 18.408188f
; expectedquat
.y
= 5.970223f
; expectedquat
.z
= -2.985111f
; expectedquat
.w
= 0.502494f
;
1731 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1732 expect_quaternion(&expectedquat
, &gotquat
, 4);
1733 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
1734 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1735 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1736 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1737 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1738 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.5f
;
1739 U(mat
).m
[3][3] = 48.0f
;
1740 expectedquat
.x
= 15.105186f
; expectedquat
.y
= 4.898980f
; expectedquat
.z
= -2.449490f
; expectedquat
.w
= 0.612372f
;
1741 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1742 expect_quaternion(&expectedquat
, &gotquat
, 8);
1743 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
1744 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1745 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1746 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1747 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1748 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.70f
;
1749 U(mat
).m
[3][3] = 48.0f
;
1750 expectedquat
.x
= 14.188852f
; expectedquat
.y
= 4.601790f
; expectedquat
.z
= -2.300895f
; expectedquat
.w
= 0.651920f
;
1751 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1752 expect_quaternion(&expectedquat
, &gotquat
, 4);
1753 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
1754 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1755 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1756 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1757 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1758 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.99f
;
1759 U(mat
).m
[3][3] = 48.0f
;
1760 expectedquat
.x
= 13.114303f
; expectedquat
.y
= 4.253287f
; expectedquat
.z
= -2.126644f
; expectedquat
.w
= 0.705337f
;
1761 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1762 expect_quaternion(&expectedquat
, &gotquat
, 4);
1763 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
1764 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
1765 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
1766 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
1767 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
1768 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 2.0f
;
1769 U(mat
).m
[3][3] = 48.0f
;
1770 expectedquat
.x
= 10.680980f
; expectedquat
.y
= 3.464102f
; expectedquat
.z
= -1.732051f
; expectedquat
.w
= 0.866025f
;
1771 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
1772 expect_quaternion(&expectedquat
, &gotquat
, 8);
1774 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
1775 expectedquat
.x
= 0.303261f
; expectedquat
.y
= 0.262299f
; expectedquat
.z
= 0.410073f
; expectedquat
.w
= 0.819190f
;
1776 D3DXQuaternionRotationYawPitchRoll(&gotquat
,D3DX_PI
/4.0f
,D3DX_PI
/11.0f
,D3DX_PI
/3.0f
);
1777 expect_quaternion(&expectedquat
, &gotquat
, 16);
1779 /*_______________D3DXQuaternionSlerp________________________*/
1780 expectedquat
.x
= -0.2f
; expectedquat
.y
= 2.6f
; expectedquat
.z
= 1.3f
; expectedquat
.w
= 9.1f
;
1781 D3DXQuaternionSlerp(&gotquat
,&q
,&r
,scale
);
1782 expect_quaternion(&expectedquat
, &gotquat
, 4);
1783 expectedquat
.x
= 334.0f
; expectedquat
.y
= -31.9f
; expectedquat
.z
= 6.1f
; expectedquat
.w
= 6.7f
;
1784 D3DXQuaternionSlerp(&gotquat
,&q
,&t
,scale
);
1785 expect_quaternion(&expectedquat
, &gotquat
, 2);
1786 expectedquat
.x
= 0.239485f
; expectedquat
.y
= 0.346580f
; expectedquat
.z
= 0.453676f
; expectedquat
.w
= 0.560772f
;
1787 D3DXQuaternionSlerp(&gotquat
,&smallq
,&smallr
,scale
);
1788 expect_quaternion(&expectedquat
, &gotquat
, 32);
1790 /*_______________D3DXQuaternionSquad________________________*/
1791 expectedquat
.x
= -156.296f
; expectedquat
.y
= 30.242f
; expectedquat
.z
= -2.5022f
; expectedquat
.w
= 7.3576f
;
1792 D3DXQuaternionSquad(&gotquat
,&q
,&r
,&t
,&u
,scale
);
1793 expect_quaternion(&expectedquat
, &gotquat
, 2);
1795 /*_______________D3DXQuaternionSquadSetup___________________*/
1796 r
.x
= 1.0f
; r
.y
= 2.0f
; r
.z
= 4.0f
; r
.w
= 10.0f
;
1797 s
.x
= -3.0f
; s
.y
= 4.0f
; s
.z
= -5.0f
; s
.w
= 7.0;
1798 t
.x
= -1111.0f
; t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
1799 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
1800 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1801 expectedquat
.x
= 7.121285f
; expectedquat
.y
= 2.159964f
; expectedquat
.z
= -3.855094f
; expectedquat
.w
= 5.362844f
;
1802 expect_quaternion(&expectedquat
, &gotquat
, 2);
1803 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
1804 expect_quaternion(&expectedquat
, &Nq
, 4);
1805 expectedquat
.x
= -1111.0f
; expectedquat
.y
= 111.0f
; expectedquat
.z
= -11.0f
; expectedquat
.w
= 1.0f
;
1806 expect_quaternion(&expectedquat
, &Nq1
, 0);
1808 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &gotquat
, &t
, &u
);
1809 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
1810 expect_quaternion(&expectedquat
, &Nq
, 4);
1812 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &Nq1
);
1813 expect_quaternion(&expectedquat
, &Nq
, 4);
1814 r
.x
= 0.2f
; r
.y
= 0.3f
; r
.z
= 1.3f
; r
.w
= -0.6f
;
1815 s
.x
= -3.0f
; s
.y
=-2.0f
; s
.z
= 4.0f
; s
.w
= 0.2f
;
1816 t
.x
= 0.4f
; t
.y
= 8.3f
; t
.z
= -3.1f
; t
.w
= -2.7f
;
1817 u
.x
= 1.1f
; u
.y
= -0.7f
; u
.z
= 9.2f
; u
.w
= 0.0f
;
1818 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &u
, &t
);
1819 expectedquat
.x
= -4.139569f
; expectedquat
.y
= -2.469115f
; expectedquat
.z
= 2.364477f
; expectedquat
.w
= 0.465494f
;
1820 expect_quaternion(&expectedquat
, &gotquat
, 16);
1821 expectedquat
.x
= 2.342533f
; expectedquat
.y
= 2.365127f
; expectedquat
.z
= 8.628538f
; expectedquat
.w
= -0.898356f
;
1822 expect_quaternion(&expectedquat
, &Nq
, 16);
1823 expectedquat
.x
= 1.1f
; expectedquat
.y
= -0.7f
; expectedquat
.z
= 9.2f
; expectedquat
.w
= 0.0f
;
1824 expect_quaternion(&expectedquat
, &Nq1
, 0);
1825 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1826 expectedquat
.x
= -3.754567f
; expectedquat
.y
= -0.586085f
; expectedquat
.z
= 3.815818f
; expectedquat
.w
= -0.198150f
;
1827 expect_quaternion(&expectedquat
, &gotquat
, 32);
1828 expectedquat
.x
= 0.140773f
; expectedquat
.y
= -8.737090f
; expectedquat
.z
= -0.516593f
; expectedquat
.w
= 3.053942f
;
1829 expect_quaternion(&expectedquat
, &Nq
, 16);
1830 expectedquat
.x
= -0.4f
; expectedquat
.y
= -8.3f
; expectedquat
.z
= 3.1f
; expectedquat
.w
= 2.7f
;
1831 expect_quaternion(&expectedquat
, &Nq1
, 0);
1832 r
.x
= -1.0f
; r
.y
= 0.0f
; r
.z
= 0.0f
; r
.w
= 0.0f
;
1833 s
.x
= 1.0f
; s
.y
=0.0f
; s
.z
= 0.0f
; s
.w
= 0.0f
;
1834 t
.x
= 1.0f
; t
.y
= 0.0f
; t
.z
= 0.0f
; t
.w
= 0.0f
;
1835 u
.x
= -1.0f
; u
.y
= 0.0f
; u
.z
= 0.0f
; u
.w
= 0.0f
;
1836 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1837 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1838 expect_quaternion(&expectedquat
, &gotquat
, 0);
1839 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1840 expect_quaternion(&expectedquat
, &Nq
, 0);
1841 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1842 expect_quaternion(&expectedquat
, &Nq1
, 0);
1844 /*_______________D3DXQuaternionToAxisAngle__________________*/
1845 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
1846 expectedvec
.x
= 1.0f
/22.0f
; expectedvec
.y
= 2.0f
/22.0f
; expectedvec
.z
= 4.0f
/22.0f
;
1847 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
1848 expect_vec3(&expectedvec
, &axis
, 0);
1849 equal
= compare_float(angle
, 2.197869f
, 1);
1850 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1851 /* Test if |w|>1.0f */
1852 expectedvec
.x
= 1.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= 4.0f
;
1853 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
1854 expect_vec3(&expectedvec
, &axis
, 0);
1855 /* Test the null quaternion */
1856 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1857 D3DXQuaternionToAxisAngle(&nul
, &axis
, &angle
);
1858 expect_vec3(&expectedvec
, &axis
, 0);
1859 equal
= compare_float(angle
, 3.14159274e+00f
, 0);
1860 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1862 D3DXQuaternionToAxisAngle(&nul
, &axis
, NULL
);
1863 D3DXQuaternionToAxisAngle(&nul
, NULL
, &angle
);
1864 expect_vec3(&expectedvec
, &axis
, 0);
1865 equal
= compare_float(angle
, 3.14159274e+00f
, 0);
1866 ok(equal
, "Got unexpected angle %.8e.\n", angle
);
1869 static void D3DXVector2Test(void)
1871 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1872 LPD3DXVECTOR2 funcpointer
;
1873 D3DXVECTOR4 expectedtrans
, gottrans
;
1874 float coeff1
, coeff2
, got
, scale
;
1878 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
1879 u
.x
= 3.0f
; u
.y
= 4.0f
;
1880 v
.x
= -7.0f
; v
.y
= 9.0f
;
1881 w
.x
= 4.0f
; w
.y
= -3.0f
;
1882 x
.x
= 2.0f
; x
.y
= -11.0f
;
1885 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1886 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1887 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1888 13.0f
, 14.0f
, 15.0f
, 16.0f
);
1890 coeff1
= 2.0f
; coeff2
= 5.0f
;
1893 /*_______________D3DXVec2Add__________________________*/
1894 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
1895 D3DXVec2Add(&gotvec
,&u
,&v
);
1896 expect_vec2(&expectedvec
, &gotvec
, 0);
1897 /* Tests the case NULL */
1898 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
1899 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1900 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
1901 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1903 /*_______________D3DXVec2BaryCentric___________________*/
1904 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
1905 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1906 expect_vec2(&expectedvec
, &gotvec
, 0);
1908 /*_______________D3DXVec2CatmullRom____________________*/
1909 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
1910 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1911 expect_vec2(&expectedvec
, &gotvec
, 0);
1913 /*_______________D3DXVec2CCW__________________________*/
1914 got
= D3DXVec2CCW(&u
, &v
);
1915 equal
= compare_float(got
, 55.0f
, 0);
1916 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1917 /* Tests the case NULL. */
1918 got
= D3DXVec2CCW(NULL
, &v
);
1919 equal
= compare_float(got
, 0.0f
, 0);
1920 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1921 got
= D3DXVec2CCW(NULL
, NULL
);
1922 equal
= compare_float(got
, 0.0f
, 0);
1923 ok(equal
, "Got unexpected ccw %.8e.\n", got
);
1925 /*_______________D3DXVec2Dot__________________________*/
1926 got
= D3DXVec2Dot(&u
, &v
);
1927 equal
= compare_float(got
, 15.0f
, 0);
1928 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1929 /* Tests the case NULL */
1930 got
= D3DXVec2Dot(NULL
, &v
);
1931 equal
= compare_float(got
, 0.0f
, 0);
1932 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1933 got
= D3DXVec2Dot(NULL
, NULL
);
1934 equal
= compare_float(got
, 0.0f
, 0);
1935 ok(equal
, "Got unexpected dot %.8e.\n", got
);
1937 /*_______________D3DXVec2Hermite__________________________*/
1938 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
1939 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1940 expect_vec2(&expectedvec
, &gotvec
, 0);
1942 /*_______________D3DXVec2Length__________________________*/
1943 got
= D3DXVec2Length(&u
);
1944 equal
= compare_float(got
, 5.0f
, 0);
1945 ok(equal
, "Got unexpected length %.8e.\n", got
);
1946 /* Tests the case NULL. */
1947 got
= D3DXVec2Length(NULL
);
1948 equal
= compare_float(got
, 0.0f
, 0);
1949 ok(equal
, "Got unexpected length %.8e.\n", got
);
1951 /*_______________D3DXVec2LengthSq________________________*/
1952 got
= D3DXVec2LengthSq(&u
);
1953 equal
= compare_float(got
, 25.0f
, 0);
1954 ok(equal
, "Got unexpected length %.8e.\n", got
);
1955 /* Tests the case NULL. */
1956 got
= D3DXVec2LengthSq(NULL
);
1957 equal
= compare_float(got
, 0.0f
, 0);
1958 ok(equal
, "Got unexpected length %.8e.\n", got
);
1960 /*_______________D3DXVec2Lerp__________________________*/
1961 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
1962 D3DXVec2Lerp(&gotvec
, &u
, &v
, scale
);
1963 expect_vec2(&expectedvec
, &gotvec
, 0);
1964 /* Tests the case NULL. */
1965 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
1966 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1967 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
1968 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1970 /*_______________D3DXVec2Maximize__________________________*/
1971 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
1972 D3DXVec2Maximize(&gotvec
, &u
, &v
);
1973 expect_vec2(&expectedvec
, &gotvec
, 0);
1974 /* Tests the case NULL. */
1975 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
1976 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1977 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1978 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1980 /*_______________D3DXVec2Minimize__________________________*/
1981 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1982 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1983 expect_vec2(&expectedvec
, &gotvec
, 0);
1984 /* Tests the case NULL */
1985 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1986 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1987 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1988 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1990 /*_______________D3DXVec2Normalize_________________________*/
1991 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1992 D3DXVec2Normalize(&gotvec
,&u
);
1993 expect_vec2(&expectedvec
, &gotvec
, 0);
1994 /* Test the nul vector */
1995 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1996 D3DXVec2Normalize(&gotvec
,&nul
);
1997 expect_vec2(&expectedvec
, &gotvec
, 0);
1999 /*_______________D3DXVec2Scale____________________________*/
2000 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
2001 D3DXVec2Scale(&gotvec
,&u
,scale
);
2002 expect_vec2(&expectedvec
, &gotvec
, 0);
2003 /* Tests the case NULL */
2004 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
2005 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2006 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
2007 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2009 /*_______________D3DXVec2Subtract__________________________*/
2010 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
2011 D3DXVec2Subtract(&gotvec
, &u
, &v
);
2012 expect_vec2(&expectedvec
, &gotvec
, 0);
2013 /* Tests the case NULL. */
2014 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
2015 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2016 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
2017 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2019 /*_______________D3DXVec2Transform_______________________*/
2020 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
2021 D3DXVec2Transform(&gottrans
, &u
, &mat
);
2022 expect_vec4(&expectedtrans
, &gottrans
, 0);
2023 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
;
2024 D3DXVec2Transform(&gottrans
, (D3DXVECTOR2
*)&gottrans
, &mat
);
2025 expect_vec4(&expectedtrans
, &gottrans
, 0);
2027 /*_______________D3DXVec2TransformCoord_______________________*/
2028 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
2029 D3DXVec2TransformCoord(&gotvec
, &u
, &mat
);
2030 expect_vec2(&expectedvec
, &gotvec
, 1);
2031 gotvec
.x
= u
.x
; gotvec
.y
= u
.y
;
2032 D3DXVec2TransformCoord(&gotvec
, &gotvec
, &mat
);
2033 expect_vec2(&expectedvec
, &gotvec
, 1);
2035 /*_______________D3DXVec2TransformNormal______________________*/
2036 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
2037 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
2038 expect_vec2(&expectedvec
, &gotvec
, 0);
2041 static void D3DXVector3Test(void)
2043 D3DVIEWPORT9 viewport
;
2044 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
2045 LPD3DXVECTOR3 funcpointer
;
2046 D3DXVECTOR4 expectedtrans
, gottrans
;
2047 D3DXMATRIX mat
, projection
, view
, world
;
2048 float coeff1
, coeff2
, got
, scale
;
2051 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
2052 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
2053 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
2054 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
2055 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
2057 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
2058 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
2061 1.0f
, 2.0f
, 3.0f
, 4.0f
,
2062 5.0f
, 6.0f
, 7.0f
, 8.0f
,
2063 9.0f
, 10.0f
, 11.0f
, 12.0f
,
2064 13.0f
, 14.0f
, 15.0f
, 16.0f
);
2066 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
2067 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
2068 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
2069 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
2070 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
2071 U(view
).m
[3][3] = -40.0f
;
2074 21.0f
, 2.0f
, 3.0f
, 4.0f
,
2075 5.0f
, 23.0f
, 7.0f
, 8.0f
,
2076 -8.0f
, -7.0f
, 25.0f
, -5.0f
,
2077 -4.0f
, -3.0f
, -2.0f
, 27.0f
);
2079 coeff1
= 2.0f
; coeff2
= 5.0f
;
2082 /*_______________D3DXVec3Add__________________________*/
2083 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
2084 D3DXVec3Add(&gotvec
,&u
,&v
);
2085 expect_vec3(&expectedvec
, &gotvec
, 0);
2086 /* Tests the case NULL */
2087 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
2088 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2089 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
2090 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2092 /*_______________D3DXVec3BaryCentric___________________*/
2093 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
2094 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
2095 expect_vec3(&expectedvec
, &gotvec
, 0);
2097 /*_______________D3DXVec3CatmullRom____________________*/
2098 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
2099 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
2100 expect_vec3(&expectedvec
, &gotvec
, 0);
2102 /*_______________D3DXVec3Cross________________________*/
2103 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
2104 D3DXVec3Cross(&gotvec
,&u
,&v
);
2105 expect_vec3(&expectedvec
, &gotvec
, 0);
2106 expectedvec
.x
= -277.0f
; expectedvec
.y
= -150.0f
; expectedvec
.z
= -26.0f
;
2107 D3DXVec3Cross(&gotvec
,&gotvec
,&v
);
2108 expect_vec3(&expectedvec
, &gotvec
, 0);
2109 /* Tests the case NULL */
2110 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
2111 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2112 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
2113 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2115 /*_______________D3DXVec3Dot__________________________*/
2116 got
= D3DXVec3Dot(&u
, &v
);
2117 equal
= compare_float(got
, -8.0f
, 0);
2118 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2119 /* Tests the case NULL */
2120 got
= D3DXVec3Dot(NULL
, &v
);
2121 equal
= compare_float(got
, 0.0f
, 0);
2122 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2123 got
= D3DXVec3Dot(NULL
, NULL
);
2124 equal
= compare_float(got
, 0.0f
, 0);
2125 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2127 /*_______________D3DXVec3Hermite__________________________*/
2128 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
2129 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
2130 expect_vec3(&expectedvec
, &gotvec
, 0);
2132 /*_______________D3DXVec3Length__________________________*/
2133 got
= D3DXVec3Length(&u
);
2134 equal
= compare_float(got
, 11.0f
, 0);
2135 ok(equal
, "Got unexpected length %.8e.\n", got
);
2136 /* Tests the case NULL. */
2137 got
= D3DXVec3Length(NULL
);
2138 equal
= compare_float(got
, 0.0f
, 0);
2139 ok(equal
, "Got unexpected length %.8e.\n", got
);
2141 /*_______________D3DXVec3LengthSq________________________*/
2142 got
= D3DXVec3LengthSq(&u
);
2143 equal
= compare_float(got
, 121.0f
, 0);
2144 ok(equal
, "Got unexpected length %.8e.\n", got
);
2145 /* Tests the case NULL. */
2146 got
= D3DXVec3LengthSq(NULL
);
2147 equal
= compare_float(got
, 0.0f
, 0);
2148 ok(equal
, "Got unexpected length %.8e.\n", got
);
2150 /*_______________D3DXVec3Lerp__________________________*/
2151 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
; expectedvec
.z
= 41.0f
;
2152 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
2153 expect_vec3(&expectedvec
, &gotvec
, 0);
2154 /* Tests the case NULL */
2155 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
2156 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2157 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
2158 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2160 /*_______________D3DXVec3Maximize__________________________*/
2161 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
2162 D3DXVec3Maximize(&gotvec
,&u
,&v
);
2163 expect_vec3(&expectedvec
, &gotvec
, 0);
2164 /* Tests the case NULL */
2165 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
2166 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2167 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
2168 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2170 /*_______________D3DXVec3Minimize__________________________*/
2171 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
2172 D3DXVec3Minimize(&gotvec
,&u
,&v
);
2173 expect_vec3(&expectedvec
, &gotvec
, 0);
2174 /* Tests the case NULL */
2175 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
2176 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2177 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
2178 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2180 /*_______________D3DXVec3Normalize_________________________*/
2181 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
2182 D3DXVec3Normalize(&gotvec
,&u
);
2183 expect_vec3(&expectedvec
, &gotvec
, 1);
2184 /* Test the nul vector */
2185 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
2186 D3DXVec3Normalize(&gotvec
,&nul
);
2187 expect_vec3(&expectedvec
, &gotvec
, 0);
2189 /*_______________D3DXVec3Scale____________________________*/
2190 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
2191 D3DXVec3Scale(&gotvec
,&u
,scale
);
2192 expect_vec3(&expectedvec
, &gotvec
, 0);
2193 /* Tests the case NULL */
2194 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
2195 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2196 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
2197 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2199 /*_______________D3DXVec3Subtract_______________________*/
2200 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
2201 D3DXVec3Subtract(&gotvec
,&u
,&v
);
2202 expect_vec3(&expectedvec
, &gotvec
, 0);
2203 /* Tests the case NULL */
2204 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
2205 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2206 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
2207 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2209 /*_______________D3DXVec3Transform_______________________*/
2210 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
2211 D3DXVec3Transform(&gottrans
, &u
, &mat
);
2212 expect_vec4(&expectedtrans
, &gottrans
, 0);
2214 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
; gottrans
.z
= u
.z
;
2215 D3DXVec3Transform(&gottrans
, (D3DXVECTOR3
*)&gottrans
, &mat
);
2216 expect_vec4(&expectedtrans
, &gottrans
, 0);
2218 /*_______________D3DXVec3TransformCoord_______________________*/
2219 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
2220 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
2221 expect_vec3(&expectedvec
, &gotvec
, 1);
2223 /*_______________D3DXVec3TransformNormal______________________*/
2224 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
2225 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
2226 expect_vec3(&expectedvec
, &gotvec
, 0);
2228 /*_______________D3DXVec3Project_________________________*/
2229 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
2230 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2231 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
2232 expect_vec3(&expectedvec
, &gotvec
, 32);
2233 /* World matrix can be omitted */
2234 D3DXMatrixMultiply(&mat
,&world
,&view
);
2235 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
2236 expect_vec3(&expectedvec
, &gotvec
, 32);
2237 /* Projection matrix can be omitted */
2238 D3DXMatrixMultiply(&mat
,&view
,&projection
);
2239 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
2240 expect_vec3(&expectedvec
, &gotvec
, 32);
2241 /* View matrix can be omitted */
2242 D3DXMatrixMultiply(&mat
,&world
,&view
);
2243 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
2244 expect_vec3(&expectedvec
, &gotvec
, 32);
2245 /* All matrices can be omitted */
2246 expectedvec
.x
= 4010.000000f
; expectedvec
.y
= -1695.000000f
; expectedvec
.z
= 1.600000f
;
2247 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
2248 expect_vec3(&expectedvec
, &gotvec
, 2);
2249 /* Viewport can be omitted */
2250 expectedvec
.x
= 1.814305f
; expectedvec
.y
= 0.582097f
; expectedvec
.z
= -0.066555f
;
2251 D3DXVec3Project(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
2252 expect_vec3(&expectedvec
, &gotvec
, 64);
2254 /*_______________D3DXVec3Unproject_________________________*/
2255 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
2256 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2257 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
2258 expect_vec3(&expectedvec
, &gotvec
, 16);
2259 /* World matrix can be omitted */
2260 D3DXMatrixMultiply(&mat
,&world
,&view
);
2261 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
2262 expect_vec3(&expectedvec
, &gotvec
, 16);
2263 /* Projection matrix can be omitted */
2264 D3DXMatrixMultiply(&mat
,&view
,&projection
);
2265 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
2266 expect_vec3(&expectedvec
, &gotvec
, 32);
2267 /* View matrix can be omitted */
2268 D3DXMatrixMultiply(&mat
,&world
,&view
);
2269 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
2270 expect_vec3(&expectedvec
, &gotvec
, 16);
2271 /* All matrices can be omitted */
2272 expectedvec
.x
= -1.002500f
; expectedvec
.y
= 0.997059f
; expectedvec
.z
= 2.571429f
;
2273 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
2274 expect_vec3(&expectedvec
, &gotvec
, 4);
2275 /* Viewport can be omitted */
2276 expectedvec
.x
= -11.018396f
; expectedvec
.y
= 3.218991f
; expectedvec
.z
= 1.380329f
;
2277 D3DXVec3Unproject(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
2278 expect_vec3(&expectedvec
, &gotvec
, 8);
2281 static void D3DXVector4Test(void)
2283 D3DXVECTOR4 expectedvec
, gotvec
, u
, v
, w
, x
;
2284 LPD3DXVECTOR4 funcpointer
;
2285 D3DXVECTOR4 expectedtrans
, gottrans
;
2286 float coeff1
, coeff2
, got
, scale
;
2290 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
2291 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
2292 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
2293 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
2296 1.0f
, 2.0f
, 3.0f
, 4.0f
,
2297 5.0f
, 6.0f
, 7.0f
, 8.0f
,
2298 9.0f
, 10.0f
, 11.0f
, 12.0f
,
2299 13.0f
, 14.0f
, 15.0f
, 16.0f
);
2301 coeff1
= 2.0f
; coeff2
= 5.0;
2304 /*_______________D3DXVec4Add__________________________*/
2305 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
2306 D3DXVec4Add(&gotvec
,&u
,&v
);
2307 expect_vec4(&expectedvec
, &gotvec
, 0);
2308 /* Tests the case NULL */
2309 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
2310 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2311 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
2312 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2314 /*_______________D3DXVec4BaryCentric____________________*/
2315 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
2316 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
2317 expect_vec4(&expectedvec
, &gotvec
, 0);
2319 /*_______________D3DXVec4CatmullRom____________________*/
2320 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
2321 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
2322 expect_vec4(&expectedvec
, &gotvec
, 0);
2324 /*_______________D3DXVec4Cross_________________________*/
2325 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
2326 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
2327 expect_vec4(&expectedvec
, &gotvec
, 0);
2329 /*_______________D3DXVec4Dot__________________________*/
2330 got
= D3DXVec4Dot(&u
, &v
);
2331 equal
= compare_float(got
, 55.0f
, 0);
2332 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2333 /* Tests the case NULL. */
2334 got
= D3DXVec4Dot(NULL
, &v
);
2335 equal
= compare_float(got
, 0.0f
, 0);
2336 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2337 got
= D3DXVec4Dot(NULL
, NULL
);
2338 equal
= compare_float(got
, 0.0f
, 0);
2339 ok(equal
, "Got unexpected dot %.8e.\n", got
);
2341 /*_______________D3DXVec4Hermite_________________________*/
2342 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
2343 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
2344 expect_vec4(&expectedvec
, &gotvec
, 0);
2346 /*_______________D3DXVec4Length__________________________*/
2347 got
= D3DXVec4Length(&u
);
2348 equal
= compare_float(got
, 11.0f
, 0);
2349 ok(equal
, "Got unexpected length %.8e.\n", got
);
2350 /* Tests the case NULL. */
2351 got
= D3DXVec4Length(NULL
);
2352 equal
= compare_float(got
, 0.0f
, 0);
2353 ok(equal
, "Got unexpected length %.8e.\n", got
);
2355 /*_______________D3DXVec4LengthSq________________________*/
2356 got
= D3DXVec4LengthSq(&u
);
2357 equal
= compare_float(got
, 121.0f
, 0);
2358 ok(equal
, "Got unexpected length %.8e.\n", got
);
2359 /* Tests the case NULL. */
2360 got
= D3DXVec4LengthSq(NULL
);
2361 equal
= compare_float(got
, 0.0f
, 0);
2362 ok(equal
, "Got unexpected length %.8e.\n", got
);
2364 /*_______________D3DXVec4Lerp__________________________*/
2365 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
2366 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
2367 expect_vec4(&expectedvec
, &gotvec
, 0);
2368 /* Tests the case NULL */
2369 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
2370 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2371 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
2372 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2374 /*_______________D3DXVec4Maximize__________________________*/
2375 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
2376 D3DXVec4Maximize(&gotvec
,&u
,&v
);
2377 expect_vec4(&expectedvec
, &gotvec
, 0);
2378 /* Tests the case NULL */
2379 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
2380 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2381 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
2382 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2384 /*_______________D3DXVec4Minimize__________________________*/
2385 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
2386 D3DXVec4Minimize(&gotvec
,&u
,&v
);
2387 expect_vec4(&expectedvec
, &gotvec
, 0);
2388 /* Tests the case NULL */
2389 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
2390 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2391 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
2392 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2394 /*_______________D3DXVec4Normalize_________________________*/
2395 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
2396 D3DXVec4Normalize(&gotvec
,&u
);
2397 expect_vec4(&expectedvec
, &gotvec
, 1);
2399 /*_______________D3DXVec4Scale____________________________*/
2400 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
2401 D3DXVec4Scale(&gotvec
,&u
,scale
);
2402 expect_vec4(&expectedvec
, &gotvec
, 0);
2403 /* Tests the case NULL */
2404 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
2405 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2406 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
2407 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2409 /*_______________D3DXVec4Subtract__________________________*/
2410 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
2411 D3DXVec4Subtract(&gotvec
,&u
,&v
);
2412 expect_vec4(&expectedvec
, &gotvec
, 0);
2413 /* Tests the case NULL */
2414 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
2415 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2416 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
2417 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
2419 /*_______________D3DXVec4Transform_______________________*/
2420 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
2421 D3DXVec4Transform(&gottrans
,&u
,&mat
);
2422 expect_vec4(&expectedtrans
, &gottrans
, 0);
2425 static void test_matrix_stack(void)
2427 ID3DXMatrixStack
*stack
;
2431 const D3DXMATRIX mat1
= {{{
2432 1.0f
, 2.0f
, 3.0f
, 4.0f
,
2433 5.0f
, 6.0f
, 7.0f
, 8.0f
,
2434 9.0f
, 10.0f
, 11.0f
, 12.0f
,
2435 13.0f
, 14.0f
, 15.0f
, 16.0f
2438 const D3DXMATRIX mat2
= {{{
2439 17.0f
, 18.0f
, 19.0f
, 20.0f
,
2440 21.0f
, 22.0f
, 23.0f
, 24.0f
,
2441 25.0f
, 26.0f
, 27.0f
, 28.0f
,
2442 29.0f
, 30.0f
, 31.0f
, 32.0f
2445 hr
= D3DXCreateMatrixStack(0, &stack
);
2446 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
2447 if (FAILED(hr
)) return;
2449 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
2450 "The top of an empty matrix stack should be an identity matrix\n");
2452 hr
= ID3DXMatrixStack_Pop(stack
);
2453 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
2455 hr
= ID3DXMatrixStack_Push(stack
);
2456 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
2457 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
2459 hr
= ID3DXMatrixStack_Push(stack
);
2460 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
2462 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
2463 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
2464 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
2466 hr
= ID3DXMatrixStack_Push(stack
);
2467 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
2468 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
2470 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
2471 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
2472 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
2474 hr
= ID3DXMatrixStack_Push(stack
);
2475 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
2476 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
2478 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
2479 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
2480 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
2482 hr
= ID3DXMatrixStack_Pop(stack
);
2483 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
2484 expect_matrix(&mat2
, ID3DXMatrixStack_GetTop(stack
), 0);
2486 hr
= ID3DXMatrixStack_Pop(stack
);
2487 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
2488 expect_matrix(&mat1
, ID3DXMatrixStack_GetTop(stack
), 0);
2490 hr
= ID3DXMatrixStack_Pop(stack
);
2491 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
2492 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
2494 hr
= ID3DXMatrixStack_Pop(stack
);
2495 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
2496 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
2498 refcount
= ID3DXMatrixStack_Release(stack
);
2499 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
2502 static void test_Matrix_AffineTransformation2D(void)
2504 D3DXMATRIX exp_mat
, got_mat
;
2505 D3DXVECTOR2 center
, position
;
2514 angle
= D3DX_PI
/3.0f
;
2518 U(exp_mat
).m
[0][0] = 10.0f
;
2519 U(exp_mat
).m
[1][0] = -17.320507f
;
2520 U(exp_mat
).m
[2][0] = 0.0f
;
2521 U(exp_mat
).m
[3][0] = -1.035898f
;
2522 U(exp_mat
).m
[0][1] = 17.320507f
;
2523 U(exp_mat
).m
[1][1] = 10.0f
;
2524 U(exp_mat
).m
[2][1] = 0.0f
;
2525 U(exp_mat
).m
[3][1] = 6.401924f
;
2526 U(exp_mat
).m
[0][2] = 0.0f
;
2527 U(exp_mat
).m
[1][2] = 0.0f
;
2528 U(exp_mat
).m
[2][2] = 1.0f
;
2529 U(exp_mat
).m
[3][2] = 0.0f
;
2530 U(exp_mat
).m
[0][3] = 0.0f
;
2531 U(exp_mat
).m
[1][3] = 0.0f
;
2532 U(exp_mat
).m
[2][3] = 0.0f
;
2533 U(exp_mat
).m
[3][3] = 1.0f
;
2535 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, &position
);
2536 expect_matrix(&exp_mat
, &got_mat
, 2);
2543 angle
= D3DX_PI
/3.0f
;
2547 U(exp_mat
).m
[0][0] = 10.0f
;
2548 U(exp_mat
).m
[1][0] = -17.320507f
;
2549 U(exp_mat
).m
[2][0] = 0.0f
;
2550 U(exp_mat
).m
[3][0] = 4.964102f
;
2551 U(exp_mat
).m
[0][1] = 17.320507f
;
2552 U(exp_mat
).m
[1][1] = 10.0f
;
2553 U(exp_mat
).m
[2][1] = 0.0f
;
2554 U(exp_mat
).m
[3][1] = -0.598076f
;
2555 U(exp_mat
).m
[0][2] = 0.0f
;
2556 U(exp_mat
).m
[1][2] = 0.0f
;
2557 U(exp_mat
).m
[2][2] = 1.0f
;
2558 U(exp_mat
).m
[3][2] = 0.0f
;
2559 U(exp_mat
).m
[0][3] = 0.0f
;
2560 U(exp_mat
).m
[1][3] = 0.0f
;
2561 U(exp_mat
).m
[2][3] = 0.0f
;
2562 U(exp_mat
).m
[3][3] = 1.0f
;
2564 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, NULL
);
2565 expect_matrix(&exp_mat
, &got_mat
, 8);
2572 angle
= D3DX_PI
/3.0f
;
2576 U(exp_mat
).m
[0][0] = 10.0f
;
2577 U(exp_mat
).m
[1][0] = -17.320507f
;
2578 U(exp_mat
).m
[2][0] = 0.0f
;
2579 U(exp_mat
).m
[3][0] = -6.0f
;
2580 U(exp_mat
).m
[0][1] = 17.320507f
;
2581 U(exp_mat
).m
[1][1] = 10.0f
;
2582 U(exp_mat
).m
[2][1] = 0.0f
;
2583 U(exp_mat
).m
[3][1] = 7.0f
;
2584 U(exp_mat
).m
[0][2] = 0.0f
;
2585 U(exp_mat
).m
[1][2] = 0.0f
;
2586 U(exp_mat
).m
[2][2] = 1.0f
;
2587 U(exp_mat
).m
[3][2] = 0.0f
;
2588 U(exp_mat
).m
[0][3] = 0.0f
;
2589 U(exp_mat
).m
[1][3] = 0.0f
;
2590 U(exp_mat
).m
[2][3] = 0.0f
;
2591 U(exp_mat
).m
[3][3] = 1.0f
;
2593 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, &position
);
2594 expect_matrix(&exp_mat
, &got_mat
, 1);
2598 angle
= 5.0f
* D3DX_PI
/4.0f
;
2602 U(exp_mat
).m
[0][0] = 14.142133f
;
2603 U(exp_mat
).m
[1][0] = -14.142133f
;
2604 U(exp_mat
).m
[2][0] = 0.0f
;
2605 U(exp_mat
).m
[3][0] = 0.0f
;
2606 U(exp_mat
).m
[0][1] = 14.142133;
2607 U(exp_mat
).m
[1][1] = 14.142133f
;
2608 U(exp_mat
).m
[2][1] = 0.0f
;
2609 U(exp_mat
).m
[3][1] = 0.0f
;
2610 U(exp_mat
).m
[0][2] = 0.0f
;
2611 U(exp_mat
).m
[1][2] = 0.0f
;
2612 U(exp_mat
).m
[2][2] = 1.0f
;
2613 U(exp_mat
).m
[3][2] = 0.0f
;
2614 U(exp_mat
).m
[0][3] = 0.0f
;
2615 U(exp_mat
).m
[1][3] = 0.0f
;
2616 U(exp_mat
).m
[2][3] = 0.0f
;
2617 U(exp_mat
).m
[3][3] = 1.0f
;
2619 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, NULL
);
2620 expect_matrix(&exp_mat
, &got_mat
, 8);
2623 static void test_Matrix_Decompose(void)
2626 D3DXQUATERNION exp_rotation
, got_rotation
;
2627 D3DXVECTOR3 exp_scale
, got_scale
, exp_translation
, got_translation
;
2633 U(pm
).m
[0][0] = -9.23879206e-01f
;
2634 U(pm
).m
[1][0] = -2.70598412e-01f
;
2635 U(pm
).m
[2][0] = 2.70598441e-01f
;
2636 U(pm
).m
[3][0] = -5.00000000e+00f
;
2637 U(pm
).m
[0][1] = 2.70598471e-01f
;
2638 U(pm
).m
[1][1] = 3.80604863e-02f
;
2639 U(pm
).m
[2][1] = 9.61939573e-01f
;
2640 U(pm
).m
[3][1] = 0.00000000e+00f
;
2641 U(pm
).m
[0][2] = -2.70598441e-01f
;
2642 U(pm
).m
[1][2] = 9.61939573e-01f
;
2643 U(pm
).m
[2][2] = 3.80603075e-02f
;
2644 U(pm
).m
[3][2] = 1.00000000e+01f
;
2645 U(pm
).m
[0][3] = 0.00000000e+00f
;
2646 U(pm
).m
[1][3] = 0.00000000e+00f
;
2647 U(pm
).m
[2][3] = 0.00000000e+00f
;
2648 U(pm
).m
[3][3] = 1.00000000e+00f
;
2650 exp_scale
.x
= 9.99999881e-01f
;
2651 exp_scale
.y
= 9.99999881e-01f
;
2652 exp_scale
.z
= 9.99999881e-01f
;
2654 exp_rotation
.x
= 2.14862776e-08f
;
2655 exp_rotation
.y
= 6.93519890e-01f
;
2656 exp_rotation
.z
= 6.93519890e-01f
;
2657 exp_rotation
.w
= 1.95090637e-01f
;
2659 exp_translation
.x
= -5.0f
;
2660 exp_translation
.y
= 0.0f
;
2661 exp_translation
.z
= 10.0f
;
2663 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2664 expect_vec3(&exp_scale
, &got_scale
, 1);
2665 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2666 expect_vec3(&exp_translation
, &got_translation
, 0);
2670 U(pm
).m
[0][0] = -2.255813f
;
2671 U(pm
).m
[1][0] = 1.302324f
;
2672 U(pm
).m
[2][0] = 1.488373f
;
2673 U(pm
).m
[3][0] = 1.0f
;
2674 U(pm
).m
[0][1] = 1.302327f
;
2675 U(pm
).m
[1][1] = -0.7209296f
;
2676 U(pm
).m
[2][1] = 2.60465f
;
2677 U(pm
).m
[3][1] = 2.0f
;
2678 U(pm
).m
[0][2] = 1.488371f
;
2679 U(pm
).m
[1][2] = 2.604651f
;
2680 U(pm
).m
[2][2] = -0.02325551f
;
2681 U(pm
).m
[3][2] = 3.0f
;
2682 U(pm
).m
[0][3] = 0.0f
;
2683 U(pm
).m
[1][3] = 0.0f
;
2684 U(pm
).m
[2][3] = 0.0f
;
2685 U(pm
).m
[3][3] = 1.0f
;
2687 exp_scale
.x
= 2.99999928e+00f
;
2688 exp_scale
.y
= 2.99999905e+00f
;
2689 exp_scale
.z
= 2.99999952e+00f
;
2691 exp_rotation
.x
= 3.52180451e-01f
;
2692 exp_rotation
.y
= 6.16315663e-01f
;
2693 exp_rotation
.z
= 7.04360664e-01f
;
2694 exp_rotation
.w
= 3.38489343e-07f
;
2696 exp_translation
.x
= 1.0f
;
2697 exp_translation
.y
= 2.0f
;
2698 exp_translation
.z
= 3.0f
;
2700 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2701 expect_vec3(&exp_scale
, &got_scale
, 0);
2702 expect_quaternion(&exp_rotation
, &got_rotation
, 2);
2703 expect_vec3(&exp_translation
, &got_translation
, 0);
2707 U(pm
).m
[0][0] = 2.427051f
;
2708 U(pm
).m
[1][0] = 0.0f
;
2709 U(pm
).m
[2][0] = 1.763355f
;
2710 U(pm
).m
[3][0] = 5.0f
;
2711 U(pm
).m
[0][1] = 0.0f
;
2712 U(pm
).m
[1][1] = 3.0f
;
2713 U(pm
).m
[2][1] = 0.0f
;
2714 U(pm
).m
[3][1] = 5.0f
;
2715 U(pm
).m
[0][2] = -1.763355f
;
2716 U(pm
).m
[1][2] = 0.0f
;
2717 U(pm
).m
[2][2] = 2.427051f
;
2718 U(pm
).m
[3][2] = 5.0f
;
2719 U(pm
).m
[0][3] = 0.0f
;
2720 U(pm
).m
[1][3] = 0.0f
;
2721 U(pm
).m
[2][3] = 0.0f
;
2722 U(pm
).m
[3][3] = 1.0f
;
2724 exp_scale
.x
= 2.99999976e+00f
;
2725 exp_scale
.y
= 3.00000000e+00f
;
2726 exp_scale
.z
= 2.99999976e+00f
;
2728 exp_rotation
.x
= 0.00000000e+00f
;
2729 exp_rotation
.y
= 3.09016883e-01f
;
2730 exp_rotation
.z
= 0.00000000e+00f
;
2731 exp_rotation
.w
= 9.51056540e-01f
;
2733 exp_translation
.x
= 5.0f
;
2734 exp_translation
.y
= 5.0f
;
2735 exp_translation
.z
= 5.0f
;
2737 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2738 expect_vec3(&exp_scale
, &got_scale
, 1);
2739 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2740 expect_vec3(&exp_translation
, &got_translation
, 0);
2744 U(pm
).m
[0][0] = -9.23879206e-01f
;
2745 U(pm
).m
[1][0] = -2.70598412e-01f
;
2746 U(pm
).m
[2][0] = 2.70598441e-01f
;
2747 U(pm
).m
[3][0] = -5.00000000e+00f
;
2748 U(pm
).m
[0][1] = 2.70598471e-01f
;
2749 U(pm
).m
[1][1] = 3.80604863e-02f
;
2750 U(pm
).m
[2][1] = 9.61939573e-01f
;
2751 U(pm
).m
[3][1] = 0.00000000e+00f
;
2752 U(pm
).m
[0][2] = -2.70598441e-01f
;
2753 U(pm
).m
[1][2] = 9.61939573e-01f
;
2754 U(pm
).m
[2][2] = 3.80603075e-02f
;
2755 U(pm
).m
[3][2] = 1.00000000e+01f
;
2756 U(pm
).m
[0][3] = 0.00000000e+00f
;
2757 U(pm
).m
[1][3] = 0.00000000e+00f
;
2758 U(pm
).m
[2][3] = 0.00000000e+00f
;
2759 U(pm
).m
[3][3] = 1.00000000e+00f
;
2761 exp_scale
.x
= 9.99999881e-01f
;
2762 exp_scale
.y
= 9.99999881e-01f
;
2763 exp_scale
.z
= 9.99999881e-01f
;
2765 exp_rotation
.x
= 2.14862776e-08f
;
2766 exp_rotation
.y
= 6.93519890e-01f
;
2767 exp_rotation
.z
= 6.93519890e-01f
;
2768 exp_rotation
.w
= 1.95090637e-01f
;
2770 exp_translation
.x
= -5.0f
;
2771 exp_translation
.y
= 0.0f
;
2772 exp_translation
.z
= 10.0f
;
2774 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2775 expect_vec3(&exp_scale
, &got_scale
, 1);
2776 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2777 expect_vec3(&exp_translation
, &got_translation
, 0);
2781 U(pm
).m
[0][0] = -9.23878908e-01f
;
2782 U(pm
).m
[1][0] = -5.41196704e-01f
;
2783 U(pm
).m
[2][0] = 8.11795175e-01f
;
2784 U(pm
).m
[3][0] = -5.00000000e+00f
;
2785 U(pm
).m
[0][1] = 2.70598322e-01f
;
2786 U(pm
).m
[1][1] = 7.61209577e-02f
;
2787 U(pm
).m
[2][1] = 2.88581824e+00f
;
2788 U(pm
).m
[3][1] = 0.00000000e+00f
;
2789 U(pm
).m
[0][2] = -2.70598352e-01f
;
2790 U(pm
).m
[1][2] = 1.92387879e+00f
;
2791 U(pm
).m
[2][2] = 1.14180908e-01f
;
2792 U(pm
).m
[3][2] = 1.00000000e+01f
;
2793 U(pm
).m
[0][3] = 0.00000000e+00f
;
2794 U(pm
).m
[1][3] = 0.00000000e+00f
;
2795 U(pm
).m
[2][3] = 0.00000000e+00f
;
2796 U(pm
).m
[3][3] = 1.00000000e+00f
;
2798 exp_scale
.x
= 9.99999583e-01f
;
2799 exp_scale
.y
= 1.99999940e+00f
;
2800 exp_scale
.z
= 2.99999928e+00f
;
2802 exp_rotation
.x
= 1.07431388e-08f
;
2803 exp_rotation
.y
= 6.93519890e-01f
;
2804 exp_rotation
.z
= 6.93519831e-01f
;
2805 exp_rotation
.w
= 1.95090622e-01f
;
2807 exp_translation
.x
= -5.0f
;
2808 exp_translation
.y
= 0.0f
;
2809 exp_translation
.z
= 10.0f
;
2811 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2812 expect_vec3(&exp_scale
, &got_scale
, 1);
2813 equal
= compare_quaternion(&exp_rotation
, &got_rotation
, 1);
2814 exp_rotation
.x
= 0.0f
;
2815 equal
|= compare_quaternion(&exp_rotation
, &got_rotation
, 2);
2816 ok(equal
, "Got unexpected quaternion {%.8e, %.8e, %.8e, %.8e}.\n",
2817 got_rotation
.x
, got_rotation
.y
, got_rotation
.z
, got_rotation
.w
);
2818 expect_vec3(&exp_translation
, &got_translation
, 0);
2822 U(pm
).m
[0][0] = 0.7156004f
;
2823 U(pm
).m
[1][0] = -0.5098283f
;
2824 U(pm
).m
[2][0] = -0.4774843f
;
2825 U(pm
).m
[3][0] = -5.0f
;
2826 U(pm
).m
[0][1] = -0.6612288f
;
2827 U(pm
).m
[1][1] = -0.7147621f
;
2828 U(pm
).m
[2][1] = -0.2277977f
;
2829 U(pm
).m
[3][1] = 0.0f
;
2830 U(pm
).m
[0][2] = -0.2251499f
;
2831 U(pm
).m
[1][2] = 0.4787385f
;
2832 U(pm
).m
[2][2] = -0.8485972f
;
2833 U(pm
).m
[3][2] = 10.0f
;
2834 U(pm
).m
[0][3] = 0.0f
;
2835 U(pm
).m
[1][3] = 0.0f
;
2836 U(pm
).m
[2][3] = 0.0f
;
2837 U(pm
).m
[3][3] = 1.0f
;
2839 exp_scale
.x
= 9.99999940e-01f
;
2840 exp_scale
.y
= 1.00000012e+00f
;
2841 exp_scale
.z
= 1.00000012e+00f
;
2843 exp_rotation
.x
= 9.05394852e-01f
;
2844 exp_rotation
.y
= -3.23355347e-01f
;
2845 exp_rotation
.z
= -1.94013178e-01f
;
2846 exp_rotation
.w
= 1.95090592e-01f
;
2848 exp_translation
.x
= -5.0f
;
2849 exp_translation
.y
= 0.0f
;
2850 exp_translation
.z
= 10.0f
;
2852 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2853 expect_vec3(&exp_scale
, &got_scale
, 0);
2854 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2855 expect_vec3(&exp_translation
, &got_translation
, 0);
2859 U(pm
).m
[0][0] = 0.06554436f
;
2860 U(pm
).m
[1][0] = -0.6873012f
;
2861 U(pm
).m
[2][0] = 0.7234092f
;
2862 U(pm
).m
[3][0] = -5.0f
;
2863 U(pm
).m
[0][1] = -0.9617381f
;
2864 U(pm
).m
[1][1] = -0.2367795f
;
2865 U(pm
).m
[2][1] = -0.1378230f
;
2866 U(pm
).m
[3][1] = 0.0f
;
2867 U(pm
).m
[0][2] = 0.2660144f
;
2868 U(pm
).m
[1][2] = -0.6866967f
;
2869 U(pm
).m
[2][2] = -0.6765233f
;
2870 U(pm
).m
[3][2] = 10.0f
;
2871 U(pm
).m
[0][3] = 0.0f
;
2872 U(pm
).m
[1][3] = 0.0f
;
2873 U(pm
).m
[2][3] = 0.0f
;
2874 U(pm
).m
[3][3] = 1.0f
;
2876 exp_scale
.x
= 9.99999940e-01f
;
2877 exp_scale
.y
= 9.99999940e-01f
;
2878 exp_scale
.z
= 9.99999881e-01f
;
2880 exp_rotation
.x
= 7.03357518e-01f
;
2881 exp_rotation
.y
= -5.86131275e-01f
;
2882 exp_rotation
.z
= 3.51678789e-01f
;
2883 exp_rotation
.w
= -1.95090577e-01f
;
2885 exp_translation
.x
= -5.0f
;
2886 exp_translation
.y
= 0.0f
;
2887 exp_translation
.z
= 10.0f
;
2889 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2890 expect_vec3(&exp_scale
, &got_scale
, 1);
2891 expect_quaternion(&exp_rotation
, &got_rotation
, 2);
2892 expect_vec3(&exp_translation
, &got_translation
, 0);
2896 U(pm
).m
[0][0] = 7.12104797e+00f
;
2897 U(pm
).m
[1][0] = -5.88348627e+00f
;
2898 U(pm
).m
[2][0] = 1.18184204e+01f
;
2899 U(pm
).m
[3][0] = -5.00000000e+00f
;
2900 U(pm
).m
[0][1] = 5.88348627e+00f
;
2901 U(pm
).m
[1][1] = -1.06065865e+01f
;
2902 U(pm
).m
[2][1] = -8.82523251e+00f
;
2903 U(pm
).m
[3][1] = 0.00000000e+00f
;
2904 U(pm
).m
[0][2] = 1.18184204e+01f
;
2905 U(pm
).m
[1][2] = 8.82523155e+00f
;
2906 U(pm
).m
[2][2] = -2.72764111e+00f
;
2907 U(pm
).m
[3][2] = 2.00000000e+00f
;
2908 U(pm
).m
[0][3] = 0.00000000e+00f
;
2909 U(pm
).m
[1][3] = 0.00000000e+00f
;
2910 U(pm
).m
[2][3] = 0.00000000e+00f
;
2911 U(pm
).m
[3][3] = 1.00000000e+00f
;
2913 exp_scale
.x
= 1.49999933e+01f
;
2914 exp_scale
.y
= 1.49999933e+01f
;
2915 exp_scale
.z
= 1.49999943e+01f
;
2917 exp_rotation
.x
= 7.68714130e-01f
;
2918 exp_rotation
.y
= 0.00000000e+00f
;
2919 exp_rotation
.z
= 5.12475967e-01f
;
2920 exp_rotation
.w
= 3.82683903e-01f
;
2922 exp_translation
.x
= -5.0f
;
2923 exp_translation
.y
= 0.0f
;
2924 exp_translation
.z
= 2.0f
;
2926 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2927 expect_vec3(&exp_scale
, &got_scale
, 0);
2928 expect_quaternion(&exp_rotation
, &got_rotation
, 1);
2929 expect_vec3(&exp_translation
, &got_translation
, 0);
2933 U(pm
).m
[0][0] = 0.0f
;
2934 U(pm
).m
[1][0] = 4.0f
;
2935 U(pm
).m
[2][0] = 5.0f
;
2936 U(pm
).m
[3][0] = -5.0f
;
2937 U(pm
).m
[0][1] = 0.0f
;
2938 U(pm
).m
[1][1] = -10.60660f
;
2939 U(pm
).m
[2][1] = -8.825232f
;
2940 U(pm
).m
[3][1] = 6.0f
;
2941 U(pm
).m
[0][2] = 0.0f
;
2942 U(pm
).m
[1][2] = 8.8252320f
;
2943 U(pm
).m
[2][2] = 2.727645;
2944 U(pm
).m
[3][2] = 3.0f
;
2945 U(pm
).m
[0][3] = 0.0f
;
2946 U(pm
).m
[1][3] = 0.0f
;
2947 U(pm
).m
[2][3] = 0.0f
;
2948 U(pm
).m
[3][3] = 1.0f
;
2950 hr
= D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2951 ok(hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %x\n", hr
);
2954 static void test_Matrix_Transformation2D(void)
2956 D3DXMATRIX exp_mat
, got_mat
;
2957 D3DXVECTOR2 rot_center
, sca
, sca_center
, trans
;
2960 rot_center
.x
= 3.0f
;
2961 rot_center
.y
= 4.0f
;
2966 sca_center
.x
= 9.0f
;
2967 sca_center
.y
= -5.0f
;
2974 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2976 U(exp_mat
).m
[0][0] = -4.245192f
;
2977 U(exp_mat
).m
[1][0] = -0.147116f
;
2978 U(exp_mat
).m
[2][0] = 0.0f
;
2979 U(exp_mat
).m
[3][0] = 45.265373f
;
2980 U(exp_mat
).m
[0][1] = 7.647113f
;
2981 U(exp_mat
).m
[1][1] = 8.745192f
;
2982 U(exp_mat
).m
[2][1] = 0.0f
;
2983 U(exp_mat
).m
[3][1] = -13.401899f
;
2984 U(exp_mat
).m
[0][2] = 0.0f
;
2985 U(exp_mat
).m
[1][2] = 0.0f
;
2986 U(exp_mat
).m
[2][2] = 1.0f
;
2987 U(exp_mat
).m
[3][2] = 0.0f
;
2988 U(exp_mat
).m
[0][3] = 0.0f
;
2989 U(exp_mat
).m
[1][3] = 0.0f
;
2990 U(exp_mat
).m
[2][3] = 0.0f
;
2991 U(exp_mat
).m
[3][3] = 1.0f
;
2993 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, &sca
, &rot_center
, rot
, &trans
);
2994 expect_matrix(&exp_mat
, &got_mat
, 64);
2998 sca_center
.x
= 9.0f
;
2999 sca_center
.y
= -5.0f
;
3006 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
3008 U(exp_mat
).m
[0][0] = 0.50f
;
3009 U(exp_mat
).m
[1][0] = -0.866025f
;
3010 U(exp_mat
).m
[2][0] = 0.0f
;
3011 U(exp_mat
).m
[3][0] = -6.0f
;
3012 U(exp_mat
).m
[0][1] = 0.866025f
;
3013 U(exp_mat
).m
[1][1] = 0.50f
;
3014 U(exp_mat
).m
[2][1] = 0.0f
;
3015 U(exp_mat
).m
[3][1] = 7.0f
;
3016 U(exp_mat
).m
[0][2] = 0.0f
;
3017 U(exp_mat
).m
[1][2] = 0.0f
;
3018 U(exp_mat
).m
[2][2] = 1.0f
;
3019 U(exp_mat
).m
[3][2] = 0.0f
;
3020 U(exp_mat
).m
[0][3] = 0.0f
;
3021 U(exp_mat
).m
[1][3] = 0.0f
;
3022 U(exp_mat
).m
[2][3] = 0.0f
;
3023 U(exp_mat
).m
[3][3] = 1.0f
;
3025 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, NULL
, NULL
, rot
, &trans
);
3026 expect_matrix(&exp_mat
, &got_mat
, 8);
3030 U(exp_mat
).m
[0][0] = 0.50f
;
3031 U(exp_mat
).m
[1][0] = -0.866025f
;
3032 U(exp_mat
).m
[2][0] = 0.0f
;
3033 U(exp_mat
).m
[3][0] = 0.0f
;
3034 U(exp_mat
).m
[0][1] = 0.866025f
;
3035 U(exp_mat
).m
[1][1] = 0.50f
;
3036 U(exp_mat
).m
[2][1] = 0.0f
;
3037 U(exp_mat
).m
[3][1] = 0.0f
;
3038 U(exp_mat
).m
[0][2] = 0.0f
;
3039 U(exp_mat
).m
[1][2] = 0.0f
;
3040 U(exp_mat
).m
[2][2] = 1.0f
;
3041 U(exp_mat
).m
[3][2] = 0.0f
;
3042 U(exp_mat
).m
[0][3] = 0.0f
;
3043 U(exp_mat
).m
[1][3] = 0.0f
;
3044 U(exp_mat
).m
[2][3] = 0.0f
;
3045 U(exp_mat
).m
[3][3] = 1.0f
;
3047 D3DXMatrixTransformation2D(&got_mat
, NULL
, sca_rot
, NULL
, NULL
, rot
, NULL
);
3048 expect_matrix(&exp_mat
, &got_mat
, 8);
3051 static void test_D3DXVec_Array(void)
3053 D3DXPLANE inp_plane
[5], out_plane
[7], exp_plane
[7];
3054 D3DXVECTOR4 inp_vec
[5], out_vec
[7], exp_vec
[7];
3055 D3DXMATRIX mat
, projection
, view
, world
;
3056 D3DVIEWPORT9 viewport
;
3059 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
3060 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
3062 memset(out_vec
, 0, sizeof(out_vec
));
3063 memset(exp_vec
, 0, sizeof(exp_vec
));
3064 memset(out_plane
, 0, sizeof(out_plane
));
3065 memset(exp_plane
, 0, sizeof(exp_plane
));
3067 for (i
= 0; i
< ARRAY_SIZE(inp_vec
); ++i
)
3069 inp_plane
[i
].a
= inp_plane
[i
].c
= inp_vec
[i
].x
= inp_vec
[i
].z
= i
;
3070 inp_plane
[i
].b
= inp_plane
[i
].d
= inp_vec
[i
].y
= inp_vec
[i
].w
= ARRAY_SIZE(inp_vec
) - i
;
3074 1.0f
, 2.0f
, 3.0f
, 4.0f
,
3075 5.0f
, 6.0f
, 7.0f
, 8.0f
,
3076 9.0f
, 10.0f
, 11.0f
, 12.0f
,
3077 13.0f
, 14.0f
, 15.0f
, 16.0f
);
3079 D3DXMatrixPerspectiveFovLH(&projection
, D3DX_PI
/ 4.0f
, 20.0f
/ 17.0f
, 1.0f
, 1000.0f
);
3081 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
3082 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
3083 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
3084 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
3085 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
3086 U(view
).m
[3][3] = -40.0f
;
3089 21.0f
, 2.0f
, 3.0f
, 4.0f
,
3090 5.0f
, 23.0f
, 7.0f
, 8.0f
,
3091 -8.0f
, -7.0f
, 25.0f
, -5.0f
,
3092 -4.0f
, -3.0f
, -2.0f
, 27.0f
);
3094 /* D3DXVec2TransformCoordArray */
3095 exp_vec
[1].x
= 6.78571403e-01f
; exp_vec
[1].y
= 7.85714269e-01f
;
3096 exp_vec
[2].x
= 6.53846204e-01f
; exp_vec
[2].y
= 7.69230783e-01f
;
3097 exp_vec
[3].x
= 6.25000000e-01f
; exp_vec
[3].y
= 7.50000000e-01f
;
3098 exp_vec
[4].x
= 5.90909123e-01f
; exp_vec
[4].y
= 7.27272749e-01f
;
3099 exp_vec
[5].x
= 5.49999952e-01f
; exp_vec
[5].y
= 6.99999928e-01f
;
3100 D3DXVec2TransformCoordArray((D3DXVECTOR2
*)&out_vec
[1], sizeof(*out_vec
),
3101 (D3DXVECTOR2
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3102 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 1);
3104 /* D3DXVec2TransformNormalArray */
3105 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
;
3106 exp_vec
[2].x
= 21.0f
; exp_vec
[2].y
= 26.0f
;
3107 exp_vec
[3].x
= 17.0f
; exp_vec
[3].y
= 22.0f
;
3108 exp_vec
[4].x
= 13.0f
; exp_vec
[4].y
= 18.0f
;
3109 exp_vec
[5].x
= 9.0f
; exp_vec
[5].y
= 14.0f
;
3110 D3DXVec2TransformNormalArray((D3DXVECTOR2
*)&out_vec
[1], sizeof(*out_vec
),
3111 (D3DXVECTOR2
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3112 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 0);
3114 /* D3DXVec3TransformCoordArray */
3115 exp_vec
[1].x
= 6.78571403e-01f
; exp_vec
[1].y
= 7.85714269e-01f
; exp_vec
[1].z
= 8.92857075e-01f
;
3116 exp_vec
[2].x
= 6.71874940e-01f
; exp_vec
[2].y
= 7.81249940e-01f
; exp_vec
[2].z
= 8.90624940e-01f
;
3117 exp_vec
[3].x
= 6.66666627e-01f
; exp_vec
[3].y
= 7.77777731e-01f
; exp_vec
[3].z
= 8.88888836e-01f
;
3118 exp_vec
[4].x
= 6.62499964e-01f
; exp_vec
[4].y
= 7.74999976e-01f
; exp_vec
[4].z
= 8.87499928e-01f
;
3119 exp_vec
[5].x
= 6.59090877e-01f
; exp_vec
[5].y
= 7.72727251e-01f
; exp_vec
[5].z
= 8.86363566e-01f
;
3120 D3DXVec3TransformCoordArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
),
3121 (D3DXVECTOR3
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3122 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 1);
3124 /* D3DXVec3TransformNormalArray */
3125 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
; exp_vec
[1].z
= 35.0f
;
3126 exp_vec
[2].x
= 30.0f
; exp_vec
[2].y
= 36.0f
; exp_vec
[2].z
= 42.0f
;
3127 exp_vec
[3].x
= 35.0f
; exp_vec
[3].y
= 42.0f
; exp_vec
[3].z
= 49.0f
;
3128 exp_vec
[4].x
= 40.0f
; exp_vec
[4].y
= 48.0f
; exp_vec
[4].z
= 56.0f
;
3129 exp_vec
[5].x
= 45.0f
; exp_vec
[5].y
= 54.0f
; exp_vec
[5].z
= 63.0f
;
3130 D3DXVec3TransformNormalArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
),
3131 (D3DXVECTOR3
*)inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3132 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 0);
3134 /* D3DXVec3ProjectArray */
3135 exp_vec
[1].x
= 1.08955420e+03f
; exp_vec
[1].y
= -2.26590622e+02f
; exp_vec
[1].z
= 2.15272754e-01f
;
3136 exp_vec
[2].x
= 1.06890344e+03f
; exp_vec
[2].y
= 1.03085144e+02f
; exp_vec
[2].z
= 1.83049560e-01f
;
3137 exp_vec
[3].x
= 1.05177905e+03f
; exp_vec
[3].y
= 3.76462280e+02f
; exp_vec
[3].z
= 1.56329080e-01f
;
3138 exp_vec
[4].x
= 1.03734888e+03f
; exp_vec
[4].y
= 6.06827393e+02f
; exp_vec
[4].z
= 1.33812696e-01f
;
3139 exp_vec
[5].x
= 1.02502356e+03f
; exp_vec
[5].y
= 8.03591248e+02f
; exp_vec
[5].z
= 1.14580572e-01f
;
3140 D3DXVec3ProjectArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
3141 sizeof(*inp_vec
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE(inp_vec
));
3142 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 8);
3144 /* D3DXVec3UnprojectArray */
3145 exp_vec
[1].x
= -6.12403107e+00f
; exp_vec
[1].y
= 3.22536016e+00f
; exp_vec
[1].z
= 6.20571136e-01f
;
3146 exp_vec
[2].x
= -3.80710936e+00f
; exp_vec
[2].y
= 2.04657936e+00f
; exp_vec
[2].z
= 4.46894377e-01f
;
3147 exp_vec
[3].x
= -2.92283988e+00f
; exp_vec
[3].y
= 1.59668946e+00f
; exp_vec
[3].z
= 3.80609393e-01f
;
3148 exp_vec
[4].x
= -2.45622563e+00f
; exp_vec
[4].y
= 1.35928988e+00f
; exp_vec
[4].z
= 3.45631927e-01f
;
3149 exp_vec
[5].x
= -2.16789746e+00f
; exp_vec
[5].y
= 1.21259713e+00f
; exp_vec
[5].z
= 3.24018806e-01f
;
3150 D3DXVec3UnprojectArray((D3DXVECTOR3
*)&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
3151 sizeof(*inp_vec
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE(inp_vec
));
3152 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 4);
3154 /* D3DXVec2TransformArray */
3155 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
3156 exp_vec
[2].x
= 34.0f
; exp_vec
[2].y
= 40.0f
; exp_vec
[2].z
= 46.0f
; exp_vec
[2].w
= 52.0f
;
3157 exp_vec
[3].x
= 30.0f
; exp_vec
[3].y
= 36.0f
; exp_vec
[3].z
= 42.0f
; exp_vec
[3].w
= 48.0f
;
3158 exp_vec
[4].x
= 26.0f
; exp_vec
[4].y
= 32.0f
; exp_vec
[4].z
= 38.0f
; exp_vec
[4].w
= 44.0f
;
3159 exp_vec
[5].x
= 22.0f
; exp_vec
[5].y
= 28.0f
; exp_vec
[5].z
= 34.0f
; exp_vec
[5].w
= 40.0f
;
3160 D3DXVec2TransformArray(&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR2
*)inp_vec
,
3161 sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3162 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 0);
3164 /* D3DXVec3TransformArray */
3165 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
3166 exp_vec
[2].x
= 43.0f
; exp_vec
[2].y
= 50.0f
; exp_vec
[2].z
= 57.0f
; exp_vec
[2].w
= 64.0f
;
3167 exp_vec
[3].x
= 48.0f
; exp_vec
[3].y
= 56.0f
; exp_vec
[3].z
= 64.0f
; exp_vec
[3].w
= 72.0f
;
3168 exp_vec
[4].x
= 53.0f
; exp_vec
[4].y
= 62.0f
; exp_vec
[4].z
= 71.0f
; exp_vec
[4].w
= 80.0f
;
3169 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
3170 D3DXVec3TransformArray(&out_vec
[1], sizeof(*out_vec
), (D3DXVECTOR3
*)inp_vec
,
3171 sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3172 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 0);
3174 /* D3DXVec4TransformArray */
3175 exp_vec
[1].x
= 90.0f
; exp_vec
[1].y
= 100.0f
; exp_vec
[1].z
= 110.0f
; exp_vec
[1].w
= 120.0f
;
3176 exp_vec
[2].x
= 82.0f
; exp_vec
[2].y
= 92.0f
; exp_vec
[2].z
= 102.0f
; exp_vec
[2].w
= 112.0f
;
3177 exp_vec
[3].x
= 74.0f
; exp_vec
[3].y
= 84.0f
; exp_vec
[3].z
= 94.0f
; exp_vec
[3].w
= 104.0f
;
3178 exp_vec
[4].x
= 66.0f
; exp_vec
[4].y
= 76.0f
; exp_vec
[4].z
= 86.0f
; exp_vec
[4].w
= 96.0f
;
3179 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
3180 D3DXVec4TransformArray(&out_vec
[1], sizeof(*out_vec
), inp_vec
, sizeof(*inp_vec
), &mat
, ARRAY_SIZE(inp_vec
));
3181 expect_vec4_array(ARRAY_SIZE(exp_vec
), exp_vec
, out_vec
, 0);
3183 /* D3DXPlaneTransformArray */
3184 exp_plane
[1].a
= 90.0f
; exp_plane
[1].b
= 100.0f
; exp_plane
[1].c
= 110.0f
; exp_plane
[1].d
= 120.0f
;
3185 exp_plane
[2].a
= 82.0f
; exp_plane
[2].b
= 92.0f
; exp_plane
[2].c
= 102.0f
; exp_plane
[2].d
= 112.0f
;
3186 exp_plane
[3].a
= 74.0f
; exp_plane
[3].b
= 84.0f
; exp_plane
[3].c
= 94.0f
; exp_plane
[3].d
= 104.0f
;
3187 exp_plane
[4].a
= 66.0f
; exp_plane
[4].b
= 76.0f
; exp_plane
[4].c
= 86.0f
; exp_plane
[4].d
= 96.0f
;
3188 exp_plane
[5].a
= 58.0f
; exp_plane
[5].b
= 68.0f
; exp_plane
[5].c
= 78.0f
; exp_plane
[5].d
= 88.0f
;
3189 D3DXPlaneTransformArray(&out_plane
[1], sizeof(*out_plane
), inp_plane
,
3190 sizeof(*inp_plane
), &mat
, ARRAY_SIZE(inp_plane
));
3191 for (i
= 0; i
< ARRAY_SIZE(exp_plane
); ++i
)
3193 BOOL equal
= compare_plane(&exp_plane
[i
], &out_plane
[i
], 0);
3194 ok(equal
, "Got unexpected plane {%.8e, %.8e, %.8e, %.8e} at index %u, expected {%.8e, %.8e, %.8e, %.8e}.\n",
3195 out_plane
[i
].a
, out_plane
[i
].b
, out_plane
[i
].c
, out_plane
[i
].d
, i
,
3196 exp_plane
[i
].a
, exp_plane
[i
].b
, exp_plane
[i
].c
, exp_plane
[i
].d
);
3202 static void test_D3DXFloat_Array(void)
3209 /* Input floats through bit patterns because compilers do not generate reliable INF and NaN values. */
3218 union convert single_in
;
3220 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
3221 WORD half_ver1
, half_ver2
;
3223 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
3224 union convert single_out_ver1
, single_out_ver2
;
3228 { { 0x479c4000 }, 0x7c00, 0x7ce2, { 0x47800000 }, { 0x479c4000 } }, /* 80000.0f */
3229 { { 0x477fdf00 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65503.0f */
3230 { { 0x477fe000 }, 0x7bff, 0x7bff, { 0x477fe000 }, { 0x477fe000 } }, /* 65504.0f */
3231 { { 0x477ff000 }, 0x7bff, 0x7c00, { 0x477fe000 }, { 0x47800000 } }, /* 65520.0f */
3232 { { 0x477ff100 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65521.0f */
3234 { { 0x477ffe00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65534.0f */
3235 { { 0x477fff00 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65535.0f */
3236 { { 0x47800000 }, 0x7c00, 0x7c00, { 0x47800000 }, { 0x47800000 } }, /* 65536.0f */
3237 { { 0xc79c4000 }, 0xfc00, 0xfce2, { 0xc7800000 }, { 0xc79c4000 } }, /* -80000.0f */
3238 { { 0xc77fdf00 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65503.0f */
3240 { { 0xc77fe000 }, 0xfbff, 0xfbff, { 0xc77fe000 }, { 0xc77fe000 } }, /* -65504.0f */
3241 { { 0xc77ff000 }, 0xfbff, 0xfc00, { 0xc77fe000 }, { 0xc7800000 } }, /* -65520.0f */
3242 { { 0xc77ff100 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65521.0f */
3243 { { 0xc77ffe00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65534.0f */
3244 { { 0xc77fff00 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65535.0f */
3246 { { 0xc7800000 }, 0xfc00, 0xfc00, { 0xc7800000 }, { 0xc7800000 } }, /* -65536.0f */
3247 { { 0x7f800000 }, 0x7c00, 0x7fff, { 0x47800000 }, { 0x47ffe000 } }, /* INF */
3248 { { 0xff800000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -INF */
3249 { { 0x7fc00000 }, 0x7fff, 0xffff, { 0x47ffe000 }, { 0xc7ffe000 } }, /* NaN */
3250 { { 0xffc00000 }, 0xffff, 0xffff, { 0xc7ffe000 }, { 0xc7ffe000 } }, /* -NaN */
3252 { { 0x00000000 }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 0.0f */
3253 { { 0x80000000 }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -0.0f */
3254 { { 0x330007ff }, 0x0000, 0x0000, { 0x00000000 }, { 0x00000000 } }, /* 2.9809595e-08f */
3255 { { 0xb30007ff }, 0x8000, 0x8000, { 0x80000000 }, { 0x80000000 } }, /* -2.9809595e-08f */
3256 { { 0x33000800 }, 0x0001, 0x0000, { 0x33800000 }, { 0x00000000 } }, /* 2.9809598e-08f */
3258 { { 0xb3000800 }, 0x8001, 0x8000, { 0xb3800000 }, { 0x80000000 } }, /* -2.9809598e-08f */
3259 { { 0x33c00000 }, 0x0002, 0x0001, { 0x34000000 }, { 0x33800000 } }, /* 8.9406967e-08f */
3262 /* exception on NULL out or in parameter */
3263 out
= D3DXFloat32To16Array(&half
, &single
.f
, 0);
3264 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
3266 out
= D3DXFloat16To32Array(&single
.f
, &half
, 0);
3267 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
3269 for (i
= 0; i
< ARRAY_SIZE(testdata
); ++i
)
3271 out
= D3DXFloat32To16Array(&half
, &testdata
[i
].single_in
.f
, 1);
3272 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
3273 ok(half
.value
== testdata
[i
].half_ver1
|| half
.value
== testdata
[i
].half_ver2
,
3274 "Got %x, expected %x or %x for index %d.\n", half
.value
, testdata
[i
].half_ver1
,
3275 testdata
[i
].half_ver2
, i
);
3277 out
= D3DXFloat16To32Array(&single
.f
, (D3DXFLOAT16
*)&testdata
[i
].half_ver1
, 1);
3278 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
3279 equal
= compare_float(single
.f
, testdata
[i
].single_out_ver1
.f
, 0);
3280 ok(equal
, "Got %#x, expected %#x at index %u.\n", single
.d
, testdata
[i
].single_out_ver1
.d
, i
);
3282 out
= D3DXFloat16To32Array(&single
.f
, (D3DXFLOAT16
*)&testdata
[i
].half_ver2
, 1);
3283 ok(out
== &single
.f
, "Got %p, expected %p.\n", out
, &single
.f
);
3284 equal
= compare_float(single
.f
, testdata
[i
].single_out_ver2
.f
, 0);
3285 ok(equal
, "Got %#x, expected %#x at index %u.\n", single
.d
, testdata
[i
].single_out_ver2
.d
, i
);
3289 static void test_D3DXSHAdd(void)
3291 float out
[50] = {0.0f
};
3296 static const float in1
[50] =
3298 1.11f
, 1.12f
, 1.13f
, 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
,
3299 1.19f
, 1.20f
, 1.21f
, 1.22f
, 1.23f
, 1.24f
, 1.25f
, 1.26f
,
3300 1.27f
, 1.28f
, 1.29f
, 1.30f
, 1.31f
, 1.32f
, 1.33f
, 1.34f
,
3301 1.35f
, 1.36f
, 1.37f
, 1.38f
, 1.39f
, 1.40f
, 1.41f
, 1.42f
,
3302 1.43f
, 1.44f
, 1.45f
, 1.46f
, 1.47f
, 1.48f
, 1.49f
, 1.50f
,
3303 1.51f
, 1.52f
, 1.53f
, 1.54f
, 1.55f
, 1.56f
, 1.57f
, 1.58f
,
3306 static const float in2
[50] =
3308 2.11f
, 2.12f
, 2.13f
, 2.14f
, 2.15f
, 2.16f
, 2.17f
, 2.18f
,
3309 2.19f
, 2.20f
, 2.21f
, 2.22f
, 2.23f
, 2.24f
, 2.25f
, 2.26f
,
3310 2.27f
, 2.28f
, 2.29f
, 2.30f
, 2.31f
, 2.32f
, 2.33f
, 2.34f
,
3311 2.35f
, 2.36f
, 2.37f
, 2.38f
, 2.39f
, 2.40f
, 2.41f
, 2.42f
,
3312 2.43f
, 2.44f
, 2.45f
, 2.46f
, 2.47f
, 2.48f
, 2.49f
, 2.50f
,
3313 2.51f
, 2.52f
, 2.53f
, 2.54f
, 2.55f
, 2.56f
, 2.57f
, 2.58f
,
3318 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
3319 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
3320 * Exceptions will show up when out, in1 or in2 is NULL
3322 for (k
= 0; k
<= D3DXSH_MAXORDER
+ 1; k
++)
3326 ret
= D3DXSHAdd(&out
[0], k
, &in1
[0], &in2
[0]);
3327 ok(ret
== out
, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k
, out
, ret
);
3329 for (i
= 0; i
< count
; ++i
)
3331 equal
= compare_float(in1
[i
] + in2
[i
], out
[i
], 0);
3332 ok(equal
, "%u-%u: Got %.8e, expected %.8e.\n", k
, i
, out
[i
], in1
[i
] + in2
[i
]);
3334 equal
= compare_float(out
[count
], 0.0f
, 0);
3335 ok(equal
, "%u-%u: Got %.8e, expected 0.0.\n", k
, k
* k
, out
[count
]);
3339 static void test_D3DXSHDot(void)
3341 float a
[49], b
[49], got
;
3345 static const float expected
[] = {0.5f
, 0.5f
, 25.0f
, 262.5f
, 1428.0f
, 5362.5f
, 15873.0f
, 39812.5f
};
3347 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
3353 /* D3DXSHDot computes by using order * order elements */
3354 for (i
= 0; i
<= D3DXSH_MAXORDER
+ 1; i
++)
3356 got
= D3DXSHDot(i
, a
, b
);
3357 equal
= compare_float(got
, expected
[i
], 0);
3358 ok(equal
, "order %u: Got %.8e, expected %.8e.\n", i
, got
, expected
[i
]);
3362 static void test_D3DXSHEvalConeLight(void)
3364 float bout
[49], expected
, gout
[49], rout
[49];
3365 unsigned int j
, l
, order
;
3370 static const float table
[] =
3373 1.604815f
, -3.131381f
, 7.202175f
, -2.870432f
, 6.759296f
, -16.959688f
,
3374 32.303082f
, -15.546381f
, -0.588878f
, -5.902123f
, 40.084042f
, -77.423569f
,
3375 137.556320f
, -70.971603f
, -3.492171f
, 7.683092f
, -2.129311f
, -35.971344f
,
3376 183.086548f
, -312.414948f
, 535.091064f
, -286.380371f
, -15.950727f
, 46.825714f
,
3377 -12.127637f
, 11.289261f
, -12.417809f
, -155.039566f
, 681.182556f
, -1079.733643f
,
3378 1807.650513f
, -989.755798f
, -59.345467f
, 201.822815f
, -70.726486f
, 7.206529f
,
3380 3.101155f
, -3.128710f
, 7.196033f
, -2.867984f
, -0.224708f
, 0.563814f
,
3381 -1.073895f
, 0.516829f
, 0.019577f
, 2.059788f
, -13.988971f
, 27.020128f
,
3382 -48.005917f
, 24.768450f
, 1.218736f
, -2.681329f
, -0.088639f
, -1.497410f
,
3383 7.621501f
, -13.005165f
, 22.274696f
, -11.921401f
, -0.663995f
, 1.949254f
,
3384 -0.504848f
, 4.168484f
, -4.585193f
, -57.247314f
, 251.522095f
, -398.684387f
,
3385 667.462891f
, -365.460693f
, -21.912912f
, 74.521721f
, -26.115280f
, 2.660963f
,
3387 2.454422f
, -4.789170f
, 11.015091f
, -4.390072f
, 10.337747f
, -25.938347f
,
3388 49.404713f
, -23.776817f
, -0.900637f
, -9.026776f
, 61.305000f
, -118.412514f
,
3389 210.380249f
, -108.544792f
, -5.340967f
, 11.750610f
, -3.256593f
, -55.014996f
,
3390 280.014709f
, -477.811066f
, 818.374512f
, -437.993469f
, -24.395227f
, 71.615799f
,
3391 -18.548151f
, 17.265928f
, -18.991943f
, -237.119324f
, 1041.808594f
, -1651.357300f
,
3392 2764.642090f
, -1513.744141f
, -90.763657f
, 308.670197f
, -108.169922f
, 11.021750f
,
3394 4.742942f
, -4.785086f
, 11.005697f
, -4.386329f
, -0.343672f
, 0.862303f
,
3395 -1.642427f
, 0.790444f
, 0.029941f
, 3.150264f
, -21.394896f
, 41.324898f
,
3396 -73.420807f
, 37.881153f
, 1.863950f
, -4.100857f
, -0.135565f
, -2.290156f
,
3397 11.656413f
, -19.890251f
, 34.067181f
, -18.232729f
, -1.015521f
, 2.981212f
,
3398 -0.772120f
, 6.375328f
, -7.012648f
, -87.554710f
, 384.680817f
, -609.752563f
,
3399 1020.825500f
, -558.939819f
, -33.513863f
, 113.974388f
, -39.941013f
, 4.069707f
,
3401 3.304030f
, -6.446959f
, 14.828006f
, -5.909713f
, 13.916198f
, -34.917004f
,
3402 66.506340f
, -32.007256f
, -1.212396f
, -12.151429f
, 82.525963f
, -159.401459f
,
3403 283.204193f
, -146.117996f
, -7.189764f
, 15.818130f
, -4.383876f
, -74.058655f
,
3404 376.942871f
, -643.207214f
, 1101.658081f
, -589.606628f
, -32.839729f
, 96.405884f
,
3405 -24.968664f
, 23.242596f
, -25.566080f
, -319.199097f
, 1402.434692f
, -2222.980957f
,
3406 3721.633545f
, -2037.732544f
, -122.181847f
, 415.517578f
, -145.613358f
, 14.836972f
,
3408 6.384730f
, -6.441462f
, 14.815362f
, -5.904673f
, -0.462635f
, 1.160793f
,
3409 -2.210959f
, 1.064060f
, 0.040305f
, 4.240739f
, -28.800821f
, 55.629673f
,
3410 -98.835709f
, 50.993862f
, 2.509163f
, -5.520384f
, -0.182491f
, -3.082903f
,
3411 15.691326f
, -26.775339f
, 45.859665f
, -24.544060f
, -1.367048f
, 4.013170f
,
3412 -1.039392f
, 8.582172f
, -9.440103f
, -117.862114f
, 517.839600f
, -820.820740f
,
3413 1374.188232f
, -752.419067f
, -45.114819f
, 153.427063f
, -53.766754f
, 5.478452f
, };
3416 float *red_received
, *green_received
, *blue_received
;
3417 const float *red_expected
, *green_expected
, *blue_expected
;
3418 float radius
, roffset
, goffset
, boffset
;
3422 { rout
, gout
, bout
, table
, &table
[72], &table
[144], 0.5f
, 1.01f
, 1.02f
, 1.03f
, },
3423 { rout
, gout
, bout
, &table
[36], &table
[108], &table
[180], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
3424 { rout
, rout
, rout
, &table
[144], &table
[144], &table
[144], 0.5f
, 1.03f
, 1.03f
, 1.03f
, },
3425 { rout
, rout
, bout
, &table
[72], &table
[72], &table
[144], 0.5, 1.02f
, 1.02f
, 1.03f
, },
3426 { rout
, gout
, gout
, table
, &table
[144], &table
[144], 0.5f
, 1.01f
, 1.03f
, 1.03f
, },
3427 { rout
, gout
, rout
, &table
[144], &table
[72], &table
[144], 0.5f
, 1.03f
, 1.02f
, 1.03f
, },
3428 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
3429 { rout
, NULL
, bout
, table
, NULL
, &table
[144], 0.5f
, 1.01f
, 0.0f
, 1.03f
, },
3430 { rout
, gout
, NULL
, table
, &table
[72], NULL
, 0.5f
, 1.01f
, 1.02f
, 0.0f
, },
3431 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 0.5f
, 1.01f
, 0.0f
, 0.0f
, },
3434 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3436 for (l
= 0; l
< ARRAY_SIZE(test
); ++l
)
3438 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3440 for (j
= 0; j
< 49; j
++)
3442 test
[l
].red_received
[j
] = 1.01f
+ j
;
3443 if (test
[l
].green_received
)
3444 test
[l
].green_received
[j
] = 1.02f
+ j
;
3445 if (test
[l
].blue_received
)
3446 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3449 hr
= D3DXSHEvalConeLight(order
, &dir
, test
[l
].radius
, 1.7f
, 2.6f
, 3.5f
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
3450 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3452 for (j
= 0; j
< 49; j
++)
3454 if (j
>= order
* order
)
3455 expected
= j
+ test
[l
].roffset
;
3457 expected
= test
[l
].red_expected
[j
];
3458 equal
= compare_float(test
[l
].red_received
[j
], expected
, 128);
3459 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3460 l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3462 if (test
[l
].green_received
)
3464 if (j
>= order
* order
)
3465 expected
= j
+ test
[l
].goffset
;
3467 expected
= test
[l
].green_expected
[j
];
3468 equal
= compare_float(test
[l
].green_received
[j
], expected
, 64);
3469 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3470 l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3473 if (test
[l
].blue_received
)
3475 if (j
>= order
* order
)
3476 expected
= j
+ test
[l
].boffset
;
3478 expected
= test
[l
].blue_expected
[j
];
3479 equal
= compare_float(test
[l
].blue_received
[j
], expected
, 128);
3480 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3481 l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3487 /* Cone light with radius <= 0.0f behaves as a directional light */
3488 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3490 FLOAT blue
[49], green
[49], red
[49];
3492 for (j
= 0; j
< 49; j
++)
3494 rout
[j
] = 1.01f
+ j
;
3495 gout
[j
] = 1.02f
+ j
;
3496 bout
[j
] = 1.03f
+ j
;
3498 green
[j
] = 1.02f
+ j
;
3499 blue
[j
] = 1.03f
+ j
;
3502 hr
= D3DXSHEvalConeLight(order
, &dir
, -0.1f
, 1.7f
, 2.6f
, 3.5f
, rout
, gout
, bout
);
3503 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3504 D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red
, green
, blue
);
3506 for (j
= 0; j
< 49; j
++)
3508 equal
= compare_float(red
[j
], rout
[j
], 0);
3509 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3510 l
, order
, j
, red
[j
], rout
[j
]);
3512 equal
= compare_float(green
[j
], gout
[j
], 0);
3513 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3514 l
, order
, j
, green
[j
], gout
[j
]);
3516 equal
= compare_float(blue
[j
], bout
[j
], 0);
3517 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3518 l
, order
, j
, blue
[j
], bout
[j
]);
3522 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3523 hr
= D3DXSHEvalConeLight(7, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3524 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3525 hr
= D3DXSHEvalConeLight(0, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3526 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3527 hr
= D3DXSHEvalConeLight(1, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3528 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3531 static void test_D3DXSHEvalDirection(void)
3533 float a
[49], expected
, *received_ptr
;
3534 unsigned int i
, order
;
3538 static const float table
[36] =
3540 2.82094806e-01f
, -9.77205038e-01f
, 1.46580756e+00f
, -4.88602519e-01f
, 2.18509698e+00f
, -6.55529118e+00f
,
3541 8.20018101e+00f
, -3.27764559e-00f
, -1.63882279e+00f
, 1.18008721e+00f
, 1.73436680e+01f
, -4.02200317e+01f
,
3542 4.70202179e+01f
, -2.01100159e+01f
, -1.30077515e+01f
, 6.49047947e+00f
, -1.50200577e+01f
, 1.06207848e+01f
,
3543 1.17325661e+02f
, -2.40856750e+02f
, 2.71657288e+02f
, -1.20428375e+02f
, -8.79942474e+01f
, 5.84143143e+01f
,
3544 -4.38084984e+00f
, 2.49425201e+01f
, -1.49447693e+02f
, 7.82781296e+01f
, 7.47791748e+02f
, -1.42768787e+03f
,
3545 1.57461914e+03f
, -7.13843933e+02f
, -5.60843811e+02f
, 4.30529724e+02f
, -4.35889091e+01f
, -2.69116650e+01f
,
3548 d
.x
= 1.0; d
.y
= 2.0f
; d
.z
= 3.0f
;
3550 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3552 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
3555 received_ptr
= D3DXSHEvalDirection(a
, order
, &d
);
3556 ok(received_ptr
== a
, "Expected %p, received %p\n", a
, received_ptr
);
3558 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
3560 /* if the order is < D3DXSH_MINORDER or order > D3DXSH_MAXORDER or
3561 * the index of the element is greater than order * order - 1,
3562 * D3DXSHEvalDirection() does not modify the output. */
3563 if ((order
< D3DXSH_MINORDER
) || (order
> D3DXSH_MAXORDER
) || (i
>= order
* order
))
3564 expected
= 1.5f
+ i
;
3566 expected
= table
[i
];
3568 equal
= compare_float(a
[i
], expected
, 2);
3569 ok(equal
, "order %u, index %u: Got unexpected result %.8e, expected %.8e.\n",
3570 order
, i
, a
[i
], expected
);
3575 static void test_D3DXSHEvalDirectionalLight(void)
3577 float *blue_out
, bout
[49], expected
, gout
[49], *green_out
, *red_out
, rout
[49];
3578 unsigned int j
, l
, order
, startindex
;
3583 static const float table
[] =
3586 2.008781f
, -4.175174f
, 9.602900f
, -3.827243f
, 1.417963f
, -2.947181f
,
3587 6.778517f
, -2.701583f
, 7.249108f
, -18.188671f
, 34.643921f
, -16.672949f
,
3588 -0.631551f
, 1.417963f
, -2.947181f
, 6.778517f
, -2.701583f
, 7.249108f
,
3589 -18.188671f
, 34.643921f
, -16.672949f
, -0.631551f
, -7.794341f
, 52.934967f
,
3590 -102.245529f
, 181.656815f
, -93.725060f
, -4.611760f
, 10.146287f
, 1.555186f
,
3591 -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
, 37.996559f
,
3592 -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
, 199.236496f
,
3593 -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
, 360.268829f
,
3594 -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
, -23.864176f
,
3595 1.555186f
, -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
,
3596 37.996559f
, -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
,
3597 199.236496f
, -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
,
3598 360.268829f
, -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
,
3599 -23.864176f
, 34.868664f
, -38.354366f
, -478.864166f
, 2103.939941f
, -3334.927734f
,
3600 5583.213867f
, -3057.017090f
, -183.297836f
, 623.361633f
, -218.449921f
, 22.258503f
,
3602 3.072254f
, -6.385560f
, 14.686787f
, -5.853429f
, 2.168650f
, -4.507453f
,
3603 10.367143f
, -4.131832f
, 11.086870f
, -27.817965f
, 52.984818f
, -25.499800f
,
3604 -0.965902f
, 2.168650f
, -4.507453f
, 10.367143f
, -4.131832f
, 11.086870f
,
3605 -27.817965f
, 52.984818f
, -25.499800f
, -0.965902f
, -11.920755f
, 80.959351f
,
3606 -156.375488f
, 277.828033f
, -143.344193f
, -7.053278f
, 15.517849f
, 2.378519f
,
3607 -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
, 58.112385f
,
3608 -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
, 304.714630f
,
3609 -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
, 550.999390f
,
3610 -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
, -36.498150f
,
3611 2.378519f
, -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
,
3612 58.112385f
, -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
,
3613 304.714630f
, -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
,
3614 550.999390f
, -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
,
3615 -36.498150f
, 53.328545f
, -58.659618f
, -732.380493f
, 3217.790283f
, -5100.477539f
,
3616 8539.033203f
, -4675.437500f
, -280.337860f
, 953.376587f
, -334.099884f
, 34.042416f
,
3618 4.135726f
, -8.595945f
, 19.770674f
, -7.879617f
, 2.919336f
, -6.067726f
,
3619 13.955770f
, -5.562082f
, 14.924634f
, -37.447262f
, 71.325722f
, -34.326656f
,
3620 -1.300252f
, 2.919336f
, -6.067726f
, 13.955770f
, -5.562082f
, 14.924634f
,
3621 -37.447262f
, 71.325722f
, -34.326656f
, -1.300252f
, -16.047173f
, 108.983749f
,
3622 -210.505493f
, 373.999298f
, -192.963348f
, -9.494799f
, 20.889414f
, 3.201853f
,
3623 -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
, 78.228210f
,
3624 -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
, 410.192780f
,
3625 -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
, 741.729919f
,
3626 -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
, -49.132126f
,
3627 3.201853f
, -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
,
3628 78.228210f
, -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
,
3629 410.192780f
, -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
,
3630 741.729919f
, -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
,
3631 -49.132126f
, 71.788422f
, -78.964867f
, -985.896790f
, 4331.640625f
, -6866.027344f
,
3632 11494.852539f
, -6293.858398f
, -377.377899f
, 1283.391479f
, -449.749817f
, 45.826328f
, };
3635 float *red_in
, *green_in
, *blue_in
;
3636 const float *red_out
, *green_out
, *blue_out
;
3637 float roffset
, goffset
, boffset
;
3641 { rout
, gout
, bout
, table
, &table
[90], &table
[180], 1.01f
, 1.02f
, 1.03f
, },
3642 { rout
, rout
, rout
, &table
[180], &table
[180], &table
[180], 1.03f
, 1.03f
, 1.03f
, },
3643 { rout
, rout
, bout
, &table
[90], &table
[90], &table
[180], 1.02f
, 1.02f
, 1.03f
, },
3644 { rout
, gout
, gout
, table
, &table
[180], &table
[180], 1.01f
, 1.03f
, 1.03f
, },
3645 { rout
, gout
, rout
, &table
[180], &table
[90], &table
[180], 1.03f
, 1.02f
, 1.03f
, },
3646 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
3647 { rout
, NULL
, bout
, table
, NULL
, &table
[180], 1.01f
, 0.0f
, 1.03f
, },
3648 { rout
, gout
, NULL
, table
, &table
[90], NULL
, 1.01f
, 1.02f
, 0.0f
, },
3649 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 0.0f
, 0.0f
, },
3652 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3654 for (l
= 0; l
< ARRAY_SIZE(test
); ++l
)
3658 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3660 red_out
= test
[l
].red_in
;
3661 green_out
= test
[l
].green_in
;
3662 blue_out
= test
[l
].blue_in
;
3664 for (j
= 0; j
< ARRAY_SIZE(rout
); ++j
)
3666 red_out
[j
] = 1.01f
+ j
;
3668 green_out
[j
] = 1.02f
+ j
;
3670 blue_out
[j
] = 1.03f
+ j
;
3673 hr
= D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red_out
, green_out
, blue_out
);
3674 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3676 for (j
= 0; j
< ARRAY_SIZE(rout
); ++j
)
3678 if ( j
>= order
* order
)
3679 expected
= j
+ test
[l
].roffset
;
3681 expected
= test
[l
].red_out
[startindex
+ j
];
3682 equal
= compare_float(expected
, red_out
[j
], 8);
3683 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3684 l
, order
, j
, expected
, red_out
[j
]);
3688 if ( j
>= order
* order
)
3689 expected
= j
+ test
[l
].goffset
;
3691 expected
= test
[l
].green_out
[startindex
+ j
];
3692 equal
= compare_float(expected
, green_out
[j
], 8);
3693 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3694 l
, order
, j
, expected
, green_out
[j
]);
3699 if ( j
>= order
* order
)
3700 expected
= j
+ test
[l
].boffset
;
3702 expected
= test
[l
].blue_out
[startindex
+ j
];
3703 equal
= compare_float(expected
, blue_out
[j
], 4);
3704 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3705 l
, order
, j
, expected
, blue_out
[j
]);
3709 startindex
+= order
* order
;
3713 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
3714 hr
= D3DXSHEvalDirectionalLight(7, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3715 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3716 hr
= D3DXSHEvalDirectionalLight(0, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3717 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3718 hr
= D3DXSHEvalDirectionalLight(1, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3719 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3722 static void test_D3DXSHEvalHemisphereLight(void)
3724 float bout
[49], expected
, gout
[49], rout
[49];
3725 unsigned int j
, l
, order
;
3726 D3DXCOLOR bottom
, top
;
3731 static const float table
[] =
3734 23.422981f
, 15.859521f
, -36.476898f
, 14.537894f
,
3736 19.966694f
, 6.096982f
, -14.023058f
, 5.588900f
,
3738 24.566214f
, 8.546826f
, -19.657701f
, 7.834591f
,
3742 float *red_received
, *green_received
, *blue_received
;
3743 const float *red_expected
, *green_expected
, *blue_expected
;
3744 const float roffset
, goffset
, boffset
;
3748 { rout
, gout
, bout
, table
, &table
[4], &table
[8], 1.01f
, 1.02f
, 1.03f
, },
3749 { rout
, rout
, rout
, &table
[8], &table
[8], &table
[8], 1.03f
, 1.03f
, 1.03f
, },
3750 { rout
, rout
, bout
, &table
[4], &table
[4], &table
[8], 1.02f
, 1.02f
, 1.03f
, },
3751 { rout
, gout
, gout
, table
, &table
[8], &table
[8], 1.01f
, 1.03f
, 1.03f
, },
3752 { rout
, gout
, rout
, &table
[8], &table
[4], &table
[8], 1.03f
, 1.02f
, 1.03f
, },
3753 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
3754 { rout
, NULL
, bout
, table
, NULL
, &table
[8], 1.01f
, 1.02f
, 1.03f
, },
3755 { rout
, gout
, NULL
, table
, &table
[4], NULL
, 1.01f
, 1.02f
, 1.03f
, },
3756 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 1.02f
, 1.03f
, },
3759 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3760 top
.r
= 0.1f
; top
.g
= 2.1f
; top
.b
= 2.3f
; top
.a
= 4.3f
;
3761 bottom
.r
= 8.71f
; bottom
.g
= 5.41f
; bottom
.b
= 6.94f
; bottom
.a
= 8.43f
;
3763 for (l
= 0; l
< ARRAY_SIZE(test
); ++l
)
3764 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3766 for (j
= 0; j
< 49; j
++)
3768 test
[l
].red_received
[j
] = 1.01f
+ j
;
3769 if (test
[l
].green_received
)
3770 test
[l
].green_received
[j
] = 1.02f
+ j
;
3771 if (test
[l
].blue_received
)
3772 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3775 hr
= D3DXSHEvalHemisphereLight(order
, &dir
, top
, bottom
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
3776 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3778 for (j
= 0; j
< 49; j
++)
3781 expected
= test
[l
].red_expected
[j
];
3782 else if (j
< order
* order
)
3785 expected
= test
[l
].roffset
+ j
;
3786 equal
= compare_float(test
[l
].red_received
[j
], expected
, 4);
3787 ok(equal
, "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3788 l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3790 if (test
[l
].green_received
)
3793 expected
= test
[l
].green_expected
[j
];
3794 else if (j
< order
* order
)
3797 expected
= test
[l
].goffset
+ j
;
3798 equal
= compare_float(expected
, test
[l
].green_received
[j
], 4);
3799 ok(equal
, "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3800 l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3803 if (test
[l
].blue_received
)
3806 expected
= test
[l
].blue_expected
[j
];
3807 else if (j
< order
* order
)
3810 expected
= test
[l
].boffset
+ j
;
3811 equal
= compare_float(expected
, test
[l
].blue_received
[j
], 4);
3812 ok(equal
, "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3813 l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3819 static void test_D3DXSHEvalSphericalLight(void)
3821 float bout
[49], expected
, gout
[49], rout
[49];
3822 unsigned int j
, l
, order
;
3827 static const float table
[] =
3830 3.01317163e+00f
, -9.77240128e-01f
, 2.24765220e+00f
, -8.95803434e-01f
, 3.25255224e-35f
, -8.16094904e-35f
,
3831 8.95199460e-35f
, -7.48086982e-35f
, -2.83366352e-36f
, 6.29281376e-02f
, -4.27374053e-01f
, 6.19212543e-01f
,
3832 -3.04508915e-01f
, 5.67611487e-01f
, 3.72333533e-02f
, -8.19167317e-02f
, 1.25205729e-36f
, 2.11515287e-35f
,
3833 -8.85884025e-35f
, 8.22100105e-35f
, -1.41290744e-37f
, 7.53591749e-35f
, 7.71793061e-36f
, -2.75340121e-35f
,
3834 7.13117824e-36f
, 1.24992691e-02f
, -1.37487792e-02f
, -1.48109290e-01f
, 4.34345843e-01f
, -2.45986100e-01f
,
3835 -1.51757946e-01f
, -2.25487254e-01f
, -3.78407442e-02f
, 1.92801335e-01f
, -7.83071154e-02f
, 7.97894137e-03f
,
3837 4.02519645e-01f
, -2.43653315e-01f
, 5.60402600e-01f
, -2.23348868e-01f
, 1.62046875e-01f
, -4.06590330e-01f
,
3838 4.46001368e-01f
, -3.72707796e-01f
, -1.41177231e-02f
, -4.31995198e-02f
, 2.93387896e-01f
, -4.25083048e-01f
,
3839 2.09042241e-01f
, -3.89659453e-01f
, -2.55603144e-02f
, 5.62349945e-02f
, -4.68822967e-03f
, -7.92002290e-02f
,
3840 3.31712278e-01f
, -3.07828893e-01f
, 5.29052032e-04f
, -2.82176480e-01f
, -2.88991817e-02f
, 1.03098934e-01f
,
3841 -2.67021338e-02f
, 7.24339502e-03f
, -7.96749298e-03f
, -8.58301461e-02f
, 2.51705799e-01f
, -1.42550295e-01f
,
3842 -8.79445626e-02f
, -1.30671101e-01f
, -2.19289189e-02f
, 1.11729432e-01f
, -4.53794030e-02f
, 4.62384030e-03f
,
3844 1.95445306e+00f
, -8.56593659e-01f
, 1.97016533e+00f
, -7.85210840e-01f
, 2.31033385e-01f
, -5.79683751e-01f
,
3845 6.35872835e-01f
, -5.31376762e-01f
, -2.01279127e-02f
, 2.11104646e-02f
, -1.43370917e-01f
, 2.07726860e-01f
,
3846 -1.02153423e-01f
, 1.90416285e-01f
, 1.24906507e-02f
, -2.74805568e-02f
, 6.33162467e-03f
, 1.06962790e-01f
,
3847 -4.47989495e-01f
, 4.15734115e-01f
, -7.14504011e-04f
, 3.81089599e-01f
, 3.90293960e-02f
, -1.39238860e-01f
,
3848 3.60622028e-02f
, -4.47359268e-03f
, 4.92080277e-03f
, 5.30095505e-02f
, -1.55456001e-01f
, 8.80404774e-02f
,
3849 5.43154350e-02f
, 8.07037695e-02f
, 1.35435180e-02f
, -6.90052063e-02f
, 2.80267699e-02f
, -2.85572968e-03f
,
3851 4.60837984e+00f
, -1.49460245e+00f
, 3.43758549e+00f
, -1.37005222e+00f
, 4.97449134e-35f
, -1.24814507e-34f
,
3852 1.36912850e-34f
, -1.14413296e-34f
, -4.33383805e-36f
, 9.62430278e-02f
, -6.53630863e-01f
, 9.47030887e-01f
,
3853 -4.65719486e-01f
, 8.68111630e-01f
, 5.69451249e-02f
, -1.25284405e-01f
, 1.91491103e-36f
, 3.23493947e-35f
,
3854 -1.35488136e-34f
, 1.25732949e-34f
, -2.16091711e-37f
, 1.15255201e-34f
, 1.18038931e-35f
, -4.21108392e-35f
,
3855 1.09065072e-35f
, 1.91165280e-02f
, -2.10275433e-02f
, -2.26520076e-01f
, 6.64293599e-01f
, -3.76214011e-01f
,
3856 -2.32100374e-01f
, -3.44862837e-01f
, -5.78740756e-02f
, 2.94872611e-01f
, -1.19763816e-01f
, 1.22030860e-02f
,
3858 6.15618240e-01f
, -3.72646222e-01f
, 8.57086273e-01f
, -3.41592364e-01f
, 2.47836381e-01f
, -6.21843994e-01f
,
3859 6.82119695e-01f
, -5.70023651e-01f
, -2.15918104e-02f
, -6.60698496e-02f
, 4.48710870e-01f
, -6.50126972e-01f
,
3860 3.19711642e-01f
, -5.95949713e-01f
, -3.90922430e-02f
, 8.60064566e-02f
, -7.17023314e-03f
, -1.21129754e-01f
,
3861 5.07324627e-01f
, -4.70797100e-01f
, 8.09138350e-04f
, -4.31564000e-01f
, -4.41987457e-02f
, 1.57680712e-01f
,
3862 -4.08385549e-02f
, 1.10781328e-02f
, -1.21855767e-02f
, -1.31269627e-01f
, 3.84961785e-01f
, -2.18018084e-01f
,
3863 -1.34503440e-01f
, -1.99849906e-01f
, -3.35383443e-02f
, 1.70880296e-01f
, -6.94037884e-02f
, 7.07175529e-03f
,
3865 2.98916331e+00f
, -1.31008433e+00f
, 3.01319384e+00f
, -1.20091062e+00f
, 3.53345154e-01f
, -8.86575090e-01f
,
3866 9.72511332e-01f
, -8.12693818e-01f
, -3.07838645e-02f
, 3.22865908e-02f
, -2.19273153e-01f
, 3.17699883e-01f
,
3867 -1.56234637e-01f
, 2.91224888e-01f
, 1.91033469e-02f
, -4.20290842e-02f
, 9.68366064e-03f
, 1.63590138e-01f
,
3868 -6.85160360e-01f
, 6.35828606e-01f
, -1.09277077e-03f
, 5.82842878e-01f
, 5.96920135e-02f
, -2.12953537e-01f
,
3869 5.51539537e-02f
, -6.84196484e-03f
, 7.52593316e-03f
, 8.10734249e-02f
, -2.37756221e-01f
, 1.34650133e-01f
,
3870 8.30706600e-02f
, 1.23429287e-01f
, 2.07136145e-02f
, -1.05537368e-01f
, 4.28644688e-02f
, -4.36758628e-03f
,
3872 6.20358848e+00f
, -2.01196491e+00f
, 4.62751910e+00f
, -1.84430114e+00f
, 6.69643089e-35f
, -1.68019534e-34f
,
3873 1.84305766e-34f
, -1.54017904e-34f
, -5.83401297e-36f
, 1.29557927e-01f
, -8.79887732e-01f
, 1.27484932e+00f
,
3874 -6.26930101e-01f
, 1.16861185e+00f
, 7.66569017e-02f
, -1.68652090e-01f
, 2.57776494e-36f
, 4.35472637e-35f
,
3875 -1.82387882e-34f
, 1.69255899e-34f
, -2.90892699e-37f
, 1.55151238e-34f
, 1.58898567e-35f
, -5.66876703e-35f
,
3876 1.46818371e-35f
, 2.57337886e-02f
, -2.83063093e-02f
, -3.04930882e-01f
, 8.94241416e-01f
, -5.06441957e-01f
,
3877 -3.12442822e-01f
, -4.64238452e-01f
, -7.79074123e-02f
, 3.96943914e-01f
, -1.61220527e-01f
, 1.64272318e-02f
,
3879 8.28716892e-01f
, -5.01639163e-01f
, 1.15377003e+00f
, -4.59835891e-01f
, 3.33625909e-01f
, -8.37097715e-01f
,
3880 9.18238085e-01f
, -7.67339558e-01f
, -2.90658997e-02f
, -8.89401854e-02f
, 6.04033886e-01f
, -8.75170956e-01f
,
3881 4.30381072e-01f
, -8.02240028e-01f
, -5.26241753e-02f
, 1.15777927e-01f
, -9.65223728e-03f
, -1.63059290e-01f
,
3882 6.82937023e-01f
, -6.33765350e-01f
, 1.08922474e-03f
, -5.80951560e-01f
, -5.94983136e-02f
, 2.12262505e-01f
,
3883 -5.49749798e-02f
, 1.49128717e-02f
, -1.64036616e-02f
, -1.76709119e-01f
, 5.18217807e-01f
, -2.93485893e-01f
,
3884 -1.81062330e-01f
, -2.69028730e-01f
, -4.51477729e-02f
, 2.30031176e-01f
, -9.34281801e-02f
, 9.51967094e-03f
,
3886 4.02387383e+00f
, -1.76357513e+00f
, 4.05622263e+00f
, -1.61661051e+00f
, 4.75656955e-01f
, -1.19346651e+00f
,
3887 1.30914992e+00f
, -1.09401095e+00f
, -4.14398191e-02f
, 4.34627200e-02f
, -2.95175409e-01f
, 4.27672935e-01f
,
3888 -2.10315865e-01f
, 3.92033517e-01f
, 2.57160448e-02f
, -5.65776154e-02f
, 1.30356975e-02f
, 2.20217502e-01f
,
3889 -9.22331288e-01f
, 8.55923154e-01f
, -1.47103763e-03f
, 7.84596211e-01f
, 8.03546365e-02f
, -2.86668233e-01f
,
3890 7.42457096e-02f
, -9.21033762e-03f
, 1.01310642e-02f
, 1.09137307e-01f
, -3.20056463e-01f
, 1.81259801e-01f
,
3891 1.11825893e-01f
, 1.66154815e-01f
, 2.78837128e-02f
, -1.42069538e-01f
, 5.77021717e-02f
, -5.87944329e-03f
,
3895 float *red_received
, *green_received
, *blue_received
;
3896 const float *red_expected
, *green_expected
, *blue_expected
;
3897 float radius
, roffset
, goffset
, boffset
;
3901 { rout
, gout
, bout
, table
, &table
[108], &table
[216], 17.4f
, 1.01f
, 1.02f
, 1.03f
, },
3902 { rout
, gout
, bout
, &table
[36], &table
[144], &table
[252], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
3903 { rout
, gout
, bout
, &table
[72], &table
[180], &table
[288], -3.0f
, 1.01f
, 1.02f
, 1.03f
, },
3904 { rout
, rout
, rout
, &table
[216], &table
[216], &table
[216], 17.4f
, 1.03f
, 1.03f
, 1.03f
, },
3905 { rout
, rout
, bout
, &table
[108], &table
[108], &table
[216], 17.4, 1.02f
, 1.02f
, 1.03f
, },
3906 { rout
, gout
, gout
, table
, &table
[216], &table
[216], 17.4f
, 1.01f
, 1.03f
, 1.03f
, },
3907 { rout
, gout
, rout
, &table
[216], &table
[108], &table
[216], 17.4f
, 1.03f
, 1.02f
, 1.03f
, },
3908 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
3909 { rout
, NULL
, bout
, table
, NULL
, &table
[216], 17.4f
, 1.01f
, 0.0f
, 1.03f
, },
3910 { rout
, gout
, NULL
, table
, &table
[108], NULL
, 17.4f
, 1.01f
, 1.02f
, 0.0f
, },
3911 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 17.4f
, 1.01f
, 0.0f
, 0.0f
, },
3914 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3916 for (l
= 0; l
< ARRAY_SIZE(test
); ++l
)
3918 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3920 for (j
= 0; j
< 49; j
++)
3922 test
[l
].red_received
[j
] = 1.01f
+ j
;
3923 if (test
[l
].green_received
)
3924 test
[l
].green_received
[j
] = 1.02f
+ j
;
3925 if (test
[l
].blue_received
)
3926 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3929 hr
= D3DXSHEvalSphericalLight(order
, &dir
, test
[l
].radius
, 1.7f
, 2.6f
, 3.5f
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
3930 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3932 for (j
= 0; j
< 49; j
++)
3934 if (j
>= order
* order
)
3935 expected
= j
+ test
[l
].roffset
;
3937 expected
= test
[l
].red_expected
[j
];
3938 equal
= compare_float(expected
, test
[l
].red_received
[j
], 4096);
3939 ok(equal
|| (fabs(expected
) < 1.0e-6f
&& fabs(test
[l
].red_received
[j
]) < 1.0e-6f
),
3940 "Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3941 l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3943 if (test
[l
].green_received
)
3945 if (j
>= order
* order
)
3946 expected
= j
+ test
[l
].goffset
;
3948 expected
= test
[l
].green_expected
[j
];
3949 equal
= compare_float(expected
, test
[l
].green_received
[j
], 4096);
3950 ok(equal
|| (fabs(expected
) < 1.0e-6f
&& fabs(test
[l
].green_received
[j
]) < 1.0e-6f
),
3951 "Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3952 l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3955 if (test
[l
].blue_received
)
3957 if (j
>= order
* order
)
3958 expected
= j
+ test
[l
].boffset
;
3960 expected
= test
[l
].blue_expected
[j
];
3961 equal
= compare_float(expected
, test
[l
].blue_received
[j
], 4096);
3962 ok(equal
|| (fabs(expected
) < 1.0e-6f
&& fabs(test
[l
].blue_received
[j
]) < 1.0e-6f
),
3963 "Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
3964 l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3970 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3971 hr
= D3DXSHEvalSphericalLight(7, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3972 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3973 hr
= D3DXSHEvalSphericalLight(0, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3974 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3975 hr
= D3DXSHEvalSphericalLight(1, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3976 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3979 static void test_D3DXSHMultiply2(void)
3981 float a
[20], b
[20], c
[20];
3985 /* D3DXSHMultiply2() only modifies the first 4 elements of the array. */
3986 static const float expected
[20] =
3988 3.41859412f
, 1.69821072f
, 1.70385253f
, 1.70949447f
, 4.0f
, 5.0f
, 6.0f
,
3989 7.0f
, 8.0f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3990 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3993 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
3995 a
[i
] = 1.0f
+ i
/ 100.0f
;
3996 b
[i
] = 3.0f
- i
/ 100.0f
;
4000 D3DXSHMultiply2(c
, a
, b
);
4001 for (i
= 0; i
< ARRAY_SIZE(expected
); ++i
)
4003 equal
= compare_float(c
[i
], expected
[i
], 2);
4004 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
4008 static void test_D3DXSHMultiply3(void)
4010 float a
[20], b
[20], c
[20];
4014 /* D3DXSHMultiply3() only modifies the first 9 elements of the array. */
4015 static const float expected
[20] =
4017 7.81391382e+00f
, 2.25605774e+00f
, 5.94839954e+00f
, 4.97089481e+00f
, 2.89985824e+00f
, 3.59894633e+00f
,
4018 1.72657156e+00f
, 5.57353783e+00f
, 6.22063160e-01f
, 9.00000000e+00f
, 1.00000000e+01f
, 1.10000000e+01f
,
4019 1.20000000e+01f
, 1.30000000e+01f
, 1.40000000e+01f
, 1.50000000e+01f
, 1.60000000e+01f
, 1.70000000e+01f
,
4020 1.80000000e+01f
, 1.90000000e+01f
,
4022 static const float expected_aliased
[20] =
4024 4.54092499e+02f
, 2.12640405e+00f
, 5.57040071e+00f
, 1.53303785e+01f
, 2.27960873e+01f
, 4.36041260e+01f
,
4025 4.27384138e+00f
, 1.75772034e+02f
, 2.37672729e+02f
, 1.09000003e+00f
, 1.10000002e+00f
, 1.11000001e+00f
,
4026 1.12000000e+00f
, 1.13000000e+00f
, 1.13999999e+00f
, 1.14999998e+00f
, 1.15999997e+00f
, 1.16999996e+00f
,
4027 1.17999995e+00f
, 1.19000006e+00f
,
4030 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
4032 a
[i
] = 1.0f
+ i
/ 100.0f
;
4033 b
[i
] = 3.0f
- i
/ 100.0f
;
4037 D3DXSHMultiply3(c
, a
, b
);
4038 for (i
= 0; i
< ARRAY_SIZE(expected
); ++i
)
4040 equal
= compare_float(c
[i
], expected
[i
], 4);
4041 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
4044 memcpy(c
, a
, sizeof(c
));
4045 D3DXSHMultiply3(c
, c
, b
);
4046 for (i
= 0; i
< ARRAY_SIZE(expected_aliased
); ++i
)
4048 equal
= compare_float(c
[i
], expected_aliased
[i
], 32);
4049 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected_aliased
[i
], c
[i
]);
4053 static void test_D3DXSHMultiply4(void)
4055 float a
[20], b
[20], c
[20];
4059 /* D3DXSHMultiply4() only modifies the first 16 elements of the array. */
4060 static const float expected
[] =
4063 1.41825991e+01f
, 2.61570334e+00f
, 1.28286009e+01f
, 9.82059574e+00f
, 3.03969646e+00f
, 4.53044176e+00f
,
4064 5.82058382e+00f
, 1.22498465e+01f
, 2.19434643e+00f
, 3.90015244e+00f
, 5.41660881e+00f
, 5.60181284e+00f
,
4065 9.59981740e-01f
, 7.03754997e+00f
, 3.62523031e+00f
, 4.63601470e-01f
, 1.60000000e+01f
, 1.70000000e+01f
,
4066 1.80000000e+01f
, 1.90000000e+01f
,
4068 -2.11441266e+05f
, -2.52915771e+03f
, -1.00233936e+04f
, -4.41277191e+02f
, -1.63994385e+02f
, -5.26305115e+02f
,
4069 2.96361875e+04f
, -3.93183081e+03f
, -1.35771113e+04f
, -3.97897388e+03f
, -1.03303418e+04f
, -1.37797871e+04f
,
4070 -1.66851094e+04f
, -4.49813750e+04f
, -7.32697422e+04f
, -9.52373359e+04f
, 1.60000000e+01f
, 1.70000000e+01f
,
4071 1.80000000e+01f
, 1.90000000e+01f
,
4073 2.36682415e-01f
, -7.17648506e-01f
, -1.80499524e-01f
, -7.71235973e-02f
, 1.44830629e-01f
, 5.73285699e-01f
,
4074 -3.37959230e-01f
, 5.56938872e-02f
, -4.42100227e-01f
, 1.47701755e-01f
, -5.51566519e-02f
, 8.43374059e-02f
,
4075 1.79876596e-01f
, 9.09878965e-03f
, 2.32199892e-01f
, 7.41420984e-02f
, 1.60000002e+00f
, 1.70000005e+00f
,
4076 1.80000007e+00f
, 1.89999998e+00f
,
4079 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
4081 a
[i
] = 1.0f
+ i
/ 100.0f
;
4082 b
[i
] = 3.0f
- i
/ 100.0f
;
4086 D3DXSHMultiply4(c
, a
, b
);
4087 for (i
= 0; i
< ARRAY_SIZE(c
); ++i
)
4089 equal
= compare_float(c
[i
], expected
[i
], 16);
4090 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[i
], c
[i
]);
4093 for (i
= 0; i
< ARRAY_SIZE(b
); ++i
)
4095 b
[i
] = 3.0f
- i
/ 100.0f
;
4099 D3DXSHMultiply4(c
, c
, b
);
4100 for (i
= 0; i
< ARRAY_SIZE(c
); ++i
)
4102 equal
= compare_float(c
[i
], expected
[20 + i
], 32);
4103 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[20 + i
], c
[i
]);
4106 for (i
= 0; i
< ARRAY_SIZE(c
); ++i
)
4109 D3DXSHMultiply4(c
, c
, c
);
4110 for (i
= 0; i
< ARRAY_SIZE(c
); ++i
)
4112 equal
= compare_float(c
[i
], expected
[40 + i
], 8);
4113 ok(equal
, "Expected[%u] = %.8e, received = %.8e.\n", i
, expected
[40 + i
], c
[i
]);
4117 static void test_D3DXSHRotate(void)
4119 float expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
4120 unsigned int i
, j
, l
, order
;
4124 static const float table
[]=
4126 /* Rotation around the x-axis, π/2. */
4127 1.00999999e+00f
, -3.00999999e+00f
, 2.00999975e+00f
, 4.01000023e+00f
, -8.01000023e+00f
, -6.00999928e+00f
,
4128 -1.13078899e+01f
, 5.00999975e+00f
, -1.56583869e+00f
, 1.09359801e+00f
, -1.10099983e+01f
, 1.98334141e+01f
,
4129 -1.52681913e+01f
, -1.90041180e+01f
, -3.36488891e+00f
, -9.56262684e+00f
, 1.20996542e+01f
, -2.72131383e-01f
,
4130 3.02410126e+01f
, 2.69199905e+01f
, 3.92368774e+01f
, -2.26324463e+01f
, 6.70738792e+00f
, -1.17682819e+01f
,
4131 3.44367194e+00f
, -6.07445812e+00f
, 1.16183939e+01f
, 1.52756083e+00f
, 3.78963356e+01f
, -5.69012184e+01f
,
4132 4.74228935e+01f
, 5.03915329e+01f
, 1.06181908e+01f
, 2.55010109e+01f
, 4.92456071e-02f
, 1.69833069e+01f
,
4134 1.00999999e+00f
, -3.00999999e+00f
, -3.01000023e+00f
, 4.01000023e+00f
, -8.01000023e+00f
, -6.00999928e+00f
,
4135 -1.13078890e+01f
, -8.01000023e+00f
, 1.42979193e+01f
,
4136 /* Rotation around the x-axis, -π/2. */
4137 1.00999999e+00f
, 3.00999999e+00f
, -2.01000023e+00f
, 4.01000023e+00f
, 8.01000023e+00f
, -6.01000118e+00f
,
4138 -1.13078880e+01f
, -5.01000071e+00f
, -1.56583774e+00f
, -1.09359753e+00f
, -1.10100021e+01f
, -1.98334103e+01f
,
4139 1.52681961e+01f
, -1.90041142e+01f
, 3.36489248e+00f
, -9.56262398e+00f
, -1.20996523e+01f
, -2.72129118e-01f
,
4140 -3.02410049e+01f
, 2.69200020e+01f
, 3.92368736e+01f
, 2.26324520e+01f
, 6.70738268e+00f
, 1.17682877e+01f
,
4141 3.44367099e+00f
, 6.07445717e+00f
, 1.16183996e+01f
, -1.52756333e+00f
, 3.78963509e+01f
, 5.69011993e+01f
,
4142 -4.74229126e+01f
, 5.03915253e+01f
, -1.06182041e+01f
, 2.55009995e+01f
, -4.92481887e-02f
, 1.69833050e+01f
,
4144 1.00999999e+00f
, 3.00999999e+00f
, -3.01000023e+00f
, 4.01000023e+00f
, 8.01000023e+00f
, -6.01000118e+00f
,
4145 -1.13078899e+01f
, -8.01000023e+00f
, 1.42979193e+01f
,
4146 /* Yaw π/3, pitch π/4, roll π/5. */
4147 1.00999999e+00f
, 4.94489908e+00f
, 1.44230127e+00f
, 1.62728095e+00f
, 2.19220325e-01f
, 1.05408239e+01f
,
4148 -9.13690281e+00f
, 2.76374960e+00f
, -7.30904531e+00f
, -5.87572050e+00f
, 5.30312395e+00f
, -8.68215370e+00f
,
4149 -2.56833839e+01f
, 1.68027866e+00f
, -1.88083878e+01f
, 7.65365601e+00f
, 1.69391327e+01f
, -1.73280182e+01f
,
4150 1.46297951e+01f
, -5.44671021e+01f
, -1.22310352e+01f
, -4.08985710e+00f
, -9.44422245e+00f
, 3.05603528e+00f
,
4151 1.79257303e-01f
, -1.00418749e+01f
, 2.30900917e+01f
, -2.31887093e+01f
, 1.17270985e+01f
, -6.51830902e+01f
,
4152 4.86715775e+01f
, -1.50732088e+01f
, 3.87931709e+01f
, -2.60395355e+01f
, 6.19276857e+00f
, -1.76722469e+01f
,
4154 1.00999999e+00f
, 4.94489908e+00f
, -8.91142070e-01f
, 4.60769463e+00f
, 2.19218358e-01f
, 1.07733250e+01f
,
4155 -8.20476913e+00f
, 1.35638294e+01f
, -1.20077667e+01f
,
4156 /* Rotation around the z-axis, π/6. */
4157 1.00999999e+00f
, 3.74571109e+00f
, 3.00999999e+00f
, 2.46776199e+00f
, 1.03078890e+01f
, 9.20981312e+00f
,
4158 7.01000023e+00f
, 3.93186355e+00f
, 1.66212186e-01f
, 1.60099983e+01f
, 1.85040417e+01f
, 1.74059658e+01f
,
4159 1.30100002e+01f
, 6.12801647e+00f
, -2.02994061e+00f
, -1.00100012e+01f
, 1.31542921e+01f
, 2.40099964e+01f
,
4160 2.94322453e+01f
, 2.83341675e+01f
, 2.10100021e+01f
, 9.05622101e+00f
, -4.95814323e+00f
, -1.80100002e+01f
,
4161 -2.72360935e+01f
, -4.52033186e+00f
, 1.68145428e+01f
, 3.40099945e+01f
, 4.30924950e+01f
, 4.19944229e+01f
,
4162 3.10100002e+01f
, 1.27164707e+01f
, -8.61839962e+00f
, -2.80100021e+01f
, -4.08963470e+01f
, -4.41905708e+01f
,
4164 1.00999999e+00f
, 3.74571109e+00f
, 3.00999999e+00f
, 1.59990644e+00f
, 1.03078890e+01f
, 9.20981312e+00f
,
4165 7.01000023e+00f
, 2.33195710e+00f
, -4.42189360e+00f
,
4168 D3DXMatrixRotationX(&m
[0], -D3DX_PI
/ 2.0f
);
4169 D3DXMatrixRotationX(&m
[1], D3DX_PI
/ 2.0f
);
4170 D3DXMatrixRotationYawPitchRoll(&m
[2], D3DX_PI
/ 3.0f
, D3DX_PI
/ 4.0f
, D3DX_PI
/ 5.0f
);
4171 D3DXMatrixRotationZ(&m
[3], D3DX_PI
/ 6.0f
);
4173 for (l
= 0; l
< 2; l
++)
4180 for (j
= 0; j
< ARRAY_SIZE(m
); ++j
)
4182 for (order
= 0; order
<= D3DXSH_MAXORDER
; order
++)
4184 for (i
= 0; i
< ARRAY_SIZE(out
); ++i
)
4186 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
4190 received_ptr
= D3DXSHRotate(out_temp
, order
, &m
[j
], in
);
4191 ok(received_ptr
== out_temp
, "Order %u, expected %p, received %p.\n",
4192 order
, out
, received_ptr
);
4194 for (i
= 0; i
< ARRAY_SIZE(out
); ++i
)
4196 if ((i
> 0) && ((i
>= order
* order
) || (order
> D3DXSH_MAXORDER
)))
4199 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
4201 expected
= i
+ 1.01f
;
4203 else if ((l
== 0) || (order
> 3))
4204 expected
= table
[45 * j
+ i
];
4206 expected
= table
[45 * j
+ 36 +i
];
4207 equal
= compare_float(out_temp
[i
], expected
, 4096);
4208 ok(equal
, "Order %u index %u, expected %.8e, received %.8e.\n",
4209 order
, i
, expected
, out_temp
[i
]);
4216 static void test_D3DXSHRotateZ(void)
4218 float expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
4219 unsigned int end
, i
, j
, l
, order
, square
;
4222 static const float angle
[] = {D3DX_PI
/ 3.0f
, -D3DX_PI
/ 3.0f
, 4.0f
* D3DX_PI
/ 3.0f
};
4223 static const float table
[] =
4226 1.00999999e+00f
, 4.47776222e+00f
, 3.00999999e+00f
, 2.64288902e-01f
, 5.29788828e+00f
, 9.94186401e+00f
,
4227 7.01000023e+00f
, -1.19981313e+00f
, -8.84378910e+00f
, -1.00100021e+01f
, 7.49403954e+00f
, 1.81380157e+01f
,
4228 1.30100002e+01f
, -3.39596605e+00f
, -1.70399418e+01f
, -1.60099983e+01f
, -3.01642971e+01f
, -1.80100040e+01f
,
4229 1.04222422e+01f
, 2.90662193e+01f
, 2.10100002e+01f
, -6.32417059e+00f
, -2.79681454e+01f
, -2.40099983e+01f
,
4230 2.22609901e+00f
, -1.81805649e+01f
, -4.38245506e+01f
, -2.80100040e+01f
, 1.40824928e+01f
, 4.27264709e+01f
,
4231 3.10100002e+01f
, -9.98442554e+00f
, -4.16283989e+01f
, -3.40099945e+01f
, 5.88635778e+00f
, 4.05303307e+01f
,
4233 1.00999999e+00f
, 4.47776222e+00f
, 0.00000000e+00f
, -5.81678391e+00f
, 5.29788828e+00f
, 6.93686390e+00f
,
4234 0.00000000e+00f
, -9.01125050e+00f
, -2.29405236e+00f
, -1.00100021e+01f
, 1.29990416e+01f
, 1.21330166e+01f
,
4235 0.00000000e+00f
, -1.57612505e+01f
, -5.62874842e+00f
, 0.00000000e+00f
, -3.01642971e+01f
, -3.29017075e-06f
,
4236 1.99272442e+01f
, 1.90612202e+01f
, 0.00000000e+00f
, -2.47612514e+01f
, -8.62874794e+00f
, 0.00000000e+00f
,
4237 -1.30615301e+01f
, -1.81805649e+01f
, -3.03195534e+01f
, -4.66050415e-06f
, 2.85874958e+01f
, 2.77214737e+01f
,
4238 0.00000000e+00f
, -3.60112534e+01f
, -1.23787460e+01f
, 0.00000000e+00f
, -1.31287584e+01f
, -2.36172504e+01f
,
4240 1.00999999e+00f
, 3.97776222e+00f
, 3.97776222e+00f
, 1.11419535e+00f
, 7.24579096e+00f
, 1.05597591e+01f
,
4241 1.05597591e+01f
, -9.95159924e-01f
, -4.67341393e-01f
, 4.67339337e-01f
, 1.27653713e+01f
, 1.85157013e+01f
,
4242 1.85157013e+01f
, -1.79728663e+00f
, 4.93915796e-01f
, -4.93915856e-01f
, -2.14123421e+01f
, 2.14123383e+01f
,
4243 9.22107220e+00f
, 2.36717567e+01f
, 2.36717567e+01f
, 3.85019469e+00f
, -2.04687271e+01f
, 2.04687233e+01f
,
4244 -1.06621027e+01f
, -3.65166283e+01f
, -1.20612450e+01f
, 1.20612402e+01f
, 2.25568752e+01f
, 3.89999084e+01f
,
4245 3.89999084e+01f
, -3.48751247e-02f
, -1.04279022e+01f
, 1.04279003e+01f
, -3.68382835e+01f
, -2.76528034e+01f
,
4247 1.00999999e+00f
, -2.46776247e+00f
, 3.00999999e+00f
, 3.74571109e+00f
, -1.03078899e+01f
, -3.93186426e+00f
,
4248 7.01000023e+00f
, 9.20981312e+00f
, -1.66213632e-01f
, -1.00099983e+01f
, -1.85040436e+01f
, -6.12801695e+00f
,
4249 1.30100002e+01f
, 1.74059658e+01f
, 2.02993774e+00f
, -1.60100021e+01f
, 1.31543026e+01f
, -1.80099964e+01f
,
4250 -2.94322472e+01f
, -9.05622101e+00f
, 2.10100002e+01f
, 2.83341694e+01f
, 4.95813942e+00f
, -2.40100021e+01f
,
4251 -2.72360916e+01f
, 4.41905823e+01f
, 1.68145580e+01f
, -2.80099964e+01f
, -4.30924988e+01f
, -1.27164736e+01f
,
4252 3.10100002e+01f
, 4.19944229e+01f
, 8.61839294e+00f
, -3.40100021e+01f
, -4.08963470e+01f
, -4.52030993e+00f
,
4254 1.00999999e+00f
, -2.46776247e+00f
, 0.00000000e+00f
, -3.20571756e+00f
, -1.03078899e+01f
, -6.93686390e+00f
,
4255 0.00000000e+00f
, -9.01125050e+00f
, -4.46344614e+00f
, -1.00099983e+01f
, -1.29990416e+01f
, -1.21330166e+01f
,
4256 0.00000000e+00f
, -1.57612505e+01f
, -5.62874842e+00f
, 0.00000000e+00f
, 1.31543026e+01f
, 3.29017075e-06f
,
4257 -1.99272442e+01f
, -1.90612202e+01f
, 0.00000000e+00f
, -2.47612514e+01f
, -8.62874794e+00f
, 0.00000000e+00f
,
4258 -5.69598293e+00f
, 4.41905823e+01f
, 3.03195534e+01f
, 4.66050415e-06f
, -2.85874958e+01f
, -2.77214737e+01f
,
4259 0.00000000e+00f
, -3.60112534e+01f
, -1.23787460e+01f
, 0.00000000e+00f
, -1.31287584e+01f
, -5.74052582e+01f
,
4261 1.00999999e+00f
, -2.96776223e+00f
, -2.96776223e+00f
, -6.09195352e-01f
, -7.49829102e+00f
, -1.06860094e+01f
,
4262 -1.06860094e+01f
, -1.18367157e+01f
, 5.39078045e+00f
, -5.39077854e+00f
, -1.03036509e+01f
, -1.72848415e+01f
,
4263 -1.72848415e+01f
, -1.75656433e+01f
, 4.11427259e+00f
, -4.11427307e+00f
, 2.37164364e+01f
, -2.37164326e+01f
,
4264 -8.06902504e+00f
, -2.30957317e+01f
, -2.30957317e+01f
, -1.85358467e+01f
, -1.12711067e+01f
, 1.12711039e+01f
,
4265 -2.07248449e+00f
, 3.01493301e+01f
, 1.52448931e+01f
, -1.52448883e+01f
, -2.09650497e+01f
, -3.82039986e+01f
,
4266 -3.82039986e+01f
, -3.72582664e+01f
, 5.42667723e+00f
, -5.42667913e+00f
, -2.33967514e+01f
, -9.90355873e+00f
,
4268 1.00999999e+00f
, -4.47776222e+00f
, 3.00999999e+00f
, -2.64288664e-01f
, 5.29788685e+00f
, -9.94186401e+00f
,
4269 7.01000023e+00f
, 1.19981360e+00f
, -8.84378815e+00f
, 1.00100040e+01f
, 7.49403811e+00f
, -1.81380157e+01f
,
4270 1.30100002e+01f
, 3.39596677e+00f
, -1.70399399e+01f
, 1.60099964e+01f
, -3.01642933e+01f
, 1.80100060e+01f
,
4271 1.04222393e+01f
, -2.90662193e+01f
, 2.10100002e+01f
, 6.32417202e+00f
, -2.79681435e+01f
, 2.40099926e+01f
,
4272 2.22610497e+00f
, 1.81805515e+01f
, -4.38245430e+01f
, 2.80100079e+01f
, 1.40824890e+01f
, -4.27264709e+01f
,
4273 3.10100002e+01f
, 9.98442745e+00f
, -4.16283989e+01f
, 3.40099869e+01f
, 5.88636589e+00f
, -4.05303268e+01f
,
4275 1.00999999e+00f
, -4.47776222e+00f
, 0.00000000e+00f
, -1.93892837e+00f
, 5.29788685e+00f
, -6.93686390e+00f
,
4276 0.00000000e+00f
, -3.00375080e+00f
, -2.29405141e+00f
, 1.00100040e+01f
, 1.29990396e+01f
, -1.21330166e+01f
,
4277 0.00000000e+00f
, -5.25375128e+00f
, -5.62874699e+00f
, -5.68378528e-06f
, -3.01642933e+01f
, 7.00829787e-06f
,
4278 1.99272423e+01f
, -1.90612202e+01f
, 0.00000000e+00f
, -8.25375271e+00f
, -8.62874603e+00f
, -4.09131496e-12f
,
4279 -1.30615349e+01f
, 1.81805515e+01f
, -3.03195534e+01f
, 9.92720470e-06f
, 2.85874920e+01f
, -2.77214737e+01f
,
4280 0.00000000e+00f
, -1.20037527e+01f
, -1.23787422e+01f
, -5.79531909e-12f
, -1.31287651e+01f
, -7.87240028e+00f
,
4282 1.00999999e+00f
, -3.97776222e+00f
, -3.97776222e+00f
, 2.86356640e+00f
, 6.37110424e+00f
, -1.01224155e+01f
,
4283 -1.01224155e+01f
, 1.05787458e+01f
, -7.76929522e+00f
, -7.76928997e+00f
, 1.68836861e+01f
, -2.05748577e+01f
,
4284 -2.05748577e+01f
, 2.49091301e+01f
, -5.72616625e+00f
, -5.72616386e+00f
, -1.87962208e+01f
, -1.87962112e+01f
,
4285 2.93253498e+01f
, -3.37238922e+01f
, -3.37238922e+01f
, 4.22584419e+01f
, -4.85123205e+00f
, -4.85122633e+00f
,
4286 -2.53339314e+00f
, 3.24522591e+01f
, -4.65456696e+01f
, -4.65456543e+01f
, 5.18603249e+01f
, -5.36516304e+01f
,
4287 -5.36516304e+01f
, 7.17381744e+01f
, 4.44061565e+00f
, 4.44062901e+00f
, 2.58841743e+01f
, -1.07481155e+01f
,
4290 for (l
= 0; l
< 3; l
++)
4295 out_temp
= &in
[l
- 1];
4302 for (j
= 0; j
< ARRAY_SIZE(angle
); ++j
)
4304 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
4306 for (i
= 0; i
< ARRAY_SIZE(out
); ++i
)
4308 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
4312 received_ptr
= D3DXSHRotateZ(out_temp
, order
, angle
[j
], in
);
4313 ok(received_ptr
== out_temp
, "angle %f, order %u, expected %p, received %p\n", angle
[j
], order
, out_temp
, received_ptr
);
4315 for (i
= 0; i
< end
; i
++)
4317 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
4318 square
= (order
<= D3DXSH_MINORDER
) ? D3DXSH_MINORDER
* D3DXSH_MINORDER
: order
* order
;
4319 if (i
>= square
|| ((order
>= D3DXSH_MAXORDER
) && (i
>= D3DXSH_MAXORDER
* D3DXSH_MAXORDER
)))
4321 expected
= i
+ l
+ 0.01f
;
4323 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
4325 expected
= table
[36 * (l
+ 3 * j
) + i
];
4326 equal
= compare_float(expected
, out_temp
[i
], 256);
4327 ok(equal
|| (fabs(expected
) < 2.0e-5f
&& fabs(out_temp
[i
]) < 2.0e-5f
),
4328 "angle %.8e, order %u index %u, expected %.8e, received %.8e.\n",
4329 angle
[j
], order
, i
, expected
, out_temp
[i
]);
4336 static void test_D3DXSHScale(void)
4338 float a
[49], b
[49], expected
, *received_array
;
4339 unsigned int i
, order
;
4342 for (i
= 0; i
< ARRAY_SIZE(a
); ++i
)
4348 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
4350 received_array
= D3DXSHScale(b
, order
, a
, 5.0f
);
4351 ok(received_array
== b
, "Expected %p, received %p\n", b
, received_array
);
4353 for (i
= 0; i
< ARRAY_SIZE(b
); ++i
)
4355 if (i
< order
* order
)
4356 expected
= 5.0f
* a
[i
];
4357 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
4360 equal
= compare_float(b
[i
], expected
, 0);
4361 ok(equal
, "order %u, element %u, expected %.8e, received %.8e.\n", order
, i
, expected
, b
[i
]);
4372 D3DXQuaternionTest();
4376 test_matrix_stack();
4377 test_Matrix_AffineTransformation2D();
4378 test_Matrix_Decompose();
4379 test_Matrix_Transformation2D();
4380 test_D3DXVec_Array();
4381 test_D3DXFloat_Array();
4384 test_D3DXSHEvalConeLight();
4385 test_D3DXSHEvalDirection();
4386 test_D3DXSHEvalDirectionalLight();
4387 test_D3DXSHEvalHemisphereLight();
4388 test_D3DXSHEvalSphericalLight();
4389 test_D3DXSHMultiply2();
4390 test_D3DXSHMultiply3();
4391 test_D3DXSHMultiply4();
4392 test_D3DXSHRotate();
4393 test_D3DXSHRotateZ();