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"
28 #define admitted_error 0.0001f
30 #define relative_error(exp, out) (fabsf(exp) < 1e-38f ? fabsf(exp - out) : fabsf(1.0f - (out) / (exp)))
32 #define expect_color(expectedcolor,gotcolor) ok((relative_error(expectedcolor.r, gotcolor.r)<admitted_error)&&(relative_error(expectedcolor.g, gotcolor.g)<admitted_error)&&(relative_error(expectedcolor.b, gotcolor.b)<admitted_error)&&(relative_error(expectedcolor.a, gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
34 static inline BOOL
compare_matrix(const D3DXMATRIX
*m1
, const D3DXMATRIX
*m2
)
38 for (i
= 0; i
< 4; ++i
)
40 for (j
= 0; j
< 4; ++j
)
42 if (relative_error(U(*m1
).m
[i
][j
], U(*m2
).m
[i
][j
]) > admitted_error
)
50 #define expect_mat(expectedmat, gotmat) \
52 const D3DXMATRIX *__m1 = (expectedmat); \
53 const D3DXMATRIX *__m2 = (gotmat); \
54 ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
55 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
56 U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
57 U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
58 U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
59 U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
60 U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
61 U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
62 U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
63 U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
66 #define compare_rotation(exp, got) \
67 ok(relative_error(exp.w, got.w) < admitted_error && \
68 relative_error(exp.x, got.x) < admitted_error && \
69 relative_error(exp.y, got.y) < admitted_error && \
70 relative_error(exp.z, got.z) < admitted_error, \
71 "Expected rotation = (%f, %f, %f, %f), \
72 got rotation = (%f, %f, %f, %f)\n", \
73 exp.w, exp.x, exp.y, exp.z, got.w, got.x, got.y, got.z)
75 #define compare_scale(exp, got) \
76 ok(relative_error(exp.x, got.x) < admitted_error && \
77 relative_error(exp.y, got.y) < admitted_error && \
78 relative_error(exp.z, got.z) < admitted_error, \
79 "Expected scale = (%f, %f, %f), \
80 got scale = (%f, %f, %f)\n", \
81 exp.x, exp.y, exp.z, got.x, got.y, got.z)
83 #define compare_translation(exp, got) \
84 ok(relative_error(exp.x, got.x) < admitted_error && \
85 relative_error(exp.y, got.y) < admitted_error && \
86 relative_error(exp.z, got.z) < admitted_error, \
87 "Expected translation = (%f, %f, %f), \
88 got translation = (%f, %f, %f)\n", \
89 exp.x, exp.y, exp.z, got.x, got.y, got.z)
91 #define compare_vectors(exp, out) \
92 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
93 ok(relative_error(exp[i].x, out[i].x) < admitted_error && \
94 relative_error(exp[i].y, out[i].y) < admitted_error && \
95 relative_error(exp[i].z, out[i].z) < admitted_error && \
96 relative_error(exp[i].w, out[i].w) < admitted_error, \
97 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
98 out[i].x, out[i].y, out[i].z, out[i].w, \
99 exp[i].x, exp[i].y, exp[i].z, exp[i].w, \
103 #define compare_planes(exp, out) \
104 for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
105 ok(relative_error(exp[i].a, out[i].a) < admitted_error && \
106 relative_error(exp[i].b, out[i].b) < admitted_error && \
107 relative_error(exp[i].c, out[i].c) < admitted_error && \
108 relative_error(exp[i].d, out[i].d) < admitted_error, \
109 "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
110 out[i].a, out[i].b, out[i].c, out[i].d, \
111 exp[i].a, exp[i].b, exp[i].c, exp[i].d, \
115 #define expect_plane(expectedplane,gotplane) ok((relative_error(expectedplane.a, gotplane.a)<admitted_error)&&(relative_error(expectedplane.b, gotplane.b)<admitted_error)&&(relative_error(expectedplane.c, gotplane.c)<admitted_error)&&(relative_error(expectedplane.d, gotplane.d)<admitted_error),"Expected Plane= (%f, %f, %f, %f)\n , Got Plane= (%f, %f, %f, %f)\n", expectedplane.a, expectedplane.b, expectedplane.c, expectedplane.d, gotplane.a, gotplane.b, gotplane.c, gotplane.d);
117 #define expect_vec(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
119 #define expect_vec3(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
121 #define expect_vec4(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error)&&(relative_error(expectedvec.w, gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
124 static void D3DXColorTest(void)
126 D3DXCOLOR color
, color1
, color2
, expected
, got
;
127 LPD3DXCOLOR funcpointer
;
130 color
.r
= 0.2f
; color
.g
= 0.75f
; color
.b
= 0.41f
; color
.a
= 0.93f
;
131 color1
.r
= 0.6f
; color1
.g
= 0.55f
; color1
.b
= 0.23f
; color1
.a
= 0.82f
;
132 color2
.r
= 0.3f
; color2
.g
= 0.5f
; color2
.b
= 0.76f
; color2
.a
= 0.11f
;
136 /*_______________D3DXColorAdd________________*/
137 expected
.r
= 0.9f
; expected
.g
= 1.05f
; expected
.b
= 0.99f
, expected
.a
= 0.93f
;
138 D3DXColorAdd(&got
,&color1
,&color2
);
139 expect_color(expected
,got
);
140 /* Test the NULL case */
141 funcpointer
= D3DXColorAdd(&got
,NULL
,&color2
);
142 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
143 funcpointer
= D3DXColorAdd(NULL
,NULL
,&color2
);
144 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
145 funcpointer
= D3DXColorAdd(NULL
,NULL
,NULL
);
146 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
148 /*_______________D3DXColorAdjustContrast______*/
149 expected
.r
= 0.41f
; expected
.g
= 0.575f
; expected
.b
= 0.473f
, expected
.a
= 0.93f
;
150 D3DXColorAdjustContrast(&got
,&color
,scale
);
151 expect_color(expected
,got
);
153 /*_______________D3DXColorAdjustSaturation______*/
154 expected
.r
= 0.486028f
; expected
.g
= 0.651028f
; expected
.b
= 0.549028f
, expected
.a
= 0.93f
;
155 D3DXColorAdjustSaturation(&got
,&color
,scale
);
156 expect_color(expected
,got
);
158 /*_______________D3DXColorLerp________________*/
159 expected
.r
= 0.32f
; expected
.g
= 0.69f
; expected
.b
= 0.356f
; expected
.a
= 0.897f
;
160 D3DXColorLerp(&got
,&color
,&color1
,scale
);
161 expect_color(expected
,got
);
162 /* Test the NULL case */
163 funcpointer
= D3DXColorLerp(&got
,NULL
,&color1
,scale
);
164 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
165 funcpointer
= D3DXColorLerp(NULL
,NULL
,&color1
,scale
);
166 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
167 funcpointer
= D3DXColorLerp(NULL
,NULL
,NULL
,scale
);
168 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
170 /*_______________D3DXColorModulate________________*/
171 expected
.r
= 0.18f
; expected
.g
= 0.275f
; expected
.b
= 0.1748f
; expected
.a
= 0.0902f
;
172 D3DXColorModulate(&got
,&color1
,&color2
);
173 expect_color(expected
,got
);
174 /* Test the NULL case */
175 funcpointer
= D3DXColorModulate(&got
,NULL
,&color2
);
176 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
177 funcpointer
= D3DXColorModulate(NULL
,NULL
,&color2
);
178 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
179 funcpointer
= D3DXColorModulate(NULL
,NULL
,NULL
);
180 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
182 /*_______________D3DXColorNegative________________*/
183 expected
.r
= 0.8f
; expected
.g
= 0.25f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
184 D3DXColorNegative(&got
,&color
);
185 expect_color(got
,expected
);
186 /* Test the greater than 1 case */
187 color1
.r
= 0.2f
; color1
.g
= 1.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
188 expected
.r
= 0.8f
; expected
.g
= -0.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
189 D3DXColorNegative(&got
,&color1
);
190 expect_color(got
,expected
);
191 /* Test the negative case */
192 color1
.r
= 0.2f
; color1
.g
= -0.75f
; color1
.b
= 0.41f
; color1
.a
= 0.93f
;
193 expected
.r
= 0.8f
; expected
.g
= 1.75f
; expected
.b
= 0.59f
; expected
.a
= 0.93f
;
194 D3DXColorNegative(&got
,&color1
);
195 expect_color(got
,expected
);
196 /* Test the NULL case */
197 funcpointer
= D3DXColorNegative(&got
,NULL
);
198 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
199 funcpointer
= D3DXColorNegative(NULL
,NULL
);
200 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
202 /*_______________D3DXColorScale________________*/
203 expected
.r
= 0.06f
; expected
.g
= 0.225f
; expected
.b
= 0.123f
; expected
.a
= 0.279f
;
204 D3DXColorScale(&got
,&color
,scale
);
205 expect_color(expected
,got
);
206 /* Test the NULL case */
207 funcpointer
= D3DXColorScale(&got
,NULL
,scale
);
208 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
209 funcpointer
= D3DXColorScale(NULL
,NULL
,scale
);
210 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
212 /*_______________D3DXColorSubtract_______________*/
213 expected
.r
= -0.1f
; expected
.g
= 0.25f
; expected
.b
= -0.35f
, expected
.a
= 0.82f
;
214 D3DXColorSubtract(&got
,&color
,&color2
);
215 expect_color(expected
,got
);
216 /* Test the NULL case */
217 funcpointer
= D3DXColorSubtract(&got
,NULL
,&color2
);
218 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
219 funcpointer
= D3DXColorSubtract(NULL
,NULL
,&color2
);
220 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
221 funcpointer
= D3DXColorSubtract(NULL
,NULL
,NULL
);
222 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
225 static void D3DXFresnelTest(void)
230 got
= D3DXFresnelTerm(0.5f
,1.5);
231 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
234 static void D3DXMatrixTest(void)
236 D3DXMATRIX expectedmat
, gotmat
, mat
, mat2
, mat3
;
237 D3DXMATRIX
*funcpointer
;
240 D3DXVECTOR3 at
, axis
, eye
, last
;
243 FLOAT angle
, determinant
, expectedfloat
, gotfloat
;
245 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
246 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
247 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
248 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
249 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
250 U(mat
).m
[3][3] = -40.0f
;
252 U(mat2
).m
[0][0] = 1.0f
; U(mat2
).m
[1][0] = 2.0f
; U(mat2
).m
[2][0] = 3.0f
;
253 U(mat2
).m
[3][0] = 4.0f
; U(mat2
).m
[0][1] = 5.0f
; U(mat2
).m
[1][1] = 6.0f
;
254 U(mat2
).m
[2][1] = 7.0f
; U(mat2
).m
[3][1] = 8.0f
; U(mat2
).m
[0][2] = -8.0f
;
255 U(mat2
).m
[1][2] = -7.0f
; U(mat2
).m
[2][2] = -6.0f
; U(mat2
).m
[3][2] = -5.0f
;
256 U(mat2
).m
[0][3] = -4.0f
; U(mat2
).m
[1][3] = -3.0f
; U(mat2
).m
[2][3] = -2.0f
;
257 U(mat2
).m
[3][3] = -1.0f
;
259 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
261 q
.x
= 1.0f
; q
.y
= -4.0f
; q
.z
=7.0f
; q
.w
= -11.0f
;
262 r
.x
= 0.87f
; r
.y
= 0.65f
; r
.z
=0.43f
; r
.w
= 0.21f
;
264 at
.x
= -2.0f
; at
.y
= 13.0f
; at
.z
= -9.0f
;
265 axis
.x
= 1.0f
; axis
.y
= -3.0f
; axis
.z
= 7.0f
;
266 eye
.x
= 8.0f
; eye
.y
= -5.0f
; eye
.z
= 5.75f
;
267 last
.x
= 9.7f
; last
.y
= -8.6; last
.z
= 1.3f
;
269 light
.x
= 9.6f
; light
.y
= 8.5f
; light
.z
= 7.4; light
.w
= 6.3;
271 angle
= D3DX_PI
/3.0f
;
273 /*____________D3DXMatrixAffineTransformation______*/
274 U(expectedmat
).m
[0][0] = -459.239990f
; U(expectedmat
).m
[0][1] = -576.719971f
; U(expectedmat
).m
[0][2] = -263.440002f
; U(expectedmat
).m
[0][3] = 0.0f
;
275 U(expectedmat
).m
[1][0] = 519.760010f
; U(expectedmat
).m
[1][1] = -352.440002f
; U(expectedmat
).m
[1][2] = -277.679993f
; U(expectedmat
).m
[1][3] = 0.0f
;
276 U(expectedmat
).m
[2][0] = 363.119995f
; U(expectedmat
).m
[2][1] = -121.040001f
; U(expectedmat
).m
[2][2] = -117.479996f
; U(expectedmat
).m
[2][3] = 0.0f
;
277 U(expectedmat
).m
[3][0] = -1239.0f
; U(expectedmat
).m
[3][1] = 667.0f
; U(expectedmat
).m
[3][2] = 567.0f
; U(expectedmat
).m
[3][3] = 1.0f
;
278 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, &axis
);
279 expect_mat(&expectedmat
, &gotmat
);
281 /* Test the NULL case */
282 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
;
283 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, &axis
);
284 expect_mat(&expectedmat
, &gotmat
);
286 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
;
287 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, &q
, NULL
);
288 expect_mat(&expectedmat
, &gotmat
);
290 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
;
291 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, &q
, NULL
);
292 expect_mat(&expectedmat
, &gotmat
);
294 U(expectedmat
).m
[0][0] = 3.56f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
295 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 3.56f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
296 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 3.56f
; U(expectedmat
).m
[2][3] = 0.0f
;
297 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
;
298 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, &axis
);
299 expect_mat(&expectedmat
, &gotmat
);
301 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, &axis
);
302 expect_mat(&expectedmat
, &gotmat
);
304 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
;
305 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, &at
, NULL
, NULL
);
306 expect_mat(&expectedmat
, &gotmat
);
308 D3DXMatrixAffineTransformation(&gotmat
, 3.56f
, NULL
, NULL
, NULL
);
309 expect_mat(&expectedmat
, &gotmat
);
311 /*____________D3DXMatrixfDeterminant_____________*/
312 expectedfloat
= -147888.0f
;
313 gotfloat
= D3DXMatrixDeterminant(&mat
);
314 ok(relative_error(gotfloat
, expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, gotfloat
);
316 /*____________D3DXMatrixInverse______________*/
317 U(expectedmat
).m
[0][0] = 16067.0f
/73944.0f
; U(expectedmat
).m
[0][1] = -10165.0f
/147888.0f
; U(expectedmat
).m
[0][2] = -2729.0f
/147888.0f
; U(expectedmat
).m
[0][3] = -1631.0f
/49296.0f
;
318 U(expectedmat
).m
[1][0] = -565.0f
/36972.0f
; U(expectedmat
).m
[1][1] = 2723.0f
/73944.0f
; U(expectedmat
).m
[1][2] = -1073.0f
/73944.0f
; U(expectedmat
).m
[1][3] = 289.0f
/24648.0f
;
319 U(expectedmat
).m
[2][0] = -389.0f
/2054.0f
; U(expectedmat
).m
[2][1] = 337.0f
/4108.0f
; U(expectedmat
).m
[2][2] = 181.0f
/4108.0f
; U(expectedmat
).m
[2][3] = 317.0f
/4108.0f
;
320 U(expectedmat
).m
[3][0] = 163.0f
/5688.0f
; U(expectedmat
).m
[3][1] = -101.0f
/11376.0f
; U(expectedmat
).m
[3][2] = -73.0f
/11376.0f
; U(expectedmat
).m
[3][3] = -127.0f
/3792.0f
;
321 expectedfloat
= -147888.0f
;
322 D3DXMatrixInverse(&gotmat
,&determinant
,&mat
);
323 expect_mat(&expectedmat
, &gotmat
);
324 ok(relative_error( determinant
, expectedfloat
) < admitted_error
, "Expected: %f, Got: %f\n", expectedfloat
, determinant
);
325 funcpointer
= D3DXMatrixInverse(&gotmat
,NULL
,&mat2
);
326 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
328 /*____________D3DXMatrixIsIdentity______________*/
330 memset(&mat3
, 0, sizeof(mat3
));
331 got
= D3DXMatrixIsIdentity(&mat3
);
332 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
333 D3DXMatrixIdentity(&mat3
);
335 got
= D3DXMatrixIsIdentity(&mat3
);
336 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
337 U(mat3
).m
[0][0] = 0.000009f
;
339 got
= D3DXMatrixIsIdentity(&mat3
);
340 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
341 /* Test the NULL case */
343 got
= D3DXMatrixIsIdentity(NULL
);
344 ok(expected
== got
, "Expected : %d, Got : %d\n", expected
, got
);
346 /*____________D3DXMatrixLookatLH_______________*/
347 U(expectedmat
).m
[0][0] = -0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = -0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
348 U(expectedmat
).m
[1][0] = -0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = 0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
349 U(expectedmat
).m
[2][0] = -0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = -0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
350 U(expectedmat
).m
[3][0] = 4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = 10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
351 D3DXMatrixLookAtLH(&gotmat
,&eye
,&at
,&axis
);
352 expect_mat(&expectedmat
, &gotmat
);
354 /*____________D3DXMatrixLookatRH_______________*/
355 U(expectedmat
).m
[0][0] = 0.822465f
; U(expectedmat
).m
[0][1] = -0.409489f
; U(expectedmat
).m
[0][2] = 0.394803f
; U(expectedmat
).m
[0][3] = 0.0f
;
356 U(expectedmat
).m
[1][0] = 0.555856f
; U(expectedmat
).m
[1][1] = 0.431286f
; U(expectedmat
).m
[1][2] = -0.710645f
; U(expectedmat
).m
[1][3] = 0.0f
;
357 U(expectedmat
).m
[2][0] = 0.120729f
; U(expectedmat
).m
[2][1] = 0.803935f
; U(expectedmat
).m
[2][2] = 0.582335f
; U(expectedmat
).m
[2][3] = 0.0f
;
358 U(expectedmat
).m
[3][0] = -4.494634f
; U(expectedmat
).m
[3][1] = 0.809719f
; U(expectedmat
).m
[3][2] = -10.060076f
; U(expectedmat
).m
[3][3] = 1.0f
;
359 D3DXMatrixLookAtRH(&gotmat
,&eye
,&at
,&axis
);
360 expect_mat(&expectedmat
, &gotmat
);
362 /*____________D3DXMatrixMultiply______________*/
363 U(expectedmat
).m
[0][0] = 73.0f
; U(expectedmat
).m
[0][1] = 193.0f
; U(expectedmat
).m
[0][2] = -197.0f
; U(expectedmat
).m
[0][3] = -77.0f
;
364 U(expectedmat
).m
[1][0] = 231.0f
; U(expectedmat
).m
[1][1] = 551.0f
; U(expectedmat
).m
[1][2] = -489.0f
; U(expectedmat
).m
[1][3] = -169.0;
365 U(expectedmat
).m
[2][0] = 239.0f
; U(expectedmat
).m
[2][1] = 523.0f
; U(expectedmat
).m
[2][2] = -400.0f
; U(expectedmat
).m
[2][3] = -116.0f
;
366 U(expectedmat
).m
[3][0] = -164.0f
; U(expectedmat
).m
[3][1] = -320.0f
; U(expectedmat
).m
[3][2] = 187.0f
; U(expectedmat
).m
[3][3] = 31.0f
;
367 D3DXMatrixMultiply(&gotmat
,&mat
,&mat2
);
368 expect_mat(&expectedmat
, &gotmat
);
370 /*____________D3DXMatrixMultiplyTranspose____*/
371 U(expectedmat
).m
[0][0] = 73.0f
; U(expectedmat
).m
[0][1] = 231.0f
; U(expectedmat
).m
[0][2] = 239.0f
; U(expectedmat
).m
[0][3] = -164.0f
;
372 U(expectedmat
).m
[1][0] = 193.0f
; U(expectedmat
).m
[1][1] = 551.0f
; U(expectedmat
).m
[1][2] = 523.0f
; U(expectedmat
).m
[1][3] = -320.0;
373 U(expectedmat
).m
[2][0] = -197.0f
; U(expectedmat
).m
[2][1] = -489.0f
; U(expectedmat
).m
[2][2] = -400.0f
; U(expectedmat
).m
[2][3] = 187.0f
;
374 U(expectedmat
).m
[3][0] = -77.0f
; U(expectedmat
).m
[3][1] = -169.0f
; U(expectedmat
).m
[3][2] = -116.0f
; U(expectedmat
).m
[3][3] = 31.0f
;
375 D3DXMatrixMultiplyTranspose(&gotmat
,&mat
,&mat2
);
376 expect_mat(&expectedmat
, &gotmat
);
378 /*____________D3DXMatrixOrthoLH_______________*/
379 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
380 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
381 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
382 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
383 D3DXMatrixOrthoLH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
384 expect_mat(&expectedmat
, &gotmat
);
386 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
387 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
388 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
389 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
390 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
391 D3DXMatrixOrthoOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
392 expect_mat(&expectedmat
, &gotmat
);
394 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
395 U(expectedmat
).m
[0][0] = 3.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
396 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.180180f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
397 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.045662f
; U(expectedmat
).m
[2][3] = 0.0f
;
398 U(expectedmat
).m
[3][0] = -1.727272f
; U(expectedmat
).m
[3][1] = -0.567568f
; U(expectedmat
).m
[3][2] = 0.424658f
; U(expectedmat
).m
[3][3] = 1.0f
;
399 D3DXMatrixOrthoOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 9.3, -12.6);
400 expect_mat(&expectedmat
, &gotmat
);
402 /*____________D3DXMatrixOrthoRH_______________*/
403 U(expectedmat
).m
[0][0] = 0.8f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
404 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.270270f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
405 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.151515f
; U(expectedmat
).m
[2][3] = 0.0f
;
406 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -0.484848f
; U(expectedmat
).m
[3][3] = 1.0f
;
407 D3DXMatrixOrthoRH(&gotmat
, 2.5f
, 7.4f
, -3.2f
, -9.8f
);
408 expect_mat(&expectedmat
, &gotmat
);
410 /*____________D3DXMatrixPerspectiveFovLH_______________*/
411 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
412 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
413 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
414 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
415 D3DXMatrixPerspectiveFovLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
416 expect_mat(&expectedmat
, &gotmat
);
418 /*____________D3DXMatrixPerspectiveFovRH_______________*/
419 U(expectedmat
).m
[0][0] = 13.288858f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
420 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 9.966644f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
421 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
422 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
423 D3DXMatrixPerspectiveFovRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
424 expect_mat(&expectedmat
, &gotmat
);
426 /*____________D3DXMatrixPerspectiveLH_______________*/
427 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
428 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
429 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.783784f
; U(expectedmat
).m
[2][3] = 1.0f
;
430 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
431 D3DXMatrixPerspectiveLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
432 expect_mat(&expectedmat
, &gotmat
);
434 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
435 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
436 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
437 U(expectedmat
).m
[2][0] = -1.727273f
; U(expectedmat
).m
[2][1] = -0.567568f
; U(expectedmat
).m
[2][2] = 0.840796f
; U(expectedmat
).m
[2][3] = 1.0f
;
438 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
439 D3DXMatrixPerspectiveOffCenterLH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
440 expect_mat(&expectedmat
, &gotmat
);
442 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
443 U(expectedmat
).m
[0][0] = 11.636364f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
444 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = 0.576577f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
445 U(expectedmat
).m
[2][0] = 1.727273f
; U(expectedmat
).m
[2][1] = 0.567568f
; U(expectedmat
).m
[2][2] = -0.840796f
; U(expectedmat
).m
[2][3] = -1.0f
;
446 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = -2.690547f
; U(expectedmat
).m
[3][3] = 0.0f
;
447 D3DXMatrixPerspectiveOffCenterRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
, 3.2f
, -16.9f
);
448 expect_mat(&expectedmat
, &gotmat
);
450 /*____________D3DXMatrixPerspectiveRH_______________*/
451 U(expectedmat
).m
[0][0] = -24.0f
; U(expectedmat
).m
[0][1] = -0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
452 U(expectedmat
).m
[1][0] = 0.0f
; U(expectedmat
).m
[1][1] = -6.4f
; U(expectedmat
).m
[1][2] = 0.0; U(expectedmat
).m
[1][3] = 0.0f
;
453 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = -0.783784f
; U(expectedmat
).m
[2][3] = -1.0f
;
454 U(expectedmat
).m
[3][0] = 0.0f
; U(expectedmat
).m
[3][1] = 0.0f
; U(expectedmat
).m
[3][2] = 1.881081f
; U(expectedmat
).m
[3][3] = 0.0f
;
455 D3DXMatrixPerspectiveRH(&gotmat
, 0.2f
, 0.75f
, -2.4f
, 8.7f
);
456 expect_mat(&expectedmat
, &gotmat
);
458 /*____________D3DXMatrixReflect______________*/
459 U(expectedmat
).m
[0][0] = 0.307692f
; U(expectedmat
).m
[0][1] = -0.230769f
; U(expectedmat
).m
[0][2] = 0.923077f
; U(expectedmat
).m
[0][3] = 0.0f
;
460 U(expectedmat
).m
[1][0] = -0.230769; U(expectedmat
).m
[1][1] = 0.923077f
; U(expectedmat
).m
[1][2] = 0.307693f
; U(expectedmat
).m
[1][3] = 0.0f
;
461 U(expectedmat
).m
[2][0] = 0.923077f
; U(expectedmat
).m
[2][1] = 0.307693f
; U(expectedmat
).m
[2][2] = -0.230769f
; U(expectedmat
).m
[2][3] = 0.0f
;
462 U(expectedmat
).m
[3][0] = 1.615385f
; U(expectedmat
).m
[3][1] = 0.538462f
; U(expectedmat
).m
[3][2] = -2.153846f
; U(expectedmat
).m
[3][3] = 1.0f
;
463 D3DXMatrixReflect(&gotmat
,&plane
);
464 expect_mat(&expectedmat
, &gotmat
);
466 /*____________D3DXMatrixRotationAxis_____*/
467 U(expectedmat
).m
[0][0] = 0.508475f
; U(expectedmat
).m
[0][1] = 0.763805f
; U(expectedmat
).m
[0][2] = 0.397563f
; U(expectedmat
).m
[0][3] = 0.0f
;
468 U(expectedmat
).m
[1][0] = -0.814652f
; U(expectedmat
).m
[1][1] = 0.576271f
; U(expectedmat
).m
[1][2] = -0.065219f
; U(expectedmat
).m
[1][3] = 0.0f
;
469 U(expectedmat
).m
[2][0] = -0.278919f
; U(expectedmat
).m
[2][1] = -0.290713f
; U(expectedmat
).m
[2][2] = 0.915254f
; U(expectedmat
).m
[2][3] = 0.0f
;
470 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
;
471 D3DXMatrixRotationAxis(&gotmat
,&axis
,angle
);
472 expect_mat(&expectedmat
, &gotmat
);
474 /*____________D3DXMatrixRotationQuaternion______________*/
475 U(expectedmat
).m
[0][0] = -129.0f
; U(expectedmat
).m
[0][1] = -162.0f
; U(expectedmat
).m
[0][2] = -74.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
476 U(expectedmat
).m
[1][0] = 146.0f
; U(expectedmat
).m
[1][1] = -99.0f
; U(expectedmat
).m
[1][2] = -78.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
477 U(expectedmat
).m
[2][0] = 102.0f
; U(expectedmat
).m
[2][1] = -34.0f
; U(expectedmat
).m
[2][2] = -33.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
478 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
;
479 D3DXMatrixRotationQuaternion(&gotmat
,&q
);
480 expect_mat(&expectedmat
, &gotmat
);
482 /*____________D3DXMatrixRotationX______________*/
483 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
484 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
485 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
486 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
;
487 D3DXMatrixRotationX(&gotmat
,angle
);
488 expect_mat(&expectedmat
, &gotmat
);
490 /*____________D3DXMatrixRotationY______________*/
491 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
492 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
493 U(expectedmat
).m
[2][0] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 0.5f
; U(expectedmat
).m
[2][3] = 0.0f
;
494 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
;
495 D3DXMatrixRotationY(&gotmat
,angle
);
496 expect_mat(&expectedmat
, &gotmat
);
498 /*____________D3DXMatrixRotationYawPitchRoll____*/
499 U(expectedmat
).m
[0][0] = 0.888777f
; U(expectedmat
).m
[0][1] = 0.091875f
; U(expectedmat
).m
[0][2] = -0.449037f
; U(expectedmat
).m
[0][3] = 0.0f
;
500 U(expectedmat
).m
[1][0] = 0.351713f
; U(expectedmat
).m
[1][1] = 0.491487f
; U(expectedmat
).m
[1][2] = 0.796705f
; U(expectedmat
).m
[1][3] = 0.0f
;
501 U(expectedmat
).m
[2][0] = 0.293893f
; U(expectedmat
).m
[2][1] = -0.866025f
; U(expectedmat
).m
[2][2] = 0.404509f
; U(expectedmat
).m
[2][3] = 0.0f
;
502 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
;
503 D3DXMatrixRotationYawPitchRoll(&gotmat
, 3.0f
*angle
/5.0f
, angle
, 3.0f
*angle
/17.0f
);
504 expect_mat(&expectedmat
, &gotmat
);
506 /*____________D3DXMatrixRotationZ______________*/
507 U(expectedmat
).m
[0][0] = 0.5f
; U(expectedmat
).m
[0][1] = sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
508 U(expectedmat
).m
[1][0] = -sqrt(3.0f
)/2.0f
; U(expectedmat
).m
[1][1] = 0.5f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
509 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
510 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
;
511 D3DXMatrixRotationZ(&gotmat
,angle
);
512 expect_mat(&expectedmat
, &gotmat
);
514 /*____________D3DXMatrixScaling______________*/
515 U(expectedmat
).m
[0][0] = 0.69f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
516 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 0.53f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
517 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 4.11f
; U(expectedmat
).m
[2][3] = 0.0f
;
518 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
;
519 D3DXMatrixScaling(&gotmat
,0.69f
,0.53f
,4.11f
);
520 expect_mat(&expectedmat
, &gotmat
);
522 /*____________D3DXMatrixShadow______________*/
523 U(expectedmat
).m
[0][0] = 12.786773f
; U(expectedmat
).m
[0][1] = 5.000961f
; U(expectedmat
).m
[0][2] = 4.353778f
; U(expectedmat
).m
[0][3] = 3.706595f
;
524 U(expectedmat
).m
[1][0] = 1.882715; U(expectedmat
).m
[1][1] = 8.805615f
; U(expectedmat
).m
[1][2] = 1.451259f
; U(expectedmat
).m
[1][3] = 1.235532f
;
525 U(expectedmat
).m
[2][0] = -7.530860f
; U(expectedmat
).m
[2][1] = -6.667949f
; U(expectedmat
).m
[2][2] = 1.333590f
; U(expectedmat
).m
[2][3] = -4.942127f
;
526 U(expectedmat
).m
[3][0] = -13.179006f
; U(expectedmat
).m
[3][1] = -11.668910f
; U(expectedmat
).m
[3][2] = -10.158816f
; U(expectedmat
).m
[3][3] = -1.510094f
;
527 D3DXMatrixShadow(&gotmat
,&light
,&plane
);
528 expect_mat(&expectedmat
, &gotmat
);
530 /*____________D3DXMatrixTransformation______________*/
531 U(expectedmat
).m
[0][0] = -0.2148f
; U(expectedmat
).m
[0][1] = 1.3116f
; U(expectedmat
).m
[0][2] = 0.4752f
; U(expectedmat
).m
[0][3] = 0.0f
;
532 U(expectedmat
).m
[1][0] = 0.9504f
; U(expectedmat
).m
[1][1] = -0.8836f
; U(expectedmat
).m
[1][2] = 0.9244f
; U(expectedmat
).m
[1][3] = 0.0f
;
533 U(expectedmat
).m
[2][0] = 1.0212f
; U(expectedmat
).m
[2][1] = 0.1936f
; U(expectedmat
).m
[2][2] = -1.3588f
; U(expectedmat
).m
[2][3] = 0.0f
;
534 U(expectedmat
).m
[3][0] = 18.2985f
; U(expectedmat
).m
[3][1] = -29.624001f
; U(expectedmat
).m
[3][2] = 15.683499f
; U(expectedmat
).m
[3][3] = 1.0f
;
535 D3DXMatrixTransformation(&gotmat
,&at
,&q
,NULL
,&eye
,&r
,&last
);
536 expect_mat(&expectedmat
, &gotmat
);
538 /*____________D3DXMatrixTranslation______________*/
539 U(expectedmat
).m
[0][0] = 1.0f
; U(expectedmat
).m
[0][1] = 0.0f
; U(expectedmat
).m
[0][2] = 0.0f
; U(expectedmat
).m
[0][3] = 0.0f
;
540 U(expectedmat
).m
[1][0] = 0.0; U(expectedmat
).m
[1][1] = 1.0f
; U(expectedmat
).m
[1][2] = 0.0f
; U(expectedmat
).m
[1][3] = 0.0f
;
541 U(expectedmat
).m
[2][0] = 0.0f
; U(expectedmat
).m
[2][1] = 0.0f
; U(expectedmat
).m
[2][2] = 1.0f
; U(expectedmat
).m
[2][3] = 0.0f
;
542 U(expectedmat
).m
[3][0] = 0.69f
; U(expectedmat
).m
[3][1] = 0.53f
; U(expectedmat
).m
[3][2] = 4.11f
; U(expectedmat
).m
[3][3] = 1.0f
;
543 D3DXMatrixTranslation(&gotmat
,0.69f
,0.53f
,4.11f
);
544 expect_mat(&expectedmat
, &gotmat
);
546 /*____________D3DXMatrixTranspose______________*/
547 U(expectedmat
).m
[0][0] = 10.0f
; U(expectedmat
).m
[0][1] = 11.0f
; U(expectedmat
).m
[0][2] = 19.0f
; U(expectedmat
).m
[0][3] = 2.0f
;
548 U(expectedmat
).m
[1][0] = 5.0; U(expectedmat
).m
[1][1] = 20.0f
; U(expectedmat
).m
[1][2] = -21.0f
; U(expectedmat
).m
[1][3] = 3.0f
;
549 U(expectedmat
).m
[2][0] = 7.0f
; U(expectedmat
).m
[2][1] = 16.0f
; U(expectedmat
).m
[2][2] = 30.f
; U(expectedmat
).m
[2][3] = -4.0f
;
550 U(expectedmat
).m
[3][0] = 8.0f
; U(expectedmat
).m
[3][1] = 33.0f
; U(expectedmat
).m
[3][2] = 43.0f
; U(expectedmat
).m
[3][3] = -40.0f
;
551 D3DXMatrixTranspose(&gotmat
,&mat
);
552 expect_mat(&expectedmat
, &gotmat
);
555 static void D3DXPlaneTest(void)
558 D3DXPLANE expectedplane
, gotplane
, nulplane
, plane
;
559 D3DXVECTOR3 expectedvec
, gotvec
, vec1
, vec2
, vec3
;
560 LPD3DXVECTOR3 funcpointer
;
564 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
565 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
566 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
567 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
568 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
569 U(mat
).m
[3][3] = -40.0f
;
571 plane
.a
= -3.0f
; plane
.b
= -1.0f
; plane
.c
= 4.0f
; plane
.d
= 7.0f
;
573 vec
.x
= 2.0f
; vec
.y
= 5.0f
; vec
.z
= -6.0f
; vec
.w
= 11.0f
;
575 /*_______________D3DXPlaneDot________________*/
577 got
= D3DXPlaneDot(&plane
,&vec
),
578 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
580 got
= D3DXPlaneDot(NULL
,&vec
),
581 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
583 got
= D3DXPlaneDot(NULL
,NULL
),
584 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
586 /*_______________D3DXPlaneDotCoord________________*/
588 got
= D3DXPlaneDotCoord(&plane
,&vec
),
589 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
591 got
= D3DXPlaneDotCoord(NULL
,&vec
),
592 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
594 got
= D3DXPlaneDotCoord(NULL
,NULL
),
595 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
597 /*_______________D3DXPlaneDotNormal______________*/
599 got
= D3DXPlaneDotNormal(&plane
,&vec
),
600 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
602 got
= D3DXPlaneDotNormal(NULL
,&vec
),
603 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
605 got
= D3DXPlaneDotNormal(NULL
,NULL
),
606 ok( expected
== got
, "Expected : %f, Got : %f\n",expected
, got
);
608 /*_______________D3DXPlaneFromPointNormal_______*/
609 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
610 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
611 expectedplane
.a
= 17.0f
; expectedplane
.b
= 31.0f
; expectedplane
.c
= 24.0f
; expectedplane
.d
= -950.0f
;
612 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, &vec2
);
613 expect_plane(expectedplane
, gotplane
);
614 gotplane
.a
= vec2
.x
; gotplane
.b
= vec2
.y
; gotplane
.c
= vec2
.z
;
615 D3DXPlaneFromPointNormal(&gotplane
, &vec1
, (D3DXVECTOR3
*)&gotplane
);
616 expect_plane(expectedplane
, gotplane
);
617 gotplane
.a
= vec1
.x
; gotplane
.b
= vec1
.y
; gotplane
.c
= vec1
.z
;
618 expectedplane
.d
= -1826.0f
;
619 D3DXPlaneFromPointNormal(&gotplane
, (D3DXVECTOR3
*)&gotplane
, &vec2
);
620 expect_plane(expectedplane
, gotplane
);
622 /*_______________D3DXPlaneFromPoints_______*/
623 vec1
.x
= 1.0f
; vec1
.y
= 2.0f
; vec1
.z
= 3.0f
;
624 vec2
.x
= 1.0f
; vec2
.y
= -6.0f
; vec2
.z
= -5.0f
;
625 vec3
.x
= 83.0f
; vec3
.y
= 74.0f
; vec3
.z
= 65.0f
;
626 expectedplane
.a
= 0.085914f
; expectedplane
.b
= -0.704492f
; expectedplane
.c
= 0.704492f
; expectedplane
.d
= -0.790406f
;
627 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
628 expect_plane(expectedplane
, gotplane
);
630 /*_______________D3DXPlaneIntersectLine___________*/
631 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
632 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
633 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
634 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
635 expect_vec3(expectedvec
, gotvec
);
636 /* Test a parallel line */
637 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
638 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
639 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
640 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
641 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
643 /*_______________D3DXPlaneNormalize______________*/
644 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
);
645 D3DXPlaneNormalize(&gotplane
, &plane
);
646 expect_plane(expectedplane
, gotplane
);
647 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
648 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
649 D3DXPlaneNormalize(&gotplane
, &nulplane
);
650 expect_plane(expectedplane
, gotplane
);
652 /*_______________D3DXPlaneTransform____________*/
653 expectedplane
.a
= 49.0f
; expectedplane
.b
= -98.0f
; expectedplane
.c
= 55.0f
; expectedplane
.d
= -165.0f
;
654 D3DXPlaneTransform(&gotplane
,&plane
,&mat
);
655 expect_plane(expectedplane
, gotplane
);
658 static void D3DXQuaternionTest(void)
661 D3DXQUATERNION expectedquat
, gotquat
, Nq
, Nq1
, nul
, smallq
, smallr
, q
, r
, s
, t
, u
;
662 LPD3DXQUATERNION funcpointer
;
663 D3DXVECTOR3 axis
, expectedvec
;
664 FLOAT angle
, expected
, got
, scale
, scale2
;
665 BOOL expectedbool
, gotbool
;
667 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
668 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
669 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
670 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
671 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
672 smallq
.x
= 0.1f
; smallq
.y
= 0.2f
; smallq
.z
= 0.3f
; smallq
.w
= 0.4f
;
673 smallr
.x
= 0.5f
; smallr
.y
= 0.6f
; smallr
.z
= 0.7f
; smallr
.w
= 0.8f
;
678 /*_______________D3DXQuaternionBaryCentric________________________*/
679 expectedquat
.x
= -867.444458; expectedquat
.y
= 87.851111f
; expectedquat
.z
= -9.937778f
; expectedquat
.w
= 3.235555f
;
680 D3DXQuaternionBaryCentric(&gotquat
,&q
,&r
,&t
,scale
,scale2
);
681 expect_vec4(expectedquat
,gotquat
);
683 /*_______________D3DXQuaternionConjugate________________*/
684 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
685 D3DXQuaternionConjugate(&gotquat
,&q
);
686 expect_vec4(expectedquat
,gotquat
);
687 /* Test the NULL case */
688 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
689 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
690 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
691 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
693 /*_______________D3DXQuaternionDot______________________*/
695 got
= D3DXQuaternionDot(&q
,&r
);
696 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
697 /* Tests the case NULL */
699 got
= D3DXQuaternionDot(NULL
,&r
);
700 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
702 got
= D3DXQuaternionDot(NULL
,NULL
);
703 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
705 /*_______________D3DXQuaternionExp______________________________*/
706 expectedquat
.x
= -0.216382f
; expectedquat
.y
= -0.432764f
; expectedquat
.z
= -0.8655270f
; expectedquat
.w
= -0.129449f
;
707 D3DXQuaternionExp(&gotquat
,&q
);
708 expect_vec4(expectedquat
,gotquat
);
709 /* Test the null quaternion */
710 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
711 D3DXQuaternionExp(&gotquat
,&nul
);
712 expect_vec4(expectedquat
,gotquat
);
713 /* Test the case where the norm of the quaternion is <1 */
714 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
715 expectedquat
.x
= 0.195366; expectedquat
.y
= 0.097683f
; expectedquat
.z
= 0.293049f
; expectedquat
.w
= 0.930813f
;
716 D3DXQuaternionExp(&gotquat
,&Nq1
);
717 expect_vec4(expectedquat
,gotquat
);
719 /*_______________D3DXQuaternionIdentity________________*/
720 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
721 D3DXQuaternionIdentity(&gotquat
);
722 expect_vec4(expectedquat
,gotquat
);
723 /* Test the NULL case */
724 funcpointer
= D3DXQuaternionIdentity(NULL
);
725 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
727 /*_______________D3DXQuaternionInverse________________________*/
728 expectedquat
.x
= -1.0f
/121.0f
; expectedquat
.y
= -2.0f
/121.0f
; expectedquat
.z
= -4.0f
/121.0f
; expectedquat
.w
= 10.0f
/121.0f
;
729 D3DXQuaternionInverse(&gotquat
,&q
);
730 expect_vec4(expectedquat
,gotquat
);
732 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 10.0f
;
733 D3DXQuaternionInverse(&gotquat
,&gotquat
);
734 expect_vec4(expectedquat
,gotquat
);
737 /*_______________D3DXQuaternionIsIdentity________________*/
738 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
740 gotbool
= D3DXQuaternionIsIdentity(&s
);
741 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
742 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
743 expectedbool
= FALSE
;
744 gotbool
= D3DXQuaternionIsIdentity(&q
);
745 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
746 /* Test the NULL case */
747 gotbool
= D3DXQuaternionIsIdentity(NULL
);
748 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
750 /*_______________D3DXQuaternionLength__________________________*/
752 got
= D3DXQuaternionLength(&q
);
753 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
754 /* Tests the case NULL */
756 got
= D3DXQuaternionLength(NULL
);
757 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
759 /*_______________D3DXQuaternionLengthSq________________________*/
761 got
= D3DXQuaternionLengthSq(&q
);
762 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
763 /* Tests the case NULL */
765 got
= D3DXQuaternionLengthSq(NULL
);
766 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
768 /*_______________D3DXQuaternionLn______________________________*/
769 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 0.0f
;
770 D3DXQuaternionLn(&gotquat
,&q
);
771 expect_vec4(expectedquat
,gotquat
);
772 expectedquat
.x
= -3.0f
; expectedquat
.y
= 4.0f
; expectedquat
.z
= -5.0f
; expectedquat
.w
= 0.0f
;
773 D3DXQuaternionLn(&gotquat
,&r
);
774 expect_vec4(expectedquat
,gotquat
);
775 Nq
.x
= 1.0f
/11.0f
; Nq
.y
= 2.0f
/11.0f
; Nq
.z
= 4.0f
/11.0f
; Nq
.w
=10.0f
/11.0f
;
776 expectedquat
.x
= 0.093768f
; expectedquat
.y
= 0.187536f
; expectedquat
.z
= 0.375073f
; expectedquat
.w
= 0.0f
;
777 D3DXQuaternionLn(&gotquat
,&Nq
);
778 expect_vec4(expectedquat
,gotquat
);
779 Nq
.x
= 0.0f
; Nq
.y
= 0.0f
; Nq
.z
= 0.0f
; Nq
.w
= 1.0f
;
780 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
781 D3DXQuaternionLn(&gotquat
,&Nq
);
782 expect_vec4(expectedquat
,gotquat
);
783 Nq
.x
= 5.4f
; Nq
.y
= 1.2f
; Nq
.z
= -0.3f
; Nq
.w
= -0.3f
;
784 expectedquat
.x
= 10.616652f
; expectedquat
.y
= 2.359256f
; expectedquat
.z
= -0.589814f
; expectedquat
.w
= 0.0f
;
785 D3DXQuaternionLn(&gotquat
,&Nq
);
786 expect_vec4(expectedquat
,gotquat
);
787 /* Test the case where the norm of the quaternion is <1 */
788 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
789 expectedquat
.x
= 0.206945f
; expectedquat
.y
= 0.103473f
; expectedquat
.z
= 0.310418f
; expectedquat
.w
= 0.0f
;
790 D3DXQuaternionLn(&gotquat
,&Nq1
);
791 expect_vec4(expectedquat
,gotquat
);
792 /* Test the case where the real part of the quaternion is -1.0f */
793 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= -1.0f
;
794 expectedquat
.x
= 0.2f
; expectedquat
.y
= 0.1f
; expectedquat
.z
= 0.3f
; expectedquat
.w
= 0.0f
;
795 D3DXQuaternionLn(&gotquat
,&Nq1
);
796 expect_vec4(expectedquat
,gotquat
);
798 /*_______________D3DXQuaternionMultiply________________________*/
799 expectedquat
.x
= 3.0f
; expectedquat
.y
= 61.0f
; expectedquat
.z
= -32.0f
; expectedquat
.w
= 85.0f
;
800 D3DXQuaternionMultiply(&gotquat
,&q
,&r
);
801 expect_vec4(expectedquat
,gotquat
);
803 /*_______________D3DXQuaternionNormalize________________________*/
804 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
805 D3DXQuaternionNormalize(&gotquat
,&q
);
806 expect_vec4(expectedquat
,gotquat
);
808 /*_______________D3DXQuaternionRotationAxis___________________*/
809 axis
.x
= 2.0f
; axis
.y
= 7.0; axis
.z
= 13.0f
;
810 angle
= D3DX_PI
/3.0f
;
811 expectedquat
.x
= 0.067116; expectedquat
.y
= 0.234905f
; expectedquat
.z
= 0.436251f
; expectedquat
.w
= 0.866025f
;
812 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
813 expect_vec4(expectedquat
,gotquat
);
814 /* Test the nul quaternion */
815 axis
.x
= 0.0f
; axis
.y
= 0.0; axis
.z
= 0.0f
;
816 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.866025f
;
817 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
818 expect_vec4(expectedquat
,gotquat
);
820 /*_______________D3DXQuaternionRotationMatrix___________________*/
821 /* test when the trace is >0 */
822 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
823 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
824 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
825 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
826 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
827 U(mat
).m
[3][3] = 48.0f
;
828 expectedquat
.x
= 2.368682f
; expectedquat
.y
= 0.768221f
; expectedquat
.z
= -0.384111f
; expectedquat
.w
= 3.905125f
;
829 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
830 expect_vec4(expectedquat
,gotquat
);
831 /* test the case when the greater element is (2,2) */
832 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
833 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
834 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
835 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
836 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = -60.0f
; U(mat
).m
[2][2] = 40.0f
;
837 U(mat
).m
[3][3] = 48.0f
;
838 expectedquat
.x
= 1.233905f
; expectedquat
.y
= -0.237290f
; expectedquat
.z
= 5.267827f
; expectedquat
.w
= -0.284747f
;
839 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
840 expect_vec4(expectedquat
,gotquat
);
841 /* test the case when the greater element is (1,1) */
842 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
843 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
844 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
845 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
846 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 60.0f
; U(mat
).m
[2][2] = -80.0f
;
847 U(mat
).m
[3][3] = 48.0f
;
848 expectedquat
.x
= 0.651031f
; expectedquat
.y
= 6.144103f
; expectedquat
.z
= -0.203447f
; expectedquat
.w
= 0.488273f
;
849 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
850 expect_vec4(expectedquat
,gotquat
);
851 /* test the case when the trace is near 0 in a matrix which is not a rotation */
852 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
853 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
854 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
855 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
856 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.9f
;
857 U(mat
).m
[3][3] = 48.0f
;
858 expectedquat
.x
= 1.709495f
; expectedquat
.y
= 2.339872f
; expectedquat
.z
= -0.534217f
; expectedquat
.w
= 1.282122f
;
859 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
860 expect_vec4(expectedquat
,gotquat
);
861 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
862 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
863 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
864 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
865 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
866 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.51f
;
867 U(mat
).m
[3][3] = 48.0f
;
868 expectedquat
.x
= 1.724923f
; expectedquat
.y
= 2.318944f
; expectedquat
.z
= -0.539039f
; expectedquat
.w
= 1.293692f
;
869 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
870 expect_vec4(expectedquat
,gotquat
);
871 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
872 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
873 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
874 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
875 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
876 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.49f
;
877 U(mat
).m
[3][3] = 48.0f
;
878 expectedquat
.x
= 1.725726f
; expectedquat
.y
= 2.317865f
; expectedquat
.z
= -0.539289f
; expectedquat
.w
= 1.294294f
;
879 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
880 expect_vec4(expectedquat
,gotquat
);
881 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
882 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
883 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
884 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
885 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
886 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.01f
;
887 U(mat
).m
[3][3] = 48.0f
;
888 expectedquat
.x
= 1.745328f
; expectedquat
.y
= 2.291833f
; expectedquat
.z
= -0.545415f
; expectedquat
.w
= 1.308996f
;
889 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
890 expect_vec4(expectedquat
,gotquat
);
891 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
892 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
893 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
894 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
895 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
896 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.0f
;
897 U(mat
).m
[3][3] = 48.0f
;
898 expectedquat
.x
= 1.745743f
; expectedquat
.y
= 2.291288f
; expectedquat
.z
= -0.545545f
; expectedquat
.w
= 1.309307f
;
899 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
900 expect_vec4(expectedquat
,gotquat
);
901 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
902 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
903 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
904 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
905 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
906 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.01f
;
907 U(mat
).m
[3][3] = 48.0f
;
908 expectedquat
.x
= 18.408188f
; expectedquat
.y
= 5.970223f
; expectedquat
.z
= -2.985111f
; expectedquat
.w
= 0.502494f
;
909 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
910 expect_vec4(expectedquat
,gotquat
);
911 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
912 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
913 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
914 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
915 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
916 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.5f
;
917 U(mat
).m
[3][3] = 48.0f
;
918 expectedquat
.x
= 15.105186f
; expectedquat
.y
= 4.898980f
; expectedquat
.z
= -2.449490f
; expectedquat
.w
= 0.612372f
;
919 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
920 expect_vec4(expectedquat
,gotquat
);
921 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
922 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
923 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
924 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
925 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
926 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.70f
;
927 U(mat
).m
[3][3] = 48.0f
;
928 expectedquat
.x
= 14.188852f
; expectedquat
.y
= 4.601790f
; expectedquat
.z
= -2.300895f
; expectedquat
.w
= 0.651920f
;
929 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
930 expect_vec4(expectedquat
,gotquat
);
931 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
932 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
933 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
934 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
935 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
936 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.99f
;
937 U(mat
).m
[3][3] = 48.0f
;
938 expectedquat
.x
= 13.114303f
; expectedquat
.y
= 4.253287f
; expectedquat
.z
= -2.126644f
; expectedquat
.w
= 0.705337f
;
939 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
940 expect_vec4(expectedquat
,gotquat
);
941 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
942 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
943 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
944 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
945 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
946 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 2.0f
;
947 U(mat
).m
[3][3] = 48.0f
;
948 expectedquat
.x
= 10.680980f
; expectedquat
.y
= 3.464102f
; expectedquat
.z
= -1.732051f
; expectedquat
.w
= 0.866025f
;
949 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
950 expect_vec4(expectedquat
,gotquat
);
952 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
953 expectedquat
.x
= 0.303261f
; expectedquat
.y
= 0.262299f
; expectedquat
.z
= 0.410073f
; expectedquat
.w
= 0.819190f
;
954 D3DXQuaternionRotationYawPitchRoll(&gotquat
,D3DX_PI
/4.0f
,D3DX_PI
/11.0f
,D3DX_PI
/3.0f
);
955 expect_vec4(expectedquat
,gotquat
);
957 /*_______________D3DXQuaternionSlerp________________________*/
958 expectedquat
.x
= -0.2f
; expectedquat
.y
= 2.6f
; expectedquat
.z
= 1.3f
; expectedquat
.w
= 9.1f
;
959 D3DXQuaternionSlerp(&gotquat
,&q
,&r
,scale
);
960 expect_vec4(expectedquat
,gotquat
);
961 expectedquat
.x
= 334.0f
; expectedquat
.y
= -31.9f
; expectedquat
.z
= 6.1f
; expectedquat
.w
= 6.7f
;
962 D3DXQuaternionSlerp(&gotquat
,&q
,&t
,scale
);
963 expect_vec4(expectedquat
,gotquat
);
964 expectedquat
.x
= 0.239485f
; expectedquat
.y
= 0.346580f
; expectedquat
.z
= 0.453676f
; expectedquat
.w
= 0.560772f
;
965 D3DXQuaternionSlerp(&gotquat
,&smallq
,&smallr
,scale
);
966 expect_vec4(expectedquat
,gotquat
);
968 /*_______________D3DXQuaternionSquad________________________*/
969 expectedquat
.x
= -156.296f
; expectedquat
.y
= 30.242f
; expectedquat
.z
= -2.5022f
; expectedquat
.w
= 7.3576f
;
970 D3DXQuaternionSquad(&gotquat
,&q
,&r
,&t
,&u
,scale
);
971 expect_vec4(expectedquat
,gotquat
);
973 /*_______________D3DXQuaternionSquadSetup___________________*/
974 r
.x
= 1.0f
, r
.y
= 2.0f
; r
.z
= 4.0f
; r
.w
= 10.0f
;
975 s
.x
= -3.0f
; s
.y
= 4.0f
; s
.z
= -5.0f
; s
.w
= 7.0;
976 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
977 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
978 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
979 expectedquat
.x
= 7.121285f
; expectedquat
.y
= 2.159964f
; expectedquat
.z
= -3.855094f
; expectedquat
.w
= 5.362844f
;
980 expect_vec4(expectedquat
,gotquat
);
981 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
982 expect_vec4(expectedquat
,Nq
);
983 expectedquat
.x
= -1111.0f
; expectedquat
.y
= 111.0f
; expectedquat
.z
= -11.0f
; expectedquat
.w
= 1.0f
;
984 expect_vec4(expectedquat
,Nq1
);
985 r
.x
= 0.2f
; r
.y
= 0.3f
; r
.z
= 1.3f
; r
.w
= -0.6f
;
986 s
.x
= -3.0f
; s
.y
=-2.0f
; s
.z
= 4.0f
; s
.w
= 0.2f
;
987 t
.x
= 0.4f
; t
.y
= 8.3f
; t
.z
= -3.1f
; t
.w
= -2.7f
;
988 u
.x
= 1.1f
; u
.y
= -0.7f
; u
.z
= 9.2f
; u
.w
= 0.0f
;
989 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&u
,&t
);
990 expectedquat
.x
= -4.139569f
; expectedquat
.y
= -2.469115f
; expectedquat
.z
= 2.364477f
; expectedquat
.w
= 0.465494f
;
991 expect_vec4(expectedquat
,gotquat
);
992 expectedquat
.x
= 2.342533f
; expectedquat
.y
= 2.365127f
; expectedquat
.z
= 8.628538f
; expectedquat
.w
= -0.898356f
;
993 expect_vec4(expectedquat
,Nq
);
994 expectedquat
.x
= 1.1f
; expectedquat
.y
= -0.7f
; expectedquat
.z
= 9.2f
; expectedquat
.w
= 0.0f
;
995 expect_vec4(expectedquat
,Nq1
);
996 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
997 expectedquat
.x
= -3.754567f
; expectedquat
.y
= -0.586085f
; expectedquat
.z
= 3.815818f
; expectedquat
.w
= -0.198150f
;
998 expect_vec4(expectedquat
,gotquat
);
999 expectedquat
.x
= 0.140773f
; expectedquat
.y
= -8.737090f
; expectedquat
.z
= -0.516593f
; expectedquat
.w
= 3.053942f
;
1000 expect_vec4(expectedquat
,Nq
);
1001 expectedquat
.x
= -0.4f
; expectedquat
.y
= -8.3f
; expectedquat
.z
= 3.1f
; expectedquat
.w
= 2.7f
;
1002 expect_vec4(expectedquat
,Nq1
);
1003 r
.x
= -1.0f
; r
.y
= 0.0f
; r
.z
= 0.0f
; r
.w
= 0.0f
;
1004 s
.x
= 1.0f
; s
.y
=0.0f
; s
.z
= 0.0f
; s
.w
= 0.0f
;
1005 t
.x
= 1.0f
; t
.y
= 0.0f
; t
.z
= 0.0f
; t
.w
= 0.0f
;
1006 u
.x
= -1.0f
; u
.y
= 0.0f
; u
.z
= 0.0f
; u
.w
= 0.0f
;
1007 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
1008 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1009 expect_vec4(expectedquat
,gotquat
);
1010 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1011 expect_vec4(expectedquat
,Nq
);
1012 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1013 expect_vec4(expectedquat
,Nq1
);
1015 /*_______________D3DXQuaternionToAxisAngle__________________*/
1016 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
1017 expectedvec
.x
= 1.0f
/22.0f
; expectedvec
.y
= 2.0f
/22.0f
; expectedvec
.z
= 4.0f
/22.0f
;
1018 expected
= 2.197869f
;
1019 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
1020 expect_vec3(expectedvec
,axis
);
1021 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1022 /* Test if |w|>1.0f */
1023 expectedvec
.x
= 1.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= 4.0f
;
1024 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
1025 expect_vec3(expectedvec
,axis
);
1026 /* Test the null quaternion */
1027 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1028 expected
= 3.141593f
;
1029 D3DXQuaternionToAxisAngle(&nul
, &axis
, &angle
);
1030 expect_vec3(expectedvec
, axis
);
1031 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1033 D3DXQuaternionToAxisAngle(&nul
, &axis
, NULL
);
1034 D3DXQuaternionToAxisAngle(&nul
, NULL
, &angle
);
1035 expect_vec3(expectedvec
, axis
);
1036 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1039 static void D3DXVector2Test(void)
1041 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1042 LPD3DXVECTOR2 funcpointer
;
1043 D3DXVECTOR4 expectedtrans
, gottrans
;
1045 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1047 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
1048 u
.x
= 3.0f
; u
.y
= 4.0f
;
1049 v
.x
= -7.0f
; v
.y
= 9.0f
;
1050 w
.x
= 4.0f
; w
.y
= -3.0f
;
1051 x
.x
= 2.0f
; x
.y
= -11.0f
;
1053 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1054 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1055 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1056 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1058 coeff1
= 2.0f
; coeff2
= 5.0f
;
1061 /*_______________D3DXVec2Add__________________________*/
1062 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
1063 D3DXVec2Add(&gotvec
,&u
,&v
);
1064 expect_vec(expectedvec
,gotvec
);
1065 /* Tests the case NULL */
1066 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
1067 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1068 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
1069 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1071 /*_______________D3DXVec2BaryCentric___________________*/
1072 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
1073 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1074 expect_vec(expectedvec
,gotvec
);
1076 /*_______________D3DXVec2CatmullRom____________________*/
1077 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
1078 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1079 expect_vec(expectedvec
,gotvec
);
1081 /*_______________D3DXVec2CCW__________________________*/
1083 got
= D3DXVec2CCW(&u
,&v
);
1084 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1085 /* Tests the case NULL */
1087 got
= D3DXVec2CCW(NULL
,&v
);
1088 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1090 got
= D3DXVec2CCW(NULL
,NULL
);
1091 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1093 /*_______________D3DXVec2Dot__________________________*/
1095 got
= D3DXVec2Dot(&u
,&v
);
1096 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1097 /* Tests the case NULL */
1099 got
= D3DXVec2Dot(NULL
,&v
);
1100 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1102 got
= D3DXVec2Dot(NULL
,NULL
);
1103 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1105 /*_______________D3DXVec2Hermite__________________________*/
1106 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
1107 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1108 expect_vec(expectedvec
,gotvec
);
1110 /*_______________D3DXVec2Length__________________________*/
1112 got
= D3DXVec2Length(&u
);
1113 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1114 /* Tests the case NULL */
1116 got
= D3DXVec2Length(NULL
);
1117 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1119 /*_______________D3DXVec2LengthSq________________________*/
1121 got
= D3DXVec2LengthSq(&u
);
1122 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1123 /* Tests the case NULL */
1125 got
= D3DXVec2LengthSq(NULL
);
1126 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1128 /*_______________D3DXVec2Lerp__________________________*/
1129 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
1130 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
1131 expect_vec(expectedvec
,gotvec
);
1132 /* Tests the case NULL */
1133 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
1134 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1135 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
1136 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1138 /*_______________D3DXVec2Maximize__________________________*/
1139 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
1140 D3DXVec2Maximize(&gotvec
,&u
,&v
);
1141 expect_vec(expectedvec
,gotvec
);
1142 /* Tests the case NULL */
1143 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
1144 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1145 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1146 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1148 /*_______________D3DXVec2Minimize__________________________*/
1149 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1150 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1151 expect_vec(expectedvec
,gotvec
);
1152 /* Tests the case NULL */
1153 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1154 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1155 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1156 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1158 /*_______________D3DXVec2Normalize_________________________*/
1159 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1160 D3DXVec2Normalize(&gotvec
,&u
);
1161 expect_vec(expectedvec
,gotvec
);
1162 /* Test the nul vector */
1163 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1164 D3DXVec2Normalize(&gotvec
,&nul
);
1165 expect_vec(expectedvec
,gotvec
);
1167 /*_______________D3DXVec2Scale____________________________*/
1168 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
1169 D3DXVec2Scale(&gotvec
,&u
,scale
);
1170 expect_vec(expectedvec
,gotvec
);
1171 /* Tests the case NULL */
1172 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
1173 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1174 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
1175 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1177 /*_______________D3DXVec2Subtract__________________________*/
1178 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
1179 D3DXVec2Subtract(&gotvec
,&u
,&v
);
1180 expect_vec(expectedvec
,gotvec
);
1181 /* Tests the case NULL */
1182 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
1183 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1184 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
1185 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1187 /*_______________D3DXVec2Transform_______________________*/
1188 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
1189 D3DXVec2Transform(&gottrans
,&u
,&mat
);
1190 expect_vec4(expectedtrans
,gottrans
);
1192 /*_______________D3DXVec2TransformCoord_______________________*/
1193 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
1194 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
1195 expect_vec(expectedvec
,gotvec
);
1197 /*_______________D3DXVec2TransformNormal______________________*/
1198 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
1199 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
1200 expect_vec(expectedvec
,gotvec
);
1203 static void D3DXVector3Test(void)
1205 D3DVIEWPORT9 viewport
;
1206 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1207 LPD3DXVECTOR3 funcpointer
;
1208 D3DXVECTOR4 expectedtrans
, gottrans
;
1209 D3DXMATRIX mat
, projection
, view
, world
;
1210 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1212 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
1213 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
1214 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
1215 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
1216 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
1218 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
1219 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
1221 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1222 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1223 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1224 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1226 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
1227 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
1228 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
1229 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
1230 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
1231 U(view
).m
[3][3] = -40.0f
;
1233 U(world
).m
[0][0] = 21.0f
; U(world
).m
[0][1] = 2.0f
; U(world
).m
[0][2] = 3.0f
; U(world
).m
[0][3] = 4.0;
1234 U(world
).m
[1][0] = 5.0f
; U(world
).m
[1][1] = 23.0f
; U(world
).m
[1][2] = 7.0f
; U(world
).m
[1][3] = 8.0f
;
1235 U(world
).m
[2][0] = -8.0f
; U(world
).m
[2][1] = -7.0f
; U(world
).m
[2][2] = 25.0f
; U(world
).m
[2][3] = -5.0f
;
1236 U(world
).m
[3][0] = -4.0f
; U(world
).m
[3][1] = -3.0f
; U(world
).m
[3][2] = -2.0f
; U(world
).m
[3][3] = 27.0f
;
1238 coeff1
= 2.0f
; coeff2
= 5.0f
;
1241 /*_______________D3DXVec3Add__________________________*/
1242 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
1243 D3DXVec3Add(&gotvec
,&u
,&v
);
1244 expect_vec3(expectedvec
,gotvec
);
1245 /* Tests the case NULL */
1246 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
1247 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1248 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
1249 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1251 /*_______________D3DXVec3BaryCentric___________________*/
1252 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
1253 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1255 expect_vec3(expectedvec
,gotvec
);
1257 /*_______________D3DXVec3CatmullRom____________________*/
1258 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
1259 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1260 expect_vec3(expectedvec
,gotvec
);
1262 /*_______________D3DXVec3Cross________________________*/
1263 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
1264 D3DXVec3Cross(&gotvec
,&u
,&v
);
1265 expect_vec3(expectedvec
,gotvec
);
1266 expectedvec
.x
= -277.0f
; expectedvec
.y
= -150.0f
; expectedvec
.z
= -26.0f
;
1267 D3DXVec3Cross(&gotvec
,&gotvec
,&v
);
1268 expect_vec3(expectedvec
,gotvec
);
1269 /* Tests the case NULL */
1270 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
1271 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1272 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
1273 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1275 /*_______________D3DXVec3Dot__________________________*/
1277 got
= D3DXVec3Dot(&u
,&v
);
1278 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1279 /* Tests the case NULL */
1281 got
= D3DXVec3Dot(NULL
,&v
);
1282 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1284 got
= D3DXVec3Dot(NULL
,NULL
);
1285 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1287 /*_______________D3DXVec3Hermite__________________________*/
1288 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
1289 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1290 expect_vec3(expectedvec
,gotvec
);
1292 /*_______________D3DXVec3Length__________________________*/
1294 got
= D3DXVec3Length(&u
);
1295 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1296 /* Tests the case NULL */
1298 got
= D3DXVec3Length(NULL
);
1299 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1301 /*_______________D3DXVec3LengthSq________________________*/
1303 got
= D3DXVec3LengthSq(&u
);
1304 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1305 /* Tests the case NULL */
1307 got
= D3DXVec3LengthSq(NULL
);
1308 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1310 /*_______________D3DXVec3Lerp__________________________*/
1311 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
1312 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
1313 expect_vec3(expectedvec
,gotvec
);
1314 /* Tests the case NULL */
1315 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
1316 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1317 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
1318 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1320 /*_______________D3DXVec3Maximize__________________________*/
1321 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
1322 D3DXVec3Maximize(&gotvec
,&u
,&v
);
1323 expect_vec3(expectedvec
,gotvec
);
1324 /* Tests the case NULL */
1325 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
1326 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1327 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
1328 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1330 /*_______________D3DXVec3Minimize__________________________*/
1331 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
1332 D3DXVec3Minimize(&gotvec
,&u
,&v
);
1333 expect_vec3(expectedvec
,gotvec
);
1334 /* Tests the case NULL */
1335 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
1336 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1337 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
1338 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1340 /*_______________D3DXVec3Normalize_________________________*/
1341 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
1342 D3DXVec3Normalize(&gotvec
,&u
);
1343 expect_vec3(expectedvec
,gotvec
);
1344 /* Test the nul vector */
1345 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1346 D3DXVec3Normalize(&gotvec
,&nul
);
1347 expect_vec3(expectedvec
,gotvec
);
1349 /*_______________D3DXVec3Scale____________________________*/
1350 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
1351 D3DXVec3Scale(&gotvec
,&u
,scale
);
1352 expect_vec3(expectedvec
,gotvec
);
1353 /* Tests the case NULL */
1354 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
1355 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1356 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
1357 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1359 /*_______________D3DXVec3Subtract_______________________*/
1360 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
1361 D3DXVec3Subtract(&gotvec
,&u
,&v
);
1362 expect_vec3(expectedvec
,gotvec
);
1363 /* Tests the case NULL */
1364 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
1365 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1366 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
1367 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1369 /*_______________D3DXVec3Transform_______________________*/
1370 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
1371 D3DXVec3Transform(&gottrans
, &u
, &mat
);
1372 expect_vec4(expectedtrans
, gottrans
);
1374 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
; gottrans
.z
= u
.z
;
1375 D3DXVec3Transform(&gottrans
, (D3DXVECTOR3
*)&gottrans
, &mat
);
1376 expect_vec4(expectedtrans
, gottrans
);
1378 /*_______________D3DXVec3TransformCoord_______________________*/
1379 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
1380 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
1381 expect_vec3(expectedvec
,gotvec
);
1383 /*_______________D3DXVec3TransformNormal______________________*/
1384 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
1385 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
1386 expect_vec3(expectedvec
,gotvec
);
1388 /*_______________D3DXVec3Project_________________________*/
1389 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
1390 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1391 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1392 expect_vec3(expectedvec
,gotvec
);
1393 /* World matrix can be omitted */
1394 D3DXMatrixMultiply(&mat
,&world
,&view
);
1395 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1396 expect_vec3(expectedvec
,gotvec
);
1397 /* Projection matrix can be omitted */
1398 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1399 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1400 expect_vec3(expectedvec
,gotvec
);
1401 /* View matrix can be omitted */
1402 D3DXMatrixMultiply(&mat
,&world
,&view
);
1403 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1404 expect_vec3(expectedvec
,gotvec
);
1405 /* All matrices can be omitted */
1406 expectedvec
.x
= 4010.000000f
; expectedvec
.y
= -1695.000000f
; expectedvec
.z
= 1.600000f
;
1407 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1408 expect_vec3(expectedvec
,gotvec
);
1409 /* Viewport can be omitted */
1410 expectedvec
.x
= 1.814305f
; expectedvec
.y
= 0.582097f
; expectedvec
.z
= -0.066555f
;
1411 D3DXVec3Project(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1412 expect_vec3(expectedvec
,gotvec
);
1414 /*_______________D3DXVec3Unproject_________________________*/
1415 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
1416 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1417 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1418 expect_vec3(expectedvec
,gotvec
);
1419 /* World matrix can be omitted */
1420 D3DXMatrixMultiply(&mat
,&world
,&view
);
1421 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1422 expect_vec3(expectedvec
,gotvec
);
1423 /* Projection matrix can be omitted */
1424 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1425 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1426 expect_vec3(expectedvec
,gotvec
);
1427 /* View matrix can be omitted */
1428 D3DXMatrixMultiply(&mat
,&world
,&view
);
1429 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1430 expect_vec3(expectedvec
,gotvec
);
1431 /* All matrices can be omitted */
1432 expectedvec
.x
= -1.002500f
; expectedvec
.y
= 0.997059f
; expectedvec
.z
= 2.571429f
;
1433 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1434 expect_vec3(expectedvec
,gotvec
);
1435 /* Viewport can be omitted */
1436 expectedvec
.x
= -11.018396f
; expectedvec
.y
= 3.218991f
; expectedvec
.z
= 1.380329f
;
1437 D3DXVec3Unproject(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1438 expect_vec3(expectedvec
,gotvec
);
1441 static void D3DXVector4Test(void)
1443 D3DXVECTOR4 expectedvec
, gotvec
, u
, v
, w
, x
;
1444 LPD3DXVECTOR4 funcpointer
;
1445 D3DXVECTOR4 expectedtrans
, gottrans
;
1447 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1449 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
1450 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
1451 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
1452 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
1454 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
1455 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
1456 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
1457 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
1459 coeff1
= 2.0f
; coeff2
= 5.0;
1462 /*_______________D3DXVec4Add__________________________*/
1463 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
1464 D3DXVec4Add(&gotvec
,&u
,&v
);
1465 expect_vec4(expectedvec
,gotvec
);
1466 /* Tests the case NULL */
1467 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
1468 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1469 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
1470 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1472 /*_______________D3DXVec4BaryCentric____________________*/
1473 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
1474 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1475 expect_vec4(expectedvec
,gotvec
);
1477 /*_______________D3DXVec4CatmullRom____________________*/
1478 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
1479 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1480 expect_vec4(expectedvec
,gotvec
);
1482 /*_______________D3DXVec4Cross_________________________*/
1483 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
1484 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1485 expect_vec4(expectedvec
,gotvec
);
1487 /*_______________D3DXVec4Dot__________________________*/
1489 got
= D3DXVec4Dot(&u
,&v
);
1490 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1491 /* Tests the case NULL */
1493 got
= D3DXVec4Dot(NULL
,&v
);
1494 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1496 got
= D3DXVec4Dot(NULL
,NULL
);
1497 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1499 /*_______________D3DXVec4Hermite_________________________*/
1500 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1501 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1502 expect_vec4(expectedvec
,gotvec
);
1504 /*_______________D3DXVec4Length__________________________*/
1506 got
= D3DXVec4Length(&u
);
1507 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1508 /* Tests the case NULL */
1510 got
= D3DXVec4Length(NULL
);
1511 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1513 /*_______________D3DXVec4LengthSq________________________*/
1515 got
= D3DXVec4LengthSq(&u
);
1516 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1517 /* Tests the case NULL */
1519 got
= D3DXVec4LengthSq(NULL
);
1520 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1522 /*_______________D3DXVec4Lerp__________________________*/
1523 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1524 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1525 expect_vec4(expectedvec
,gotvec
);
1526 /* Tests the case NULL */
1527 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1528 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1529 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1530 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1532 /*_______________D3DXVec4Maximize__________________________*/
1533 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1534 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1535 expect_vec4(expectedvec
,gotvec
);
1536 /* Tests the case NULL */
1537 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1538 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1539 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1540 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1542 /*_______________D3DXVec4Minimize__________________________*/
1543 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1544 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1545 expect_vec4(expectedvec
,gotvec
);
1546 /* Tests the case NULL */
1547 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1548 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1549 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1550 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1552 /*_______________D3DXVec4Normalize_________________________*/
1553 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1554 D3DXVec4Normalize(&gotvec
,&u
);
1555 expect_vec4(expectedvec
,gotvec
);
1557 /*_______________D3DXVec4Scale____________________________*/
1558 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1559 D3DXVec4Scale(&gotvec
,&u
,scale
);
1560 expect_vec4(expectedvec
,gotvec
);
1561 /* Tests the case NULL */
1562 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1563 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1564 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1565 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1567 /*_______________D3DXVec4Subtract__________________________*/
1568 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1569 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1570 expect_vec4(expectedvec
,gotvec
);
1571 /* Tests the case NULL */
1572 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1573 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1574 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1575 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1577 /*_______________D3DXVec4Transform_______________________*/
1578 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1579 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1580 expect_vec4(expectedtrans
,gottrans
);
1583 static void test_matrix_stack(void)
1585 ID3DXMatrixStack
*stack
;
1589 const D3DXMATRIX mat1
= {{{
1590 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1591 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1592 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1593 13.0f
, 14.0f
, 15.0f
, 16.0f
1596 const D3DXMATRIX mat2
= {{{
1597 17.0f
, 18.0f
, 19.0f
, 20.0f
,
1598 21.0f
, 22.0f
, 23.0f
, 24.0f
,
1599 25.0f
, 26.0f
, 27.0f
, 28.0f
,
1600 29.0f
, 30.0f
, 31.0f
, 32.0f
1603 hr
= D3DXCreateMatrixStack(0, &stack
);
1604 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
1605 if (FAILED(hr
)) return;
1607 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
1608 "The top of an empty matrix stack should be an identity matrix\n");
1610 hr
= ID3DXMatrixStack_Pop(stack
);
1611 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1613 hr
= ID3DXMatrixStack_Push(stack
);
1614 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1615 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1617 hr
= ID3DXMatrixStack_Push(stack
);
1618 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1620 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
1621 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1622 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1624 hr
= ID3DXMatrixStack_Push(stack
);
1625 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1626 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1628 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
1629 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1630 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1632 hr
= ID3DXMatrixStack_Push(stack
);
1633 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1634 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1636 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
1637 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
1638 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1640 hr
= ID3DXMatrixStack_Pop(stack
);
1641 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1642 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1644 hr
= ID3DXMatrixStack_Pop(stack
);
1645 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1646 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1648 hr
= ID3DXMatrixStack_Pop(stack
);
1649 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1650 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1652 hr
= ID3DXMatrixStack_Pop(stack
);
1653 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1654 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1656 refcount
= ID3DXMatrixStack_Release(stack
);
1657 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
1660 static void test_Matrix_AffineTransformation2D(void)
1662 D3DXMATRIX exp_mat
, got_mat
;
1663 D3DXVECTOR2 center
, position
;
1672 angle
= D3DX_PI
/3.0f
;
1676 U(exp_mat
).m
[0][0] = 10.0f
;
1677 U(exp_mat
).m
[1][0] = -17.320507f
;
1678 U(exp_mat
).m
[2][0] = 0.0f
;
1679 U(exp_mat
).m
[3][0] = -1.035898f
;
1680 U(exp_mat
).m
[0][1] = 17.320507f
;
1681 U(exp_mat
).m
[1][1] = 10.0f
;
1682 U(exp_mat
).m
[2][1] = 0.0f
;
1683 U(exp_mat
).m
[3][1] = 6.401924f
;
1684 U(exp_mat
).m
[0][2] = 0.0f
;
1685 U(exp_mat
).m
[1][2] = 0.0f
;
1686 U(exp_mat
).m
[2][2] = 1.0f
;
1687 U(exp_mat
).m
[3][2] = 0.0f
;
1688 U(exp_mat
).m
[0][3] = 0.0f
;
1689 U(exp_mat
).m
[1][3] = 0.0f
;
1690 U(exp_mat
).m
[2][3] = 0.0f
;
1691 U(exp_mat
).m
[3][3] = 1.0f
;
1693 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, &position
);
1695 expect_mat(&exp_mat
, &got_mat
);
1702 angle
= D3DX_PI
/3.0f
;
1706 U(exp_mat
).m
[0][0] = 10.0f
;
1707 U(exp_mat
).m
[1][0] = -17.320507f
;
1708 U(exp_mat
).m
[2][0] = 0.0f
;
1709 U(exp_mat
).m
[3][0] = 4.964102f
;
1710 U(exp_mat
).m
[0][1] = 17.320507f
;
1711 U(exp_mat
).m
[1][1] = 10.0f
;
1712 U(exp_mat
).m
[2][1] = 0.0f
;
1713 U(exp_mat
).m
[3][1] = -0.598076f
;
1714 U(exp_mat
).m
[0][2] = 0.0f
;
1715 U(exp_mat
).m
[1][2] = 0.0f
;
1716 U(exp_mat
).m
[2][2] = 1.0f
;
1717 U(exp_mat
).m
[3][2] = 0.0f
;
1718 U(exp_mat
).m
[0][3] = 0.0f
;
1719 U(exp_mat
).m
[1][3] = 0.0f
;
1720 U(exp_mat
).m
[2][3] = 0.0f
;
1721 U(exp_mat
).m
[3][3] = 1.0f
;
1723 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, NULL
);
1725 expect_mat(&exp_mat
, &got_mat
);
1732 angle
= D3DX_PI
/3.0f
;
1736 U(exp_mat
).m
[0][0] = 10.0f
;
1737 U(exp_mat
).m
[1][0] = -17.320507f
;
1738 U(exp_mat
).m
[2][0] = 0.0f
;
1739 U(exp_mat
).m
[3][0] = -6.0f
;
1740 U(exp_mat
).m
[0][1] = 17.320507f
;
1741 U(exp_mat
).m
[1][1] = 10.0f
;
1742 U(exp_mat
).m
[2][1] = 0.0f
;
1743 U(exp_mat
).m
[3][1] = 7.0f
;
1744 U(exp_mat
).m
[0][2] = 0.0f
;
1745 U(exp_mat
).m
[1][2] = 0.0f
;
1746 U(exp_mat
).m
[2][2] = 1.0f
;
1747 U(exp_mat
).m
[3][2] = 0.0f
;
1748 U(exp_mat
).m
[0][3] = 0.0f
;
1749 U(exp_mat
).m
[1][3] = 0.0f
;
1750 U(exp_mat
).m
[2][3] = 0.0f
;
1751 U(exp_mat
).m
[3][3] = 1.0f
;
1753 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, &position
);
1755 expect_mat(&exp_mat
, &got_mat
);
1759 angle
= 5.0f
* D3DX_PI
/4.0f
;
1763 U(exp_mat
).m
[0][0] = 14.142133f
;
1764 U(exp_mat
).m
[1][0] = -14.142133f
;
1765 U(exp_mat
).m
[2][0] = 0.0f
;
1766 U(exp_mat
).m
[3][0] = 0.0f
;
1767 U(exp_mat
).m
[0][1] = 14.142133;
1768 U(exp_mat
).m
[1][1] = 14.142133f
;
1769 U(exp_mat
).m
[2][1] = 0.0f
;
1770 U(exp_mat
).m
[3][1] = 0.0f
;
1771 U(exp_mat
).m
[0][2] = 0.0f
;
1772 U(exp_mat
).m
[1][2] = 0.0f
;
1773 U(exp_mat
).m
[2][2] = 1.0f
;
1774 U(exp_mat
).m
[3][2] = 0.0f
;
1775 U(exp_mat
).m
[0][3] = 0.0f
;
1776 U(exp_mat
).m
[1][3] = 0.0f
;
1777 U(exp_mat
).m
[2][3] = 0.0f
;
1778 U(exp_mat
).m
[3][3] = 1.0f
;
1780 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, NULL
);
1782 expect_mat(&exp_mat
, &got_mat
);
1785 static void test_Matrix_Decompose(void)
1788 D3DXQUATERNION exp_rotation
, got_rotation
;
1789 D3DXVECTOR3 exp_scale
, got_scale
, exp_translation
, got_translation
;
1794 U(pm
).m
[0][0] = -0.9238790f
;
1795 U(pm
).m
[1][0] = -0.2705984f
;
1796 U(pm
).m
[2][0] = 0.2705984f
;
1797 U(pm
).m
[3][0] = -5.0f
;
1798 U(pm
).m
[0][1] = 0.2705984f
;
1799 U(pm
).m
[1][1] = 0.03806049f
;
1800 U(pm
).m
[2][1] = 0.9619395f
;
1801 U(pm
).m
[3][1] = 0.0f
;
1802 U(pm
).m
[0][2] = -0.2705984f
;
1803 U(pm
).m
[1][2] = 0.9619395f
;
1804 U(pm
).m
[2][2] = 0.03806049f
;
1805 U(pm
).m
[3][2] = 10.0f
;
1806 U(pm
).m
[0][3] = 0.0f
;
1807 U(pm
).m
[1][3] = 0.0f
;
1808 U(pm
).m
[2][3] = 0.0f
;
1809 U(pm
).m
[3][3] = 1.0f
;
1815 exp_rotation
.w
= 0.195091f
;
1816 exp_rotation
.x
= 0.0f
;
1817 exp_rotation
.y
= 0.693520f
;
1818 exp_rotation
.z
= 0.693520f
;
1820 exp_translation
.x
= -5.0f
;
1821 exp_translation
.y
= 0.0f
;
1822 exp_translation
.z
= 10.0f
;
1824 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1826 compare_scale(exp_scale
, got_scale
);
1827 compare_rotation(exp_rotation
, got_rotation
);
1828 compare_translation(exp_translation
, got_translation
);
1832 U(pm
).m
[0][0] = -2.255813f
;
1833 U(pm
).m
[1][0] = 1.302324f
;
1834 U(pm
).m
[2][0] = 1.488373f
;
1835 U(pm
).m
[3][0] = 1.0f
;
1836 U(pm
).m
[0][1] = 1.302327f
;
1837 U(pm
).m
[1][1] = -0.7209296f
;
1838 U(pm
).m
[2][1] = 2.60465f
;
1839 U(pm
).m
[3][1] = 2.0f
;
1840 U(pm
).m
[0][2] = 1.488371f
;
1841 U(pm
).m
[1][2] = 2.604651f
;
1842 U(pm
).m
[2][2] = -0.02325551f
;
1843 U(pm
).m
[3][2] = 3.0f
;
1844 U(pm
).m
[0][3] = 0.0f
;
1845 U(pm
).m
[1][3] = 0.0f
;
1846 U(pm
).m
[2][3] = 0.0f
;
1847 U(pm
).m
[3][3] = 1.0f
;
1853 exp_rotation
.w
= 0.0;
1854 exp_rotation
.x
= 0.352180f
;
1855 exp_rotation
.y
= 0.616316f
;
1856 exp_rotation
.z
= 0.704361f
;
1858 exp_translation
.x
= 1.0f
;
1859 exp_translation
.y
= 2.0f
;
1860 exp_translation
.z
= 3.0f
;
1862 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1864 compare_scale(exp_scale
, got_scale
);
1865 compare_rotation(exp_rotation
, got_rotation
);
1866 compare_translation(exp_translation
, got_translation
);
1870 U(pm
).m
[0][0] = 2.427051f
;
1871 U(pm
).m
[1][0] = 0.0f
;
1872 U(pm
).m
[2][0] = 1.763355f
;
1873 U(pm
).m
[3][0] = 5.0f
;
1874 U(pm
).m
[0][1] = 0.0f
;
1875 U(pm
).m
[1][1] = 3.0f
;
1876 U(pm
).m
[2][1] = 0.0f
;
1877 U(pm
).m
[3][1] = 5.0f
;
1878 U(pm
).m
[0][2] = -1.763355f
;
1879 U(pm
).m
[1][2] = 0.0f
;
1880 U(pm
).m
[2][2] = 2.427051f
;
1881 U(pm
).m
[3][2] = 5.0f
;
1882 U(pm
).m
[0][3] = 0.0f
;
1883 U(pm
).m
[1][3] = 0.0f
;
1884 U(pm
).m
[2][3] = 0.0f
;
1885 U(pm
).m
[3][3] = 1.0f
;
1891 exp_rotation
.w
= 0.951057f
;
1892 exp_rotation
.x
= 0.0f
;
1893 exp_rotation
.y
= 0.309017f
;
1894 exp_rotation
.z
= 0.0f
;
1896 exp_translation
.x
= 5.0f
;
1897 exp_translation
.y
= 5.0f
;
1898 exp_translation
.z
= 5.0f
;
1900 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1902 compare_scale(exp_scale
, got_scale
);
1903 compare_rotation(exp_rotation
, got_rotation
);
1904 compare_translation(exp_translation
, got_translation
);
1908 U(pm
).m
[0][0] = -0.9238790f
;
1909 U(pm
).m
[1][0] = -0.2705984f
;
1910 U(pm
).m
[2][0] = 0.2705984f
;
1911 U(pm
).m
[3][0] = -5.0f
;
1912 U(pm
).m
[0][1] = 0.2705984f
;
1913 U(pm
).m
[1][1] = 0.03806049f
;
1914 U(pm
).m
[2][1] = 0.9619395f
;
1915 U(pm
).m
[3][1] = 0.0f
;
1916 U(pm
).m
[0][2] = -0.2705984f
;
1917 U(pm
).m
[1][2] = 0.9619395f
;
1918 U(pm
).m
[2][2] = 0.03806049f
;
1919 U(pm
).m
[3][2] = 10.0f
;
1920 U(pm
).m
[0][3] = 0.0f
;
1921 U(pm
).m
[1][3] = 0.0f
;
1922 U(pm
).m
[2][3] = 0.0f
;
1923 U(pm
).m
[3][3] = 1.0f
;
1929 exp_rotation
.w
= 0.195091f
;
1930 exp_rotation
.x
= 0.0f
;
1931 exp_rotation
.y
= 0.693520f
;
1932 exp_rotation
.z
= 0.693520f
;
1934 exp_translation
.x
= -5.0f
;
1935 exp_translation
.y
= 0.0f
;
1936 exp_translation
.z
= 10.0f
;
1938 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1940 compare_scale(exp_scale
, got_scale
);
1941 compare_rotation(exp_rotation
, got_rotation
);
1942 compare_translation(exp_translation
, got_translation
);
1946 U(pm
).m
[0][0] = -0.9238790f
;
1947 U(pm
).m
[1][0] = -0.5411968f
;
1948 U(pm
).m
[2][0] = 0.8117952f
;
1949 U(pm
).m
[3][0] = -5.0f
;
1950 U(pm
).m
[0][1] = 0.2705984f
;
1951 U(pm
).m
[1][1] = 0.07612098f
;
1952 U(pm
).m
[2][1] = 2.8858185f
;
1953 U(pm
).m
[3][1] = 0.0f
;
1954 U(pm
).m
[0][2] = -0.2705984f
;
1955 U(pm
).m
[1][2] = 1.9238790f
;
1956 U(pm
).m
[2][2] = 0.11418147f
;
1957 U(pm
).m
[3][2] = 10.0f
;
1958 U(pm
).m
[0][3] = 0.0f
;
1959 U(pm
).m
[1][3] = 0.0f
;
1960 U(pm
).m
[2][3] = 0.0f
;
1961 U(pm
).m
[3][3] = 1.0f
;
1967 exp_rotation
.w
= 0.195091f
;
1968 exp_rotation
.x
= 0.0f
;
1969 exp_rotation
.y
= 0.693520f
;
1970 exp_rotation
.z
= 0.693520f
;
1972 exp_translation
.x
= -5.0f
;
1973 exp_translation
.y
= 0.0f
;
1974 exp_translation
.z
= 10.0f
;
1976 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1978 compare_scale(exp_scale
, got_scale
);
1979 compare_rotation(exp_rotation
, got_rotation
);
1980 compare_translation(exp_translation
, got_translation
);
1984 U(pm
).m
[0][0] = 0.7156004f
;
1985 U(pm
).m
[1][0] = -0.5098283f
;
1986 U(pm
).m
[2][0] = -0.4774843f
;
1987 U(pm
).m
[3][0] = -5.0f
;
1988 U(pm
).m
[0][1] = -0.6612288f
;
1989 U(pm
).m
[1][1] = -0.7147621f
;
1990 U(pm
).m
[2][1] = -0.2277977f
;
1991 U(pm
).m
[3][1] = 0.0f
;
1992 U(pm
).m
[0][2] = -0.2251499f
;
1993 U(pm
).m
[1][2] = 0.4787385f
;
1994 U(pm
).m
[2][2] = -0.8485972f
;
1995 U(pm
).m
[3][2] = 10.0f
;
1996 U(pm
).m
[0][3] = 0.0f
;
1997 U(pm
).m
[1][3] = 0.0f
;
1998 U(pm
).m
[2][3] = 0.0f
;
1999 U(pm
).m
[3][3] = 1.0f
;
2005 exp_rotation
.w
= 0.195091f
;
2006 exp_rotation
.x
= 0.905395f
;
2007 exp_rotation
.y
= -0.323355f
;
2008 exp_rotation
.z
= -0.194013f
;
2010 exp_translation
.x
= -5.0f
;
2011 exp_translation
.y
= 0.0f
;
2012 exp_translation
.z
= 10.0f
;
2014 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2016 compare_scale(exp_scale
, got_scale
);
2017 compare_rotation(exp_rotation
, got_rotation
);
2018 compare_translation(exp_translation
, got_translation
);
2022 U(pm
).m
[0][0] = 0.06554436f
;
2023 U(pm
).m
[1][0] = -0.6873012f
;
2024 U(pm
).m
[2][0] = 0.7234092f
;
2025 U(pm
).m
[3][0] = -5.0f
;
2026 U(pm
).m
[0][1] = -0.9617381f
;
2027 U(pm
).m
[1][1] = -0.2367795f
;
2028 U(pm
).m
[2][1] = -0.1378230f
;
2029 U(pm
).m
[3][1] = 0.0f
;
2030 U(pm
).m
[0][2] = 0.2660144f
;
2031 U(pm
).m
[1][2] = -0.6866967f
;
2032 U(pm
).m
[2][2] = -0.6765233f
;
2033 U(pm
).m
[3][2] = 10.0f
;
2034 U(pm
).m
[0][3] = 0.0f
;
2035 U(pm
).m
[1][3] = 0.0f
;
2036 U(pm
).m
[2][3] = 0.0f
;
2037 U(pm
).m
[3][3] = 1.0f
;
2043 exp_rotation
.w
= -0.195091f
;
2044 exp_rotation
.x
= 0.703358f
;
2045 exp_rotation
.y
= -0.586131f
;
2046 exp_rotation
.z
= 0.351679f
;
2048 exp_translation
.x
= -5.0f
;
2049 exp_translation
.y
= 0.0f
;
2050 exp_translation
.z
= 10.0f
;
2052 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2054 compare_scale(exp_scale
, got_scale
);
2055 compare_rotation(exp_rotation
, got_rotation
);
2056 compare_translation(exp_translation
, got_translation
);
2060 U(pm
).m
[0][0] = 7.121047f
;
2061 U(pm
).m
[1][0] = -5.883487f
;
2062 U(pm
).m
[2][0] = 11.81843f
;
2063 U(pm
).m
[3][0] = -5.0f
;
2064 U(pm
).m
[0][1] = 5.883487f
;
2065 U(pm
).m
[1][1] = -10.60660f
;
2066 U(pm
).m
[2][1] = -8.825232f
;
2067 U(pm
).m
[3][1] = 0.0f
;
2068 U(pm
).m
[0][2] = 11.81843f
;
2069 U(pm
).m
[1][2] = 8.8252320f
;
2070 U(pm
).m
[2][2] = -2.727645f
;
2071 U(pm
).m
[3][2] = 2.0f
;
2072 U(pm
).m
[0][3] = 0.0f
;
2073 U(pm
).m
[1][3] = 0.0f
;
2074 U(pm
).m
[2][3] = 0.0f
;
2075 U(pm
).m
[3][3] = 1.0f
;
2077 exp_scale
.x
= 15.0f
;
2078 exp_scale
.y
= 15.0f
;
2079 exp_scale
.z
= 15.0f
;
2081 exp_rotation
.w
= 0.382684f
;
2082 exp_rotation
.x
= 0.768714f
;
2083 exp_rotation
.y
= 0.0f
;
2084 exp_rotation
.z
= 0.512476f
;
2086 exp_translation
.x
= -5.0f
;
2087 exp_translation
.y
= 0.0f
;
2088 exp_translation
.z
= 2.0f
;
2090 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2092 compare_scale(exp_scale
, got_scale
);
2093 compare_rotation(exp_rotation
, got_rotation
);
2094 compare_translation(exp_translation
, got_translation
);
2098 U(pm
).m
[0][0] = 0.0f
;
2099 U(pm
).m
[1][0] = 4.0f
;
2100 U(pm
).m
[2][0] = 5.0f
;
2101 U(pm
).m
[3][0] = -5.0f
;
2102 U(pm
).m
[0][1] = 0.0f
;
2103 U(pm
).m
[1][1] = -10.60660f
;
2104 U(pm
).m
[2][1] = -8.825232f
;
2105 U(pm
).m
[3][1] = 6.0f
;
2106 U(pm
).m
[0][2] = 0.0f
;
2107 U(pm
).m
[1][2] = 8.8252320f
;
2108 U(pm
).m
[2][2] = 2.727645;
2109 U(pm
).m
[3][2] = 3.0f
;
2110 U(pm
).m
[0][3] = 0.0f
;
2111 U(pm
).m
[1][3] = 0.0f
;
2112 U(pm
).m
[2][3] = 0.0f
;
2113 U(pm
).m
[3][3] = 1.0f
;
2115 hr
= D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2116 ok(hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %x\n", hr
);
2119 static void test_Matrix_Transformation2D(void)
2121 D3DXMATRIX exp_mat
, got_mat
;
2122 D3DXVECTOR2 rot_center
, sca
, sca_center
, trans
;
2125 rot_center
.x
= 3.0f
;
2126 rot_center
.y
= 4.0f
;
2131 sca_center
.x
= 9.0f
;
2132 sca_center
.y
= -5.0f
;
2139 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2141 U(exp_mat
).m
[0][0] = -4.245192f
;
2142 U(exp_mat
).m
[1][0] = -0.147116f
;
2143 U(exp_mat
).m
[2][0] = 0.0f
;
2144 U(exp_mat
).m
[3][0] = 45.265373f
;
2145 U(exp_mat
).m
[0][1] = 7.647113f
;
2146 U(exp_mat
).m
[1][1] = 8.745192f
;
2147 U(exp_mat
).m
[2][1] = 0.0f
;
2148 U(exp_mat
).m
[3][1] = -13.401899f
;
2149 U(exp_mat
).m
[0][2] = 0.0f
;
2150 U(exp_mat
).m
[1][2] = 0.0f
;
2151 U(exp_mat
).m
[2][2] = 1.0f
;
2152 U(exp_mat
).m
[3][2] = 0.0f
;
2153 U(exp_mat
).m
[0][3] = 0.0f
;
2154 U(exp_mat
).m
[1][3] = 0.0f
;
2155 U(exp_mat
).m
[2][3] = 0.0f
;
2156 U(exp_mat
).m
[3][3] = 1.0f
;
2158 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, &sca
, &rot_center
, rot
, &trans
);
2160 expect_mat(&exp_mat
, &got_mat
);
2164 sca_center
.x
= 9.0f
;
2165 sca_center
.y
= -5.0f
;
2172 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2174 U(exp_mat
).m
[0][0] = 0.50f
;
2175 U(exp_mat
).m
[1][0] = -0.866025f
;
2176 U(exp_mat
).m
[2][0] = 0.0f
;
2177 U(exp_mat
).m
[3][0] = -6.0f
;
2178 U(exp_mat
).m
[0][1] = 0.866025f
;
2179 U(exp_mat
).m
[1][1] = 0.50f
;
2180 U(exp_mat
).m
[2][1] = 0.0f
;
2181 U(exp_mat
).m
[3][1] = 7.0f
;
2182 U(exp_mat
).m
[0][2] = 0.0f
;
2183 U(exp_mat
).m
[1][2] = 0.0f
;
2184 U(exp_mat
).m
[2][2] = 1.0f
;
2185 U(exp_mat
).m
[3][2] = 0.0f
;
2186 U(exp_mat
).m
[0][3] = 0.0f
;
2187 U(exp_mat
).m
[1][3] = 0.0f
;
2188 U(exp_mat
).m
[2][3] = 0.0f
;
2189 U(exp_mat
).m
[3][3] = 1.0f
;
2191 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, NULL
, NULL
, rot
, &trans
);
2193 expect_mat(&exp_mat
, &got_mat
);
2197 U(exp_mat
).m
[0][0] = 0.50f
;
2198 U(exp_mat
).m
[1][0] = -0.866025f
;
2199 U(exp_mat
).m
[2][0] = 0.0f
;
2200 U(exp_mat
).m
[3][0] = 0.0f
;
2201 U(exp_mat
).m
[0][1] = 0.866025f
;
2202 U(exp_mat
).m
[1][1] = 0.50f
;
2203 U(exp_mat
).m
[2][1] = 0.0f
;
2204 U(exp_mat
).m
[3][1] = 0.0f
;
2205 U(exp_mat
).m
[0][2] = 0.0f
;
2206 U(exp_mat
).m
[1][2] = 0.0f
;
2207 U(exp_mat
).m
[2][2] = 1.0f
;
2208 U(exp_mat
).m
[3][2] = 0.0f
;
2209 U(exp_mat
).m
[0][3] = 0.0f
;
2210 U(exp_mat
).m
[1][3] = 0.0f
;
2211 U(exp_mat
).m
[2][3] = 0.0f
;
2212 U(exp_mat
).m
[3][3] = 1.0f
;
2214 D3DXMatrixTransformation2D(&got_mat
, NULL
, sca_rot
, NULL
, NULL
, rot
, NULL
);
2216 expect_mat(&exp_mat
, &got_mat
);
2219 static void test_D3DXVec_Array(void)
2222 D3DVIEWPORT9 viewport
;
2223 D3DXMATRIX mat
, projection
, view
, world
;
2224 D3DXVECTOR4 inp_vec
[ARRAY_SIZE
];
2225 D3DXVECTOR4 out_vec
[ARRAY_SIZE
+ 2];
2226 D3DXVECTOR4 exp_vec
[ARRAY_SIZE
+ 2];
2227 D3DXPLANE inp_plane
[ARRAY_SIZE
];
2228 D3DXPLANE out_plane
[ARRAY_SIZE
+ 2];
2229 D3DXPLANE exp_plane
[ARRAY_SIZE
+ 2];
2231 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
2232 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
2234 for (i
= 0; i
< ARRAY_SIZE
+ 2; ++i
) {
2235 out_vec
[i
].x
= out_vec
[i
].y
= out_vec
[i
].z
= out_vec
[i
].w
= 0.0f
;
2236 exp_vec
[i
].x
= exp_vec
[i
].y
= exp_vec
[i
].z
= exp_vec
[i
].w
= 0.0f
;
2237 out_plane
[i
].a
= out_plane
[i
].b
= out_plane
[i
].c
= out_plane
[i
].d
= 0.0f
;
2238 exp_plane
[i
].a
= exp_plane
[i
].b
= exp_plane
[i
].c
= exp_plane
[i
].d
= 0.0f
;
2241 for (i
= 0; i
< ARRAY_SIZE
; ++i
) {
2242 inp_plane
[i
].a
= inp_plane
[i
].c
= inp_vec
[i
].x
= inp_vec
[i
].z
= i
;
2243 inp_plane
[i
].b
= inp_plane
[i
].d
= inp_vec
[i
].y
= inp_vec
[i
].w
= ARRAY_SIZE
- i
;
2246 U(mat
).m
[0][0] = 1.0f
; U(mat
).m
[0][1] = 2.0f
; U(mat
).m
[0][2] = 3.0f
; U(mat
).m
[0][3] = 4.0f
;
2247 U(mat
).m
[1][0] = 5.0f
; U(mat
).m
[1][1] = 6.0f
; U(mat
).m
[1][2] = 7.0f
; U(mat
).m
[1][3] = 8.0f
;
2248 U(mat
).m
[2][0] = 9.0f
; U(mat
).m
[2][1] = 10.0f
; U(mat
).m
[2][2] = 11.0f
; U(mat
).m
[2][3] = 12.0f
;
2249 U(mat
).m
[3][0] = 13.0f
; U(mat
).m
[3][1] = 14.0f
; U(mat
).m
[3][2] = 15.0f
; U(mat
).m
[3][3] = 16.0f
;
2251 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2253 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
2254 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
2255 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
2256 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
2257 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
2258 U(view
).m
[3][3] = -40.0f
;
2260 U(world
).m
[0][0] = 21.0f
; U(world
).m
[0][1] = 2.0f
; U(world
).m
[0][2] = 3.0f
; U(world
).m
[0][3] = 4.0;
2261 U(world
).m
[1][0] = 5.0f
; U(world
).m
[1][1] = 23.0f
; U(world
).m
[1][2] = 7.0f
; U(world
).m
[1][3] = 8.0f
;
2262 U(world
).m
[2][0] = -8.0f
; U(world
).m
[2][1] = -7.0f
; U(world
).m
[2][2] = 25.0f
; U(world
).m
[2][3] = -5.0f
;
2263 U(world
).m
[3][0] = -4.0f
; U(world
).m
[3][1] = -3.0f
; U(world
).m
[3][2] = -2.0f
; U(world
).m
[3][3] = 27.0f
;
2265 /* D3DXVec2TransformCoordArray */
2266 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
;
2267 exp_vec
[2].x
= 0.653846f
; exp_vec
[2].y
= 0.769231f
;
2268 exp_vec
[3].x
= 0.625f
; exp_vec
[3].y
= 0.75f
;
2269 exp_vec
[4].x
= 0.590909f
; exp_vec
[4].y
= 8.0f
/11.0f
;
2270 exp_vec
[5].x
= 0.55f
; exp_vec
[5].y
= 0.7f
;
2271 D3DXVec2TransformCoordArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2272 compare_vectors(exp_vec
, out_vec
);
2274 /* D3DXVec2TransformNormalArray */
2275 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
;
2276 exp_vec
[2].x
= 21.0f
; exp_vec
[2].y
= 26.0f
;
2277 exp_vec
[3].x
= 17.0f
; exp_vec
[3].y
= 22.0f
;
2278 exp_vec
[4].x
= 13.0f
; exp_vec
[4].y
= 18.0f
;
2279 exp_vec
[5].x
= 9.0f
; exp_vec
[5].y
= 14.0f
;
2280 D3DXVec2TransformNormalArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2281 compare_vectors(exp_vec
, out_vec
);
2283 /* D3DXVec3TransformCoordArray */
2284 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
; exp_vec
[1].z
= 0.892857f
;
2285 exp_vec
[2].x
= 0.671875f
; exp_vec
[2].y
= 0.78125f
; exp_vec
[2].z
= 0.890625f
;
2286 exp_vec
[3].x
= 6.0f
/9.0f
; exp_vec
[3].y
= 7.0f
/9.0f
; exp_vec
[3].z
= 8.0f
/9.0f
;
2287 exp_vec
[4].x
= 0.6625f
; exp_vec
[4].y
= 0.775f
; exp_vec
[4].z
= 0.8875f
;
2288 exp_vec
[5].x
= 0.659091f
; exp_vec
[5].y
= 0.772727f
; exp_vec
[5].z
= 0.886364f
;
2289 D3DXVec3TransformCoordArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2290 compare_vectors(exp_vec
, out_vec
);
2292 /* D3DXVec3TransformNormalArray */
2293 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
; exp_vec
[1].z
= 35.0f
;
2294 exp_vec
[2].x
= 30.0f
; exp_vec
[2].y
= 36.0f
; exp_vec
[2].z
= 42.0f
;
2295 exp_vec
[3].x
= 35.0f
; exp_vec
[3].y
= 42.0f
; exp_vec
[3].z
= 49.0f
;
2296 exp_vec
[4].x
= 40.0f
; exp_vec
[4].y
= 48.0f
; exp_vec
[4].z
= 56.0f
;
2297 exp_vec
[5].x
= 45.0f
; exp_vec
[5].y
= 54.0f
; exp_vec
[5].z
= 63.0f
;
2298 D3DXVec3TransformNormalArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2299 compare_vectors(exp_vec
, out_vec
);
2301 /* D3DXVec3ProjectArray */
2302 exp_vec
[1].x
= 1089.554199f
; exp_vec
[1].y
= -226.590622f
; exp_vec
[1].z
= 0.215273f
;
2303 exp_vec
[2].x
= 1068.903320f
; exp_vec
[2].y
= 103.085129f
; exp_vec
[2].z
= 0.183050f
;
2304 exp_vec
[3].x
= 1051.778931f
; exp_vec
[3].y
= 376.462250f
; exp_vec
[3].z
= 0.156329f
;
2305 exp_vec
[4].x
= 1037.348877f
; exp_vec
[4].y
= 606.827393f
; exp_vec
[4].z
= 0.133813f
;
2306 exp_vec
[5].x
= 1025.023560f
; exp_vec
[5].y
= 803.591248f
; exp_vec
[5].z
= 0.114581f
;
2307 D3DXVec3ProjectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2308 compare_vectors(exp_vec
, out_vec
);
2310 /* D3DXVec3UnprojectArray */
2311 exp_vec
[1].x
= -6.124031f
; exp_vec
[1].y
= 3.225360f
; exp_vec
[1].z
= 0.620571f
;
2312 exp_vec
[2].x
= -3.807109f
; exp_vec
[2].y
= 2.046579f
; exp_vec
[2].z
= 0.446894f
;
2313 exp_vec
[3].x
= -2.922839f
; exp_vec
[3].y
= 1.596689f
; exp_vec
[3].z
= 0.380609f
;
2314 exp_vec
[4].x
= -2.456225f
; exp_vec
[4].y
= 1.359290f
; exp_vec
[4].z
= 0.345632f
;
2315 exp_vec
[5].x
= -2.167897f
; exp_vec
[5].y
= 1.212597f
; exp_vec
[5].z
= 0.324019f
;
2316 D3DXVec3UnprojectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2317 compare_vectors(exp_vec
, out_vec
);
2319 /* D3DXVec2TransformArray */
2320 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2321 exp_vec
[2].x
= 34.0f
; exp_vec
[2].y
= 40.0f
; exp_vec
[2].z
= 46.0f
; exp_vec
[2].w
= 52.0f
;
2322 exp_vec
[3].x
= 30.0f
; exp_vec
[3].y
= 36.0f
; exp_vec
[3].z
= 42.0f
; exp_vec
[3].w
= 48.0f
;
2323 exp_vec
[4].x
= 26.0f
; exp_vec
[4].y
= 32.0f
; exp_vec
[4].z
= 38.0f
; exp_vec
[4].w
= 44.0f
;
2324 exp_vec
[5].x
= 22.0f
; exp_vec
[5].y
= 28.0f
; exp_vec
[5].z
= 34.0f
; exp_vec
[5].w
= 40.0f
;
2325 D3DXVec2TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2326 compare_vectors(exp_vec
, out_vec
);
2328 /* D3DXVec3TransformArray */
2329 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2330 exp_vec
[2].x
= 43.0f
; exp_vec
[2].y
= 50.0f
; exp_vec
[2].z
= 57.0f
; exp_vec
[2].w
= 64.0f
;
2331 exp_vec
[3].x
= 48.0f
; exp_vec
[3].y
= 56.0f
; exp_vec
[3].z
= 64.0f
; exp_vec
[3].w
= 72.0f
;
2332 exp_vec
[4].x
= 53.0f
; exp_vec
[4].y
= 62.0f
; exp_vec
[4].z
= 71.0f
; exp_vec
[4].w
= 80.0f
;
2333 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2334 D3DXVec3TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2335 compare_vectors(exp_vec
, out_vec
);
2337 /* D3DXVec4TransformArray */
2338 exp_vec
[1].x
= 90.0f
; exp_vec
[1].y
= 100.0f
; exp_vec
[1].z
= 110.0f
; exp_vec
[1].w
= 120.0f
;
2339 exp_vec
[2].x
= 82.0f
; exp_vec
[2].y
= 92.0f
; exp_vec
[2].z
= 102.0f
; exp_vec
[2].w
= 112.0f
;
2340 exp_vec
[3].x
= 74.0f
; exp_vec
[3].y
= 84.0f
; exp_vec
[3].z
= 94.0f
; exp_vec
[3].w
= 104.0f
;
2341 exp_vec
[4].x
= 66.0f
; exp_vec
[4].y
= 76.0f
; exp_vec
[4].z
= 86.0f
; exp_vec
[4].w
= 96.0f
;
2342 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2343 D3DXVec4TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2344 compare_vectors(exp_vec
, out_vec
);
2346 /* D3DXPlaneTransformArray */
2347 exp_plane
[1].a
= 90.0f
; exp_plane
[1].b
= 100.0f
; exp_plane
[1].c
= 110.0f
; exp_plane
[1].d
= 120.0f
;
2348 exp_plane
[2].a
= 82.0f
; exp_plane
[2].b
= 92.0f
; exp_plane
[2].c
= 102.0f
; exp_plane
[2].d
= 112.0f
;
2349 exp_plane
[3].a
= 74.0f
; exp_plane
[3].b
= 84.0f
; exp_plane
[3].c
= 94.0f
; exp_plane
[3].d
= 104.0f
;
2350 exp_plane
[4].a
= 66.0f
; exp_plane
[4].b
= 76.0f
; exp_plane
[4].c
= 86.0f
; exp_plane
[4].d
= 96.0f
;
2351 exp_plane
[5].a
= 58.0f
; exp_plane
[5].b
= 68.0f
; exp_plane
[5].c
= 78.0f
; exp_plane
[5].d
= 88.0f
;
2352 D3DXPlaneTransformArray(out_plane
+ 1, sizeof(D3DXPLANE
), inp_plane
, sizeof(D3DXPLANE
), &mat
, ARRAY_SIZE
);
2353 compare_planes(exp_plane
, out_plane
);
2356 static void test_D3DXFloat_Array(void)
2358 static const float z
= 0.0f
;
2359 /* Compilers set different sign bits on 0.0 / 0.0, pick the right ones for NaN and -NaN */
2360 float tmpnan
= 0.0f
/z
;
2361 float nnan
= copysignf(1, tmpnan
) < 0.0f
? tmpnan
: -tmpnan
;
2371 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
2372 WORD half_ver1
, half_ver2
;
2374 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
2375 FLOAT single_out_ver1
, single_out_ver2
;
2377 { 80000.0f
, 0x7c00, 0x7ce2, 65536.0f
, 80000.0f
},
2378 { 65503.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2379 { 65504.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2380 { 65520.0f
, 0x7bff, 0x7c00, 65504.0f
, 65536.0f
},
2381 { 65521.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2382 { 65534.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2383 { 65535.0f
, 0x7c00, 0x7c00, 65535.0f
, 65536.0f
},
2384 { 65536.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2385 { -80000.0f
, 0xfc00, 0xfce2, -65536.0f
, -80000.0f
},
2386 { -65503.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2387 { -65504.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2388 { -65520.0f
, 0xfbff, 0xfc00, -65504.0f
, -65536.0f
},
2389 { -65521.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2390 { -65534.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2391 { -65535.0f
, 0xfc00, 0xfc00, -65535.0f
, -65536.0f
},
2392 { -65536.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2393 { 1.0f
/z
, 0x7c00, 0x7fff, 65536.0f
, 131008.0f
},
2394 { -1.0f
/z
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2395 { nan
, 0x7fff, 0xffff, 131008.0f
, -131008.0f
},
2396 { nnan
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2397 { 0.0f
, 0x0, 0x0, 0.0f
, 0.0f
},
2398 { -0.0f
, 0x8000, 0x8000, 0.0f
, 0.0f
},
2399 { 2.9809595e-08f
, 0x0, 0x0, 0.0f
, 0.0f
},
2400 { -2.9809595e-08f
, 0x8000, 0x8000, -0.0f
, -0.0f
},
2401 { 2.9809598e-08f
, 0x1, 0x0, 5.96046e-08f
, 5.96046e-08f
},
2402 { -2.9809598e-08f
, 0x8001, 0x8000, -5.96046e-08f
, -5.96046e-08f
},
2403 { 8.9406967e-08f
, 0x2, 0x1, 1.19209e-07f
, 5.96046e-008 }
2406 /* exception on NULL out or in parameter */
2407 out
= D3DXFloat32To16Array(&half
, &single
, 0);
2408 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2410 out
= D3DXFloat16To32Array(&single
, &half
, 0);
2411 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2413 for (i
= 0; i
< sizeof(testdata
)/sizeof(testdata
[0]); i
++)
2415 out
= D3DXFloat32To16Array(&half
, &testdata
[i
].single_in
, 1);
2416 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2417 ok(half
.value
== testdata
[i
].half_ver1
|| half
.value
== testdata
[i
].half_ver2
,
2418 "Got %x, expected %x or %x for index %d.\n", half
.value
, testdata
[i
].half_ver1
,
2419 testdata
[i
].half_ver2
, i
);
2421 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver1
, 1);
2422 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2423 ok(relative_error(single
, testdata
[i
].single_out_ver1
) < admitted_error
,
2424 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver1
, i
);
2426 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver2
, 1);
2427 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2428 ok(relative_error(single
, testdata
[i
].single_out_ver2
) < admitted_error
,
2429 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver2
, i
);
2433 static void test_D3DXSHAdd(void)
2436 FLOAT
*ret
= (FLOAT
*)0xdeadbeef;
2437 const FLOAT in1
[50] =
2439 1.11f
, 1.12f
, 1.13f
, 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
,
2440 1.19f
, 1.20f
, 1.21f
, 1.22f
, 1.23f
, 1.24f
, 1.25f
, 1.26f
,
2441 1.27f
, 1.28f
, 1.29f
, 1.30f
, 1.31f
, 1.32f
, 1.33f
, 1.34f
,
2442 1.35f
, 1.36f
, 1.37f
, 1.38f
, 1.39f
, 1.40f
, 1.41f
, 1.42f
,
2443 1.43f
, 1.44f
, 1.45f
, 1.46f
, 1.47f
, 1.48f
, 1.49f
, 1.50f
,
2444 1.51f
, 1.52f
, 1.53f
, 1.54f
, 1.55f
, 1.56f
, 1.57f
, 1.58f
,
2447 const FLOAT in2
[50] =
2449 2.11f
, 2.12f
, 2.13f
, 2.14f
, 2.15f
, 2.16f
, 2.17f
, 2.18f
,
2450 2.19f
, 2.20f
, 2.21f
, 2.22f
, 2.23f
, 2.24f
, 2.25f
, 2.26f
,
2451 2.27f
, 2.28f
, 2.29f
, 2.30f
, 2.31f
, 2.32f
, 2.33f
, 2.34f
,
2452 2.35f
, 2.36f
, 2.37f
, 2.38f
, 2.39f
, 2.40f
, 2.41f
, 2.42f
,
2453 2.43f
, 2.44f
, 2.45f
, 2.46f
, 2.47f
, 2.48f
, 2.49f
, 2.50f
,
2454 2.51f
, 2.52f
, 2.53f
, 2.54f
, 2.55f
, 2.56f
, 2.57f
, 2.58f
,
2457 FLOAT out
[50] = {0.0f
};
2460 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
2461 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
2462 * Exceptions will show up when out, in1 or in2 is NULL
2464 for (k
= 0; k
<= D3DXSH_MAXORDER
+ 1; k
++)
2468 ret
= D3DXSHAdd(&out
[0], k
, &in1
[0], &in2
[0]);
2469 ok(ret
== out
, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k
, out
, ret
);
2471 for (i
= 0; i
< count
; ++i
)
2473 ok(relative_error(in1
[i
] + in2
[i
], out
[i
]) < admitted_error
,
2474 "%u-%u: D3DXSHAdd() failed, got %f, expected %f\n", k
, i
, out
[i
], in1
[i
] + in2
[i
]);
2476 ok(relative_error(out
[count
], 0.0f
) < admitted_error
, "%u-%u: D3DXSHAdd() failed, got %f, expected 0.0\n", k
, k
* k
, out
[count
]);
2480 static void test_D3DXSHDot(void)
2483 FLOAT a
[49], b
[49], got
;
2484 const FLOAT expected
[] =
2485 { 0.5f
, 0.5f
, 25.0f
, 262.5f
, 1428.0f
, 5362.0f
, 15873.0f
, 39812.0f
, };
2487 for (i
= 0; i
< 49; i
++)
2493 /* D3DXSHDot computes by using order * order elements */
2494 for (i
= 0; i
<= D3DXSH_MAXORDER
+ 1; i
++)
2496 got
= D3DXSHDot(i
, a
, b
);
2497 ok(relative_error(got
, expected
[i
]) < admitted_error
, "order %d: expected %f, received %f\n", i
, expected
[i
], got
);
2503 static void test_D3DXSHEvalConeLight(void)
2506 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2507 const FLOAT table
[] = {
2509 1.604815f
, -3.131381f
, 7.202175f
, -2.870432f
, 6.759296f
, -16.959688f
,
2510 32.303082f
, -15.546381f
, -0.588878f
, -5.902123f
, 40.084042f
, -77.423569f
,
2511 137.556320f
, -70.971603f
, -3.492171f
, 7.683092f
, -2.129311f
, -35.971344f
,
2512 183.086548f
, -312.414948f
, 535.091064f
, -286.380371f
, -15.950727f
, 46.825714f
,
2513 -12.127637f
, 11.289261f
, -12.417809f
, -155.039566f
, 681.182556f
, -1079.733643f
,
2514 1807.650513f
, -989.755798f
, -59.345467f
, 201.822815f
, -70.726486f
, 7.206529f
,
2516 3.101155f
, -3.128710f
, 7.196033f
, -2.867984f
, -0.224708f
, 0.563814f
,
2517 -1.073895f
, 0.516829f
, 0.019577f
, 2.059788f
, -13.988971f
, 27.020128f
,
2518 -48.005917f
, 24.768450f
, 1.218736f
, -2.681329f
, -0.088639f
, -1.497410f
,
2519 7.621501f
, -13.005165f
, 22.274696f
, -11.921401f
, -0.663995f
, 1.949254f
,
2520 -0.504848f
, 4.168484f
, -4.585193f
, -57.247314f
, 251.522095f
, -398.684387f
,
2521 667.462891f
, -365.460693f
, -21.912912f
, 74.521721f
, -26.115280f
, 2.660963f
,
2523 2.454422f
, -4.789170f
, 11.015091f
, -4.390072f
, 10.337747f
, -25.938347f
,
2524 49.404713f
, -23.776817f
, -0.900637f
, -9.026776f
, 61.305000f
, -118.412514f
,
2525 210.380249f
, -108.544792f
, -5.340967f
, 11.750610f
, -3.256593f
, -55.014996f
,
2526 280.014709f
, -477.811066f
, 818.374512f
, -437.993469f
, -24.395227f
, 71.615799f
,
2527 -18.548151f
, 17.265928f
, -18.991943f
, -237.119324f
, 1041.808594f
, -1651.357300f
,
2528 2764.642090f
, -1513.744141f
, -90.763657f
, 308.670197f
, -108.169922f
, 11.021750f
,
2530 4.742942f
, -4.785086f
, 11.005697f
, -4.386329f
, -0.343672f
, 0.862303f
,
2531 -1.642427f
, 0.790444f
, 0.029941f
, 3.150264f
, -21.394896f
, 41.324898f
,
2532 -73.420807f
, 37.881153f
, 1.863950f
, -4.100857f
, -0.135565f
, -2.290156f
,
2533 11.656413f
, -19.890251f
, 34.067181f
, -18.232729f
, -1.015521f
, 2.981212f
,
2534 -0.772120f
, 6.375328f
, -7.012648f
, -87.554710f
, 384.680817f
, -609.752563f
,
2535 1020.825500f
, -558.939819f
, -33.513863f
, 113.974388f
, -39.941013f
, 4.069707f
,
2537 3.304030f
, -6.446959f
, 14.828006f
, -5.909713f
, 13.916198f
, -34.917004f
,
2538 66.506340f
, -32.007256f
, -1.212396f
, -12.151429f
, 82.525963f
, -159.401459f
,
2539 283.204193f
, -146.117996f
, -7.189764f
, 15.818130f
, -4.383876f
, -74.058655f
,
2540 376.942871f
, -643.207214f
, 1101.658081f
, -589.606628f
, -32.839729f
, 96.405884f
,
2541 -24.968664f
, 23.242596f
, -25.566080f
, -319.199097f
, 1402.434692f
, -2222.980957f
,
2542 3721.633545f
, -2037.732544f
, -122.181847f
, 415.517578f
, -145.613358f
, 14.836972f
,
2544 6.384730f
, -6.441462f
, 14.815362f
, -5.904673f
, -0.462635f
, 1.160793f
,
2545 -2.210959f
, 1.064060f
, 0.040305f
, 4.240739f
, -28.800821f
, 55.629673f
,
2546 -98.835709f
, 50.993862f
, 2.509163f
, -5.520384f
, -0.182491f
, -3.082903f
,
2547 15.691326f
, -26.775339f
, 45.859665f
, -24.544060f
, -1.367048f
, 4.013170f
,
2548 -1.039392f
, 8.582172f
, -9.440103f
, -117.862114f
, 517.839600f
, -820.820740f
,
2549 1374.188232f
, -752.419067f
, -45.114819f
, 153.427063f
, -53.766754f
, 5.478452f
, };
2552 FLOAT
*red_received
, *green_received
, *blue_received
;
2553 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2554 FLOAT radius
, roffset
, goffset
, boffset
;
2556 { rout
, gout
, bout
, table
, &table
[72], &table
[144], 0.5f
, 1.01f
, 1.02f
, 1.03f
, },
2557 { rout
, gout
, bout
, &table
[36], &table
[108], &table
[180], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
2558 { rout
, rout
, rout
, &table
[144], &table
[144], &table
[144], 0.5f
, 1.03f
, 1.03f
, 1.03f
, },
2559 { rout
, rout
, bout
, &table
[72], &table
[72], &table
[144], 0.5, 1.02f
, 1.02f
, 1.03f
, },
2560 { rout
, gout
, gout
, table
, &table
[144], &table
[144], 0.5f
, 1.01f
, 1.03f
, 1.03f
, },
2561 { rout
, gout
, rout
, &table
[144], &table
[72], &table
[144], 0.5f
, 1.03f
, 1.02f
, 1.03f
, },
2562 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
2563 { rout
, NULL
, bout
, table
, NULL
, &table
[144], 0.5f
, 1.01f
, 0.0f
, 1.03f
, },
2564 { rout
, gout
, NULL
, table
, &table
[72], NULL
, 0.5f
, 1.01f
, 1.02f
, 0.0f
, },
2565 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 0.5f
, 1.01f
, 0.0f
, 0.0f
, }, };
2567 unsigned int j
, l
, order
;
2569 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2571 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2573 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2575 for (j
= 0; j
< 49; j
++)
2577 test
[l
].red_received
[j
] = 1.01f
+ j
;
2578 if (test
[l
].green_received
)
2579 test
[l
].green_received
[j
] = 1.02f
+ j
;
2580 if (test
[l
].blue_received
)
2581 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2584 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
);
2585 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2587 for (j
= 0; j
< 49; j
++)
2589 if (j
>= order
* order
)
2590 expected
= j
+ test
[l
].roffset
;
2592 expected
= test
[l
].red_expected
[j
];
2593 ok(relative_error(expected
, test
[l
].red_received
[j
]) < admitted_error
,
2594 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2596 if (test
[l
].green_received
)
2598 if (j
>= order
* order
)
2599 expected
= j
+ test
[l
].goffset
;
2601 expected
= test
[l
].green_expected
[j
];
2602 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2603 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2606 if (test
[l
].blue_received
)
2608 if (j
>= order
* order
)
2609 expected
= j
+ test
[l
].boffset
;
2611 expected
= test
[l
].blue_expected
[j
];
2612 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2613 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2619 /* Cone light with radius <= 0.0f behaves as a directional light */
2620 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2622 FLOAT blue
[49], green
[49], red
[49];
2624 for (j
= 0; j
< 49; j
++)
2626 rout
[j
] = 1.01f
+ j
;
2627 gout
[j
] = 1.02f
+ j
;
2628 bout
[j
] = 1.03f
+ j
;
2630 green
[j
] = 1.02f
+ j
;
2631 blue
[j
] = 1.03f
+ j
;
2634 hr
= D3DXSHEvalConeLight(order
, &dir
, -0.1f
, 1.7f
, 2.6f
, 3.5f
, rout
, gout
, bout
);
2635 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2636 D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red
, green
, blue
);
2638 for (j
= 0; j
< 49; j
++)
2641 ok(relative_error(expected
, rout
[j
]) < admitted_error
,
2642 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, rout
[j
]);
2644 expected
= green
[j
];
2645 ok(relative_error(expected
, gout
[j
]) < admitted_error
,
2646 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, gout
[j
]);
2649 ok(relative_error(expected
, bout
[j
]) < admitted_error
,
2650 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, bout
[j
]);
2654 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
2655 hr
= D3DXSHEvalConeLight(7, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2656 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2657 hr
= D3DXSHEvalConeLight(0, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2658 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2659 hr
= D3DXSHEvalConeLight(1, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2660 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2663 static void test_D3DXSHEvalDirection(void)
2665 unsigned int i
, order
;
2667 FLOAT a
[49], expected
[49], *received_ptr
;
2668 const FLOAT table
[36] =
2669 { 0.282095f
, -0.977205f
, 1.465808f
, -0.488603f
, 2.185097f
, -6.555291f
,
2670 8.200181f
, -3.277646f
, -1.638823f
, 1.180087f
, 17.343668f
, -40.220032f
,
2671 47.020218f
, -20.110016f
, -13.007751f
, 6.490479f
, -15.020058f
, 10.620785f
,
2672 117.325661f
, -240.856750f
, 271.657288f
, -120.428375f
, -87.994247f
, 58.414314f
,
2673 -4.380850f
, 24.942520f
, -149.447693f
, 78.278130f
, 747.791748f
, -1427.687866f
,
2674 1574.619141, -713.843933f
, -560.843811f
, 430.529724, -43.588909, -26.911665, };
2676 d
.x
= 1.0; d
.y
= 2.0f
; d
.z
= 3.0f
;
2678 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2680 for (i
= 0; i
< 49; i
++)
2683 received_ptr
= D3DXSHEvalDirection(a
, order
, &d
);
2684 ok(received_ptr
== a
, "Expected %p, received %p\n", a
, received_ptr
);
2686 for (i
= 0; i
< 49; i
++)
2688 /* if the order is < D3DXSH_MINORDER or order > D3DXSH_MAXORDER or the index of the element is greater than order * order - 1, D3DXSHEvalDirection does not modify the output */
2689 if ( (order
< D3DXSH_MINORDER
) || (order
> D3DXSH_MAXORDER
) || (i
>= order
* order
) )
2690 expected
[i
] = 1.5f
+ i
;
2692 expected
[i
] = table
[i
];
2694 ok(relative_error(a
[i
], expected
[i
]) < admitted_error
, "order %u, index %u: expected %f, received %f\n", order
, i
, expected
[i
], a
[i
]);
2699 static void test_D3DXSHEvalDirectionalLight(void)
2702 FLOAT
*blue_out
, bout
[49], expected
, gout
[49], *green_out
, *red_out
, rout
[49];
2703 static const FLOAT table
[] = {
2705 2.008781f
, -4.175174f
, 9.602900f
, -3.827243f
, 1.417963f
, -2.947181f
,
2706 6.778517f
, -2.701583f
, 7.249108f
, -18.188671f
, 34.643921f
, -16.672949f
,
2707 -0.631551f
, 1.417963f
, -2.947181f
, 6.778517f
, -2.701583f
, 7.249108f
,
2708 -18.188671f
, 34.643921f
, -16.672949f
, -0.631551f
, -7.794341f
, 52.934967f
,
2709 -102.245529f
, 181.656815f
, -93.725060f
, -4.611760f
, 10.146287f
, 1.555186f
,
2710 -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
, 37.996559f
,
2711 -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
, 199.236496f
,
2712 -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
, 360.268829f
,
2713 -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
, -23.864176f
,
2714 1.555186f
, -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
,
2715 37.996559f
, -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
,
2716 199.236496f
, -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
,
2717 360.268829f
, -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
,
2718 -23.864176f
, 34.868664f
, -38.354366f
, -478.864166f
, 2103.939941f
, -3334.927734f
,
2719 5583.213867f
, -3057.017090f
, -183.297836f
, 623.361633f
, -218.449921f
, 22.258503f
,
2721 3.072254f
, -6.385560f
, 14.686787f
, -5.853429f
, 2.168650f
, -4.507453f
,
2722 10.367143f
, -4.131832f
, 11.086870f
, -27.817965f
, 52.984818f
, -25.499800f
,
2723 -0.965902f
, 2.168650f
, -4.507453f
, 10.367143f
, -4.131832f
, 11.086870f
,
2724 -27.817965f
, 52.984818f
, -25.499800f
, -0.965902f
, -11.920755f
, 80.959351f
,
2725 -156.375488f
, 277.828033f
, -143.344193f
, -7.053278f
, 15.517849f
, 2.378519f
,
2726 -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
, 58.112385f
,
2727 -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
, 304.714630f
,
2728 -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
, 550.999390f
,
2729 -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
, -36.498150f
,
2730 2.378519f
, -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
,
2731 58.112385f
, -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
,
2732 304.714630f
, -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
,
2733 550.999390f
, -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
,
2734 -36.498150f
, 53.328545f
, -58.659618f
, -732.380493f
, 3217.790283f
, -5100.477539f
,
2735 8539.033203f
, -4675.437500f
, -280.337860f
, 953.376587f
, -334.099884f
, 34.042416f
,
2737 4.135726f
, -8.595945f
, 19.770674f
, -7.879617f
, 2.919336f
, -6.067726f
,
2738 13.955770f
, -5.562082f
, 14.924634f
, -37.447262f
, 71.325722f
, -34.326656f
,
2739 -1.300252f
, 2.919336f
, -6.067726f
, 13.955770f
, -5.562082f
, 14.924634f
,
2740 -37.447262f
, 71.325722f
, -34.326656f
, -1.300252f
, -16.047173f
, 108.983749f
,
2741 -210.505493f
, 373.999298f
, -192.963348f
, -9.494799f
, 20.889414f
, 3.201853f
,
2742 -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
, 78.228210f
,
2743 -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
, 410.192780f
,
2744 -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
, 741.729919f
,
2745 -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
, -49.132126f
,
2746 3.201853f
, -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
,
2747 78.228210f
, -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
,
2748 410.192780f
, -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
,
2749 741.729919f
, -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
,
2750 -49.132126f
, 71.788422f
, -78.964867f
, -985.896790f
, 4331.640625f
, -6866.027344f
,
2751 11494.852539f
, -6293.858398f
, -377.377899f
, 1283.391479f
, -449.749817f
, 45.826328f
, };
2754 FLOAT
*red_in
, *green_in
, *blue_in
;
2755 const FLOAT
*red_out
, *green_out
, *blue_out
;
2756 FLOAT roffset
, goffset
, boffset
;
2758 { { rout
, gout
, bout
, table
, &table
[90], &table
[180], 1.01f
, 1.02f
, 1.03f
, },
2759 { rout
, rout
, rout
, &table
[180], &table
[180], &table
[180], 1.03f
, 1.03f
, 1.03f
, },
2760 { rout
, rout
, bout
, &table
[90], &table
[90], &table
[180], 1.02f
, 1.02f
, 1.03f
, },
2761 { rout
, gout
, gout
, table
, &table
[180], &table
[180], 1.01f
, 1.03f
, 1.03f
, },
2762 { rout
, gout
, rout
, &table
[180], &table
[90], &table
[180], 1.03f
, 1.02f
, 1.03f
, },
2763 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
2764 { rout
, NULL
, bout
, table
, NULL
, &table
[180], 1.01f
, 0.0f
, 1.03f
, },
2765 { rout
, gout
, NULL
, table
, &table
[90], NULL
, 1.01f
, 1.02f
, 0.0f
, },
2766 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 0.0f
, 0.0f
, }, };
2768 unsigned int j
, l
, order
, startindex
;
2770 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2772 for (l
= 0; l
< sizeof( test
) / sizeof( test
[0] ); l
++)
2776 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2778 red_out
= test
[l
].red_in
;
2779 green_out
= test
[l
].green_in
;
2780 blue_out
= test
[l
].blue_in
;
2782 for (j
= 0; j
< 49; j
++)
2784 red_out
[j
] = 1.01f
+ j
;
2786 green_out
[j
] = 1.02f
+ j
;
2788 blue_out
[j
] = 1.03f
+ j
;
2791 hr
= D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red_out
, green_out
, blue_out
);
2792 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2794 for (j
= 0; j
< 49; j
++)
2796 if ( j
>= order
* order
)
2797 expected
= j
+ test
[l
].roffset
;
2799 expected
= test
[l
].red_out
[startindex
+ j
];
2800 ok(relative_error(expected
, red_out
[j
]) < admitted_error
,
2801 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, red_out
[j
]);
2805 if ( j
>= order
* order
)
2806 expected
= j
+ test
[l
].goffset
;
2808 expected
= test
[l
].green_out
[startindex
+ j
];
2809 ok(relative_error(expected
, green_out
[j
]) < admitted_error
,
2810 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, green_out
[j
]);
2815 if ( j
>= order
* order
)
2816 expected
= j
+ test
[l
].boffset
;
2818 expected
= test
[l
].blue_out
[startindex
+ j
];
2819 ok(relative_error(expected
, blue_out
[j
]) < admitted_error
,
2820 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, blue_out
[j
]);
2824 startindex
+= order
* order
;
2828 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
2829 hr
= D3DXSHEvalDirectionalLight(7, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2830 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2831 hr
= D3DXSHEvalDirectionalLight(0, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2832 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2833 hr
= D3DXSHEvalDirectionalLight(1, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2834 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2837 static void test_D3DXSHEvalHemisphereLight(void)
2839 D3DXCOLOR bottom
, top
;
2841 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2842 const FLOAT table
[] = {
2844 23.422981f
, 15.859521f
, -36.476898f
, 14.537894f
,
2846 19.966694f
, 6.096982f
, -14.023058f
, 5.588900f
,
2848 24.566214f
, 8.546826f
, -19.657701f
, 7.834591f
, };
2851 FLOAT
*red_received
, *green_received
, *blue_received
;
2852 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2853 const FLOAT roffset
, goffset
, boffset
;
2855 { rout
, gout
, bout
, table
, &table
[4], &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2856 { rout
, rout
, rout
, &table
[8], &table
[8], &table
[8], 1.03f
, 1.03f
, 1.03f
, },
2857 { rout
, rout
, bout
, &table
[4], &table
[4], &table
[8], 1.02f
, 1.02f
, 1.03f
, },
2858 { rout
, gout
, gout
, table
, &table
[8], &table
[8], 1.01f
, 1.03f
, 1.03f
, },
2859 { rout
, gout
, rout
, &table
[8], &table
[4], &table
[8], 1.03f
, 1.02f
, 1.03f
, },
2860 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
2861 { rout
, NULL
, bout
, table
, NULL
, &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2862 { rout
, gout
, NULL
, table
, &table
[4], NULL
, 1.01f
, 1.02f
, 1.03f
, },
2863 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 1.02f
, 1.03f
, }, };
2865 unsigned int j
, l
, order
;
2867 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2868 top
.r
= 0.1f
; top
.g
= 2.1f
; top
.b
= 2.3f
; top
.a
= 4.3f
;
2869 bottom
.r
= 8.71f
; bottom
.g
= 5.41f
; bottom
.b
= 6.94f
; bottom
.a
= 8.43f
;
2871 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2872 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2874 for (j
= 0; j
< 49; j
++)
2876 test
[l
].red_received
[j
] = 1.01f
+ j
;
2877 if (test
[l
].green_received
)
2878 test
[l
].green_received
[j
] = 1.02f
+ j
;
2879 if (test
[l
].blue_received
)
2880 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2883 hr
= D3DXSHEvalHemisphereLight(order
, &dir
, top
, bottom
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
2884 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2886 for (j
= 0; j
< 49; j
++)
2889 expected
= test
[l
].red_expected
[j
];
2890 else if (j
< order
* order
)
2893 expected
= test
[l
].roffset
+ j
;
2894 ok(relative_error(test
[l
].red_received
[j
], expected
) < admitted_error
,
2895 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2897 if (test
[l
].green_received
)
2900 expected
= test
[l
].green_expected
[j
];
2901 else if (j
< order
* order
)
2904 expected
= test
[l
].goffset
+ j
;
2905 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2906 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2909 if (test
[l
].blue_received
)
2912 expected
= test
[l
].blue_expected
[j
];
2913 else if (j
< order
* order
)
2916 expected
= test
[l
].boffset
+ j
;
2917 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2918 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2924 static void test_D3DXSHEvalSphericalLight(void)
2927 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2928 const FLOAT table
[] = {
2930 3.01317239f
, -0.97724032f
, 2.24765277f
, -0.89580363f
, 0.0f
, 0.0f
,
2931 0.0f
, 0.0f
, 0.0f
, 0.06292814f
, -0.42737406f
, 0.61921263f
,
2932 -0.30450898f
, 0.56761158f
, 0.03723336f
, -0.08191673f
, 0.0f
, 0.0f
,
2933 0.0f
, 0.0f
, 0.0f
, -0.0f
, 0.0f
, 0.0f
,
2934 0.0f
, 0.01249927f
, -0.01374878f
, -0.14810932f
, 0.43434596f
, -0.24598616f
,
2935 -0.15175794f
, -0.22548729f
, -0.03784076f
, 0.19280137f
, -0.07830712f
, 0.00797894f
,
2937 0.40251964f
, -0.24365333f
, 0.56040263f
, -0.22334887f
, 0.16204689f
, -0.40659040f
,
2938 0.44600141f
, -0.37270784f
, -0.01411773f
, -0.04319951f
, 0.29338786f
, -0.42508304f
,
2939 0.20904225f
, -0.38965943f
, -0.02556031f
, 0.05623499f
, -0.00468823f
, -0.07920021f
,
2940 0.33171222f
, -0.30782884f
, 0.00052908f
, -0.28217643f
, -0.02889918f
, 0.10309891f
,
2941 -0.02670213f
, 0.00724340f
, -0.00796750f
, -0.08583023f
, 0.25170606f
, -0.14255044f
,
2942 -0.08794463f
, -0.13067122f
, -0.02192894f
, 0.11172954f
, -0.04537944f
, 0.00462384f
,
2944 1.95445275f
, -0.85659367f
, 1.97016549f
, -0.78521085f
, 0.23103346f
, -0.57968396f
,
2945 0.63587302f
, -0.53137696f
, -0.02012792f
, 0.02111043f
, -0.14337072f
, 0.20772660f
,
2946 -0.10215330f
, 0.19041604f
, 0.01249063f
, -0.02748052f
, 0.00633162f
, 0.10696279f
,
2947 -0.44798949f
, 0.41573414f
, -0.00071454f
, 0.38108963f
, 0.03902940f
, -0.13923886f
,
2948 0.03606220f
, -0.00447360f
, 0.00492081f
, 0.05300967f
, -0.15545636f
, 0.08804068f
,
2949 0.05431554f
, 0.08070395f
, 0.01354355f
, -0.06900536f
, 0.02802683f
, -0.00285574f
,
2951 4.60838127f
, -1.49460280f
, 3.43758631f
, -1.37005258f
, 0.0f
, 0.0f
,
2952 0.0f
, 0.0f
, 0.0f
, 0.09624302f
, -0.65363091f
, 0.94703102f
,
2953 -0.46571958f
, 0.86811179f
, 0.05694513f
, -0.12528442f
, -0.0f
, 0.0f
,
2954 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2955 0.0f
, 0.01911653f
, -0.02102755f
, -0.22652012f
, 0.66429377f
, -0.37621412f
,
2956 -0.23210037f
, -0.34486291f
, -0.05787410f
, 0.29487267f
, -0.11976383f
, 0.01220309f
,
2958 0.61561823f
, -0.37264627f
, 0.85708636f
, -0.34159240f
, 0.24783641f
, -0.62184411f
,
2959 0.68211979f
, -0.57002378f
, -0.02159182f
, -0.06606984f
, 0.44871080f
, -0.65012693f
,
2960 0.31971166f
, -0.59594971f
, -0.03909224f
, 0.08600645f
, -0.00717023f
, -0.12112973f
,
2961 0.50732452f
, -0.47079703f
, 0.00080918f
, -0.43156394f
, -0.04419874f
, 0.15768069f
,
2962 -0.04083854f
, 0.01107814f
, -0.01218559f
, -0.13126975f
, 0.38496217f
, -0.21801829f
,
2963 -0.13450353f
, -0.19985008f
, -0.03353838f
, 0.17088045f
, -0.06940385f
, 0.00707176f
,
2965 2.98916292f
, -1.31008446f
, 3.01319408f
, -1.20091069f
, 0.35334525f
, -0.88657540f
,
2966 0.97251165f
, -0.81269407f
, -0.03078388f
, 0.03228654f
, -0.21927285f
, 0.31769949f
,
2967 -0.15623444f
, 0.29122451f
, 0.01910332f
, -0.04202903f
, 0.00968366f
, 0.16359015f
,
2968 -0.68516040f
, 0.63582867f
, -0.00109283f
, 0.58284295f
, 0.05969203f
, -0.21295355f
,
2969 0.05515395f
, -0.00684198f
, 0.00752595f
, 0.08107361f
, -0.23775679f
, 0.13465045f
,
2970 0.08307083f
, 0.12342957f
, 0.02071366f
, -0.10553761f
, 0.04286456f
, -0.00436760f
,
2972 6.20359039f
, -2.01196527f
, 4.62752008f
, -1.84430146f
, 0.0f
, 0.0f
,
2973 0.0f
, 0.0f
, 0.0f
, 0.12955792f
, -0.87988776f
, 1.27484941f
,
2974 -0.62693024f
, 1.16861200f
, 0.07665691f
, -0.16865209f
, 0.0f
, 0.0f
,
2975 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2976 0.0f
, 0.02573379f
, -0.02830632f
, -0.30493096f
, 0.89424169f
, -0.50644207f
,
2977 -0.31244281f
, -0.46423855f
, -0.07790744f
, 0.39694402f
, -0.16122055f
, 0.01642723f
,
2979 0.82871687f
, -0.50163919f
, 1.15377009f
, -0.45983589f
, 0.33362597f
, -0.83709794f
,
2980 0.91823828f
, -0.76733971f
, -0.02906591f
, -0.08894017f
, 0.60403383f
, -0.87517095f
,
2981 0.43038112f
, -0.80224001f
, -0.05262417f
, 0.11577792f
, -0.00965224f
, -0.16305926f
,
2982 0.68293691f
, -0.63376528f
, 0.00108928f
, -0.58095151f
, -0.05949831f
, 0.21226248f
,
2983 -0.05497497f
, 0.01491288f
, -0.01640368f
, -0.17670928f
, 0.51821834f
, -0.29348618f
,
2984 -0.18106246f
, -0.26902896f
, -0.04514782f
, 0.23003140f
, -0.09342826f
, 0.00951968f
,
2986 4.02387333f
, -1.76357520f
, 4.05622292f
, -1.61661065f
, 0.47565711f
, -1.19346702f
,
2987 1.30915034f
, -1.09401131f
, -0.04143983f
, 0.04346266f
, -0.29517499f
, 0.42767239f
,
2988 -0.21031560f
, 0.39203301f
, 0.02571601f
, -0.05657754f
, 0.01303570f
, 0.22021750f
,
2989 -0.92233127f
, 0.85592318f
, -0.00147112f
, 0.78459626f
, 0.08035465f
, -0.28666824f
,
2990 0.07424571f
, -0.00921036f
, 0.01013109f
, 0.10913756f
, -0.32005721f
, 0.18126021f
,
2991 0.11182612f
, 0.16615519f
, 0.02788378f
, -0.14206986f
, 0.05770230f
, -0.00587946f
, };
2994 FLOAT
*red_received
, *green_received
, *blue_received
;
2995 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2996 FLOAT radius
, roffset
, goffset
, boffset
;
2998 { rout
, gout
, bout
, table
, &table
[108], &table
[216], 17.4f
, 1.01f
, 1.02f
, 1.03f
, },
2999 { rout
, gout
, bout
, &table
[36], &table
[144], &table
[252], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
3000 { rout
, gout
, bout
, &table
[72], &table
[180], &table
[288], -3.0f
, 1.01f
, 1.02f
, 1.03f
, },
3001 { rout
, rout
, rout
, &table
[216], &table
[216], &table
[216], 17.4f
, 1.03f
, 1.03f
, 1.03f
, },
3002 { rout
, rout
, bout
, &table
[108], &table
[108], &table
[216], 17.4, 1.02f
, 1.02f
, 1.03f
, },
3003 { rout
, gout
, gout
, table
, &table
[216], &table
[216], 17.4f
, 1.01f
, 1.03f
, 1.03f
, },
3004 { rout
, gout
, rout
, &table
[216], &table
[108], &table
[216], 17.4f
, 1.03f
, 1.02f
, 1.03f
, },
3005 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
3006 { rout
, NULL
, bout
, table
, NULL
, &table
[216], 17.4f
, 1.01f
, 0.0f
, 1.03f
, },
3007 { rout
, gout
, NULL
, table
, &table
[108], NULL
, 17.4f
, 1.01f
, 1.02f
, 0.0f
, },
3008 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 17.4f
, 1.01f
, 0.0f
, 0.0f
, }, };
3010 unsigned int j
, l
, order
;
3012 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3014 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
3016 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3018 for (j
= 0; j
< 49; j
++)
3020 test
[l
].red_received
[j
] = 1.01f
+ j
;
3021 if (test
[l
].green_received
)
3022 test
[l
].green_received
[j
] = 1.02f
+ j
;
3023 if (test
[l
].blue_received
)
3024 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3027 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
);
3028 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3030 for (j
= 0; j
< 49; j
++)
3032 if (j
>= order
* order
)
3033 expected
= j
+ test
[l
].roffset
;
3035 expected
= test
[l
].red_expected
[j
];
3036 ok(relative_error(expected
, test
[l
].red_received
[j
]) < 0.0005f
,
3037 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3039 if (test
[l
].green_received
)
3041 if (j
>= order
* order
)
3042 expected
= j
+ test
[l
].goffset
;
3044 expected
= test
[l
].green_expected
[j
];
3045 ok(relative_error(expected
, test
[l
].green_received
[j
]) < 0.0005f
,
3046 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3049 if (test
[l
].blue_received
)
3051 if (j
>= order
* order
)
3052 expected
= j
+ test
[l
].boffset
;
3054 expected
= test
[l
].blue_expected
[j
];
3055 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < 0.0005f
,
3056 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3062 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3063 hr
= D3DXSHEvalSphericalLight(7, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3064 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3065 hr
= D3DXSHEvalSphericalLight(0, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3066 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3067 hr
= D3DXSHEvalSphericalLight(1, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3068 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3071 static void test_D3DXSHMultiply2(void)
3074 FLOAT a
[20], b
[20], c
[20];
3075 /* D3DXSHMultiply2 only modifies the first 4 elements of the array */
3076 const FLOAT expected
[20] =
3077 { 3.418594f
, 1.698211f
, 1.703853f
, 1.709494f
, 4.0f
, 5.0f
,
3078 6.0f
, 7.0f
, 8.0f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3079 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
};
3081 for (i
= 0; i
< 20; i
++)
3083 a
[i
] = 1.0f
+ i
/ 100.0f
;
3084 b
[i
] = 3.0f
- i
/ 100.0f
;
3088 D3DXSHMultiply2(c
, a
, b
);
3089 for (i
= 0; i
< 20; i
++)
3090 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3093 static void test_D3DXSHMultiply3(void)
3096 FLOAT a
[20], b
[20], c
[20];
3097 /* D3DXSHMultiply3 only modifies the first 9 elements of the array */
3098 const FLOAT expected
[20] =
3099 { 7.813913f
, 2.256058f
, 5.9484005f
, 4.970894f
, 2.899858f
, 3.598946f
,
3100 1.726572f
, 5.573538f
, 0.622063f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3101 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
};
3103 for (i
= 0; i
< 20; i
++)
3105 a
[i
] = 1.0f
+ i
/ 100.0f
;
3106 b
[i
] = 3.0f
- i
/ 100.0f
;
3110 D3DXSHMultiply3(c
, a
, b
);
3111 for (i
= 0; i
< 20; i
++)
3112 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3115 static void test_D3DXSHMultiply4(void)
3118 FLOAT a
[20], b
[20], c
[20];
3119 /* D3DXSHMultiply4 only modifies the first 16 elements of the array */
3120 const FLOAT expected
[] =
3122 14.182599f
, 2.615703f
, 12.828601f
, 9.820596f
, 3.039696f
, 4.530442f
,
3123 5.820584f
, 12.249846f
, 2.194346f
, 3.900152f
, 5.416609f
, 5.601813f
,
3124 0.959982f
, 7.037550f
, 3.625230f
, 0.463601f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3126 -211441.265625f
, -2529.157715f
, -10023.393555f
, -441.277191f
, -163.994385f
,
3127 -526.305115f
, 29636.187500f
, -3931.830811f
, -13577.111328f
, -3978.973877f
,
3128 -10330.341797f
, -13779.787109f
, -16685.109375f
, -44981.375000f
, -73269.742188f
,
3129 -95237.335938f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3131 0.236682f
, -0.717649f
, -0.180500f
, -0.077124f
, 0.144831f
, 0.573286f
,
3132 -0.337959f
, 0.055694f
, -0.442100f
, 0.147702f
, -0.055157f
, 0.084337f
,
3133 0.179877f
, 0.009099f
, 0.232200f
, 0.074142f
, 1.6f
, 1.7f
, 1.8f
, 1.9f
, };
3135 for (i
= 0; i
< 20; i
++)
3137 a
[i
] = 1.0f
+ i
/ 100.0f
;
3138 b
[i
] = 3.0f
- i
/ 100.0f
;
3142 D3DXSHMultiply4(c
, a
, b
);
3143 for (i
= 0; i
< 20; i
++)
3144 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3146 for (i
= 0; i
< 20; i
++)
3148 b
[i
] = 3.0f
- i
/ 100.0f
;
3152 D3DXSHMultiply4(c
, c
, b
);
3153 for (i
= 0; i
< 20; i
++)
3154 ok(relative_error(c
[i
], expected
[20 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[20 + i
], c
[i
]);
3156 for (i
= 0; i
< 20; i
++)
3159 D3DXSHMultiply4(c
, c
, c
);
3160 for (i
= 0; i
< 20; i
++)
3161 ok(relative_error(c
[i
], expected
[40 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[40 + i
], c
[i
]);
3164 static void test_D3DXSHRotate(void)
3167 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3168 static const FLOAT table
[]=
3169 { /* Rotation around X-axis Pi/2 */
3170 1.01f
, -3.01f
, 2.01f
, 4.01f
, -8.01f
, -6.01f
,
3171 -11.307890f
, 5.01f
, -1.565839f
, 1.093598f
, -11.01f
, 19.833414f
,
3172 -15.268191f
, -19.004118f
, -3.364889f
, -9.562627f
, 12.099654f
, -0.272131f
,
3173 30.241013f
, 26.919991f
, 39.236877f
, -22.632446f
, 6.707388f
, -11.768282f
,
3174 3.443672f
, -6.07445f
, 11.61839f
, 1.527561f
, 37.89633f
, -56.9012f
,
3175 47.42289f
, 50.39153f
, 10.61819f
, 25.50101f
, 0.049241f
, 16.98330f
,
3177 1.01f
, -3.01f
, -3.01f
, 4.01f
, -8.01f
, -6.01f
, -11.307889f
, -8.01f
, 14.297919f
,
3178 /* Rotation around X-axis -Pi/2 */
3179 1.01f
, 3.01f
, -2.01f
, 4.01f
, 8.01f
, -6.01f
,
3180 -11.307890f
, -5.01f
, -1.565839f
, -1.093598f
, -11.01f
, -19.833414f
,
3181 15.268191f
, -19.004118f
, 3.364889f
, -9.562627f
, -12.099654f
, -0.272131f
,
3182 -30.241013f
, 26.919991f
, 39.236877f
, 22.632446f
, 6.707388f
, 11.768282f
,
3183 3.443672f
, 6.07445f
, 11.61839f
, -1.527561f
, 37.89633f
, 56.9012f
,
3184 -47.42289f
, 50.39153f
, -10.61819f
, 25.50101f
, -0.049248f
, 16.98330f
,
3186 1.01f
, 3.01f
, -3.01f
, 4.01f
, 8.01f
, -6.01f
, -11.307890f
, -8.01f
, 14.297919f
,
3187 /* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
3188 1.01f
, 4.944899f
, 1.442301f
, 1.627281f
, 0.219220f
, 10.540824f
,
3189 -9.136903f
, 2.763750f
, -7.30904f
, -5.875721f
, 5.303124f
, -8.682154f
,
3190 -25.683384f
, 1.680279f
, -18.808388f
, 7.653656f
, 16.939133f
, -17.328018f
,
3191 14.629795f
, -54.467102f
, -12.231035f
, -4.089857f
, -9.444222f
, 3.056035f
,
3192 0.179257f
, -10.041875f
, 23.090092f
, -23.188709f
, 11.727098f
, -65.183090f
,
3193 48.671577f
, -15.073209f
, 38.793171f
, -26.039536f
, 6.192769f
, -17.672247f
,
3195 1.01f
, 4.944899f
, -0.891142f
, 4.607695f
, 0.219218f
, 10.773325f
,
3196 -8.204769f
, 13.563829f
, -12.007767f
,
3197 /* Rotation around Z-axis Pi/6 */
3198 1.01f
, 3.745711f
, 3.01f
, 2.467762f
, 10.307889f
, 9.209813f
,
3199 7.01f
, 3.931864f
, 0.166212f
, 16.01f
, 18.504042f
, 17.405966f
,
3200 13.01f
, 6.128016f
, -2.029941f
, -10.01f
, 13.154292f
, 24.01f
,
3201 29.432245f
, 28.334167f
, 21.01f
, 9.056221f
, -4.958143f
, -18.01f
,
3202 -27.236094f
, -4.520332f
, 16.814543f
, 34.01f
, 43.092495f
, 41.994423f
,
3203 31.01f
, 12.716471f
, -8.618400f
, -28.01f
, -40.896347f
, -44.190571,
3205 1.01f
, 3.745711f
, 3.01f
, 1.599906f
, 10.307889f
, 9.209813f
,
3206 7.01f
, 2.331957f
, -4.421894f
, };
3207 unsigned int i
, j
, l
, order
;
3209 D3DXMatrixRotationX(&m
[0], -D3DX_PI
/ 2.0f
);
3210 D3DXMatrixRotationX(&m
[1], D3DX_PI
/ 2.0f
);
3211 D3DXMatrixRotationYawPitchRoll(&m
[2], D3DX_PI
/ 3.0f
, D3DX_PI
/ 4.0f
, D3DX_PI
/ 5.0f
);
3212 D3DXMatrixRotationZ(&m
[3], D3DX_PI
/ 6.0f
);
3214 for (l
= 0; l
< 2; l
++)
3221 for (j
= 0; j
< 4; j
++)
3223 for (order
= 0; order
<= D3DXSH_MAXORDER
; order
++)
3225 for (i
= 0; i
< 49; i
++)
3227 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3231 received_ptr
= D3DXSHRotate(out_temp
, order
, &m
[j
], in
);
3232 ok(received_ptr
== out_temp
, "Order %u, expected %p, received %p\n", order
, out
, received_ptr
);
3234 for (i
= 0; i
< 49; i
++)
3236 if ((i
> 0) && ((i
>= order
* order
) || (order
> D3DXSH_MAXORDER
)))
3239 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3241 expected
= i
+ 1.01f
;
3243 else if ((l
== 0) || (order
> 3))
3244 expected
= table
[45 * j
+ i
];
3246 expected
= table
[45 * j
+ 36 +i
];
3247 ok(relative_error(out_temp
[i
], expected
) < admitted_error
,
3248 "Order %u index %u, expected %f, received %f\n", order
, i
, expected
, out_temp
[i
]);
3255 static void test_D3DXSHRotateZ(void)
3257 unsigned int end
, i
, j
, l
, order
, square
;
3258 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3259 const FLOAT angle
[] = { D3DX_PI
/ 3.0f
, -D3DX_PI
/ 3.0f
, 4.0f
* D3DX_PI
/ 3.0f
, }, table
[] =
3260 { /* Angle = D3DX_PI / 3.0f */
3261 1.01f
, 4.477762f
, 3.010000f
, 0.264289f
, 5.297888f
, 9.941864f
,
3262 7.010000f
, -1.199813f
, -8.843789f
, -10.010002f
, 7.494040f
, 18.138016f
,
3263 13.010000, -3.395966f
, -17.039942f
, -16.009998f
, -30.164297f
, -18.010004f
,
3264 10.422242f
, 29.066219f
, 21.010000f
, -6.324171f
, -27.968145f
, -24.009998f
,
3265 2.226099f
, -18.180565, -43.824551f
, -28.010004f
, 14.082493f
, 42.726471f
,
3266 31.010000f
, -9.984426f
, -41.628399f
, -34.009995f
, 5.886358f
, 40.530331f
,
3268 1.01f
, 4.477762f
, 0.0f
, -5.816784f
, 5.297888f
, 6.936864f
,
3269 0.0f
, -9.011250f
, -2.294052f
, -10.010002f
, 12.999042f
, 12.133017f
,
3270 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, -30.164297f
, 0.0f
,
3271 19.927244f
, 19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3272 -13.061530f
, -18.180565f
, -30.319553f
, 0.0f
, 28.587496f
, 27.721474f
,
3273 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -23.617250f
,
3275 1.010000f
, 3.977762f
, 3.977762f
, 1.114195f
, 7.245791f
, 10.559759f
,
3276 10.559759f
, -0.995160f
, -0.467341f
, 0.467339f
, 12.765371f
, 18.515701f
,
3277 18.515701f
, -1.797287f
, 0.493916f
, -0.493916f
, -21.412342f
, 21.412338f
,
3278 9.221072f
, 23.671757f
, 23.671757f
, 3.850195f
, -20.468727f
, 20.468723f
,
3279 -10.662103f
, -36.516628f
, -12.061245f
, 12.061240f
, 22.556875f
, 38.999908f
,
3280 38.999908f
, -0.034875f
, -10.427902f
, 10.427900f
, -36.838284f
, -27.652803f
,
3281 /* Angle = -D3DX_PI / 3.0f */
3282 1.01f
, -2.467762f
, 3.010000f
, 3.745711f
, -10.307890f
, -3.931864f
,
3283 7.010000f
, 9.209813f
, -0.166214f
, -10.010002f
, -18.504044f
, -6.128017f
,
3284 13.010000f
, 17.405966f
, 2.029938f
, -16.009998f
, 13.154303f
, -18.010004f
,
3285 -29.432247f
, -9.056221f
, 21.010000f
, 28.334169f
, 4.958139f
, -24.010002f
,
3286 -27.236092f
, 44.190582f
, 16.814558f
, -28.009996f
, -43.092499f
, -12.716474f
,
3287 31.010000f
, 41.994423f
, 8.618393f
, -34.010002f
, -40.896347f
, -4.520310f
,
3289 1.01f
, -2.467762f
, 0.0f
, -3.205718f
, -10.307890f
, -6.936864f
,
3290 0.0f
, -9.011250f
, -4.463446f
, -10.009998f
, -12.999042f
, -12.133017f
,
3291 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, 13.154303f
, 0.0f
,
3292 -19.927244f
, -19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3293 -5.695983f
, 44.190582f
, 30.319553f
, 0.0f
, -28.587496f
, -27.721474f
,
3294 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -57.405258f
,
3296 1.010000f
, -2.967762f
, -2.967762f
, -0.609195f
, -7.498291f
, -10.686009f
,
3297 -10.686009f
, -11.836716f
, 5.390780f
, -5.390779f
, -10.303651f
, -17.284842f
,
3298 -17.284842f
, -17.565643f
, 4.114273f
, -4.114273f
, 23.716436f
, -23.716433f
,
3299 -8.069025f
, -23.095732f
, -23.095732f
, -18.535847f
, -11.271107f
, 11.271104f
,
3300 -2.072484f
, 30.149330f
, 15.244893f
, -15.244888f
, -20.965050f
, -38.203999f
,
3301 -38.203999f
, -37.258266f
, 5.426677f
, -5.426679f
, -23.396751f
, -9.903559f
,
3302 /* Angle = 4.0f * D3DX_PI / 3.0f */
3303 1.01f
, -4.477762f
, 3.010000f
, -0.264289f
, 5.297887f
, -9.941864f
,
3304 7.010000f
, 1.199814f
, -8.843788f
, 10.010004f
, 7.494038f
, -18.138016f
,
3305 13.010000f
, 3.395967f
, -17.039940f
, 16.009996f
, -30.164293f
, 18.010006f
,
3306 10.422239f
, -29.066219f
, 21.010000f
, 6.324172f
, -27.968143f
, 24.009993f
,
3307 2.226105f
, 18.180552f
, -43.824543f
, 28.010008f
, 14.082489f
, -42.726471f
,
3308 31.010000f
, 9.984427f
, -41.628399f
, 34.009987f
, 5.886366f
, -40.530327f
,
3310 1.01f
, -4.477762f
, 0.0f
, -1.938928f
, 5.297887f
, -6.936864f
,
3311 0.0f
, -3.003751f
, -2.294051f
, 10.010004f
, 12.999040f
, -12.133017f
,
3312 0.0f
, -5.253751f
, -5.628747f
, 0.0f
, -30.164293f
, 0.0f
,
3313 19.927242f
, -19.061220f
, 0.0f
, -8.253753f
, -8.628746f
, 0.0f
,
3314 -13.061535f
, 18.180552f
, -30.319553f
, 0.0f
, 28.587492f
, -27.721474f
,
3315 0.0f
, -12.003753f
, -12.378742f
, 0.0f
, -13.128765f
, -7.872400f
,
3317 1.010000f
, -3.977762f
, -3.977762f
, 2.863566f
, 6.371104f
, -10.122416f
,
3318 -10.122416f
, 10.578746f
, -7.769295f
, -7.769290f
, 16.883686f
, -20.574858f
,
3319 -20.574858f
, 24.909130f
, -5.726166f
, -5.726164f
, -18.796221f
, -18.796211f
,
3320 29.325350f
, -33.723892f
, -33.723892f
, 42.258442f
, -4.851232f
, -4.851226f
,
3321 -2.533393f
, 32.452259f
, -46.545670f
, -46.545654f
, 51.860325f
, -53.651630f
,
3322 -53.651630f
, 71.738174f
, 4.440616f
, 4.440629f
, 25.884174f
, -10.748116f
, };
3324 for (l
= 0; l
< 3; l
++)
3329 out_temp
= &in
[l
- 1];
3336 for (j
= 0; j
< 3; j
++)
3338 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3340 for (i
= 0; i
< 49; i
++)
3342 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3346 received_ptr
= D3DXSHRotateZ(out_temp
, order
, angle
[j
], in
);
3347 ok(received_ptr
== out_temp
, "angle %f, order %u, expected %p, received %p\n", angle
[j
], order
, out_temp
, received_ptr
);
3349 for (i
= 0; i
< end
; i
++)
3351 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
3352 square
= (order
<= D3DXSH_MINORDER
) ? D3DXSH_MINORDER
* D3DXSH_MINORDER
: order
* order
;
3353 if (i
>= square
|| ((order
>= D3DXSH_MAXORDER
) && (i
>= D3DXSH_MAXORDER
* D3DXSH_MAXORDER
)))
3355 expected
= i
+ l
+ 0.01f
;
3357 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3359 expected
= table
[36 * (l
+ 3 * j
) + i
];
3360 ok(relative_error(expected
, out_temp
[i
]) < admitted_error
, "angle %f, order %u index %u, expected %f, received %f\n", angle
[j
], order
, i
, expected
, out_temp
[i
]);
3367 static void test_D3DXSHScale(void)
3369 unsigned int i
, order
;
3370 FLOAT a
[49], b
[49], expected
, *received_array
;
3372 for (i
= 0; i
< 49; i
++)
3378 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3380 received_array
= D3DXSHScale(b
, order
, a
, 5.0f
);
3381 ok(received_array
== b
, "Expected %p, received %p\n", b
, received_array
);
3383 for (i
= 0; i
< 49; i
++)
3385 if (i
< order
* order
)
3386 expected
= 5.0f
* a
[i
];
3387 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
3390 ok(relative_error(b
[i
], expected
) < admitted_error
, "order %d, element %d, expected %f, received %f\n", order
, i
, expected
, b
[i
]);
3401 D3DXQuaternionTest();
3405 test_matrix_stack();
3406 test_Matrix_AffineTransformation2D();
3407 test_Matrix_Decompose();
3408 test_Matrix_Transformation2D();
3409 test_D3DXVec_Array();
3410 test_D3DXFloat_Array();
3413 test_D3DXSHEvalConeLight();
3414 test_D3DXSHEvalDirection();
3415 test_D3DXSHEvalDirectionalLight();
3416 test_D3DXSHEvalHemisphereLight();
3417 test_D3DXSHEvalSphericalLight();
3418 test_D3DXSHMultiply2();
3419 test_D3DXSHMultiply3();
3420 test_D3DXSHMultiply4();
3421 test_D3DXSHRotate();
3422 test_D3DXSHRotateZ();