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
);
986 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &gotquat
, &t
, &u
);
987 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
988 expect_vec4(expectedquat
, Nq
);
990 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &Nq1
);
991 expect_vec4(expectedquat
, Nq
);
992 r
.x
= 0.2f
; r
.y
= 0.3f
; r
.z
= 1.3f
; r
.w
= -0.6f
;
993 s
.x
= -3.0f
; s
.y
=-2.0f
; s
.z
= 4.0f
; s
.w
= 0.2f
;
994 t
.x
= 0.4f
; t
.y
= 8.3f
; t
.z
= -3.1f
; t
.w
= -2.7f
;
995 u
.x
= 1.1f
; u
.y
= -0.7f
; u
.z
= 9.2f
; u
.w
= 0.0f
;
996 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &u
, &t
);
997 expectedquat
.x
= -4.139569f
; expectedquat
.y
= -2.469115f
; expectedquat
.z
= 2.364477f
; expectedquat
.w
= 0.465494f
;
998 expect_vec4(expectedquat
, gotquat
);
999 expectedquat
.x
= 2.342533f
; expectedquat
.y
= 2.365127f
; expectedquat
.z
= 8.628538f
; expectedquat
.w
= -0.898356f
;
1000 expect_vec4(expectedquat
, Nq
);
1001 expectedquat
.x
= 1.1f
; expectedquat
.y
= -0.7f
; expectedquat
.z
= 9.2f
; expectedquat
.w
= 0.0f
;
1002 expect_vec4(expectedquat
, Nq1
);
1003 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1004 expectedquat
.x
= -3.754567f
; expectedquat
.y
= -0.586085f
; expectedquat
.z
= 3.815818f
; expectedquat
.w
= -0.198150f
;
1005 expect_vec4(expectedquat
, gotquat
);
1006 expectedquat
.x
= 0.140773f
; expectedquat
.y
= -8.737090f
; expectedquat
.z
= -0.516593f
; expectedquat
.w
= 3.053942f
;
1007 expect_vec4(expectedquat
, Nq
);
1008 expectedquat
.x
= -0.4f
; expectedquat
.y
= -8.3f
; expectedquat
.z
= 3.1f
; expectedquat
.w
= 2.7f
;
1009 expect_vec4(expectedquat
, Nq1
);
1010 r
.x
= -1.0f
; r
.y
= 0.0f
; r
.z
= 0.0f
; r
.w
= 0.0f
;
1011 s
.x
= 1.0f
; s
.y
=0.0f
; s
.z
= 0.0f
; s
.w
= 0.0f
;
1012 t
.x
= 1.0f
; t
.y
= 0.0f
; t
.z
= 0.0f
; t
.w
= 0.0f
;
1013 u
.x
= -1.0f
; u
.y
= 0.0f
; u
.z
= 0.0f
; u
.w
= 0.0f
;
1014 D3DXQuaternionSquadSetup(&gotquat
, &Nq
, &Nq1
, &r
, &s
, &t
, &u
);
1015 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1016 expect_vec4(expectedquat
, gotquat
);
1017 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1018 expect_vec4(expectedquat
, Nq
);
1019 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1020 expect_vec4(expectedquat
, Nq1
);
1022 /*_______________D3DXQuaternionToAxisAngle__________________*/
1023 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
1024 expectedvec
.x
= 1.0f
/22.0f
; expectedvec
.y
= 2.0f
/22.0f
; expectedvec
.z
= 4.0f
/22.0f
;
1025 expected
= 2.197869f
;
1026 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
1027 expect_vec3(expectedvec
,axis
);
1028 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1029 /* Test if |w|>1.0f */
1030 expectedvec
.x
= 1.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= 4.0f
;
1031 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
1032 expect_vec3(expectedvec
,axis
);
1033 /* Test the null quaternion */
1034 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1035 expected
= 3.141593f
;
1036 D3DXQuaternionToAxisAngle(&nul
, &axis
, &angle
);
1037 expect_vec3(expectedvec
, axis
);
1038 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1040 D3DXQuaternionToAxisAngle(&nul
, &axis
, NULL
);
1041 D3DXQuaternionToAxisAngle(&nul
, NULL
, &angle
);
1042 expect_vec3(expectedvec
, axis
);
1043 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1046 static void D3DXVector2Test(void)
1048 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1049 LPD3DXVECTOR2 funcpointer
;
1050 D3DXVECTOR4 expectedtrans
, gottrans
;
1052 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1054 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
1055 u
.x
= 3.0f
; u
.y
= 4.0f
;
1056 v
.x
= -7.0f
; v
.y
= 9.0f
;
1057 w
.x
= 4.0f
; w
.y
= -3.0f
;
1058 x
.x
= 2.0f
; x
.y
= -11.0f
;
1060 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
;
1061 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
;
1062 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
;
1063 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
;
1065 coeff1
= 2.0f
; coeff2
= 5.0f
;
1068 /*_______________D3DXVec2Add__________________________*/
1069 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
1070 D3DXVec2Add(&gotvec
,&u
,&v
);
1071 expect_vec(expectedvec
,gotvec
);
1072 /* Tests the case NULL */
1073 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
1074 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1075 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
1076 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1078 /*_______________D3DXVec2BaryCentric___________________*/
1079 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
1080 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1081 expect_vec(expectedvec
,gotvec
);
1083 /*_______________D3DXVec2CatmullRom____________________*/
1084 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
1085 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1086 expect_vec(expectedvec
,gotvec
);
1088 /*_______________D3DXVec2CCW__________________________*/
1090 got
= D3DXVec2CCW(&u
,&v
);
1091 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1092 /* Tests the case NULL */
1094 got
= D3DXVec2CCW(NULL
,&v
);
1095 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1097 got
= D3DXVec2CCW(NULL
,NULL
);
1098 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1100 /*_______________D3DXVec2Dot__________________________*/
1102 got
= D3DXVec2Dot(&u
,&v
);
1103 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1104 /* Tests the case NULL */
1106 got
= D3DXVec2Dot(NULL
,&v
);
1107 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1109 got
= D3DXVec2Dot(NULL
,NULL
);
1110 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1112 /*_______________D3DXVec2Hermite__________________________*/
1113 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
1114 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1115 expect_vec(expectedvec
,gotvec
);
1117 /*_______________D3DXVec2Length__________________________*/
1119 got
= D3DXVec2Length(&u
);
1120 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1121 /* Tests the case NULL */
1123 got
= D3DXVec2Length(NULL
);
1124 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1126 /*_______________D3DXVec2LengthSq________________________*/
1128 got
= D3DXVec2LengthSq(&u
);
1129 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1130 /* Tests the case NULL */
1132 got
= D3DXVec2LengthSq(NULL
);
1133 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1135 /*_______________D3DXVec2Lerp__________________________*/
1136 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
1137 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
1138 expect_vec(expectedvec
,gotvec
);
1139 /* Tests the case NULL */
1140 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
1141 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1142 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
1143 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1145 /*_______________D3DXVec2Maximize__________________________*/
1146 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
1147 D3DXVec2Maximize(&gotvec
,&u
,&v
);
1148 expect_vec(expectedvec
,gotvec
);
1149 /* Tests the case NULL */
1150 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
1151 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1152 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1153 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1155 /*_______________D3DXVec2Minimize__________________________*/
1156 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1157 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1158 expect_vec(expectedvec
,gotvec
);
1159 /* Tests the case NULL */
1160 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1161 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1162 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1163 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1165 /*_______________D3DXVec2Normalize_________________________*/
1166 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1167 D3DXVec2Normalize(&gotvec
,&u
);
1168 expect_vec(expectedvec
,gotvec
);
1169 /* Test the nul vector */
1170 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1171 D3DXVec2Normalize(&gotvec
,&nul
);
1172 expect_vec(expectedvec
,gotvec
);
1174 /*_______________D3DXVec2Scale____________________________*/
1175 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
1176 D3DXVec2Scale(&gotvec
,&u
,scale
);
1177 expect_vec(expectedvec
,gotvec
);
1178 /* Tests the case NULL */
1179 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
1180 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1181 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
1182 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1184 /*_______________D3DXVec2Subtract__________________________*/
1185 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
1186 D3DXVec2Subtract(&gotvec
,&u
,&v
);
1187 expect_vec(expectedvec
,gotvec
);
1188 /* Tests the case NULL */
1189 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
1190 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1191 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
1192 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1194 /*_______________D3DXVec2Transform_______________________*/
1195 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
1196 D3DXVec2Transform(&gottrans
, &u
, &mat
);
1197 expect_vec4(expectedtrans
, gottrans
);
1198 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
;
1199 D3DXVec2Transform(&gottrans
, (D3DXVECTOR2
*)&gottrans
, &mat
);
1200 expect_vec4(expectedtrans
, gottrans
);
1202 /*_______________D3DXVec2TransformCoord_______________________*/
1203 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
1204 D3DXVec2TransformCoord(&gotvec
, &u
, &mat
);
1205 expect_vec(expectedvec
, gotvec
);
1206 gotvec
.x
= u
.x
; gotvec
.y
= u
.y
;
1207 D3DXVec2TransformCoord(&gotvec
, (D3DXVECTOR2
*)&gotvec
, &mat
);
1208 expect_vec(expectedvec
, gotvec
);
1210 /*_______________D3DXVec2TransformNormal______________________*/
1211 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
1212 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
1213 expect_vec(expectedvec
,gotvec
);
1216 static void D3DXVector3Test(void)
1218 D3DVIEWPORT9 viewport
;
1219 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1220 LPD3DXVECTOR3 funcpointer
;
1221 D3DXVECTOR4 expectedtrans
, gottrans
;
1222 D3DXMATRIX mat
, projection
, view
, world
;
1223 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1225 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
1226 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
1227 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
1228 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
1229 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
1231 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
1232 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
1234 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
;
1235 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
;
1236 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
;
1237 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
;
1239 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
1240 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
1241 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
1242 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
1243 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
1244 U(view
).m
[3][3] = -40.0f
;
1246 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;
1247 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
;
1248 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
;
1249 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
;
1251 coeff1
= 2.0f
; coeff2
= 5.0f
;
1254 /*_______________D3DXVec3Add__________________________*/
1255 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
1256 D3DXVec3Add(&gotvec
,&u
,&v
);
1257 expect_vec3(expectedvec
,gotvec
);
1258 /* Tests the case NULL */
1259 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
1260 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1261 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
1262 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1264 /*_______________D3DXVec3BaryCentric___________________*/
1265 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
1266 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1268 expect_vec3(expectedvec
,gotvec
);
1270 /*_______________D3DXVec3CatmullRom____________________*/
1271 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
1272 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1273 expect_vec3(expectedvec
,gotvec
);
1275 /*_______________D3DXVec3Cross________________________*/
1276 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
1277 D3DXVec3Cross(&gotvec
,&u
,&v
);
1278 expect_vec3(expectedvec
,gotvec
);
1279 expectedvec
.x
= -277.0f
; expectedvec
.y
= -150.0f
; expectedvec
.z
= -26.0f
;
1280 D3DXVec3Cross(&gotvec
,&gotvec
,&v
);
1281 expect_vec3(expectedvec
,gotvec
);
1282 /* Tests the case NULL */
1283 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
1284 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1285 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
1286 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1288 /*_______________D3DXVec3Dot__________________________*/
1290 got
= D3DXVec3Dot(&u
,&v
);
1291 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1292 /* Tests the case NULL */
1294 got
= D3DXVec3Dot(NULL
,&v
);
1295 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1297 got
= D3DXVec3Dot(NULL
,NULL
);
1298 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1300 /*_______________D3DXVec3Hermite__________________________*/
1301 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
1302 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1303 expect_vec3(expectedvec
,gotvec
);
1305 /*_______________D3DXVec3Length__________________________*/
1307 got
= D3DXVec3Length(&u
);
1308 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1309 /* Tests the case NULL */
1311 got
= D3DXVec3Length(NULL
);
1312 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1314 /*_______________D3DXVec3LengthSq________________________*/
1316 got
= D3DXVec3LengthSq(&u
);
1317 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1318 /* Tests the case NULL */
1320 got
= D3DXVec3LengthSq(NULL
);
1321 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1323 /*_______________D3DXVec3Lerp__________________________*/
1324 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
1325 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
1326 expect_vec3(expectedvec
,gotvec
);
1327 /* Tests the case NULL */
1328 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
1329 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1330 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
1331 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1333 /*_______________D3DXVec3Maximize__________________________*/
1334 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
1335 D3DXVec3Maximize(&gotvec
,&u
,&v
);
1336 expect_vec3(expectedvec
,gotvec
);
1337 /* Tests the case NULL */
1338 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
1339 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1340 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
1341 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1343 /*_______________D3DXVec3Minimize__________________________*/
1344 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
1345 D3DXVec3Minimize(&gotvec
,&u
,&v
);
1346 expect_vec3(expectedvec
,gotvec
);
1347 /* Tests the case NULL */
1348 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
1349 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1350 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
1351 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1353 /*_______________D3DXVec3Normalize_________________________*/
1354 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
1355 D3DXVec3Normalize(&gotvec
,&u
);
1356 expect_vec3(expectedvec
,gotvec
);
1357 /* Test the nul vector */
1358 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1359 D3DXVec3Normalize(&gotvec
,&nul
);
1360 expect_vec3(expectedvec
,gotvec
);
1362 /*_______________D3DXVec3Scale____________________________*/
1363 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
1364 D3DXVec3Scale(&gotvec
,&u
,scale
);
1365 expect_vec3(expectedvec
,gotvec
);
1366 /* Tests the case NULL */
1367 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
1368 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1369 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
1370 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1372 /*_______________D3DXVec3Subtract_______________________*/
1373 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
1374 D3DXVec3Subtract(&gotvec
,&u
,&v
);
1375 expect_vec3(expectedvec
,gotvec
);
1376 /* Tests the case NULL */
1377 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
1378 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1379 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
1380 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1382 /*_______________D3DXVec3Transform_______________________*/
1383 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
1384 D3DXVec3Transform(&gottrans
, &u
, &mat
);
1385 expect_vec4(expectedtrans
, gottrans
);
1387 gottrans
.x
= u
.x
; gottrans
.y
= u
.y
; gottrans
.z
= u
.z
;
1388 D3DXVec3Transform(&gottrans
, (D3DXVECTOR3
*)&gottrans
, &mat
);
1389 expect_vec4(expectedtrans
, gottrans
);
1391 /*_______________D3DXVec3TransformCoord_______________________*/
1392 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
1393 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
1394 expect_vec3(expectedvec
,gotvec
);
1396 /*_______________D3DXVec3TransformNormal______________________*/
1397 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
1398 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
1399 expect_vec3(expectedvec
,gotvec
);
1401 /*_______________D3DXVec3Project_________________________*/
1402 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
1403 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1404 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1405 expect_vec3(expectedvec
,gotvec
);
1406 /* World matrix can be omitted */
1407 D3DXMatrixMultiply(&mat
,&world
,&view
);
1408 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1409 expect_vec3(expectedvec
,gotvec
);
1410 /* Projection matrix can be omitted */
1411 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1412 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1413 expect_vec3(expectedvec
,gotvec
);
1414 /* View matrix can be omitted */
1415 D3DXMatrixMultiply(&mat
,&world
,&view
);
1416 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1417 expect_vec3(expectedvec
,gotvec
);
1418 /* All matrices can be omitted */
1419 expectedvec
.x
= 4010.000000f
; expectedvec
.y
= -1695.000000f
; expectedvec
.z
= 1.600000f
;
1420 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1421 expect_vec3(expectedvec
,gotvec
);
1422 /* Viewport can be omitted */
1423 expectedvec
.x
= 1.814305f
; expectedvec
.y
= 0.582097f
; expectedvec
.z
= -0.066555f
;
1424 D3DXVec3Project(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1425 expect_vec3(expectedvec
,gotvec
);
1427 /*_______________D3DXVec3Unproject_________________________*/
1428 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
1429 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1430 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1431 expect_vec3(expectedvec
,gotvec
);
1432 /* World matrix can be omitted */
1433 D3DXMatrixMultiply(&mat
,&world
,&view
);
1434 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1435 expect_vec3(expectedvec
,gotvec
);
1436 /* Projection matrix can be omitted */
1437 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1438 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1439 expect_vec3(expectedvec
,gotvec
);
1440 /* View matrix can be omitted */
1441 D3DXMatrixMultiply(&mat
,&world
,&view
);
1442 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1443 expect_vec3(expectedvec
,gotvec
);
1444 /* All matrices can be omitted */
1445 expectedvec
.x
= -1.002500f
; expectedvec
.y
= 0.997059f
; expectedvec
.z
= 2.571429f
;
1446 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1447 expect_vec3(expectedvec
,gotvec
);
1448 /* Viewport can be omitted */
1449 expectedvec
.x
= -11.018396f
; expectedvec
.y
= 3.218991f
; expectedvec
.z
= 1.380329f
;
1450 D3DXVec3Unproject(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1451 expect_vec3(expectedvec
,gotvec
);
1454 static void D3DXVector4Test(void)
1456 D3DXVECTOR4 expectedvec
, gotvec
, u
, v
, w
, x
;
1457 LPD3DXVECTOR4 funcpointer
;
1458 D3DXVECTOR4 expectedtrans
, gottrans
;
1460 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1462 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
1463 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
1464 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
1465 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
1467 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
;
1468 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
;
1469 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
;
1470 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
;
1472 coeff1
= 2.0f
; coeff2
= 5.0;
1475 /*_______________D3DXVec4Add__________________________*/
1476 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
1477 D3DXVec4Add(&gotvec
,&u
,&v
);
1478 expect_vec4(expectedvec
,gotvec
);
1479 /* Tests the case NULL */
1480 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
1481 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1482 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
1483 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1485 /*_______________D3DXVec4BaryCentric____________________*/
1486 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
1487 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1488 expect_vec4(expectedvec
,gotvec
);
1490 /*_______________D3DXVec4CatmullRom____________________*/
1491 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
1492 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1493 expect_vec4(expectedvec
,gotvec
);
1495 /*_______________D3DXVec4Cross_________________________*/
1496 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
1497 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1498 expect_vec4(expectedvec
,gotvec
);
1500 /*_______________D3DXVec4Dot__________________________*/
1502 got
= D3DXVec4Dot(&u
,&v
);
1503 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1504 /* Tests the case NULL */
1506 got
= D3DXVec4Dot(NULL
,&v
);
1507 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1509 got
= D3DXVec4Dot(NULL
,NULL
);
1510 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1512 /*_______________D3DXVec4Hermite_________________________*/
1513 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1514 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1515 expect_vec4(expectedvec
,gotvec
);
1517 /*_______________D3DXVec4Length__________________________*/
1519 got
= D3DXVec4Length(&u
);
1520 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1521 /* Tests the case NULL */
1523 got
= D3DXVec4Length(NULL
);
1524 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1526 /*_______________D3DXVec4LengthSq________________________*/
1528 got
= D3DXVec4LengthSq(&u
);
1529 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1530 /* Tests the case NULL */
1532 got
= D3DXVec4LengthSq(NULL
);
1533 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1535 /*_______________D3DXVec4Lerp__________________________*/
1536 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1537 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1538 expect_vec4(expectedvec
,gotvec
);
1539 /* Tests the case NULL */
1540 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1541 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1542 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1543 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1545 /*_______________D3DXVec4Maximize__________________________*/
1546 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1547 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1548 expect_vec4(expectedvec
,gotvec
);
1549 /* Tests the case NULL */
1550 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1551 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1552 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1553 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1555 /*_______________D3DXVec4Minimize__________________________*/
1556 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1557 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1558 expect_vec4(expectedvec
,gotvec
);
1559 /* Tests the case NULL */
1560 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1561 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1562 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1563 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1565 /*_______________D3DXVec4Normalize_________________________*/
1566 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1567 D3DXVec4Normalize(&gotvec
,&u
);
1568 expect_vec4(expectedvec
,gotvec
);
1570 /*_______________D3DXVec4Scale____________________________*/
1571 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1572 D3DXVec4Scale(&gotvec
,&u
,scale
);
1573 expect_vec4(expectedvec
,gotvec
);
1574 /* Tests the case NULL */
1575 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1576 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1577 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1578 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1580 /*_______________D3DXVec4Subtract__________________________*/
1581 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1582 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1583 expect_vec4(expectedvec
,gotvec
);
1584 /* Tests the case NULL */
1585 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1586 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1587 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1588 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1590 /*_______________D3DXVec4Transform_______________________*/
1591 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1592 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1593 expect_vec4(expectedtrans
,gottrans
);
1596 static void test_matrix_stack(void)
1598 ID3DXMatrixStack
*stack
;
1602 const D3DXMATRIX mat1
= {{{
1603 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1604 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1605 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1606 13.0f
, 14.0f
, 15.0f
, 16.0f
1609 const D3DXMATRIX mat2
= {{{
1610 17.0f
, 18.0f
, 19.0f
, 20.0f
,
1611 21.0f
, 22.0f
, 23.0f
, 24.0f
,
1612 25.0f
, 26.0f
, 27.0f
, 28.0f
,
1613 29.0f
, 30.0f
, 31.0f
, 32.0f
1616 hr
= D3DXCreateMatrixStack(0, &stack
);
1617 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
1618 if (FAILED(hr
)) return;
1620 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
1621 "The top of an empty matrix stack should be an identity matrix\n");
1623 hr
= ID3DXMatrixStack_Pop(stack
);
1624 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1626 hr
= ID3DXMatrixStack_Push(stack
);
1627 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1628 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1630 hr
= ID3DXMatrixStack_Push(stack
);
1631 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1633 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
1634 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1635 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1637 hr
= ID3DXMatrixStack_Push(stack
);
1638 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1639 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1641 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
1642 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1643 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1645 hr
= ID3DXMatrixStack_Push(stack
);
1646 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1647 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1649 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
1650 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
1651 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1653 hr
= ID3DXMatrixStack_Pop(stack
);
1654 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1655 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1657 hr
= ID3DXMatrixStack_Pop(stack
);
1658 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1659 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1661 hr
= ID3DXMatrixStack_Pop(stack
);
1662 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1663 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1665 hr
= ID3DXMatrixStack_Pop(stack
);
1666 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1667 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1669 refcount
= ID3DXMatrixStack_Release(stack
);
1670 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
1673 static void test_Matrix_AffineTransformation2D(void)
1675 D3DXMATRIX exp_mat
, got_mat
;
1676 D3DXVECTOR2 center
, position
;
1685 angle
= D3DX_PI
/3.0f
;
1689 U(exp_mat
).m
[0][0] = 10.0f
;
1690 U(exp_mat
).m
[1][0] = -17.320507f
;
1691 U(exp_mat
).m
[2][0] = 0.0f
;
1692 U(exp_mat
).m
[3][0] = -1.035898f
;
1693 U(exp_mat
).m
[0][1] = 17.320507f
;
1694 U(exp_mat
).m
[1][1] = 10.0f
;
1695 U(exp_mat
).m
[2][1] = 0.0f
;
1696 U(exp_mat
).m
[3][1] = 6.401924f
;
1697 U(exp_mat
).m
[0][2] = 0.0f
;
1698 U(exp_mat
).m
[1][2] = 0.0f
;
1699 U(exp_mat
).m
[2][2] = 1.0f
;
1700 U(exp_mat
).m
[3][2] = 0.0f
;
1701 U(exp_mat
).m
[0][3] = 0.0f
;
1702 U(exp_mat
).m
[1][3] = 0.0f
;
1703 U(exp_mat
).m
[2][3] = 0.0f
;
1704 U(exp_mat
).m
[3][3] = 1.0f
;
1706 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, &position
);
1708 expect_mat(&exp_mat
, &got_mat
);
1715 angle
= D3DX_PI
/3.0f
;
1719 U(exp_mat
).m
[0][0] = 10.0f
;
1720 U(exp_mat
).m
[1][0] = -17.320507f
;
1721 U(exp_mat
).m
[2][0] = 0.0f
;
1722 U(exp_mat
).m
[3][0] = 4.964102f
;
1723 U(exp_mat
).m
[0][1] = 17.320507f
;
1724 U(exp_mat
).m
[1][1] = 10.0f
;
1725 U(exp_mat
).m
[2][1] = 0.0f
;
1726 U(exp_mat
).m
[3][1] = -0.598076f
;
1727 U(exp_mat
).m
[0][2] = 0.0f
;
1728 U(exp_mat
).m
[1][2] = 0.0f
;
1729 U(exp_mat
).m
[2][2] = 1.0f
;
1730 U(exp_mat
).m
[3][2] = 0.0f
;
1731 U(exp_mat
).m
[0][3] = 0.0f
;
1732 U(exp_mat
).m
[1][3] = 0.0f
;
1733 U(exp_mat
).m
[2][3] = 0.0f
;
1734 U(exp_mat
).m
[3][3] = 1.0f
;
1736 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, NULL
);
1738 expect_mat(&exp_mat
, &got_mat
);
1745 angle
= D3DX_PI
/3.0f
;
1749 U(exp_mat
).m
[0][0] = 10.0f
;
1750 U(exp_mat
).m
[1][0] = -17.320507f
;
1751 U(exp_mat
).m
[2][0] = 0.0f
;
1752 U(exp_mat
).m
[3][0] = -6.0f
;
1753 U(exp_mat
).m
[0][1] = 17.320507f
;
1754 U(exp_mat
).m
[1][1] = 10.0f
;
1755 U(exp_mat
).m
[2][1] = 0.0f
;
1756 U(exp_mat
).m
[3][1] = 7.0f
;
1757 U(exp_mat
).m
[0][2] = 0.0f
;
1758 U(exp_mat
).m
[1][2] = 0.0f
;
1759 U(exp_mat
).m
[2][2] = 1.0f
;
1760 U(exp_mat
).m
[3][2] = 0.0f
;
1761 U(exp_mat
).m
[0][3] = 0.0f
;
1762 U(exp_mat
).m
[1][3] = 0.0f
;
1763 U(exp_mat
).m
[2][3] = 0.0f
;
1764 U(exp_mat
).m
[3][3] = 1.0f
;
1766 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, &position
);
1768 expect_mat(&exp_mat
, &got_mat
);
1772 angle
= 5.0f
* D3DX_PI
/4.0f
;
1776 U(exp_mat
).m
[0][0] = 14.142133f
;
1777 U(exp_mat
).m
[1][0] = -14.142133f
;
1778 U(exp_mat
).m
[2][0] = 0.0f
;
1779 U(exp_mat
).m
[3][0] = 0.0f
;
1780 U(exp_mat
).m
[0][1] = 14.142133;
1781 U(exp_mat
).m
[1][1] = 14.142133f
;
1782 U(exp_mat
).m
[2][1] = 0.0f
;
1783 U(exp_mat
).m
[3][1] = 0.0f
;
1784 U(exp_mat
).m
[0][2] = 0.0f
;
1785 U(exp_mat
).m
[1][2] = 0.0f
;
1786 U(exp_mat
).m
[2][2] = 1.0f
;
1787 U(exp_mat
).m
[3][2] = 0.0f
;
1788 U(exp_mat
).m
[0][3] = 0.0f
;
1789 U(exp_mat
).m
[1][3] = 0.0f
;
1790 U(exp_mat
).m
[2][3] = 0.0f
;
1791 U(exp_mat
).m
[3][3] = 1.0f
;
1793 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, NULL
);
1795 expect_mat(&exp_mat
, &got_mat
);
1798 static void test_Matrix_Decompose(void)
1801 D3DXQUATERNION exp_rotation
, got_rotation
;
1802 D3DXVECTOR3 exp_scale
, got_scale
, exp_translation
, got_translation
;
1807 U(pm
).m
[0][0] = -0.9238790f
;
1808 U(pm
).m
[1][0] = -0.2705984f
;
1809 U(pm
).m
[2][0] = 0.2705984f
;
1810 U(pm
).m
[3][0] = -5.0f
;
1811 U(pm
).m
[0][1] = 0.2705984f
;
1812 U(pm
).m
[1][1] = 0.03806049f
;
1813 U(pm
).m
[2][1] = 0.9619395f
;
1814 U(pm
).m
[3][1] = 0.0f
;
1815 U(pm
).m
[0][2] = -0.2705984f
;
1816 U(pm
).m
[1][2] = 0.9619395f
;
1817 U(pm
).m
[2][2] = 0.03806049f
;
1818 U(pm
).m
[3][2] = 10.0f
;
1819 U(pm
).m
[0][3] = 0.0f
;
1820 U(pm
).m
[1][3] = 0.0f
;
1821 U(pm
).m
[2][3] = 0.0f
;
1822 U(pm
).m
[3][3] = 1.0f
;
1828 exp_rotation
.w
= 0.195091f
;
1829 exp_rotation
.x
= 0.0f
;
1830 exp_rotation
.y
= 0.693520f
;
1831 exp_rotation
.z
= 0.693520f
;
1833 exp_translation
.x
= -5.0f
;
1834 exp_translation
.y
= 0.0f
;
1835 exp_translation
.z
= 10.0f
;
1837 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1839 compare_scale(exp_scale
, got_scale
);
1840 compare_rotation(exp_rotation
, got_rotation
);
1841 compare_translation(exp_translation
, got_translation
);
1845 U(pm
).m
[0][0] = -2.255813f
;
1846 U(pm
).m
[1][0] = 1.302324f
;
1847 U(pm
).m
[2][0] = 1.488373f
;
1848 U(pm
).m
[3][0] = 1.0f
;
1849 U(pm
).m
[0][1] = 1.302327f
;
1850 U(pm
).m
[1][1] = -0.7209296f
;
1851 U(pm
).m
[2][1] = 2.60465f
;
1852 U(pm
).m
[3][1] = 2.0f
;
1853 U(pm
).m
[0][2] = 1.488371f
;
1854 U(pm
).m
[1][2] = 2.604651f
;
1855 U(pm
).m
[2][2] = -0.02325551f
;
1856 U(pm
).m
[3][2] = 3.0f
;
1857 U(pm
).m
[0][3] = 0.0f
;
1858 U(pm
).m
[1][3] = 0.0f
;
1859 U(pm
).m
[2][3] = 0.0f
;
1860 U(pm
).m
[3][3] = 1.0f
;
1866 exp_rotation
.w
= 0.0;
1867 exp_rotation
.x
= 0.352180f
;
1868 exp_rotation
.y
= 0.616316f
;
1869 exp_rotation
.z
= 0.704361f
;
1871 exp_translation
.x
= 1.0f
;
1872 exp_translation
.y
= 2.0f
;
1873 exp_translation
.z
= 3.0f
;
1875 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1877 compare_scale(exp_scale
, got_scale
);
1878 compare_rotation(exp_rotation
, got_rotation
);
1879 compare_translation(exp_translation
, got_translation
);
1883 U(pm
).m
[0][0] = 2.427051f
;
1884 U(pm
).m
[1][0] = 0.0f
;
1885 U(pm
).m
[2][0] = 1.763355f
;
1886 U(pm
).m
[3][0] = 5.0f
;
1887 U(pm
).m
[0][1] = 0.0f
;
1888 U(pm
).m
[1][1] = 3.0f
;
1889 U(pm
).m
[2][1] = 0.0f
;
1890 U(pm
).m
[3][1] = 5.0f
;
1891 U(pm
).m
[0][2] = -1.763355f
;
1892 U(pm
).m
[1][2] = 0.0f
;
1893 U(pm
).m
[2][2] = 2.427051f
;
1894 U(pm
).m
[3][2] = 5.0f
;
1895 U(pm
).m
[0][3] = 0.0f
;
1896 U(pm
).m
[1][3] = 0.0f
;
1897 U(pm
).m
[2][3] = 0.0f
;
1898 U(pm
).m
[3][3] = 1.0f
;
1904 exp_rotation
.w
= 0.951057f
;
1905 exp_rotation
.x
= 0.0f
;
1906 exp_rotation
.y
= 0.309017f
;
1907 exp_rotation
.z
= 0.0f
;
1909 exp_translation
.x
= 5.0f
;
1910 exp_translation
.y
= 5.0f
;
1911 exp_translation
.z
= 5.0f
;
1913 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1915 compare_scale(exp_scale
, got_scale
);
1916 compare_rotation(exp_rotation
, got_rotation
);
1917 compare_translation(exp_translation
, got_translation
);
1921 U(pm
).m
[0][0] = -0.9238790f
;
1922 U(pm
).m
[1][0] = -0.2705984f
;
1923 U(pm
).m
[2][0] = 0.2705984f
;
1924 U(pm
).m
[3][0] = -5.0f
;
1925 U(pm
).m
[0][1] = 0.2705984f
;
1926 U(pm
).m
[1][1] = 0.03806049f
;
1927 U(pm
).m
[2][1] = 0.9619395f
;
1928 U(pm
).m
[3][1] = 0.0f
;
1929 U(pm
).m
[0][2] = -0.2705984f
;
1930 U(pm
).m
[1][2] = 0.9619395f
;
1931 U(pm
).m
[2][2] = 0.03806049f
;
1932 U(pm
).m
[3][2] = 10.0f
;
1933 U(pm
).m
[0][3] = 0.0f
;
1934 U(pm
).m
[1][3] = 0.0f
;
1935 U(pm
).m
[2][3] = 0.0f
;
1936 U(pm
).m
[3][3] = 1.0f
;
1942 exp_rotation
.w
= 0.195091f
;
1943 exp_rotation
.x
= 0.0f
;
1944 exp_rotation
.y
= 0.693520f
;
1945 exp_rotation
.z
= 0.693520f
;
1947 exp_translation
.x
= -5.0f
;
1948 exp_translation
.y
= 0.0f
;
1949 exp_translation
.z
= 10.0f
;
1951 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1953 compare_scale(exp_scale
, got_scale
);
1954 compare_rotation(exp_rotation
, got_rotation
);
1955 compare_translation(exp_translation
, got_translation
);
1959 U(pm
).m
[0][0] = -0.9238790f
;
1960 U(pm
).m
[1][0] = -0.5411968f
;
1961 U(pm
).m
[2][0] = 0.8117952f
;
1962 U(pm
).m
[3][0] = -5.0f
;
1963 U(pm
).m
[0][1] = 0.2705984f
;
1964 U(pm
).m
[1][1] = 0.07612098f
;
1965 U(pm
).m
[2][1] = 2.8858185f
;
1966 U(pm
).m
[3][1] = 0.0f
;
1967 U(pm
).m
[0][2] = -0.2705984f
;
1968 U(pm
).m
[1][2] = 1.9238790f
;
1969 U(pm
).m
[2][2] = 0.11418147f
;
1970 U(pm
).m
[3][2] = 10.0f
;
1971 U(pm
).m
[0][3] = 0.0f
;
1972 U(pm
).m
[1][3] = 0.0f
;
1973 U(pm
).m
[2][3] = 0.0f
;
1974 U(pm
).m
[3][3] = 1.0f
;
1980 exp_rotation
.w
= 0.195091f
;
1981 exp_rotation
.x
= 0.0f
;
1982 exp_rotation
.y
= 0.693520f
;
1983 exp_rotation
.z
= 0.693520f
;
1985 exp_translation
.x
= -5.0f
;
1986 exp_translation
.y
= 0.0f
;
1987 exp_translation
.z
= 10.0f
;
1989 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1991 compare_scale(exp_scale
, got_scale
);
1992 compare_rotation(exp_rotation
, got_rotation
);
1993 compare_translation(exp_translation
, got_translation
);
1997 U(pm
).m
[0][0] = 0.7156004f
;
1998 U(pm
).m
[1][0] = -0.5098283f
;
1999 U(pm
).m
[2][0] = -0.4774843f
;
2000 U(pm
).m
[3][0] = -5.0f
;
2001 U(pm
).m
[0][1] = -0.6612288f
;
2002 U(pm
).m
[1][1] = -0.7147621f
;
2003 U(pm
).m
[2][1] = -0.2277977f
;
2004 U(pm
).m
[3][1] = 0.0f
;
2005 U(pm
).m
[0][2] = -0.2251499f
;
2006 U(pm
).m
[1][2] = 0.4787385f
;
2007 U(pm
).m
[2][2] = -0.8485972f
;
2008 U(pm
).m
[3][2] = 10.0f
;
2009 U(pm
).m
[0][3] = 0.0f
;
2010 U(pm
).m
[1][3] = 0.0f
;
2011 U(pm
).m
[2][3] = 0.0f
;
2012 U(pm
).m
[3][3] = 1.0f
;
2018 exp_rotation
.w
= 0.195091f
;
2019 exp_rotation
.x
= 0.905395f
;
2020 exp_rotation
.y
= -0.323355f
;
2021 exp_rotation
.z
= -0.194013f
;
2023 exp_translation
.x
= -5.0f
;
2024 exp_translation
.y
= 0.0f
;
2025 exp_translation
.z
= 10.0f
;
2027 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2029 compare_scale(exp_scale
, got_scale
);
2030 compare_rotation(exp_rotation
, got_rotation
);
2031 compare_translation(exp_translation
, got_translation
);
2035 U(pm
).m
[0][0] = 0.06554436f
;
2036 U(pm
).m
[1][0] = -0.6873012f
;
2037 U(pm
).m
[2][0] = 0.7234092f
;
2038 U(pm
).m
[3][0] = -5.0f
;
2039 U(pm
).m
[0][1] = -0.9617381f
;
2040 U(pm
).m
[1][1] = -0.2367795f
;
2041 U(pm
).m
[2][1] = -0.1378230f
;
2042 U(pm
).m
[3][1] = 0.0f
;
2043 U(pm
).m
[0][2] = 0.2660144f
;
2044 U(pm
).m
[1][2] = -0.6866967f
;
2045 U(pm
).m
[2][2] = -0.6765233f
;
2046 U(pm
).m
[3][2] = 10.0f
;
2047 U(pm
).m
[0][3] = 0.0f
;
2048 U(pm
).m
[1][3] = 0.0f
;
2049 U(pm
).m
[2][3] = 0.0f
;
2050 U(pm
).m
[3][3] = 1.0f
;
2056 exp_rotation
.w
= -0.195091f
;
2057 exp_rotation
.x
= 0.703358f
;
2058 exp_rotation
.y
= -0.586131f
;
2059 exp_rotation
.z
= 0.351679f
;
2061 exp_translation
.x
= -5.0f
;
2062 exp_translation
.y
= 0.0f
;
2063 exp_translation
.z
= 10.0f
;
2065 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2067 compare_scale(exp_scale
, got_scale
);
2068 compare_rotation(exp_rotation
, got_rotation
);
2069 compare_translation(exp_translation
, got_translation
);
2073 U(pm
).m
[0][0] = 7.121047f
;
2074 U(pm
).m
[1][0] = -5.883487f
;
2075 U(pm
).m
[2][0] = 11.81843f
;
2076 U(pm
).m
[3][0] = -5.0f
;
2077 U(pm
).m
[0][1] = 5.883487f
;
2078 U(pm
).m
[1][1] = -10.60660f
;
2079 U(pm
).m
[2][1] = -8.825232f
;
2080 U(pm
).m
[3][1] = 0.0f
;
2081 U(pm
).m
[0][2] = 11.81843f
;
2082 U(pm
).m
[1][2] = 8.8252320f
;
2083 U(pm
).m
[2][2] = -2.727645f
;
2084 U(pm
).m
[3][2] = 2.0f
;
2085 U(pm
).m
[0][3] = 0.0f
;
2086 U(pm
).m
[1][3] = 0.0f
;
2087 U(pm
).m
[2][3] = 0.0f
;
2088 U(pm
).m
[3][3] = 1.0f
;
2090 exp_scale
.x
= 15.0f
;
2091 exp_scale
.y
= 15.0f
;
2092 exp_scale
.z
= 15.0f
;
2094 exp_rotation
.w
= 0.382684f
;
2095 exp_rotation
.x
= 0.768714f
;
2096 exp_rotation
.y
= 0.0f
;
2097 exp_rotation
.z
= 0.512476f
;
2099 exp_translation
.x
= -5.0f
;
2100 exp_translation
.y
= 0.0f
;
2101 exp_translation
.z
= 2.0f
;
2103 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2105 compare_scale(exp_scale
, got_scale
);
2106 compare_rotation(exp_rotation
, got_rotation
);
2107 compare_translation(exp_translation
, got_translation
);
2111 U(pm
).m
[0][0] = 0.0f
;
2112 U(pm
).m
[1][0] = 4.0f
;
2113 U(pm
).m
[2][0] = 5.0f
;
2114 U(pm
).m
[3][0] = -5.0f
;
2115 U(pm
).m
[0][1] = 0.0f
;
2116 U(pm
).m
[1][1] = -10.60660f
;
2117 U(pm
).m
[2][1] = -8.825232f
;
2118 U(pm
).m
[3][1] = 6.0f
;
2119 U(pm
).m
[0][2] = 0.0f
;
2120 U(pm
).m
[1][2] = 8.8252320f
;
2121 U(pm
).m
[2][2] = 2.727645;
2122 U(pm
).m
[3][2] = 3.0f
;
2123 U(pm
).m
[0][3] = 0.0f
;
2124 U(pm
).m
[1][3] = 0.0f
;
2125 U(pm
).m
[2][3] = 0.0f
;
2126 U(pm
).m
[3][3] = 1.0f
;
2128 hr
= D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2129 ok(hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %x\n", hr
);
2132 static void test_Matrix_Transformation2D(void)
2134 D3DXMATRIX exp_mat
, got_mat
;
2135 D3DXVECTOR2 rot_center
, sca
, sca_center
, trans
;
2138 rot_center
.x
= 3.0f
;
2139 rot_center
.y
= 4.0f
;
2144 sca_center
.x
= 9.0f
;
2145 sca_center
.y
= -5.0f
;
2152 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2154 U(exp_mat
).m
[0][0] = -4.245192f
;
2155 U(exp_mat
).m
[1][0] = -0.147116f
;
2156 U(exp_mat
).m
[2][0] = 0.0f
;
2157 U(exp_mat
).m
[3][0] = 45.265373f
;
2158 U(exp_mat
).m
[0][1] = 7.647113f
;
2159 U(exp_mat
).m
[1][1] = 8.745192f
;
2160 U(exp_mat
).m
[2][1] = 0.0f
;
2161 U(exp_mat
).m
[3][1] = -13.401899f
;
2162 U(exp_mat
).m
[0][2] = 0.0f
;
2163 U(exp_mat
).m
[1][2] = 0.0f
;
2164 U(exp_mat
).m
[2][2] = 1.0f
;
2165 U(exp_mat
).m
[3][2] = 0.0f
;
2166 U(exp_mat
).m
[0][3] = 0.0f
;
2167 U(exp_mat
).m
[1][3] = 0.0f
;
2168 U(exp_mat
).m
[2][3] = 0.0f
;
2169 U(exp_mat
).m
[3][3] = 1.0f
;
2171 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, &sca
, &rot_center
, rot
, &trans
);
2173 expect_mat(&exp_mat
, &got_mat
);
2177 sca_center
.x
= 9.0f
;
2178 sca_center
.y
= -5.0f
;
2185 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2187 U(exp_mat
).m
[0][0] = 0.50f
;
2188 U(exp_mat
).m
[1][0] = -0.866025f
;
2189 U(exp_mat
).m
[2][0] = 0.0f
;
2190 U(exp_mat
).m
[3][0] = -6.0f
;
2191 U(exp_mat
).m
[0][1] = 0.866025f
;
2192 U(exp_mat
).m
[1][1] = 0.50f
;
2193 U(exp_mat
).m
[2][1] = 0.0f
;
2194 U(exp_mat
).m
[3][1] = 7.0f
;
2195 U(exp_mat
).m
[0][2] = 0.0f
;
2196 U(exp_mat
).m
[1][2] = 0.0f
;
2197 U(exp_mat
).m
[2][2] = 1.0f
;
2198 U(exp_mat
).m
[3][2] = 0.0f
;
2199 U(exp_mat
).m
[0][3] = 0.0f
;
2200 U(exp_mat
).m
[1][3] = 0.0f
;
2201 U(exp_mat
).m
[2][3] = 0.0f
;
2202 U(exp_mat
).m
[3][3] = 1.0f
;
2204 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, NULL
, NULL
, rot
, &trans
);
2206 expect_mat(&exp_mat
, &got_mat
);
2210 U(exp_mat
).m
[0][0] = 0.50f
;
2211 U(exp_mat
).m
[1][0] = -0.866025f
;
2212 U(exp_mat
).m
[2][0] = 0.0f
;
2213 U(exp_mat
).m
[3][0] = 0.0f
;
2214 U(exp_mat
).m
[0][1] = 0.866025f
;
2215 U(exp_mat
).m
[1][1] = 0.50f
;
2216 U(exp_mat
).m
[2][1] = 0.0f
;
2217 U(exp_mat
).m
[3][1] = 0.0f
;
2218 U(exp_mat
).m
[0][2] = 0.0f
;
2219 U(exp_mat
).m
[1][2] = 0.0f
;
2220 U(exp_mat
).m
[2][2] = 1.0f
;
2221 U(exp_mat
).m
[3][2] = 0.0f
;
2222 U(exp_mat
).m
[0][3] = 0.0f
;
2223 U(exp_mat
).m
[1][3] = 0.0f
;
2224 U(exp_mat
).m
[2][3] = 0.0f
;
2225 U(exp_mat
).m
[3][3] = 1.0f
;
2227 D3DXMatrixTransformation2D(&got_mat
, NULL
, sca_rot
, NULL
, NULL
, rot
, NULL
);
2229 expect_mat(&exp_mat
, &got_mat
);
2232 static void test_D3DXVec_Array(void)
2235 D3DVIEWPORT9 viewport
;
2236 D3DXMATRIX mat
, projection
, view
, world
;
2237 D3DXVECTOR4 inp_vec
[ARRAY_SIZE
];
2238 D3DXVECTOR4 out_vec
[ARRAY_SIZE
+ 2];
2239 D3DXVECTOR4 exp_vec
[ARRAY_SIZE
+ 2];
2240 D3DXPLANE inp_plane
[ARRAY_SIZE
];
2241 D3DXPLANE out_plane
[ARRAY_SIZE
+ 2];
2242 D3DXPLANE exp_plane
[ARRAY_SIZE
+ 2];
2244 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
2245 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
2247 for (i
= 0; i
< ARRAY_SIZE
+ 2; ++i
) {
2248 out_vec
[i
].x
= out_vec
[i
].y
= out_vec
[i
].z
= out_vec
[i
].w
= 0.0f
;
2249 exp_vec
[i
].x
= exp_vec
[i
].y
= exp_vec
[i
].z
= exp_vec
[i
].w
= 0.0f
;
2250 out_plane
[i
].a
= out_plane
[i
].b
= out_plane
[i
].c
= out_plane
[i
].d
= 0.0f
;
2251 exp_plane
[i
].a
= exp_plane
[i
].b
= exp_plane
[i
].c
= exp_plane
[i
].d
= 0.0f
;
2254 for (i
= 0; i
< ARRAY_SIZE
; ++i
) {
2255 inp_plane
[i
].a
= inp_plane
[i
].c
= inp_vec
[i
].x
= inp_vec
[i
].z
= i
;
2256 inp_plane
[i
].b
= inp_plane
[i
].d
= inp_vec
[i
].y
= inp_vec
[i
].w
= ARRAY_SIZE
- i
;
2259 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
;
2260 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
;
2261 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
;
2262 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
;
2264 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2266 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
2267 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
2268 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
2269 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
2270 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
2271 U(view
).m
[3][3] = -40.0f
;
2273 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;
2274 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
;
2275 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
;
2276 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
;
2278 /* D3DXVec2TransformCoordArray */
2279 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
;
2280 exp_vec
[2].x
= 0.653846f
; exp_vec
[2].y
= 0.769231f
;
2281 exp_vec
[3].x
= 0.625f
; exp_vec
[3].y
= 0.75f
;
2282 exp_vec
[4].x
= 0.590909f
; exp_vec
[4].y
= 8.0f
/11.0f
;
2283 exp_vec
[5].x
= 0.55f
; exp_vec
[5].y
= 0.7f
;
2284 D3DXVec2TransformCoordArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2285 compare_vectors(exp_vec
, out_vec
);
2287 /* D3DXVec2TransformNormalArray */
2288 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
;
2289 exp_vec
[2].x
= 21.0f
; exp_vec
[2].y
= 26.0f
;
2290 exp_vec
[3].x
= 17.0f
; exp_vec
[3].y
= 22.0f
;
2291 exp_vec
[4].x
= 13.0f
; exp_vec
[4].y
= 18.0f
;
2292 exp_vec
[5].x
= 9.0f
; exp_vec
[5].y
= 14.0f
;
2293 D3DXVec2TransformNormalArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2294 compare_vectors(exp_vec
, out_vec
);
2296 /* D3DXVec3TransformCoordArray */
2297 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
; exp_vec
[1].z
= 0.892857f
;
2298 exp_vec
[2].x
= 0.671875f
; exp_vec
[2].y
= 0.78125f
; exp_vec
[2].z
= 0.890625f
;
2299 exp_vec
[3].x
= 6.0f
/9.0f
; exp_vec
[3].y
= 7.0f
/9.0f
; exp_vec
[3].z
= 8.0f
/9.0f
;
2300 exp_vec
[4].x
= 0.6625f
; exp_vec
[4].y
= 0.775f
; exp_vec
[4].z
= 0.8875f
;
2301 exp_vec
[5].x
= 0.659091f
; exp_vec
[5].y
= 0.772727f
; exp_vec
[5].z
= 0.886364f
;
2302 D3DXVec3TransformCoordArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2303 compare_vectors(exp_vec
, out_vec
);
2305 /* D3DXVec3TransformNormalArray */
2306 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
; exp_vec
[1].z
= 35.0f
;
2307 exp_vec
[2].x
= 30.0f
; exp_vec
[2].y
= 36.0f
; exp_vec
[2].z
= 42.0f
;
2308 exp_vec
[3].x
= 35.0f
; exp_vec
[3].y
= 42.0f
; exp_vec
[3].z
= 49.0f
;
2309 exp_vec
[4].x
= 40.0f
; exp_vec
[4].y
= 48.0f
; exp_vec
[4].z
= 56.0f
;
2310 exp_vec
[5].x
= 45.0f
; exp_vec
[5].y
= 54.0f
; exp_vec
[5].z
= 63.0f
;
2311 D3DXVec3TransformNormalArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2312 compare_vectors(exp_vec
, out_vec
);
2314 /* D3DXVec3ProjectArray */
2315 exp_vec
[1].x
= 1089.554199f
; exp_vec
[1].y
= -226.590622f
; exp_vec
[1].z
= 0.215273f
;
2316 exp_vec
[2].x
= 1068.903320f
; exp_vec
[2].y
= 103.085129f
; exp_vec
[2].z
= 0.183050f
;
2317 exp_vec
[3].x
= 1051.778931f
; exp_vec
[3].y
= 376.462250f
; exp_vec
[3].z
= 0.156329f
;
2318 exp_vec
[4].x
= 1037.348877f
; exp_vec
[4].y
= 606.827393f
; exp_vec
[4].z
= 0.133813f
;
2319 exp_vec
[5].x
= 1025.023560f
; exp_vec
[5].y
= 803.591248f
; exp_vec
[5].z
= 0.114581f
;
2320 D3DXVec3ProjectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2321 compare_vectors(exp_vec
, out_vec
);
2323 /* D3DXVec3UnprojectArray */
2324 exp_vec
[1].x
= -6.124031f
; exp_vec
[1].y
= 3.225360f
; exp_vec
[1].z
= 0.620571f
;
2325 exp_vec
[2].x
= -3.807109f
; exp_vec
[2].y
= 2.046579f
; exp_vec
[2].z
= 0.446894f
;
2326 exp_vec
[3].x
= -2.922839f
; exp_vec
[3].y
= 1.596689f
; exp_vec
[3].z
= 0.380609f
;
2327 exp_vec
[4].x
= -2.456225f
; exp_vec
[4].y
= 1.359290f
; exp_vec
[4].z
= 0.345632f
;
2328 exp_vec
[5].x
= -2.167897f
; exp_vec
[5].y
= 1.212597f
; exp_vec
[5].z
= 0.324019f
;
2329 D3DXVec3UnprojectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2330 compare_vectors(exp_vec
, out_vec
);
2332 /* D3DXVec2TransformArray */
2333 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2334 exp_vec
[2].x
= 34.0f
; exp_vec
[2].y
= 40.0f
; exp_vec
[2].z
= 46.0f
; exp_vec
[2].w
= 52.0f
;
2335 exp_vec
[3].x
= 30.0f
; exp_vec
[3].y
= 36.0f
; exp_vec
[3].z
= 42.0f
; exp_vec
[3].w
= 48.0f
;
2336 exp_vec
[4].x
= 26.0f
; exp_vec
[4].y
= 32.0f
; exp_vec
[4].z
= 38.0f
; exp_vec
[4].w
= 44.0f
;
2337 exp_vec
[5].x
= 22.0f
; exp_vec
[5].y
= 28.0f
; exp_vec
[5].z
= 34.0f
; exp_vec
[5].w
= 40.0f
;
2338 D3DXVec2TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2339 compare_vectors(exp_vec
, out_vec
);
2341 /* D3DXVec3TransformArray */
2342 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2343 exp_vec
[2].x
= 43.0f
; exp_vec
[2].y
= 50.0f
; exp_vec
[2].z
= 57.0f
; exp_vec
[2].w
= 64.0f
;
2344 exp_vec
[3].x
= 48.0f
; exp_vec
[3].y
= 56.0f
; exp_vec
[3].z
= 64.0f
; exp_vec
[3].w
= 72.0f
;
2345 exp_vec
[4].x
= 53.0f
; exp_vec
[4].y
= 62.0f
; exp_vec
[4].z
= 71.0f
; exp_vec
[4].w
= 80.0f
;
2346 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2347 D3DXVec3TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2348 compare_vectors(exp_vec
, out_vec
);
2350 /* D3DXVec4TransformArray */
2351 exp_vec
[1].x
= 90.0f
; exp_vec
[1].y
= 100.0f
; exp_vec
[1].z
= 110.0f
; exp_vec
[1].w
= 120.0f
;
2352 exp_vec
[2].x
= 82.0f
; exp_vec
[2].y
= 92.0f
; exp_vec
[2].z
= 102.0f
; exp_vec
[2].w
= 112.0f
;
2353 exp_vec
[3].x
= 74.0f
; exp_vec
[3].y
= 84.0f
; exp_vec
[3].z
= 94.0f
; exp_vec
[3].w
= 104.0f
;
2354 exp_vec
[4].x
= 66.0f
; exp_vec
[4].y
= 76.0f
; exp_vec
[4].z
= 86.0f
; exp_vec
[4].w
= 96.0f
;
2355 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2356 D3DXVec4TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2357 compare_vectors(exp_vec
, out_vec
);
2359 /* D3DXPlaneTransformArray */
2360 exp_plane
[1].a
= 90.0f
; exp_plane
[1].b
= 100.0f
; exp_plane
[1].c
= 110.0f
; exp_plane
[1].d
= 120.0f
;
2361 exp_plane
[2].a
= 82.0f
; exp_plane
[2].b
= 92.0f
; exp_plane
[2].c
= 102.0f
; exp_plane
[2].d
= 112.0f
;
2362 exp_plane
[3].a
= 74.0f
; exp_plane
[3].b
= 84.0f
; exp_plane
[3].c
= 94.0f
; exp_plane
[3].d
= 104.0f
;
2363 exp_plane
[4].a
= 66.0f
; exp_plane
[4].b
= 76.0f
; exp_plane
[4].c
= 86.0f
; exp_plane
[4].d
= 96.0f
;
2364 exp_plane
[5].a
= 58.0f
; exp_plane
[5].b
= 68.0f
; exp_plane
[5].c
= 78.0f
; exp_plane
[5].d
= 88.0f
;
2365 D3DXPlaneTransformArray(out_plane
+ 1, sizeof(D3DXPLANE
), inp_plane
, sizeof(D3DXPLANE
), &mat
, ARRAY_SIZE
);
2366 compare_planes(exp_plane
, out_plane
);
2369 static void test_D3DXFloat_Array(void)
2371 static const float z
= 0.0f
;
2372 /* Compilers set different sign bits on 0.0 / 0.0, pick the right ones for NaN and -NaN */
2373 float tmpnan
= 0.0f
/z
;
2374 float nnan
= copysignf(1, tmpnan
) < 0.0f
? tmpnan
: -tmpnan
;
2384 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
2385 WORD half_ver1
, half_ver2
;
2387 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
2388 FLOAT single_out_ver1
, single_out_ver2
;
2390 { 80000.0f
, 0x7c00, 0x7ce2, 65536.0f
, 80000.0f
},
2391 { 65503.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2392 { 65504.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2393 { 65520.0f
, 0x7bff, 0x7c00, 65504.0f
, 65536.0f
},
2394 { 65521.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2395 { 65534.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2396 { 65535.0f
, 0x7c00, 0x7c00, 65535.0f
, 65536.0f
},
2397 { 65536.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2398 { -80000.0f
, 0xfc00, 0xfce2, -65536.0f
, -80000.0f
},
2399 { -65503.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2400 { -65504.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2401 { -65520.0f
, 0xfbff, 0xfc00, -65504.0f
, -65536.0f
},
2402 { -65521.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2403 { -65534.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2404 { -65535.0f
, 0xfc00, 0xfc00, -65535.0f
, -65536.0f
},
2405 { -65536.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2406 { 1.0f
/z
, 0x7c00, 0x7fff, 65536.0f
, 131008.0f
},
2407 { -1.0f
/z
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2408 { nan
, 0x7fff, 0xffff, 131008.0f
, -131008.0f
},
2409 { nnan
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2410 { 0.0f
, 0x0, 0x0, 0.0f
, 0.0f
},
2411 { -0.0f
, 0x8000, 0x8000, 0.0f
, 0.0f
},
2412 { 2.9809595e-08f
, 0x0, 0x0, 0.0f
, 0.0f
},
2413 { -2.9809595e-08f
, 0x8000, 0x8000, -0.0f
, -0.0f
},
2414 { 2.9809598e-08f
, 0x1, 0x0, 5.96046e-08f
, 5.96046e-08f
},
2415 { -2.9809598e-08f
, 0x8001, 0x8000, -5.96046e-08f
, -5.96046e-08f
},
2416 { 8.9406967e-08f
, 0x2, 0x1, 1.19209e-07f
, 5.96046e-008 }
2419 /* exception on NULL out or in parameter */
2420 out
= D3DXFloat32To16Array(&half
, &single
, 0);
2421 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2423 out
= D3DXFloat16To32Array(&single
, &half
, 0);
2424 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2426 for (i
= 0; i
< sizeof(testdata
)/sizeof(testdata
[0]); i
++)
2428 out
= D3DXFloat32To16Array(&half
, &testdata
[i
].single_in
, 1);
2429 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2430 ok(half
.value
== testdata
[i
].half_ver1
|| half
.value
== testdata
[i
].half_ver2
,
2431 "Got %x, expected %x or %x for index %d.\n", half
.value
, testdata
[i
].half_ver1
,
2432 testdata
[i
].half_ver2
, i
);
2434 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver1
, 1);
2435 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2436 ok(relative_error(single
, testdata
[i
].single_out_ver1
) < admitted_error
,
2437 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver1
, i
);
2439 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver2
, 1);
2440 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2441 ok(relative_error(single
, testdata
[i
].single_out_ver2
) < admitted_error
,
2442 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver2
, i
);
2446 static void test_D3DXSHAdd(void)
2449 FLOAT
*ret
= (FLOAT
*)0xdeadbeef;
2450 const FLOAT in1
[50] =
2452 1.11f
, 1.12f
, 1.13f
, 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
,
2453 1.19f
, 1.20f
, 1.21f
, 1.22f
, 1.23f
, 1.24f
, 1.25f
, 1.26f
,
2454 1.27f
, 1.28f
, 1.29f
, 1.30f
, 1.31f
, 1.32f
, 1.33f
, 1.34f
,
2455 1.35f
, 1.36f
, 1.37f
, 1.38f
, 1.39f
, 1.40f
, 1.41f
, 1.42f
,
2456 1.43f
, 1.44f
, 1.45f
, 1.46f
, 1.47f
, 1.48f
, 1.49f
, 1.50f
,
2457 1.51f
, 1.52f
, 1.53f
, 1.54f
, 1.55f
, 1.56f
, 1.57f
, 1.58f
,
2460 const FLOAT in2
[50] =
2462 2.11f
, 2.12f
, 2.13f
, 2.14f
, 2.15f
, 2.16f
, 2.17f
, 2.18f
,
2463 2.19f
, 2.20f
, 2.21f
, 2.22f
, 2.23f
, 2.24f
, 2.25f
, 2.26f
,
2464 2.27f
, 2.28f
, 2.29f
, 2.30f
, 2.31f
, 2.32f
, 2.33f
, 2.34f
,
2465 2.35f
, 2.36f
, 2.37f
, 2.38f
, 2.39f
, 2.40f
, 2.41f
, 2.42f
,
2466 2.43f
, 2.44f
, 2.45f
, 2.46f
, 2.47f
, 2.48f
, 2.49f
, 2.50f
,
2467 2.51f
, 2.52f
, 2.53f
, 2.54f
, 2.55f
, 2.56f
, 2.57f
, 2.58f
,
2470 FLOAT out
[50] = {0.0f
};
2473 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
2474 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
2475 * Exceptions will show up when out, in1 or in2 is NULL
2477 for (k
= 0; k
<= D3DXSH_MAXORDER
+ 1; k
++)
2481 ret
= D3DXSHAdd(&out
[0], k
, &in1
[0], &in2
[0]);
2482 ok(ret
== out
, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k
, out
, ret
);
2484 for (i
= 0; i
< count
; ++i
)
2486 ok(relative_error(in1
[i
] + in2
[i
], out
[i
]) < admitted_error
,
2487 "%u-%u: D3DXSHAdd() failed, got %f, expected %f\n", k
, i
, out
[i
], in1
[i
] + in2
[i
]);
2489 ok(relative_error(out
[count
], 0.0f
) < admitted_error
, "%u-%u: D3DXSHAdd() failed, got %f, expected 0.0\n", k
, k
* k
, out
[count
]);
2493 static void test_D3DXSHDot(void)
2496 FLOAT a
[49], b
[49], got
;
2497 const FLOAT expected
[] =
2498 { 0.5f
, 0.5f
, 25.0f
, 262.5f
, 1428.0f
, 5362.0f
, 15873.0f
, 39812.0f
, };
2500 for (i
= 0; i
< 49; i
++)
2506 /* D3DXSHDot computes by using order * order elements */
2507 for (i
= 0; i
<= D3DXSH_MAXORDER
+ 1; i
++)
2509 got
= D3DXSHDot(i
, a
, b
);
2510 ok(relative_error(got
, expected
[i
]) < admitted_error
, "order %d: expected %f, received %f\n", i
, expected
[i
], got
);
2516 static void test_D3DXSHEvalConeLight(void)
2519 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2520 const FLOAT table
[] = {
2522 1.604815f
, -3.131381f
, 7.202175f
, -2.870432f
, 6.759296f
, -16.959688f
,
2523 32.303082f
, -15.546381f
, -0.588878f
, -5.902123f
, 40.084042f
, -77.423569f
,
2524 137.556320f
, -70.971603f
, -3.492171f
, 7.683092f
, -2.129311f
, -35.971344f
,
2525 183.086548f
, -312.414948f
, 535.091064f
, -286.380371f
, -15.950727f
, 46.825714f
,
2526 -12.127637f
, 11.289261f
, -12.417809f
, -155.039566f
, 681.182556f
, -1079.733643f
,
2527 1807.650513f
, -989.755798f
, -59.345467f
, 201.822815f
, -70.726486f
, 7.206529f
,
2529 3.101155f
, -3.128710f
, 7.196033f
, -2.867984f
, -0.224708f
, 0.563814f
,
2530 -1.073895f
, 0.516829f
, 0.019577f
, 2.059788f
, -13.988971f
, 27.020128f
,
2531 -48.005917f
, 24.768450f
, 1.218736f
, -2.681329f
, -0.088639f
, -1.497410f
,
2532 7.621501f
, -13.005165f
, 22.274696f
, -11.921401f
, -0.663995f
, 1.949254f
,
2533 -0.504848f
, 4.168484f
, -4.585193f
, -57.247314f
, 251.522095f
, -398.684387f
,
2534 667.462891f
, -365.460693f
, -21.912912f
, 74.521721f
, -26.115280f
, 2.660963f
,
2536 2.454422f
, -4.789170f
, 11.015091f
, -4.390072f
, 10.337747f
, -25.938347f
,
2537 49.404713f
, -23.776817f
, -0.900637f
, -9.026776f
, 61.305000f
, -118.412514f
,
2538 210.380249f
, -108.544792f
, -5.340967f
, 11.750610f
, -3.256593f
, -55.014996f
,
2539 280.014709f
, -477.811066f
, 818.374512f
, -437.993469f
, -24.395227f
, 71.615799f
,
2540 -18.548151f
, 17.265928f
, -18.991943f
, -237.119324f
, 1041.808594f
, -1651.357300f
,
2541 2764.642090f
, -1513.744141f
, -90.763657f
, 308.670197f
, -108.169922f
, 11.021750f
,
2543 4.742942f
, -4.785086f
, 11.005697f
, -4.386329f
, -0.343672f
, 0.862303f
,
2544 -1.642427f
, 0.790444f
, 0.029941f
, 3.150264f
, -21.394896f
, 41.324898f
,
2545 -73.420807f
, 37.881153f
, 1.863950f
, -4.100857f
, -0.135565f
, -2.290156f
,
2546 11.656413f
, -19.890251f
, 34.067181f
, -18.232729f
, -1.015521f
, 2.981212f
,
2547 -0.772120f
, 6.375328f
, -7.012648f
, -87.554710f
, 384.680817f
, -609.752563f
,
2548 1020.825500f
, -558.939819f
, -33.513863f
, 113.974388f
, -39.941013f
, 4.069707f
,
2550 3.304030f
, -6.446959f
, 14.828006f
, -5.909713f
, 13.916198f
, -34.917004f
,
2551 66.506340f
, -32.007256f
, -1.212396f
, -12.151429f
, 82.525963f
, -159.401459f
,
2552 283.204193f
, -146.117996f
, -7.189764f
, 15.818130f
, -4.383876f
, -74.058655f
,
2553 376.942871f
, -643.207214f
, 1101.658081f
, -589.606628f
, -32.839729f
, 96.405884f
,
2554 -24.968664f
, 23.242596f
, -25.566080f
, -319.199097f
, 1402.434692f
, -2222.980957f
,
2555 3721.633545f
, -2037.732544f
, -122.181847f
, 415.517578f
, -145.613358f
, 14.836972f
,
2557 6.384730f
, -6.441462f
, 14.815362f
, -5.904673f
, -0.462635f
, 1.160793f
,
2558 -2.210959f
, 1.064060f
, 0.040305f
, 4.240739f
, -28.800821f
, 55.629673f
,
2559 -98.835709f
, 50.993862f
, 2.509163f
, -5.520384f
, -0.182491f
, -3.082903f
,
2560 15.691326f
, -26.775339f
, 45.859665f
, -24.544060f
, -1.367048f
, 4.013170f
,
2561 -1.039392f
, 8.582172f
, -9.440103f
, -117.862114f
, 517.839600f
, -820.820740f
,
2562 1374.188232f
, -752.419067f
, -45.114819f
, 153.427063f
, -53.766754f
, 5.478452f
, };
2565 FLOAT
*red_received
, *green_received
, *blue_received
;
2566 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2567 FLOAT radius
, roffset
, goffset
, boffset
;
2569 { rout
, gout
, bout
, table
, &table
[72], &table
[144], 0.5f
, 1.01f
, 1.02f
, 1.03f
, },
2570 { rout
, gout
, bout
, &table
[36], &table
[108], &table
[180], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
2571 { rout
, rout
, rout
, &table
[144], &table
[144], &table
[144], 0.5f
, 1.03f
, 1.03f
, 1.03f
, },
2572 { rout
, rout
, bout
, &table
[72], &table
[72], &table
[144], 0.5, 1.02f
, 1.02f
, 1.03f
, },
2573 { rout
, gout
, gout
, table
, &table
[144], &table
[144], 0.5f
, 1.01f
, 1.03f
, 1.03f
, },
2574 { rout
, gout
, rout
, &table
[144], &table
[72], &table
[144], 0.5f
, 1.03f
, 1.02f
, 1.03f
, },
2575 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
2576 { rout
, NULL
, bout
, table
, NULL
, &table
[144], 0.5f
, 1.01f
, 0.0f
, 1.03f
, },
2577 { rout
, gout
, NULL
, table
, &table
[72], NULL
, 0.5f
, 1.01f
, 1.02f
, 0.0f
, },
2578 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 0.5f
, 1.01f
, 0.0f
, 0.0f
, }, };
2580 unsigned int j
, l
, order
;
2582 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2584 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2586 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2588 for (j
= 0; j
< 49; j
++)
2590 test
[l
].red_received
[j
] = 1.01f
+ j
;
2591 if (test
[l
].green_received
)
2592 test
[l
].green_received
[j
] = 1.02f
+ j
;
2593 if (test
[l
].blue_received
)
2594 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2597 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
);
2598 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2600 for (j
= 0; j
< 49; j
++)
2602 if (j
>= order
* order
)
2603 expected
= j
+ test
[l
].roffset
;
2605 expected
= test
[l
].red_expected
[j
];
2606 ok(relative_error(expected
, test
[l
].red_received
[j
]) < admitted_error
,
2607 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2609 if (test
[l
].green_received
)
2611 if (j
>= order
* order
)
2612 expected
= j
+ test
[l
].goffset
;
2614 expected
= test
[l
].green_expected
[j
];
2615 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2616 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2619 if (test
[l
].blue_received
)
2621 if (j
>= order
* order
)
2622 expected
= j
+ test
[l
].boffset
;
2624 expected
= test
[l
].blue_expected
[j
];
2625 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2626 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2632 /* Cone light with radius <= 0.0f behaves as a directional light */
2633 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2635 FLOAT blue
[49], green
[49], red
[49];
2637 for (j
= 0; j
< 49; j
++)
2639 rout
[j
] = 1.01f
+ j
;
2640 gout
[j
] = 1.02f
+ j
;
2641 bout
[j
] = 1.03f
+ j
;
2643 green
[j
] = 1.02f
+ j
;
2644 blue
[j
] = 1.03f
+ j
;
2647 hr
= D3DXSHEvalConeLight(order
, &dir
, -0.1f
, 1.7f
, 2.6f
, 3.5f
, rout
, gout
, bout
);
2648 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2649 D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red
, green
, blue
);
2651 for (j
= 0; j
< 49; j
++)
2654 ok(relative_error(expected
, rout
[j
]) < admitted_error
,
2655 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, rout
[j
]);
2657 expected
= green
[j
];
2658 ok(relative_error(expected
, gout
[j
]) < admitted_error
,
2659 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, gout
[j
]);
2662 ok(relative_error(expected
, bout
[j
]) < admitted_error
,
2663 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, bout
[j
]);
2667 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
2668 hr
= D3DXSHEvalConeLight(7, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2669 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2670 hr
= D3DXSHEvalConeLight(0, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2671 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2672 hr
= D3DXSHEvalConeLight(1, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2673 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2676 static void test_D3DXSHEvalDirection(void)
2678 unsigned int i
, order
;
2680 FLOAT a
[49], expected
[49], *received_ptr
;
2681 const FLOAT table
[36] =
2682 { 0.282095f
, -0.977205f
, 1.465808f
, -0.488603f
, 2.185097f
, -6.555291f
,
2683 8.200181f
, -3.277646f
, -1.638823f
, 1.180087f
, 17.343668f
, -40.220032f
,
2684 47.020218f
, -20.110016f
, -13.007751f
, 6.490479f
, -15.020058f
, 10.620785f
,
2685 117.325661f
, -240.856750f
, 271.657288f
, -120.428375f
, -87.994247f
, 58.414314f
,
2686 -4.380850f
, 24.942520f
, -149.447693f
, 78.278130f
, 747.791748f
, -1427.687866f
,
2687 1574.619141, -713.843933f
, -560.843811f
, 430.529724, -43.588909, -26.911665, };
2689 d
.x
= 1.0; d
.y
= 2.0f
; d
.z
= 3.0f
;
2691 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2693 for (i
= 0; i
< 49; i
++)
2696 received_ptr
= D3DXSHEvalDirection(a
, order
, &d
);
2697 ok(received_ptr
== a
, "Expected %p, received %p\n", a
, received_ptr
);
2699 for (i
= 0; i
< 49; i
++)
2701 /* 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 */
2702 if ( (order
< D3DXSH_MINORDER
) || (order
> D3DXSH_MAXORDER
) || (i
>= order
* order
) )
2703 expected
[i
] = 1.5f
+ i
;
2705 expected
[i
] = table
[i
];
2707 ok(relative_error(a
[i
], expected
[i
]) < admitted_error
, "order %u, index %u: expected %f, received %f\n", order
, i
, expected
[i
], a
[i
]);
2712 static void test_D3DXSHEvalDirectionalLight(void)
2715 FLOAT
*blue_out
, bout
[49], expected
, gout
[49], *green_out
, *red_out
, rout
[49];
2716 static const FLOAT table
[] = {
2718 2.008781f
, -4.175174f
, 9.602900f
, -3.827243f
, 1.417963f
, -2.947181f
,
2719 6.778517f
, -2.701583f
, 7.249108f
, -18.188671f
, 34.643921f
, -16.672949f
,
2720 -0.631551f
, 1.417963f
, -2.947181f
, 6.778517f
, -2.701583f
, 7.249108f
,
2721 -18.188671f
, 34.643921f
, -16.672949f
, -0.631551f
, -7.794341f
, 52.934967f
,
2722 -102.245529f
, 181.656815f
, -93.725060f
, -4.611760f
, 10.146287f
, 1.555186f
,
2723 -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
, 37.996559f
,
2724 -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
, 199.236496f
,
2725 -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
, 360.268829f
,
2726 -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
, -23.864176f
,
2727 1.555186f
, -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
,
2728 37.996559f
, -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
,
2729 199.236496f
, -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
,
2730 360.268829f
, -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
,
2731 -23.864176f
, 34.868664f
, -38.354366f
, -478.864166f
, 2103.939941f
, -3334.927734f
,
2732 5583.213867f
, -3057.017090f
, -183.297836f
, 623.361633f
, -218.449921f
, 22.258503f
,
2734 3.072254f
, -6.385560f
, 14.686787f
, -5.853429f
, 2.168650f
, -4.507453f
,
2735 10.367143f
, -4.131832f
, 11.086870f
, -27.817965f
, 52.984818f
, -25.499800f
,
2736 -0.965902f
, 2.168650f
, -4.507453f
, 10.367143f
, -4.131832f
, 11.086870f
,
2737 -27.817965f
, 52.984818f
, -25.499800f
, -0.965902f
, -11.920755f
, 80.959351f
,
2738 -156.375488f
, 277.828033f
, -143.344193f
, -7.053278f
, 15.517849f
, 2.378519f
,
2739 -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
, 58.112385f
,
2740 -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
, 304.714630f
,
2741 -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
, 550.999390f
,
2742 -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
, -36.498150f
,
2743 2.378519f
, -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
,
2744 58.112385f
, -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
,
2745 304.714630f
, -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
,
2746 550.999390f
, -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
,
2747 -36.498150f
, 53.328545f
, -58.659618f
, -732.380493f
, 3217.790283f
, -5100.477539f
,
2748 8539.033203f
, -4675.437500f
, -280.337860f
, 953.376587f
, -334.099884f
, 34.042416f
,
2750 4.135726f
, -8.595945f
, 19.770674f
, -7.879617f
, 2.919336f
, -6.067726f
,
2751 13.955770f
, -5.562082f
, 14.924634f
, -37.447262f
, 71.325722f
, -34.326656f
,
2752 -1.300252f
, 2.919336f
, -6.067726f
, 13.955770f
, -5.562082f
, 14.924634f
,
2753 -37.447262f
, 71.325722f
, -34.326656f
, -1.300252f
, -16.047173f
, 108.983749f
,
2754 -210.505493f
, 373.999298f
, -192.963348f
, -9.494799f
, 20.889414f
, 3.201853f
,
2755 -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
, 78.228210f
,
2756 -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
, 410.192780f
,
2757 -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
, 741.729919f
,
2758 -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
, -49.132126f
,
2759 3.201853f
, -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
,
2760 78.228210f
, -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
,
2761 410.192780f
, -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
,
2762 741.729919f
, -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
,
2763 -49.132126f
, 71.788422f
, -78.964867f
, -985.896790f
, 4331.640625f
, -6866.027344f
,
2764 11494.852539f
, -6293.858398f
, -377.377899f
, 1283.391479f
, -449.749817f
, 45.826328f
, };
2767 FLOAT
*red_in
, *green_in
, *blue_in
;
2768 const FLOAT
*red_out
, *green_out
, *blue_out
;
2769 FLOAT roffset
, goffset
, boffset
;
2771 { { rout
, gout
, bout
, table
, &table
[90], &table
[180], 1.01f
, 1.02f
, 1.03f
, },
2772 { rout
, rout
, rout
, &table
[180], &table
[180], &table
[180], 1.03f
, 1.03f
, 1.03f
, },
2773 { rout
, rout
, bout
, &table
[90], &table
[90], &table
[180], 1.02f
, 1.02f
, 1.03f
, },
2774 { rout
, gout
, gout
, table
, &table
[180], &table
[180], 1.01f
, 1.03f
, 1.03f
, },
2775 { rout
, gout
, rout
, &table
[180], &table
[90], &table
[180], 1.03f
, 1.02f
, 1.03f
, },
2776 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
2777 { rout
, NULL
, bout
, table
, NULL
, &table
[180], 1.01f
, 0.0f
, 1.03f
, },
2778 { rout
, gout
, NULL
, table
, &table
[90], NULL
, 1.01f
, 1.02f
, 0.0f
, },
2779 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 0.0f
, 0.0f
, }, };
2781 unsigned int j
, l
, order
, startindex
;
2783 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2785 for (l
= 0; l
< sizeof( test
) / sizeof( test
[0] ); l
++)
2789 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2791 red_out
= test
[l
].red_in
;
2792 green_out
= test
[l
].green_in
;
2793 blue_out
= test
[l
].blue_in
;
2795 for (j
= 0; j
< 49; j
++)
2797 red_out
[j
] = 1.01f
+ j
;
2799 green_out
[j
] = 1.02f
+ j
;
2801 blue_out
[j
] = 1.03f
+ j
;
2804 hr
= D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red_out
, green_out
, blue_out
);
2805 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2807 for (j
= 0; j
< 49; j
++)
2809 if ( j
>= order
* order
)
2810 expected
= j
+ test
[l
].roffset
;
2812 expected
= test
[l
].red_out
[startindex
+ j
];
2813 ok(relative_error(expected
, red_out
[j
]) < admitted_error
,
2814 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, red_out
[j
]);
2818 if ( j
>= order
* order
)
2819 expected
= j
+ test
[l
].goffset
;
2821 expected
= test
[l
].green_out
[startindex
+ j
];
2822 ok(relative_error(expected
, green_out
[j
]) < admitted_error
,
2823 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, green_out
[j
]);
2828 if ( j
>= order
* order
)
2829 expected
= j
+ test
[l
].boffset
;
2831 expected
= test
[l
].blue_out
[startindex
+ j
];
2832 ok(relative_error(expected
, blue_out
[j
]) < admitted_error
,
2833 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, blue_out
[j
]);
2837 startindex
+= order
* order
;
2841 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
2842 hr
= D3DXSHEvalDirectionalLight(7, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2843 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2844 hr
= D3DXSHEvalDirectionalLight(0, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2845 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2846 hr
= D3DXSHEvalDirectionalLight(1, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2847 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2850 static void test_D3DXSHEvalHemisphereLight(void)
2852 D3DXCOLOR bottom
, top
;
2854 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2855 const FLOAT table
[] = {
2857 23.422981f
, 15.859521f
, -36.476898f
, 14.537894f
,
2859 19.966694f
, 6.096982f
, -14.023058f
, 5.588900f
,
2861 24.566214f
, 8.546826f
, -19.657701f
, 7.834591f
, };
2864 FLOAT
*red_received
, *green_received
, *blue_received
;
2865 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2866 const FLOAT roffset
, goffset
, boffset
;
2868 { rout
, gout
, bout
, table
, &table
[4], &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2869 { rout
, rout
, rout
, &table
[8], &table
[8], &table
[8], 1.03f
, 1.03f
, 1.03f
, },
2870 { rout
, rout
, bout
, &table
[4], &table
[4], &table
[8], 1.02f
, 1.02f
, 1.03f
, },
2871 { rout
, gout
, gout
, table
, &table
[8], &table
[8], 1.01f
, 1.03f
, 1.03f
, },
2872 { rout
, gout
, rout
, &table
[8], &table
[4], &table
[8], 1.03f
, 1.02f
, 1.03f
, },
2873 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
2874 { rout
, NULL
, bout
, table
, NULL
, &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2875 { rout
, gout
, NULL
, table
, &table
[4], NULL
, 1.01f
, 1.02f
, 1.03f
, },
2876 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 1.02f
, 1.03f
, }, };
2878 unsigned int j
, l
, order
;
2880 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2881 top
.r
= 0.1f
; top
.g
= 2.1f
; top
.b
= 2.3f
; top
.a
= 4.3f
;
2882 bottom
.r
= 8.71f
; bottom
.g
= 5.41f
; bottom
.b
= 6.94f
; bottom
.a
= 8.43f
;
2884 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2885 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2887 for (j
= 0; j
< 49; j
++)
2889 test
[l
].red_received
[j
] = 1.01f
+ j
;
2890 if (test
[l
].green_received
)
2891 test
[l
].green_received
[j
] = 1.02f
+ j
;
2892 if (test
[l
].blue_received
)
2893 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2896 hr
= D3DXSHEvalHemisphereLight(order
, &dir
, top
, bottom
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
2897 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2899 for (j
= 0; j
< 49; j
++)
2902 expected
= test
[l
].red_expected
[j
];
2903 else if (j
< order
* order
)
2906 expected
= test
[l
].roffset
+ j
;
2907 ok(relative_error(test
[l
].red_received
[j
], expected
) < admitted_error
,
2908 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2910 if (test
[l
].green_received
)
2913 expected
= test
[l
].green_expected
[j
];
2914 else if (j
< order
* order
)
2917 expected
= test
[l
].goffset
+ j
;
2918 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2919 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2922 if (test
[l
].blue_received
)
2925 expected
= test
[l
].blue_expected
[j
];
2926 else if (j
< order
* order
)
2929 expected
= test
[l
].boffset
+ j
;
2930 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2931 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2937 static void test_D3DXSHEvalSphericalLight(void)
2940 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2941 const FLOAT table
[] = {
2943 3.01317239f
, -0.97724032f
, 2.24765277f
, -0.89580363f
, 0.0f
, 0.0f
,
2944 0.0f
, 0.0f
, 0.0f
, 0.06292814f
, -0.42737406f
, 0.61921263f
,
2945 -0.30450898f
, 0.56761158f
, 0.03723336f
, -0.08191673f
, 0.0f
, 0.0f
,
2946 0.0f
, 0.0f
, 0.0f
, -0.0f
, 0.0f
, 0.0f
,
2947 0.0f
, 0.01249927f
, -0.01374878f
, -0.14810932f
, 0.43434596f
, -0.24598616f
,
2948 -0.15175794f
, -0.22548729f
, -0.03784076f
, 0.19280137f
, -0.07830712f
, 0.00797894f
,
2950 0.40251964f
, -0.24365333f
, 0.56040263f
, -0.22334887f
, 0.16204689f
, -0.40659040f
,
2951 0.44600141f
, -0.37270784f
, -0.01411773f
, -0.04319951f
, 0.29338786f
, -0.42508304f
,
2952 0.20904225f
, -0.38965943f
, -0.02556031f
, 0.05623499f
, -0.00468823f
, -0.07920021f
,
2953 0.33171222f
, -0.30782884f
, 0.00052908f
, -0.28217643f
, -0.02889918f
, 0.10309891f
,
2954 -0.02670213f
, 0.00724340f
, -0.00796750f
, -0.08583023f
, 0.25170606f
, -0.14255044f
,
2955 -0.08794463f
, -0.13067122f
, -0.02192894f
, 0.11172954f
, -0.04537944f
, 0.00462384f
,
2957 1.95445275f
, -0.85659367f
, 1.97016549f
, -0.78521085f
, 0.23103346f
, -0.57968396f
,
2958 0.63587302f
, -0.53137696f
, -0.02012792f
, 0.02111043f
, -0.14337072f
, 0.20772660f
,
2959 -0.10215330f
, 0.19041604f
, 0.01249063f
, -0.02748052f
, 0.00633162f
, 0.10696279f
,
2960 -0.44798949f
, 0.41573414f
, -0.00071454f
, 0.38108963f
, 0.03902940f
, -0.13923886f
,
2961 0.03606220f
, -0.00447360f
, 0.00492081f
, 0.05300967f
, -0.15545636f
, 0.08804068f
,
2962 0.05431554f
, 0.08070395f
, 0.01354355f
, -0.06900536f
, 0.02802683f
, -0.00285574f
,
2964 4.60838127f
, -1.49460280f
, 3.43758631f
, -1.37005258f
, 0.0f
, 0.0f
,
2965 0.0f
, 0.0f
, 0.0f
, 0.09624302f
, -0.65363091f
, 0.94703102f
,
2966 -0.46571958f
, 0.86811179f
, 0.05694513f
, -0.12528442f
, -0.0f
, 0.0f
,
2967 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2968 0.0f
, 0.01911653f
, -0.02102755f
, -0.22652012f
, 0.66429377f
, -0.37621412f
,
2969 -0.23210037f
, -0.34486291f
, -0.05787410f
, 0.29487267f
, -0.11976383f
, 0.01220309f
,
2971 0.61561823f
, -0.37264627f
, 0.85708636f
, -0.34159240f
, 0.24783641f
, -0.62184411f
,
2972 0.68211979f
, -0.57002378f
, -0.02159182f
, -0.06606984f
, 0.44871080f
, -0.65012693f
,
2973 0.31971166f
, -0.59594971f
, -0.03909224f
, 0.08600645f
, -0.00717023f
, -0.12112973f
,
2974 0.50732452f
, -0.47079703f
, 0.00080918f
, -0.43156394f
, -0.04419874f
, 0.15768069f
,
2975 -0.04083854f
, 0.01107814f
, -0.01218559f
, -0.13126975f
, 0.38496217f
, -0.21801829f
,
2976 -0.13450353f
, -0.19985008f
, -0.03353838f
, 0.17088045f
, -0.06940385f
, 0.00707176f
,
2978 2.98916292f
, -1.31008446f
, 3.01319408f
, -1.20091069f
, 0.35334525f
, -0.88657540f
,
2979 0.97251165f
, -0.81269407f
, -0.03078388f
, 0.03228654f
, -0.21927285f
, 0.31769949f
,
2980 -0.15623444f
, 0.29122451f
, 0.01910332f
, -0.04202903f
, 0.00968366f
, 0.16359015f
,
2981 -0.68516040f
, 0.63582867f
, -0.00109283f
, 0.58284295f
, 0.05969203f
, -0.21295355f
,
2982 0.05515395f
, -0.00684198f
, 0.00752595f
, 0.08107361f
, -0.23775679f
, 0.13465045f
,
2983 0.08307083f
, 0.12342957f
, 0.02071366f
, -0.10553761f
, 0.04286456f
, -0.00436760f
,
2985 6.20359039f
, -2.01196527f
, 4.62752008f
, -1.84430146f
, 0.0f
, 0.0f
,
2986 0.0f
, 0.0f
, 0.0f
, 0.12955792f
, -0.87988776f
, 1.27484941f
,
2987 -0.62693024f
, 1.16861200f
, 0.07665691f
, -0.16865209f
, 0.0f
, 0.0f
,
2988 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2989 0.0f
, 0.02573379f
, -0.02830632f
, -0.30493096f
, 0.89424169f
, -0.50644207f
,
2990 -0.31244281f
, -0.46423855f
, -0.07790744f
, 0.39694402f
, -0.16122055f
, 0.01642723f
,
2992 0.82871687f
, -0.50163919f
, 1.15377009f
, -0.45983589f
, 0.33362597f
, -0.83709794f
,
2993 0.91823828f
, -0.76733971f
, -0.02906591f
, -0.08894017f
, 0.60403383f
, -0.87517095f
,
2994 0.43038112f
, -0.80224001f
, -0.05262417f
, 0.11577792f
, -0.00965224f
, -0.16305926f
,
2995 0.68293691f
, -0.63376528f
, 0.00108928f
, -0.58095151f
, -0.05949831f
, 0.21226248f
,
2996 -0.05497497f
, 0.01491288f
, -0.01640368f
, -0.17670928f
, 0.51821834f
, -0.29348618f
,
2997 -0.18106246f
, -0.26902896f
, -0.04514782f
, 0.23003140f
, -0.09342826f
, 0.00951968f
,
2999 4.02387333f
, -1.76357520f
, 4.05622292f
, -1.61661065f
, 0.47565711f
, -1.19346702f
,
3000 1.30915034f
, -1.09401131f
, -0.04143983f
, 0.04346266f
, -0.29517499f
, 0.42767239f
,
3001 -0.21031560f
, 0.39203301f
, 0.02571601f
, -0.05657754f
, 0.01303570f
, 0.22021750f
,
3002 -0.92233127f
, 0.85592318f
, -0.00147112f
, 0.78459626f
, 0.08035465f
, -0.28666824f
,
3003 0.07424571f
, -0.00921036f
, 0.01013109f
, 0.10913756f
, -0.32005721f
, 0.18126021f
,
3004 0.11182612f
, 0.16615519f
, 0.02788378f
, -0.14206986f
, 0.05770230f
, -0.00587946f
, };
3007 FLOAT
*red_received
, *green_received
, *blue_received
;
3008 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
3009 FLOAT radius
, roffset
, goffset
, boffset
;
3011 { rout
, gout
, bout
, table
, &table
[108], &table
[216], 17.4f
, 1.01f
, 1.02f
, 1.03f
, },
3012 { rout
, gout
, bout
, &table
[36], &table
[144], &table
[252], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
3013 { rout
, gout
, bout
, &table
[72], &table
[180], &table
[288], -3.0f
, 1.01f
, 1.02f
, 1.03f
, },
3014 { rout
, rout
, rout
, &table
[216], &table
[216], &table
[216], 17.4f
, 1.03f
, 1.03f
, 1.03f
, },
3015 { rout
, rout
, bout
, &table
[108], &table
[108], &table
[216], 17.4, 1.02f
, 1.02f
, 1.03f
, },
3016 { rout
, gout
, gout
, table
, &table
[216], &table
[216], 17.4f
, 1.01f
, 1.03f
, 1.03f
, },
3017 { rout
, gout
, rout
, &table
[216], &table
[108], &table
[216], 17.4f
, 1.03f
, 1.02f
, 1.03f
, },
3018 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
3019 { rout
, NULL
, bout
, table
, NULL
, &table
[216], 17.4f
, 1.01f
, 0.0f
, 1.03f
, },
3020 { rout
, gout
, NULL
, table
, &table
[108], NULL
, 17.4f
, 1.01f
, 1.02f
, 0.0f
, },
3021 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 17.4f
, 1.01f
, 0.0f
, 0.0f
, }, };
3023 unsigned int j
, l
, order
;
3025 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3027 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
3029 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3031 for (j
= 0; j
< 49; j
++)
3033 test
[l
].red_received
[j
] = 1.01f
+ j
;
3034 if (test
[l
].green_received
)
3035 test
[l
].green_received
[j
] = 1.02f
+ j
;
3036 if (test
[l
].blue_received
)
3037 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3040 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
);
3041 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3043 for (j
= 0; j
< 49; j
++)
3045 if (j
>= order
* order
)
3046 expected
= j
+ test
[l
].roffset
;
3048 expected
= test
[l
].red_expected
[j
];
3049 ok(relative_error(expected
, test
[l
].red_received
[j
]) < 0.0005f
,
3050 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3052 if (test
[l
].green_received
)
3054 if (j
>= order
* order
)
3055 expected
= j
+ test
[l
].goffset
;
3057 expected
= test
[l
].green_expected
[j
];
3058 ok(relative_error(expected
, test
[l
].green_received
[j
]) < 0.0005f
,
3059 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3062 if (test
[l
].blue_received
)
3064 if (j
>= order
* order
)
3065 expected
= j
+ test
[l
].boffset
;
3067 expected
= test
[l
].blue_expected
[j
];
3068 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < 0.0005f
,
3069 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3075 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3076 hr
= D3DXSHEvalSphericalLight(7, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3077 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3078 hr
= D3DXSHEvalSphericalLight(0, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3079 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3080 hr
= D3DXSHEvalSphericalLight(1, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3081 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3084 static void test_D3DXSHMultiply2(void)
3087 FLOAT a
[20], b
[20], c
[20];
3088 /* D3DXSHMultiply2 only modifies the first 4 elements of the array */
3089 const FLOAT expected
[20] =
3090 { 3.418594f
, 1.698211f
, 1.703853f
, 1.709494f
, 4.0f
, 5.0f
,
3091 6.0f
, 7.0f
, 8.0f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3092 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
};
3094 for (i
= 0; i
< 20; i
++)
3096 a
[i
] = 1.0f
+ i
/ 100.0f
;
3097 b
[i
] = 3.0f
- i
/ 100.0f
;
3101 D3DXSHMultiply2(c
, a
, b
);
3102 for (i
= 0; i
< 20; i
++)
3103 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3106 static void test_D3DXSHMultiply3(void)
3109 FLOAT a
[20], b
[20], c
[20];
3110 /* D3DXSHMultiply3 only modifies the first 9 elements of the array */
3111 static const float expected
[20] =
3113 7.813913f
, 2.256058f
, 5.9484005f
, 4.970894f
, 2.899858f
, 3.598946f
,
3114 1.726572f
, 5.573538f
, 0.622063f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3115 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
3117 static const float expected_aliased
[20] =
3119 454.092499f
,2.126404f
, 5.570401f
, 15.330379f
, 22.796087f
, 43.604126f
,
3120 4.273841f
, 175.772034f
, 237.672729f
, 1.09f
, 1.1f
, 1.11f
, 1.12f
, 1.13f
,
3121 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
, 1.19f
3124 for (i
= 0; i
< 20; i
++)
3126 a
[i
] = 1.0f
+ i
/ 100.0f
;
3127 b
[i
] = 3.0f
- i
/ 100.0f
;
3131 D3DXSHMultiply3(c
, a
, b
);
3132 for (i
= 0; i
< 20; i
++)
3133 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
,
3134 "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3135 for (i
= 0; i
< 20; i
++)
3137 D3DXSHMultiply3(c
, c
, b
);
3138 for (i
= 0; i
< 20; i
++)
3139 ok(relative_error(c
[i
], expected_aliased
[i
]) < admitted_error
,
3140 "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3143 static void test_D3DXSHMultiply4(void)
3146 FLOAT a
[20], b
[20], c
[20];
3147 /* D3DXSHMultiply4 only modifies the first 16 elements of the array */
3148 const FLOAT expected
[] =
3150 14.182599f
, 2.615703f
, 12.828601f
, 9.820596f
, 3.039696f
, 4.530442f
,
3151 5.820584f
, 12.249846f
, 2.194346f
, 3.900152f
, 5.416609f
, 5.601813f
,
3152 0.959982f
, 7.037550f
, 3.625230f
, 0.463601f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3154 -211441.265625f
, -2529.157715f
, -10023.393555f
, -441.277191f
, -163.994385f
,
3155 -526.305115f
, 29636.187500f
, -3931.830811f
, -13577.111328f
, -3978.973877f
,
3156 -10330.341797f
, -13779.787109f
, -16685.109375f
, -44981.375000f
, -73269.742188f
,
3157 -95237.335938f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3159 0.236682f
, -0.717649f
, -0.180500f
, -0.077124f
, 0.144831f
, 0.573286f
,
3160 -0.337959f
, 0.055694f
, -0.442100f
, 0.147702f
, -0.055157f
, 0.084337f
,
3161 0.179877f
, 0.009099f
, 0.232200f
, 0.074142f
, 1.6f
, 1.7f
, 1.8f
, 1.9f
, };
3163 for (i
= 0; i
< 20; i
++)
3165 a
[i
] = 1.0f
+ i
/ 100.0f
;
3166 b
[i
] = 3.0f
- i
/ 100.0f
;
3170 D3DXSHMultiply4(c
, a
, b
);
3171 for (i
= 0; i
< 20; i
++)
3172 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3174 for (i
= 0; i
< 20; i
++)
3176 b
[i
] = 3.0f
- i
/ 100.0f
;
3180 D3DXSHMultiply4(c
, c
, b
);
3181 for (i
= 0; i
< 20; i
++)
3182 ok(relative_error(c
[i
], expected
[20 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[20 + i
], c
[i
]);
3184 for (i
= 0; i
< 20; i
++)
3187 D3DXSHMultiply4(c
, c
, c
);
3188 for (i
= 0; i
< 20; i
++)
3189 ok(relative_error(c
[i
], expected
[40 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[40 + i
], c
[i
]);
3192 static void test_D3DXSHRotate(void)
3195 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3196 static const FLOAT table
[]=
3197 { /* Rotation around X-axis Pi/2 */
3198 1.01f
, -3.01f
, 2.01f
, 4.01f
, -8.01f
, -6.01f
,
3199 -11.307890f
, 5.01f
, -1.565839f
, 1.093598f
, -11.01f
, 19.833414f
,
3200 -15.268191f
, -19.004118f
, -3.364889f
, -9.562627f
, 12.099654f
, -0.272131f
,
3201 30.241013f
, 26.919991f
, 39.236877f
, -22.632446f
, 6.707388f
, -11.768282f
,
3202 3.443672f
, -6.07445f
, 11.61839f
, 1.527561f
, 37.89633f
, -56.9012f
,
3203 47.42289f
, 50.39153f
, 10.61819f
, 25.50101f
, 0.049241f
, 16.98330f
,
3205 1.01f
, -3.01f
, -3.01f
, 4.01f
, -8.01f
, -6.01f
, -11.307889f
, -8.01f
, 14.297919f
,
3206 /* Rotation around X-axis -Pi/2 */
3207 1.01f
, 3.01f
, -2.01f
, 4.01f
, 8.01f
, -6.01f
,
3208 -11.307890f
, -5.01f
, -1.565839f
, -1.093598f
, -11.01f
, -19.833414f
,
3209 15.268191f
, -19.004118f
, 3.364889f
, -9.562627f
, -12.099654f
, -0.272131f
,
3210 -30.241013f
, 26.919991f
, 39.236877f
, 22.632446f
, 6.707388f
, 11.768282f
,
3211 3.443672f
, 6.07445f
, 11.61839f
, -1.527561f
, 37.89633f
, 56.9012f
,
3212 -47.42289f
, 50.39153f
, -10.61819f
, 25.50101f
, -0.049248f
, 16.98330f
,
3214 1.01f
, 3.01f
, -3.01f
, 4.01f
, 8.01f
, -6.01f
, -11.307890f
, -8.01f
, 14.297919f
,
3215 /* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
3216 1.01f
, 4.944899f
, 1.442301f
, 1.627281f
, 0.219220f
, 10.540824f
,
3217 -9.136903f
, 2.763750f
, -7.30904f
, -5.875721f
, 5.303124f
, -8.682154f
,
3218 -25.683384f
, 1.680279f
, -18.808388f
, 7.653656f
, 16.939133f
, -17.328018f
,
3219 14.629795f
, -54.467102f
, -12.231035f
, -4.089857f
, -9.444222f
, 3.056035f
,
3220 0.179257f
, -10.041875f
, 23.090092f
, -23.188709f
, 11.727098f
, -65.183090f
,
3221 48.671577f
, -15.073209f
, 38.793171f
, -26.039536f
, 6.192769f
, -17.672247f
,
3223 1.01f
, 4.944899f
, -0.891142f
, 4.607695f
, 0.219218f
, 10.773325f
,
3224 -8.204769f
, 13.563829f
, -12.007767f
,
3225 /* Rotation around Z-axis Pi/6 */
3226 1.01f
, 3.745711f
, 3.01f
, 2.467762f
, 10.307889f
, 9.209813f
,
3227 7.01f
, 3.931864f
, 0.166212f
, 16.01f
, 18.504042f
, 17.405966f
,
3228 13.01f
, 6.128016f
, -2.029941f
, -10.01f
, 13.154292f
, 24.01f
,
3229 29.432245f
, 28.334167f
, 21.01f
, 9.056221f
, -4.958143f
, -18.01f
,
3230 -27.236094f
, -4.520332f
, 16.814543f
, 34.01f
, 43.092495f
, 41.994423f
,
3231 31.01f
, 12.716471f
, -8.618400f
, -28.01f
, -40.896347f
, -44.190571,
3233 1.01f
, 3.745711f
, 3.01f
, 1.599906f
, 10.307889f
, 9.209813f
,
3234 7.01f
, 2.331957f
, -4.421894f
, };
3235 unsigned int i
, j
, l
, order
;
3237 D3DXMatrixRotationX(&m
[0], -D3DX_PI
/ 2.0f
);
3238 D3DXMatrixRotationX(&m
[1], D3DX_PI
/ 2.0f
);
3239 D3DXMatrixRotationYawPitchRoll(&m
[2], D3DX_PI
/ 3.0f
, D3DX_PI
/ 4.0f
, D3DX_PI
/ 5.0f
);
3240 D3DXMatrixRotationZ(&m
[3], D3DX_PI
/ 6.0f
);
3242 for (l
= 0; l
< 2; l
++)
3249 for (j
= 0; j
< 4; j
++)
3251 for (order
= 0; order
<= D3DXSH_MAXORDER
; order
++)
3253 for (i
= 0; i
< 49; i
++)
3255 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3259 received_ptr
= D3DXSHRotate(out_temp
, order
, &m
[j
], in
);
3260 ok(received_ptr
== out_temp
, "Order %u, expected %p, received %p\n", order
, out
, received_ptr
);
3262 for (i
= 0; i
< 49; i
++)
3264 if ((i
> 0) && ((i
>= order
* order
) || (order
> D3DXSH_MAXORDER
)))
3267 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3269 expected
= i
+ 1.01f
;
3271 else if ((l
== 0) || (order
> 3))
3272 expected
= table
[45 * j
+ i
];
3274 expected
= table
[45 * j
+ 36 +i
];
3275 ok(relative_error(out_temp
[i
], expected
) < admitted_error
,
3276 "Order %u index %u, expected %f, received %f\n", order
, i
, expected
, out_temp
[i
]);
3283 static void test_D3DXSHRotateZ(void)
3285 unsigned int end
, i
, j
, l
, order
, square
;
3286 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3287 const FLOAT angle
[] = { D3DX_PI
/ 3.0f
, -D3DX_PI
/ 3.0f
, 4.0f
* D3DX_PI
/ 3.0f
, }, table
[] =
3288 { /* Angle = D3DX_PI / 3.0f */
3289 1.01f
, 4.477762f
, 3.010000f
, 0.264289f
, 5.297888f
, 9.941864f
,
3290 7.010000f
, -1.199813f
, -8.843789f
, -10.010002f
, 7.494040f
, 18.138016f
,
3291 13.010000, -3.395966f
, -17.039942f
, -16.009998f
, -30.164297f
, -18.010004f
,
3292 10.422242f
, 29.066219f
, 21.010000f
, -6.324171f
, -27.968145f
, -24.009998f
,
3293 2.226099f
, -18.180565, -43.824551f
, -28.010004f
, 14.082493f
, 42.726471f
,
3294 31.010000f
, -9.984426f
, -41.628399f
, -34.009995f
, 5.886358f
, 40.530331f
,
3296 1.01f
, 4.477762f
, 0.0f
, -5.816784f
, 5.297888f
, 6.936864f
,
3297 0.0f
, -9.011250f
, -2.294052f
, -10.010002f
, 12.999042f
, 12.133017f
,
3298 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, -30.164297f
, 0.0f
,
3299 19.927244f
, 19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3300 -13.061530f
, -18.180565f
, -30.319553f
, 0.0f
, 28.587496f
, 27.721474f
,
3301 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -23.617250f
,
3303 1.010000f
, 3.977762f
, 3.977762f
, 1.114195f
, 7.245791f
, 10.559759f
,
3304 10.559759f
, -0.995160f
, -0.467341f
, 0.467339f
, 12.765371f
, 18.515701f
,
3305 18.515701f
, -1.797287f
, 0.493916f
, -0.493916f
, -21.412342f
, 21.412338f
,
3306 9.221072f
, 23.671757f
, 23.671757f
, 3.850195f
, -20.468727f
, 20.468723f
,
3307 -10.662103f
, -36.516628f
, -12.061245f
, 12.061240f
, 22.556875f
, 38.999908f
,
3308 38.999908f
, -0.034875f
, -10.427902f
, 10.427900f
, -36.838284f
, -27.652803f
,
3309 /* Angle = -D3DX_PI / 3.0f */
3310 1.01f
, -2.467762f
, 3.010000f
, 3.745711f
, -10.307890f
, -3.931864f
,
3311 7.010000f
, 9.209813f
, -0.166214f
, -10.010002f
, -18.504044f
, -6.128017f
,
3312 13.010000f
, 17.405966f
, 2.029938f
, -16.009998f
, 13.154303f
, -18.010004f
,
3313 -29.432247f
, -9.056221f
, 21.010000f
, 28.334169f
, 4.958139f
, -24.010002f
,
3314 -27.236092f
, 44.190582f
, 16.814558f
, -28.009996f
, -43.092499f
, -12.716474f
,
3315 31.010000f
, 41.994423f
, 8.618393f
, -34.010002f
, -40.896347f
, -4.520310f
,
3317 1.01f
, -2.467762f
, 0.0f
, -3.205718f
, -10.307890f
, -6.936864f
,
3318 0.0f
, -9.011250f
, -4.463446f
, -10.009998f
, -12.999042f
, -12.133017f
,
3319 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, 13.154303f
, 0.0f
,
3320 -19.927244f
, -19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3321 -5.695983f
, 44.190582f
, 30.319553f
, 0.0f
, -28.587496f
, -27.721474f
,
3322 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -57.405258f
,
3324 1.010000f
, -2.967762f
, -2.967762f
, -0.609195f
, -7.498291f
, -10.686009f
,
3325 -10.686009f
, -11.836716f
, 5.390780f
, -5.390779f
, -10.303651f
, -17.284842f
,
3326 -17.284842f
, -17.565643f
, 4.114273f
, -4.114273f
, 23.716436f
, -23.716433f
,
3327 -8.069025f
, -23.095732f
, -23.095732f
, -18.535847f
, -11.271107f
, 11.271104f
,
3328 -2.072484f
, 30.149330f
, 15.244893f
, -15.244888f
, -20.965050f
, -38.203999f
,
3329 -38.203999f
, -37.258266f
, 5.426677f
, -5.426679f
, -23.396751f
, -9.903559f
,
3330 /* Angle = 4.0f * D3DX_PI / 3.0f */
3331 1.01f
, -4.477762f
, 3.010000f
, -0.264289f
, 5.297887f
, -9.941864f
,
3332 7.010000f
, 1.199814f
, -8.843788f
, 10.010004f
, 7.494038f
, -18.138016f
,
3333 13.010000f
, 3.395967f
, -17.039940f
, 16.009996f
, -30.164293f
, 18.010006f
,
3334 10.422239f
, -29.066219f
, 21.010000f
, 6.324172f
, -27.968143f
, 24.009993f
,
3335 2.226105f
, 18.180552f
, -43.824543f
, 28.010008f
, 14.082489f
, -42.726471f
,
3336 31.010000f
, 9.984427f
, -41.628399f
, 34.009987f
, 5.886366f
, -40.530327f
,
3338 1.01f
, -4.477762f
, 0.0f
, -1.938928f
, 5.297887f
, -6.936864f
,
3339 0.0f
, -3.003751f
, -2.294051f
, 10.010004f
, 12.999040f
, -12.133017f
,
3340 0.0f
, -5.253751f
, -5.628747f
, 0.0f
, -30.164293f
, 0.0f
,
3341 19.927242f
, -19.061220f
, 0.0f
, -8.253753f
, -8.628746f
, 0.0f
,
3342 -13.061535f
, 18.180552f
, -30.319553f
, 0.0f
, 28.587492f
, -27.721474f
,
3343 0.0f
, -12.003753f
, -12.378742f
, 0.0f
, -13.128765f
, -7.872400f
,
3345 1.010000f
, -3.977762f
, -3.977762f
, 2.863566f
, 6.371104f
, -10.122416f
,
3346 -10.122416f
, 10.578746f
, -7.769295f
, -7.769290f
, 16.883686f
, -20.574858f
,
3347 -20.574858f
, 24.909130f
, -5.726166f
, -5.726164f
, -18.796221f
, -18.796211f
,
3348 29.325350f
, -33.723892f
, -33.723892f
, 42.258442f
, -4.851232f
, -4.851226f
,
3349 -2.533393f
, 32.452259f
, -46.545670f
, -46.545654f
, 51.860325f
, -53.651630f
,
3350 -53.651630f
, 71.738174f
, 4.440616f
, 4.440629f
, 25.884174f
, -10.748116f
, };
3352 for (l
= 0; l
< 3; l
++)
3357 out_temp
= &in
[l
- 1];
3364 for (j
= 0; j
< 3; j
++)
3366 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3368 for (i
= 0; i
< 49; i
++)
3370 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3374 received_ptr
= D3DXSHRotateZ(out_temp
, order
, angle
[j
], in
);
3375 ok(received_ptr
== out_temp
, "angle %f, order %u, expected %p, received %p\n", angle
[j
], order
, out_temp
, received_ptr
);
3377 for (i
= 0; i
< end
; i
++)
3379 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
3380 square
= (order
<= D3DXSH_MINORDER
) ? D3DXSH_MINORDER
* D3DXSH_MINORDER
: order
* order
;
3381 if (i
>= square
|| ((order
>= D3DXSH_MAXORDER
) && (i
>= D3DXSH_MAXORDER
* D3DXSH_MAXORDER
)))
3383 expected
= i
+ l
+ 0.01f
;
3385 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3387 expected
= table
[36 * (l
+ 3 * j
) + i
];
3388 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
]);
3395 static void test_D3DXSHScale(void)
3397 unsigned int i
, order
;
3398 FLOAT a
[49], b
[49], expected
, *received_array
;
3400 for (i
= 0; i
< 49; i
++)
3406 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3408 received_array
= D3DXSHScale(b
, order
, a
, 5.0f
);
3409 ok(received_array
== b
, "Expected %p, received %p\n", b
, received_array
);
3411 for (i
= 0; i
< 49; i
++)
3413 if (i
< order
* order
)
3414 expected
= 5.0f
* a
[i
];
3415 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
3418 ok(relative_error(b
[i
], expected
) < admitted_error
, "order %d, element %d, expected %f, received %f\n", order
, i
, expected
, b
[i
]);
3429 D3DXQuaternionTest();
3433 test_matrix_stack();
3434 test_Matrix_AffineTransformation2D();
3435 test_Matrix_Decompose();
3436 test_Matrix_Transformation2D();
3437 test_D3DXVec_Array();
3438 test_D3DXFloat_Array();
3441 test_D3DXSHEvalConeLight();
3442 test_D3DXSHEvalDirection();
3443 test_D3DXSHEvalDirectionalLight();
3444 test_D3DXSHEvalHemisphereLight();
3445 test_D3DXSHEvalSphericalLight();
3446 test_D3DXSHMultiply2();
3447 test_D3DXSHMultiply3();
3448 test_D3DXSHMultiply4();
3449 test_D3DXSHRotate();
3450 test_D3DXSHRotateZ();