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
);
615 /*_______________D3DXPlaneFromPoints_______*/
616 vec1
.x
= 1.0f
; vec1
.y
= 2.0f
; vec1
.z
= 3.0f
;
617 vec2
.x
= 1.0f
; vec2
.y
= -6.0f
; vec2
.z
= -5.0f
;
618 vec3
.x
= 83.0f
; vec3
.y
= 74.0f
; vec3
.z
= 65.0f
;
619 expectedplane
.a
= 0.085914f
; expectedplane
.b
= -0.704492f
; expectedplane
.c
= 0.704492f
; expectedplane
.d
= -0.790406f
;
620 D3DXPlaneFromPoints(&gotplane
,&vec1
,&vec2
,&vec3
);
621 expect_plane(expectedplane
, gotplane
);
623 /*_______________D3DXPlaneIntersectLine___________*/
624 vec1
.x
= 9.0f
; vec1
.y
= 6.0f
; vec1
.z
= 3.0f
;
625 vec2
.x
= 2.0f
; vec2
.y
= 5.0f
; vec2
.z
= 8.0f
;
626 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
627 D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
628 expect_vec3(expectedvec
, gotvec
);
629 /* Test a parallel line */
630 vec1
.x
= 11.0f
; vec1
.y
= 13.0f
; vec1
.z
= 15.0f
;
631 vec2
.x
= 17.0f
; vec2
.y
= 31.0f
; vec2
.z
= 24.0f
;
632 expectedvec
.x
= 20.0f
/3.0f
; expectedvec
.y
= 17.0f
/3.0f
; expectedvec
.z
= 14.0f
/3.0f
;
633 funcpointer
= D3DXPlaneIntersectLine(&gotvec
,&plane
,&vec1
,&vec2
);
634 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
636 /*_______________D3DXPlaneNormalize______________*/
637 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
);
638 D3DXPlaneNormalize(&gotplane
, &plane
);
639 expect_plane(expectedplane
, gotplane
);
640 nulplane
.a
= 0.0; nulplane
.b
= 0.0f
, nulplane
.c
= 0.0f
; nulplane
.d
= 0.0f
;
641 expectedplane
.a
= 0.0f
; expectedplane
.b
= 0.0f
; expectedplane
.c
= 0.0f
; expectedplane
.d
= 0.0f
;
642 D3DXPlaneNormalize(&gotplane
, &nulplane
);
643 expect_plane(expectedplane
, gotplane
);
645 /*_______________D3DXPlaneTransform____________*/
646 expectedplane
.a
= 49.0f
; expectedplane
.b
= -98.0f
; expectedplane
.c
= 55.0f
; expectedplane
.d
= -165.0f
;
647 D3DXPlaneTransform(&gotplane
,&plane
,&mat
);
648 expect_plane(expectedplane
, gotplane
);
651 static void D3DXQuaternionTest(void)
654 D3DXQUATERNION expectedquat
, gotquat
, Nq
, Nq1
, nul
, smallq
, smallr
, q
, r
, s
, t
, u
;
655 LPD3DXQUATERNION funcpointer
;
656 D3DXVECTOR3 axis
, expectedvec
;
657 FLOAT angle
, expected
, got
, scale
, scale2
;
658 BOOL expectedbool
, gotbool
;
660 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
; nul
.w
= 0.0f
;
661 q
.x
= 1.0f
, q
.y
= 2.0f
; q
.z
= 4.0f
; q
.w
= 10.0f
;
662 r
.x
= -3.0f
; r
.y
= 4.0f
; r
.z
= -5.0f
; r
.w
= 7.0;
663 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
664 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
665 smallq
.x
= 0.1f
; smallq
.y
= 0.2f
; smallq
.z
= 0.3f
; smallq
.w
= 0.4f
;
666 smallr
.x
= 0.5f
; smallr
.y
= 0.6f
; smallr
.z
= 0.7f
; smallr
.w
= 0.8f
;
671 /*_______________D3DXQuaternionBaryCentric________________________*/
672 expectedquat
.x
= -867.444458; expectedquat
.y
= 87.851111f
; expectedquat
.z
= -9.937778f
; expectedquat
.w
= 3.235555f
;
673 D3DXQuaternionBaryCentric(&gotquat
,&q
,&r
,&t
,scale
,scale2
);
674 expect_vec4(expectedquat
,gotquat
);
676 /*_______________D3DXQuaternionConjugate________________*/
677 expectedquat
.x
= -1.0f
; expectedquat
.y
= -2.0f
; expectedquat
.z
= -4.0f
; expectedquat
.w
= 10.0f
;
678 D3DXQuaternionConjugate(&gotquat
,&q
);
679 expect_vec4(expectedquat
,gotquat
);
680 /* Test the NULL case */
681 funcpointer
= D3DXQuaternionConjugate(&gotquat
,NULL
);
682 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
683 funcpointer
= D3DXQuaternionConjugate(NULL
,NULL
);
684 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
686 /*_______________D3DXQuaternionDot______________________*/
688 got
= D3DXQuaternionDot(&q
,&r
);
689 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
690 /* Tests the case NULL */
692 got
= D3DXQuaternionDot(NULL
,&r
);
693 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
695 got
= D3DXQuaternionDot(NULL
,NULL
);
696 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
698 /*_______________D3DXQuaternionExp______________________________*/
699 expectedquat
.x
= -0.216382f
; expectedquat
.y
= -0.432764f
; expectedquat
.z
= -0.8655270f
; expectedquat
.w
= -0.129449f
;
700 D3DXQuaternionExp(&gotquat
,&q
);
701 expect_vec4(expectedquat
,gotquat
);
702 /* Test the null quaternion */
703 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
704 D3DXQuaternionExp(&gotquat
,&nul
);
705 expect_vec4(expectedquat
,gotquat
);
706 /* Test the case where the norm of the quaternion is <1 */
707 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
708 expectedquat
.x
= 0.195366; expectedquat
.y
= 0.097683f
; expectedquat
.z
= 0.293049f
; expectedquat
.w
= 0.930813f
;
709 D3DXQuaternionExp(&gotquat
,&Nq1
);
710 expect_vec4(expectedquat
,gotquat
);
712 /*_______________D3DXQuaternionIdentity________________*/
713 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 1.0f
;
714 D3DXQuaternionIdentity(&gotquat
);
715 expect_vec4(expectedquat
,gotquat
);
716 /* Test the NULL case */
717 funcpointer
= D3DXQuaternionIdentity(NULL
);
718 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
720 /*_______________D3DXQuaternionInverse________________________*/
721 expectedquat
.x
= -1.0f
/121.0f
; expectedquat
.y
= -2.0f
/121.0f
; expectedquat
.z
= -4.0f
/121.0f
; expectedquat
.w
= 10.0f
/121.0f
;
722 D3DXQuaternionInverse(&gotquat
,&q
);
723 expect_vec4(expectedquat
,gotquat
);
725 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 10.0f
;
726 D3DXQuaternionInverse(&gotquat
,&gotquat
);
727 expect_vec4(expectedquat
,gotquat
);
730 /*_______________D3DXQuaternionIsIdentity________________*/
731 s
.x
= 0.0f
; s
.y
= 0.0f
; s
.z
= 0.0f
; s
.w
= 1.0f
;
733 gotbool
= D3DXQuaternionIsIdentity(&s
);
734 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
735 s
.x
= 2.3f
; s
.y
= -4.2f
; s
.z
= 1.2f
; s
.w
=0.2f
;
736 expectedbool
= FALSE
;
737 gotbool
= D3DXQuaternionIsIdentity(&q
);
738 ok( expectedbool
== gotbool
, "Expected boolean : %d, Got bool : %d\n", expectedbool
, gotbool
);
739 /* Test the NULL case */
740 gotbool
= D3DXQuaternionIsIdentity(NULL
);
741 ok(gotbool
== FALSE
, "Expected boolean: %d, Got boolean: %d\n", FALSE
, gotbool
);
743 /*_______________D3DXQuaternionLength__________________________*/
745 got
= D3DXQuaternionLength(&q
);
746 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
747 /* Tests the case NULL */
749 got
= D3DXQuaternionLength(NULL
);
750 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
752 /*_______________D3DXQuaternionLengthSq________________________*/
754 got
= D3DXQuaternionLengthSq(&q
);
755 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
756 /* Tests the case NULL */
758 got
= D3DXQuaternionLengthSq(NULL
);
759 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
761 /*_______________D3DXQuaternionLn______________________________*/
762 expectedquat
.x
= 1.0f
; expectedquat
.y
= 2.0f
; expectedquat
.z
= 4.0f
; expectedquat
.w
= 0.0f
;
763 D3DXQuaternionLn(&gotquat
,&q
);
764 expect_vec4(expectedquat
,gotquat
);
765 expectedquat
.x
= -3.0f
; expectedquat
.y
= 4.0f
; expectedquat
.z
= -5.0f
; expectedquat
.w
= 0.0f
;
766 D3DXQuaternionLn(&gotquat
,&r
);
767 expect_vec4(expectedquat
,gotquat
);
768 Nq
.x
= 1.0f
/11.0f
; Nq
.y
= 2.0f
/11.0f
; Nq
.z
= 4.0f
/11.0f
; Nq
.w
=10.0f
/11.0f
;
769 expectedquat
.x
= 0.093768f
; expectedquat
.y
= 0.187536f
; expectedquat
.z
= 0.375073f
; expectedquat
.w
= 0.0f
;
770 D3DXQuaternionLn(&gotquat
,&Nq
);
771 expect_vec4(expectedquat
,gotquat
);
772 Nq
.x
= 0.0f
; Nq
.y
= 0.0f
; Nq
.z
= 0.0f
; Nq
.w
= 1.0f
;
773 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
774 D3DXQuaternionLn(&gotquat
,&Nq
);
775 expect_vec4(expectedquat
,gotquat
);
776 Nq
.x
= 5.4f
; Nq
.y
= 1.2f
; Nq
.z
= -0.3f
; Nq
.w
= -0.3f
;
777 expectedquat
.x
= 10.616652f
; expectedquat
.y
= 2.359256f
; expectedquat
.z
= -0.589814f
; expectedquat
.w
= 0.0f
;
778 D3DXQuaternionLn(&gotquat
,&Nq
);
779 expect_vec4(expectedquat
,gotquat
);
780 /* Test the case where the norm of the quaternion is <1 */
781 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= 0.9f
;
782 expectedquat
.x
= 0.206945f
; expectedquat
.y
= 0.103473f
; expectedquat
.z
= 0.310418f
; expectedquat
.w
= 0.0f
;
783 D3DXQuaternionLn(&gotquat
,&Nq1
);
784 expect_vec4(expectedquat
,gotquat
);
785 /* Test the case where the real part of the quaternion is -1.0f */
786 Nq1
.x
= 0.2f
; Nq1
.y
= 0.1f
; Nq1
.z
= 0.3; Nq1
.w
= -1.0f
;
787 expectedquat
.x
= 0.2f
; expectedquat
.y
= 0.1f
; expectedquat
.z
= 0.3f
; expectedquat
.w
= 0.0f
;
788 D3DXQuaternionLn(&gotquat
,&Nq1
);
789 expect_vec4(expectedquat
,gotquat
);
791 /*_______________D3DXQuaternionMultiply________________________*/
792 expectedquat
.x
= 3.0f
; expectedquat
.y
= 61.0f
; expectedquat
.z
= -32.0f
; expectedquat
.w
= 85.0f
;
793 D3DXQuaternionMultiply(&gotquat
,&q
,&r
);
794 expect_vec4(expectedquat
,gotquat
);
796 /*_______________D3DXQuaternionNormalize________________________*/
797 expectedquat
.x
= 1.0f
/11.0f
; expectedquat
.y
= 2.0f
/11.0f
; expectedquat
.z
= 4.0f
/11.0f
; expectedquat
.w
= 10.0f
/11.0f
;
798 D3DXQuaternionNormalize(&gotquat
,&q
);
799 expect_vec4(expectedquat
,gotquat
);
801 /*_______________D3DXQuaternionRotationAxis___________________*/
802 axis
.x
= 2.0f
; axis
.y
= 7.0; axis
.z
= 13.0f
;
803 angle
= D3DX_PI
/3.0f
;
804 expectedquat
.x
= 0.067116; expectedquat
.y
= 0.234905f
; expectedquat
.z
= 0.436251f
; expectedquat
.w
= 0.866025f
;
805 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
806 expect_vec4(expectedquat
,gotquat
);
807 /* Test the nul quaternion */
808 axis
.x
= 0.0f
; axis
.y
= 0.0; axis
.z
= 0.0f
;
809 expectedquat
.x
= 0.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.866025f
;
810 D3DXQuaternionRotationAxis(&gotquat
,&axis
,angle
);
811 expect_vec4(expectedquat
,gotquat
);
813 /*_______________D3DXQuaternionRotationMatrix___________________*/
814 /* test when the trace is >0 */
815 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
816 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
817 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
818 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
819 U(mat
).m
[0][0] = 10.0f
; U(mat
).m
[1][1] = 20.0f
; U(mat
).m
[2][2] = 30.0f
;
820 U(mat
).m
[3][3] = 48.0f
;
821 expectedquat
.x
= 2.368682f
; expectedquat
.y
= 0.768221f
; expectedquat
.z
= -0.384111f
; expectedquat
.w
= 3.905125f
;
822 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
823 expect_vec4(expectedquat
,gotquat
);
824 /* test the case when the greater element is (2,2) */
825 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
826 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
827 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
828 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
829 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = -60.0f
; U(mat
).m
[2][2] = 40.0f
;
830 U(mat
).m
[3][3] = 48.0f
;
831 expectedquat
.x
= 1.233905f
; expectedquat
.y
= -0.237290f
; expectedquat
.z
= 5.267827f
; expectedquat
.w
= -0.284747f
;
832 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
833 expect_vec4(expectedquat
,gotquat
);
834 /* test the case when the greater element is (1,1) */
835 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
836 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
837 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
838 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
839 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 60.0f
; U(mat
).m
[2][2] = -80.0f
;
840 U(mat
).m
[3][3] = 48.0f
;
841 expectedquat
.x
= 0.651031f
; expectedquat
.y
= 6.144103f
; expectedquat
.z
= -0.203447f
; expectedquat
.w
= 0.488273f
;
842 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
843 expect_vec4(expectedquat
,gotquat
);
844 /* test the case when the trace is near 0 in a matrix which is not a rotation */
845 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
846 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
847 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
848 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
849 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.9f
;
850 U(mat
).m
[3][3] = 48.0f
;
851 expectedquat
.x
= 1.709495f
; expectedquat
.y
= 2.339872f
; expectedquat
.z
= -0.534217f
; expectedquat
.w
= 1.282122f
;
852 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
853 expect_vec4(expectedquat
,gotquat
);
854 /* test the case when the trace is 0.49 in a matrix which is not a rotation */
855 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
856 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
857 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
858 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
859 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.51f
;
860 U(mat
).m
[3][3] = 48.0f
;
861 expectedquat
.x
= 1.724923f
; expectedquat
.y
= 2.318944f
; expectedquat
.z
= -0.539039f
; expectedquat
.w
= 1.293692f
;
862 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
863 expect_vec4(expectedquat
,gotquat
);
864 /* test the case when the trace is 0.51 in a matrix which is not a rotation */
865 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
866 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
867 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
868 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
869 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.49f
;
870 U(mat
).m
[3][3] = 48.0f
;
871 expectedquat
.x
= 1.725726f
; expectedquat
.y
= 2.317865f
; expectedquat
.z
= -0.539289f
; expectedquat
.w
= 1.294294f
;
872 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
873 expect_vec4(expectedquat
,gotquat
);
874 /* test the case when the trace is 0.99 in a matrix which is not a rotation */
875 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
876 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
877 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
878 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
879 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = -0.01f
;
880 U(mat
).m
[3][3] = 48.0f
;
881 expectedquat
.x
= 1.745328f
; expectedquat
.y
= 2.291833f
; expectedquat
.z
= -0.545415f
; expectedquat
.w
= 1.308996f
;
882 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
883 expect_vec4(expectedquat
,gotquat
);
884 /* test the case when the trace is 1.0 in a matrix which is not a rotation */
885 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
886 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
887 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
888 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
889 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.0f
;
890 U(mat
).m
[3][3] = 48.0f
;
891 expectedquat
.x
= 1.745743f
; expectedquat
.y
= 2.291288f
; expectedquat
.z
= -0.545545f
; expectedquat
.w
= 1.309307f
;
892 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
893 expect_vec4(expectedquat
,gotquat
);
894 /* test the case when the trace is 1.01 in a matrix which is not a rotation */
895 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
896 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
897 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
898 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
899 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.01f
;
900 U(mat
).m
[3][3] = 48.0f
;
901 expectedquat
.x
= 18.408188f
; expectedquat
.y
= 5.970223f
; expectedquat
.z
= -2.985111f
; expectedquat
.w
= 0.502494f
;
902 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
903 expect_vec4(expectedquat
,gotquat
);
904 /* test the case when the trace is 1.5 in a matrix which is not a rotation */
905 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
906 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
907 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
908 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
909 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.5f
;
910 U(mat
).m
[3][3] = 48.0f
;
911 expectedquat
.x
= 15.105186f
; expectedquat
.y
= 4.898980f
; expectedquat
.z
= -2.449490f
; expectedquat
.w
= 0.612372f
;
912 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
913 expect_vec4(expectedquat
,gotquat
);
914 /* test the case when the trace is 1.7 in a matrix which is not a rotation */
915 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
916 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
917 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
918 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
919 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.70f
;
920 U(mat
).m
[3][3] = 48.0f
;
921 expectedquat
.x
= 14.188852f
; expectedquat
.y
= 4.601790f
; expectedquat
.z
= -2.300895f
; expectedquat
.w
= 0.651920f
;
922 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
923 expect_vec4(expectedquat
,gotquat
);
924 /* test the case when the trace is 1.99 in a matrix which is not a rotation */
925 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
926 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
927 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
928 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
929 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 0.99f
;
930 U(mat
).m
[3][3] = 48.0f
;
931 expectedquat
.x
= 13.114303f
; expectedquat
.y
= 4.253287f
; expectedquat
.z
= -2.126644f
; expectedquat
.w
= 0.705337f
;
932 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
933 expect_vec4(expectedquat
,gotquat
);
934 /* test the case when the trace is 2.0 in a matrix which is not a rotation */
935 U(mat
).m
[0][1] = 5.0f
; U(mat
).m
[0][2] = 7.0f
; U(mat
).m
[0][3] = 8.0f
;
936 U(mat
).m
[1][0] = 11.0f
; U(mat
).m
[1][2] = 16.0f
; U(mat
).m
[1][3] = 33.0f
;
937 U(mat
).m
[2][0] = 19.0f
; U(mat
).m
[2][1] = -21.0f
; U(mat
).m
[2][3] = 43.0f
;
938 U(mat
).m
[3][0] = 2.0f
; U(mat
).m
[3][1] = 3.0f
; U(mat
).m
[3][2] = -4.0f
;
939 U(mat
).m
[0][0] = -10.0f
; U(mat
).m
[1][1] = 10.0f
; U(mat
).m
[2][2] = 2.0f
;
940 U(mat
).m
[3][3] = 48.0f
;
941 expectedquat
.x
= 10.680980f
; expectedquat
.y
= 3.464102f
; expectedquat
.z
= -1.732051f
; expectedquat
.w
= 0.866025f
;
942 D3DXQuaternionRotationMatrix(&gotquat
,&mat
);
943 expect_vec4(expectedquat
,gotquat
);
945 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
946 expectedquat
.x
= 0.303261f
; expectedquat
.y
= 0.262299f
; expectedquat
.z
= 0.410073f
; expectedquat
.w
= 0.819190f
;
947 D3DXQuaternionRotationYawPitchRoll(&gotquat
,D3DX_PI
/4.0f
,D3DX_PI
/11.0f
,D3DX_PI
/3.0f
);
948 expect_vec4(expectedquat
,gotquat
);
950 /*_______________D3DXQuaternionSlerp________________________*/
951 expectedquat
.x
= -0.2f
; expectedquat
.y
= 2.6f
; expectedquat
.z
= 1.3f
; expectedquat
.w
= 9.1f
;
952 D3DXQuaternionSlerp(&gotquat
,&q
,&r
,scale
);
953 expect_vec4(expectedquat
,gotquat
);
954 expectedquat
.x
= 334.0f
; expectedquat
.y
= -31.9f
; expectedquat
.z
= 6.1f
; expectedquat
.w
= 6.7f
;
955 D3DXQuaternionSlerp(&gotquat
,&q
,&t
,scale
);
956 expect_vec4(expectedquat
,gotquat
);
957 expectedquat
.x
= 0.239485f
; expectedquat
.y
= 0.346580f
; expectedquat
.z
= 0.453676f
; expectedquat
.w
= 0.560772f
;
958 D3DXQuaternionSlerp(&gotquat
,&smallq
,&smallr
,scale
);
959 expect_vec4(expectedquat
,gotquat
);
961 /*_______________D3DXQuaternionSquad________________________*/
962 expectedquat
.x
= -156.296f
; expectedquat
.y
= 30.242f
; expectedquat
.z
= -2.5022f
; expectedquat
.w
= 7.3576f
;
963 D3DXQuaternionSquad(&gotquat
,&q
,&r
,&t
,&u
,scale
);
964 expect_vec4(expectedquat
,gotquat
);
966 /*_______________D3DXQuaternionSquadSetup___________________*/
967 r
.x
= 1.0f
, r
.y
= 2.0f
; r
.z
= 4.0f
; r
.w
= 10.0f
;
968 s
.x
= -3.0f
; s
.y
= 4.0f
; s
.z
= -5.0f
; s
.w
= 7.0;
969 t
.x
= -1111.0f
, t
.y
= 111.0f
; t
.z
= -11.0f
; t
.w
= 1.0f
;
970 u
.x
= 91.0f
; u
.y
= - 82.0f
; u
.z
= 7.3f
; u
.w
= -6.4f
;
971 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
972 expectedquat
.x
= 7.121285f
; expectedquat
.y
= 2.159964f
; expectedquat
.z
= -3.855094f
; expectedquat
.w
= 5.362844f
;
973 expect_vec4(expectedquat
,gotquat
);
974 expectedquat
.x
= -1113.492920f
; expectedquat
.y
= 82.679260f
; expectedquat
.z
= -6.696645f
; expectedquat
.w
= -4.090050f
;
975 expect_vec4(expectedquat
,Nq
);
976 expectedquat
.x
= -1111.0f
; expectedquat
.y
= 111.0f
; expectedquat
.z
= -11.0f
; expectedquat
.w
= 1.0f
;
977 expect_vec4(expectedquat
,Nq1
);
978 r
.x
= 0.2f
; r
.y
= 0.3f
; r
.z
= 1.3f
; r
.w
= -0.6f
;
979 s
.x
= -3.0f
; s
.y
=-2.0f
; s
.z
= 4.0f
; s
.w
= 0.2f
;
980 t
.x
= 0.4f
; t
.y
= 8.3f
; t
.z
= -3.1f
; t
.w
= -2.7f
;
981 u
.x
= 1.1f
; u
.y
= -0.7f
; u
.z
= 9.2f
; u
.w
= 0.0f
;
982 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&u
,&t
);
983 expectedquat
.x
= -4.139569f
; expectedquat
.y
= -2.469115f
; expectedquat
.z
= 2.364477f
; expectedquat
.w
= 0.465494f
;
984 expect_vec4(expectedquat
,gotquat
);
985 expectedquat
.x
= 2.342533f
; expectedquat
.y
= 2.365127f
; expectedquat
.z
= 8.628538f
; expectedquat
.w
= -0.898356f
;
986 expect_vec4(expectedquat
,Nq
);
987 expectedquat
.x
= 1.1f
; expectedquat
.y
= -0.7f
; expectedquat
.z
= 9.2f
; expectedquat
.w
= 0.0f
;
988 expect_vec4(expectedquat
,Nq1
);
989 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
990 expectedquat
.x
= -3.754567f
; expectedquat
.y
= -0.586085f
; expectedquat
.z
= 3.815818f
; expectedquat
.w
= -0.198150f
;
991 expect_vec4(expectedquat
,gotquat
);
992 expectedquat
.x
= 0.140773f
; expectedquat
.y
= -8.737090f
; expectedquat
.z
= -0.516593f
; expectedquat
.w
= 3.053942f
;
993 expect_vec4(expectedquat
,Nq
);
994 expectedquat
.x
= -0.4f
; expectedquat
.y
= -8.3f
; expectedquat
.z
= 3.1f
; expectedquat
.w
= 2.7f
;
995 expect_vec4(expectedquat
,Nq1
);
996 r
.x
= -1.0f
; r
.y
= 0.0f
; r
.z
= 0.0f
; r
.w
= 0.0f
;
997 s
.x
= 1.0f
; s
.y
=0.0f
; s
.z
= 0.0f
; s
.w
= 0.0f
;
998 t
.x
= 1.0f
; t
.y
= 0.0f
; t
.z
= 0.0f
; t
.w
= 0.0f
;
999 u
.x
= -1.0f
; u
.y
= 0.0f
; u
.z
= 0.0f
; u
.w
= 0.0f
;
1000 D3DXQuaternionSquadSetup(&gotquat
,&Nq
,&Nq1
,&r
,&s
,&t
,&u
);
1001 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1002 expect_vec4(expectedquat
,gotquat
);
1003 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1004 expect_vec4(expectedquat
,Nq
);
1005 expectedquat
.x
= 1.0f
; expectedquat
.y
= 0.0f
; expectedquat
.z
= 0.0f
; expectedquat
.w
= 0.0f
;
1006 expect_vec4(expectedquat
,Nq1
);
1008 /*_______________D3DXQuaternionToAxisAngle__________________*/
1009 Nq
.x
= 1.0f
/22.0f
; Nq
.y
= 2.0f
/22.0f
; Nq
.z
= 4.0f
/22.0f
; Nq
.w
= 10.0f
/22.0f
;
1010 expectedvec
.x
= 1.0f
/22.0f
; expectedvec
.y
= 2.0f
/22.0f
; expectedvec
.z
= 4.0f
/22.0f
;
1011 expected
= 2.197869f
;
1012 D3DXQuaternionToAxisAngle(&Nq
,&axis
,&angle
);
1013 expect_vec3(expectedvec
,axis
);
1014 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1015 /* Test if |w|>1.0f */
1016 expectedvec
.x
= 1.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= 4.0f
;
1017 D3DXQuaternionToAxisAngle(&q
,&axis
,&angle
);
1018 expect_vec3(expectedvec
,axis
);
1019 /* Test the null quaternion */
1020 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1021 expected
= 3.141593f
;
1022 D3DXQuaternionToAxisAngle(&nul
, &axis
, &angle
);
1023 expect_vec3(expectedvec
, axis
);
1024 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1026 D3DXQuaternionToAxisAngle(&nul
, &axis
, NULL
);
1027 D3DXQuaternionToAxisAngle(&nul
, NULL
, &angle
);
1028 expect_vec3(expectedvec
, axis
);
1029 ok(relative_error(angle
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, angle
);
1032 static void D3DXVector2Test(void)
1034 D3DXVECTOR2 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1035 LPD3DXVECTOR2 funcpointer
;
1036 D3DXVECTOR4 expectedtrans
, gottrans
;
1038 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1040 nul
.x
= 0.0f
; nul
.y
= 0.0f
;
1041 u
.x
= 3.0f
; u
.y
= 4.0f
;
1042 v
.x
= -7.0f
; v
.y
= 9.0f
;
1043 w
.x
= 4.0f
; w
.y
= -3.0f
;
1044 x
.x
= 2.0f
; x
.y
= -11.0f
;
1046 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
;
1047 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
;
1048 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
;
1049 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
;
1051 coeff1
= 2.0f
; coeff2
= 5.0f
;
1054 /*_______________D3DXVec2Add__________________________*/
1055 expectedvec
.x
= -4.0f
; expectedvec
.y
= 13.0f
;
1056 D3DXVec2Add(&gotvec
,&u
,&v
);
1057 expect_vec(expectedvec
,gotvec
);
1058 /* Tests the case NULL */
1059 funcpointer
= D3DXVec2Add(&gotvec
,NULL
,&v
);
1060 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1061 funcpointer
= D3DXVec2Add(NULL
,NULL
,NULL
);
1062 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1064 /*_______________D3DXVec2BaryCentric___________________*/
1065 expectedvec
.x
= -12.0f
; expectedvec
.y
= -21.0f
;
1066 D3DXVec2BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1067 expect_vec(expectedvec
,gotvec
);
1069 /*_______________D3DXVec2CatmullRom____________________*/
1070 expectedvec
.x
= 5820.25f
; expectedvec
.y
= -3654.5625f
;
1071 D3DXVec2CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1072 expect_vec(expectedvec
,gotvec
);
1074 /*_______________D3DXVec2CCW__________________________*/
1076 got
= D3DXVec2CCW(&u
,&v
);
1077 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1078 /* Tests the case NULL */
1080 got
= D3DXVec2CCW(NULL
,&v
);
1081 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1083 got
= D3DXVec2CCW(NULL
,NULL
);
1084 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1086 /*_______________D3DXVec2Dot__________________________*/
1088 got
= D3DXVec2Dot(&u
,&v
);
1089 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1090 /* Tests the case NULL */
1092 got
= D3DXVec2Dot(NULL
,&v
);
1093 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1095 got
= D3DXVec2Dot(NULL
,NULL
);
1096 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1098 /*_______________D3DXVec2Hermite__________________________*/
1099 expectedvec
.x
= 2604.625f
; expectedvec
.y
= -4533.0f
;
1100 D3DXVec2Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1101 expect_vec(expectedvec
,gotvec
);
1103 /*_______________D3DXVec2Length__________________________*/
1105 got
= D3DXVec2Length(&u
);
1106 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1107 /* Tests the case NULL */
1109 got
= D3DXVec2Length(NULL
);
1110 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1112 /*_______________D3DXVec2LengthSq________________________*/
1114 got
= D3DXVec2LengthSq(&u
);
1115 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1116 /* Tests the case NULL */
1118 got
= D3DXVec2LengthSq(NULL
);
1119 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1121 /*_______________D3DXVec2Lerp__________________________*/
1122 expectedvec
.x
= 68.0f
; expectedvec
.y
= -28.5f
;
1123 D3DXVec2Lerp(&gotvec
,&u
,&v
,scale
);
1124 expect_vec(expectedvec
,gotvec
);
1125 /* Tests the case NULL */
1126 funcpointer
= D3DXVec2Lerp(&gotvec
,NULL
,&v
,scale
);
1127 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1128 funcpointer
= D3DXVec2Lerp(NULL
,NULL
,NULL
,scale
);
1129 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1131 /*_______________D3DXVec2Maximize__________________________*/
1132 expectedvec
.x
= 3.0f
; expectedvec
.y
= 9.0f
;
1133 D3DXVec2Maximize(&gotvec
,&u
,&v
);
1134 expect_vec(expectedvec
,gotvec
);
1135 /* Tests the case NULL */
1136 funcpointer
= D3DXVec2Maximize(&gotvec
,NULL
,&v
);
1137 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1138 funcpointer
= D3DXVec2Maximize(NULL
,NULL
,NULL
);
1139 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1141 /*_______________D3DXVec2Minimize__________________________*/
1142 expectedvec
.x
= -7.0f
; expectedvec
.y
= 4.0f
;
1143 D3DXVec2Minimize(&gotvec
,&u
,&v
);
1144 expect_vec(expectedvec
,gotvec
);
1145 /* Tests the case NULL */
1146 funcpointer
= D3DXVec2Minimize(&gotvec
,NULL
,&v
);
1147 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1148 funcpointer
= D3DXVec2Minimize(NULL
,NULL
,NULL
);
1149 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1151 /*_______________D3DXVec2Normalize_________________________*/
1152 expectedvec
.x
= 0.6f
; expectedvec
.y
= 0.8f
;
1153 D3DXVec2Normalize(&gotvec
,&u
);
1154 expect_vec(expectedvec
,gotvec
);
1155 /* Test the nul vector */
1156 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
;
1157 D3DXVec2Normalize(&gotvec
,&nul
);
1158 expect_vec(expectedvec
,gotvec
);
1160 /*_______________D3DXVec2Scale____________________________*/
1161 expectedvec
.x
= -19.5f
; expectedvec
.y
= -26.0f
;
1162 D3DXVec2Scale(&gotvec
,&u
,scale
);
1163 expect_vec(expectedvec
,gotvec
);
1164 /* Tests the case NULL */
1165 funcpointer
= D3DXVec2Scale(&gotvec
,NULL
,scale
);
1166 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1167 funcpointer
= D3DXVec2Scale(NULL
,NULL
,scale
);
1168 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1170 /*_______________D3DXVec2Subtract__________________________*/
1171 expectedvec
.x
= 10.0f
; expectedvec
.y
= -5.0f
;
1172 D3DXVec2Subtract(&gotvec
,&u
,&v
);
1173 expect_vec(expectedvec
,gotvec
);
1174 /* Tests the case NULL */
1175 funcpointer
= D3DXVec2Subtract(&gotvec
,NULL
,&v
);
1176 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1177 funcpointer
= D3DXVec2Subtract(NULL
,NULL
,NULL
);
1178 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1180 /*_______________D3DXVec2Transform_______________________*/
1181 expectedtrans
.x
= 36.0f
; expectedtrans
.y
= 44.0f
; expectedtrans
.z
= 52.0f
; expectedtrans
.w
= 60.0f
;
1182 D3DXVec2Transform(&gottrans
,&u
,&mat
);
1183 expect_vec4(expectedtrans
,gottrans
);
1185 /*_______________D3DXVec2TransformCoord_______________________*/
1186 expectedvec
.x
= 0.6f
; expectedvec
.y
= 11.0f
/15.0f
;
1187 D3DXVec2TransformCoord(&gotvec
,&u
,&mat
);
1188 expect_vec(expectedvec
,gotvec
);
1190 /*_______________D3DXVec2TransformNormal______________________*/
1191 expectedvec
.x
= 23.0f
; expectedvec
.y
= 30.0f
;
1192 D3DXVec2TransformNormal(&gotvec
,&u
,&mat
);
1193 expect_vec(expectedvec
,gotvec
);
1196 static void D3DXVector3Test(void)
1198 D3DVIEWPORT9 viewport
;
1199 D3DXVECTOR3 expectedvec
, gotvec
, nul
, u
, v
, w
, x
;
1200 LPD3DXVECTOR3 funcpointer
;
1201 D3DXVECTOR4 expectedtrans
, gottrans
;
1202 D3DXMATRIX mat
, projection
, view
, world
;
1203 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1205 nul
.x
= 0.0f
; nul
.y
= 0.0f
; nul
.z
= 0.0f
;
1206 u
.x
= 9.0f
; u
.y
= 6.0f
; u
.z
= 2.0f
;
1207 v
.x
= 2.0f
; v
.y
= -3.0f
; v
.z
= -4.0;
1208 w
.x
= 3.0f
; w
.y
= -5.0f
; w
.z
= 7.0f
;
1209 x
.x
= 4.0f
; x
.y
= 1.0f
; x
.z
= 11.0f
;
1211 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
1212 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
1214 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
;
1215 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
;
1216 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
;
1217 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
;
1219 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
1220 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
1221 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
1222 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
1223 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
1224 U(view
).m
[3][3] = -40.0f
;
1226 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;
1227 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
;
1228 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
;
1229 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
;
1231 coeff1
= 2.0f
; coeff2
= 5.0f
;
1234 /*_______________D3DXVec3Add__________________________*/
1235 expectedvec
.x
= 11.0f
; expectedvec
.y
= 3.0f
; expectedvec
.z
= -2.0f
;
1236 D3DXVec3Add(&gotvec
,&u
,&v
);
1237 expect_vec3(expectedvec
,gotvec
);
1238 /* Tests the case NULL */
1239 funcpointer
= D3DXVec3Add(&gotvec
,NULL
,&v
);
1240 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1241 funcpointer
= D3DXVec3Add(NULL
,NULL
,NULL
);
1242 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1244 /*_______________D3DXVec3BaryCentric___________________*/
1245 expectedvec
.x
= -35.0f
; expectedvec
.y
= -67.0; expectedvec
.z
= 15.0f
;
1246 D3DXVec3BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1248 expect_vec3(expectedvec
,gotvec
);
1250 /*_______________D3DXVec3CatmullRom____________________*/
1251 expectedvec
.x
= 1458.0f
; expectedvec
.y
= 22.1875f
; expectedvec
.z
= 4141.375f
;
1252 D3DXVec3CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1253 expect_vec3(expectedvec
,gotvec
);
1255 /*_______________D3DXVec3Cross________________________*/
1256 expectedvec
.x
= -18.0f
; expectedvec
.y
= 40.0f
; expectedvec
.z
= -39.0f
;
1257 D3DXVec3Cross(&gotvec
,&u
,&v
);
1258 expect_vec3(expectedvec
,gotvec
);
1259 expectedvec
.x
= -277.0f
; expectedvec
.y
= -150.0f
; expectedvec
.z
= -26.0f
;
1260 D3DXVec3Cross(&gotvec
,&gotvec
,&v
);
1261 expect_vec3(expectedvec
,gotvec
);
1262 /* Tests the case NULL */
1263 funcpointer
= D3DXVec3Cross(&gotvec
,NULL
,&v
);
1264 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1265 funcpointer
= D3DXVec3Cross(NULL
,NULL
,NULL
);
1266 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1268 /*_______________D3DXVec3Dot__________________________*/
1270 got
= D3DXVec3Dot(&u
,&v
);
1271 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1272 /* Tests the case NULL */
1274 got
= D3DXVec3Dot(NULL
,&v
);
1275 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1277 got
= D3DXVec3Dot(NULL
,NULL
);
1278 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1280 /*_______________D3DXVec3Hermite__________________________*/
1281 expectedvec
.x
= -6045.75f
; expectedvec
.y
= -6650.0f
; expectedvec
.z
= 1358.875f
;
1282 D3DXVec3Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1283 expect_vec3(expectedvec
,gotvec
);
1285 /*_______________D3DXVec3Length__________________________*/
1287 got
= D3DXVec3Length(&u
);
1288 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1289 /* Tests the case NULL */
1291 got
= D3DXVec3Length(NULL
);
1292 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1294 /*_______________D3DXVec3LengthSq________________________*/
1296 got
= D3DXVec3LengthSq(&u
);
1297 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1298 /* Tests the case NULL */
1300 got
= D3DXVec3LengthSq(NULL
);
1301 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1303 /*_______________D3DXVec3Lerp__________________________*/
1304 expectedvec
.x
= 54.5f
; expectedvec
.y
= 64.5f
, expectedvec
.z
= 41.0f
;
1305 D3DXVec3Lerp(&gotvec
,&u
,&v
,scale
);
1306 expect_vec3(expectedvec
,gotvec
);
1307 /* Tests the case NULL */
1308 funcpointer
= D3DXVec3Lerp(&gotvec
,NULL
,&v
,scale
);
1309 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1310 funcpointer
= D3DXVec3Lerp(NULL
,NULL
,NULL
,scale
);
1311 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1313 /*_______________D3DXVec3Maximize__________________________*/
1314 expectedvec
.x
= 9.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= 2.0f
;
1315 D3DXVec3Maximize(&gotvec
,&u
,&v
);
1316 expect_vec3(expectedvec
,gotvec
);
1317 /* Tests the case NULL */
1318 funcpointer
= D3DXVec3Maximize(&gotvec
,NULL
,&v
);
1319 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1320 funcpointer
= D3DXVec3Maximize(NULL
,NULL
,NULL
);
1321 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1323 /*_______________D3DXVec3Minimize__________________________*/
1324 expectedvec
.x
= 2.0f
; expectedvec
.y
= -3.0f
; expectedvec
.z
= -4.0f
;
1325 D3DXVec3Minimize(&gotvec
,&u
,&v
);
1326 expect_vec3(expectedvec
,gotvec
);
1327 /* Tests the case NULL */
1328 funcpointer
= D3DXVec3Minimize(&gotvec
,NULL
,&v
);
1329 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1330 funcpointer
= D3DXVec3Minimize(NULL
,NULL
,NULL
);
1331 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1333 /*_______________D3DXVec3Normalize_________________________*/
1334 expectedvec
.x
= 9.0f
/11.0f
; expectedvec
.y
= 6.0f
/11.0f
; expectedvec
.z
= 2.0f
/11.0f
;
1335 D3DXVec3Normalize(&gotvec
,&u
);
1336 expect_vec3(expectedvec
,gotvec
);
1337 /* Test the nul vector */
1338 expectedvec
.x
= 0.0f
; expectedvec
.y
= 0.0f
; expectedvec
.z
= 0.0f
;
1339 D3DXVec3Normalize(&gotvec
,&nul
);
1340 expect_vec3(expectedvec
,gotvec
);
1342 /*_______________D3DXVec3Scale____________________________*/
1343 expectedvec
.x
= -58.5f
; expectedvec
.y
= -39.0f
; expectedvec
.z
= -13.0f
;
1344 D3DXVec3Scale(&gotvec
,&u
,scale
);
1345 expect_vec3(expectedvec
,gotvec
);
1346 /* Tests the case NULL */
1347 funcpointer
= D3DXVec3Scale(&gotvec
,NULL
,scale
);
1348 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1349 funcpointer
= D3DXVec3Scale(NULL
,NULL
,scale
);
1350 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1352 /*_______________D3DXVec3Subtract_______________________*/
1353 expectedvec
.x
= 7.0f
; expectedvec
.y
= 9.0f
; expectedvec
.z
= 6.0f
;
1354 D3DXVec3Subtract(&gotvec
,&u
,&v
);
1355 expect_vec3(expectedvec
,gotvec
);
1356 /* Tests the case NULL */
1357 funcpointer
= D3DXVec3Subtract(&gotvec
,NULL
,&v
);
1358 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1359 funcpointer
= D3DXVec3Subtract(NULL
,NULL
,NULL
);
1360 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1362 /*_______________D3DXVec3Transform_______________________*/
1363 expectedtrans
.x
= 70.0f
; expectedtrans
.y
= 88.0f
; expectedtrans
.z
= 106.0f
; expectedtrans
.w
= 124.0f
;
1364 D3DXVec3Transform(&gottrans
,&u
,&mat
);
1365 expect_vec4(expectedtrans
,gottrans
);
1367 /*_______________D3DXVec3TransformCoord_______________________*/
1368 expectedvec
.x
= 70.0f
/124.0f
; expectedvec
.y
= 88.0f
/124.0f
; expectedvec
.z
= 106.0f
/124.0f
;
1369 D3DXVec3TransformCoord(&gotvec
,&u
,&mat
);
1370 expect_vec3(expectedvec
,gotvec
);
1372 /*_______________D3DXVec3TransformNormal______________________*/
1373 expectedvec
.x
= 57.0f
; expectedvec
.y
= 74.0f
; expectedvec
.z
= 91.0f
;
1374 D3DXVec3TransformNormal(&gotvec
,&u
,&mat
);
1375 expect_vec3(expectedvec
,gotvec
);
1377 /*_______________D3DXVec3Project_________________________*/
1378 expectedvec
.x
= 1135.721924f
; expectedvec
.y
= 147.086914f
; expectedvec
.z
= 0.153412f
;
1379 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1380 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1381 expect_vec3(expectedvec
,gotvec
);
1382 /* World matrix can be omitted */
1383 D3DXMatrixMultiply(&mat
,&world
,&view
);
1384 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1385 expect_vec3(expectedvec
,gotvec
);
1386 /* Projection matrix can be omitted */
1387 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1388 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1389 expect_vec3(expectedvec
,gotvec
);
1390 /* View matrix can be omitted */
1391 D3DXMatrixMultiply(&mat
,&world
,&view
);
1392 D3DXVec3Project(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1393 expect_vec3(expectedvec
,gotvec
);
1394 /* All matrices can be omitted */
1395 expectedvec
.x
= 4010.000000f
; expectedvec
.y
= -1695.000000f
; expectedvec
.z
= 1.600000f
;
1396 D3DXVec3Project(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1397 expect_vec3(expectedvec
,gotvec
);
1398 /* Viewport can be omitted */
1399 expectedvec
.x
= 1.814305f
; expectedvec
.y
= 0.582097f
; expectedvec
.z
= -0.066555f
;
1400 D3DXVec3Project(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1401 expect_vec3(expectedvec
,gotvec
);
1403 /*_______________D3DXVec3Unproject_________________________*/
1404 expectedvec
.x
= -2.913411f
; expectedvec
.y
= 1.593215f
; expectedvec
.z
= 0.380724f
;
1405 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
1406 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&view
,&world
);
1407 expect_vec3(expectedvec
,gotvec
);
1408 /* World matrix can be omitted */
1409 D3DXMatrixMultiply(&mat
,&world
,&view
);
1410 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,&mat
,NULL
);
1411 expect_vec3(expectedvec
,gotvec
);
1412 /* Projection matrix can be omitted */
1413 D3DXMatrixMultiply(&mat
,&view
,&projection
);
1414 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,&mat
,&world
);
1415 expect_vec3(expectedvec
,gotvec
);
1416 /* View matrix can be omitted */
1417 D3DXMatrixMultiply(&mat
,&world
,&view
);
1418 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,&projection
,NULL
,&mat
);
1419 expect_vec3(expectedvec
,gotvec
);
1420 /* All matrices can be omitted */
1421 expectedvec
.x
= -1.002500f
; expectedvec
.y
= 0.997059f
; expectedvec
.z
= 2.571429f
;
1422 D3DXVec3Unproject(&gotvec
,&u
,&viewport
,NULL
,NULL
,NULL
);
1423 expect_vec3(expectedvec
,gotvec
);
1424 /* Viewport can be omitted */
1425 expectedvec
.x
= -11.018396f
; expectedvec
.y
= 3.218991f
; expectedvec
.z
= 1.380329f
;
1426 D3DXVec3Unproject(&gotvec
,&u
,NULL
,&projection
,&view
,&world
);
1427 expect_vec3(expectedvec
,gotvec
);
1430 static void D3DXVector4Test(void)
1432 D3DXVECTOR4 expectedvec
, gotvec
, u
, v
, w
, x
;
1433 LPD3DXVECTOR4 funcpointer
;
1434 D3DXVECTOR4 expectedtrans
, gottrans
;
1436 FLOAT coeff1
, coeff2
, expected
, got
, scale
;
1438 u
.x
= 1.0f
; u
.y
= 2.0f
; u
.z
= 4.0f
; u
.w
= 10.0;
1439 v
.x
= -3.0f
; v
.y
= 4.0f
; v
.z
= -5.0f
; v
.w
= 7.0;
1440 w
.x
= 4.0f
; w
.y
=6.0f
; w
.z
= -2.0f
; w
.w
= 1.0f
;
1441 x
.x
= 6.0f
; x
.y
= -7.0f
; x
.z
=8.0f
; x
.w
= -9.0f
;
1443 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
;
1444 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
;
1445 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
;
1446 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
;
1448 coeff1
= 2.0f
; coeff2
= 5.0;
1451 /*_______________D3DXVec4Add__________________________*/
1452 expectedvec
.x
= -2.0f
; expectedvec
.y
= 6.0f
; expectedvec
.z
= -1.0f
; expectedvec
.w
= 17.0f
;
1453 D3DXVec4Add(&gotvec
,&u
,&v
);
1454 expect_vec4(expectedvec
,gotvec
);
1455 /* Tests the case NULL */
1456 funcpointer
= D3DXVec4Add(&gotvec
,NULL
,&v
);
1457 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1458 funcpointer
= D3DXVec4Add(NULL
,NULL
,NULL
);
1459 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1461 /*_______________D3DXVec4BaryCentric____________________*/
1462 expectedvec
.x
= 8.0f
; expectedvec
.y
= 26.0; expectedvec
.z
= -44.0f
; expectedvec
.w
= -41.0f
;
1463 D3DXVec4BaryCentric(&gotvec
,&u
,&v
,&w
,coeff1
,coeff2
);
1464 expect_vec4(expectedvec
,gotvec
);
1466 /*_______________D3DXVec4CatmullRom____________________*/
1467 expectedvec
.x
= 2754.625f
; expectedvec
.y
= 2367.5625f
; expectedvec
.z
= 1060.1875f
; expectedvec
.w
= 131.3125f
;
1468 D3DXVec4CatmullRom(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1469 expect_vec4(expectedvec
,gotvec
);
1471 /*_______________D3DXVec4Cross_________________________*/
1472 expectedvec
.x
= 390.0f
; expectedvec
.y
= -393.0f
; expectedvec
.z
= -316.0f
; expectedvec
.w
= 166.0f
;
1473 D3DXVec4Cross(&gotvec
,&u
,&v
,&w
);
1474 expect_vec4(expectedvec
,gotvec
);
1476 /*_______________D3DXVec4Dot__________________________*/
1478 got
= D3DXVec4Dot(&u
,&v
);
1479 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1480 /* Tests the case NULL */
1482 got
= D3DXVec4Dot(NULL
,&v
);
1483 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1485 got
= D3DXVec4Dot(NULL
,NULL
);
1486 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1488 /*_______________D3DXVec4Hermite_________________________*/
1489 expectedvec
.x
= 1224.625f
; expectedvec
.y
= 3461.625f
; expectedvec
.z
= -4758.875f
; expectedvec
.w
= -5781.5f
;
1490 D3DXVec4Hermite(&gotvec
,&u
,&v
,&w
,&x
,scale
);
1491 expect_vec4(expectedvec
,gotvec
);
1493 /*_______________D3DXVec4Length__________________________*/
1495 got
= D3DXVec4Length(&u
);
1496 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1497 /* Tests the case NULL */
1499 got
= D3DXVec4Length(NULL
);
1500 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1502 /*_______________D3DXVec4LengthSq________________________*/
1504 got
= D3DXVec4LengthSq(&u
);
1505 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1506 /* Tests the case NULL */
1508 got
= D3DXVec4LengthSq(NULL
);
1509 ok(relative_error(got
, expected
) < admitted_error
, "Expected: %f, Got: %f\n", expected
, got
);
1511 /*_______________D3DXVec4Lerp__________________________*/
1512 expectedvec
.x
= 27.0f
; expectedvec
.y
= -11.0f
; expectedvec
.z
= 62.5; expectedvec
.w
= 29.5;
1513 D3DXVec4Lerp(&gotvec
,&u
,&v
,scale
);
1514 expect_vec4(expectedvec
,gotvec
);
1515 /* Tests the case NULL */
1516 funcpointer
= D3DXVec4Lerp(&gotvec
,NULL
,&v
,scale
);
1517 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1518 funcpointer
= D3DXVec4Lerp(NULL
,NULL
,NULL
,scale
);
1519 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1521 /*_______________D3DXVec4Maximize__________________________*/
1522 expectedvec
.x
= 1.0f
; expectedvec
.y
= 4.0f
; expectedvec
.z
= 4.0f
; expectedvec
.w
= 10.0;
1523 D3DXVec4Maximize(&gotvec
,&u
,&v
);
1524 expect_vec4(expectedvec
,gotvec
);
1525 /* Tests the case NULL */
1526 funcpointer
= D3DXVec4Maximize(&gotvec
,NULL
,&v
);
1527 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1528 funcpointer
= D3DXVec4Maximize(NULL
,NULL
,NULL
);
1529 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1531 /*_______________D3DXVec4Minimize__________________________*/
1532 expectedvec
.x
= -3.0f
; expectedvec
.y
= 2.0f
; expectedvec
.z
= -5.0f
; expectedvec
.w
= 7.0;
1533 D3DXVec4Minimize(&gotvec
,&u
,&v
);
1534 expect_vec4(expectedvec
,gotvec
);
1535 /* Tests the case NULL */
1536 funcpointer
= D3DXVec4Minimize(&gotvec
,NULL
,&v
);
1537 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1538 funcpointer
= D3DXVec4Minimize(NULL
,NULL
,NULL
);
1539 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1541 /*_______________D3DXVec4Normalize_________________________*/
1542 expectedvec
.x
= 1.0f
/11.0f
; expectedvec
.y
= 2.0f
/11.0f
; expectedvec
.z
= 4.0f
/11.0f
; expectedvec
.w
= 10.0f
/11.0f
;
1543 D3DXVec4Normalize(&gotvec
,&u
);
1544 expect_vec4(expectedvec
,gotvec
);
1546 /*_______________D3DXVec4Scale____________________________*/
1547 expectedvec
.x
= -6.5f
; expectedvec
.y
= -13.0f
; expectedvec
.z
= -26.0f
; expectedvec
.w
= -65.0f
;
1548 D3DXVec4Scale(&gotvec
,&u
,scale
);
1549 expect_vec4(expectedvec
,gotvec
);
1550 /* Tests the case NULL */
1551 funcpointer
= D3DXVec4Scale(&gotvec
,NULL
,scale
);
1552 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1553 funcpointer
= D3DXVec4Scale(NULL
,NULL
,scale
);
1554 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1556 /*_______________D3DXVec4Subtract__________________________*/
1557 expectedvec
.x
= 4.0f
; expectedvec
.y
= -2.0f
; expectedvec
.z
= 9.0f
; expectedvec
.w
= 3.0f
;
1558 D3DXVec4Subtract(&gotvec
,&u
,&v
);
1559 expect_vec4(expectedvec
,gotvec
);
1560 /* Tests the case NULL */
1561 funcpointer
= D3DXVec4Subtract(&gotvec
,NULL
,&v
);
1562 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1563 funcpointer
= D3DXVec4Subtract(NULL
,NULL
,NULL
);
1564 ok(funcpointer
== NULL
, "Expected: %p, Got: %p\n", NULL
, funcpointer
);
1566 /*_______________D3DXVec4Transform_______________________*/
1567 expectedtrans
.x
= 177.0f
; expectedtrans
.y
= 194.0f
; expectedtrans
.z
= 211.0f
; expectedtrans
.w
= 228.0f
;
1568 D3DXVec4Transform(&gottrans
,&u
,&mat
);
1569 expect_vec4(expectedtrans
,gottrans
);
1572 static void test_matrix_stack(void)
1574 ID3DXMatrixStack
*stack
;
1578 const D3DXMATRIX mat1
= {{{
1579 1.0f
, 2.0f
, 3.0f
, 4.0f
,
1580 5.0f
, 6.0f
, 7.0f
, 8.0f
,
1581 9.0f
, 10.0f
, 11.0f
, 12.0f
,
1582 13.0f
, 14.0f
, 15.0f
, 16.0f
1585 const D3DXMATRIX mat2
= {{{
1586 17.0f
, 18.0f
, 19.0f
, 20.0f
,
1587 21.0f
, 22.0f
, 23.0f
, 24.0f
,
1588 25.0f
, 26.0f
, 27.0f
, 28.0f
,
1589 29.0f
, 30.0f
, 31.0f
, 32.0f
1592 hr
= D3DXCreateMatrixStack(0, &stack
);
1593 ok(SUCCEEDED(hr
), "Failed to create a matrix stack, hr %#x\n", hr
);
1594 if (FAILED(hr
)) return;
1596 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)),
1597 "The top of an empty matrix stack should be an identity matrix\n");
1599 hr
= ID3DXMatrixStack_Pop(stack
);
1600 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1602 hr
= ID3DXMatrixStack_Push(stack
);
1603 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1604 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1606 hr
= ID3DXMatrixStack_Push(stack
);
1607 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1609 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat1
);
1610 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1611 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1613 hr
= ID3DXMatrixStack_Push(stack
);
1614 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1615 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1617 hr
= ID3DXMatrixStack_LoadMatrix(stack
, &mat2
);
1618 ok(SUCCEEDED(hr
), "LoadMatrix failed, hr %#x\n", hr
);
1619 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1621 hr
= ID3DXMatrixStack_Push(stack
);
1622 ok(SUCCEEDED(hr
), "Push failed, hr %#x\n", hr
);
1623 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1625 hr
= ID3DXMatrixStack_LoadIdentity(stack
);
1626 ok(SUCCEEDED(hr
), "LoadIdentity failed, hr %#x\n", hr
);
1627 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1629 hr
= ID3DXMatrixStack_Pop(stack
);
1630 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1631 expect_mat(&mat2
, ID3DXMatrixStack_GetTop(stack
));
1633 hr
= ID3DXMatrixStack_Pop(stack
);
1634 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1635 expect_mat(&mat1
, ID3DXMatrixStack_GetTop(stack
));
1637 hr
= ID3DXMatrixStack_Pop(stack
);
1638 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1639 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1641 hr
= ID3DXMatrixStack_Pop(stack
);
1642 ok(SUCCEEDED(hr
), "Pop failed, hr %#x\n", hr
);
1643 ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack
)), "The top should be an identity matrix\n");
1645 refcount
= ID3DXMatrixStack_Release(stack
);
1646 ok(!refcount
, "Matrix stack has %u references left.\n", refcount
);
1649 static void test_Matrix_AffineTransformation2D(void)
1651 D3DXMATRIX exp_mat
, got_mat
;
1652 D3DXVECTOR2 center
, position
;
1661 angle
= D3DX_PI
/3.0f
;
1665 U(exp_mat
).m
[0][0] = 10.0f
;
1666 U(exp_mat
).m
[1][0] = -17.320507f
;
1667 U(exp_mat
).m
[2][0] = 0.0f
;
1668 U(exp_mat
).m
[3][0] = -1.035898f
;
1669 U(exp_mat
).m
[0][1] = 17.320507f
;
1670 U(exp_mat
).m
[1][1] = 10.0f
;
1671 U(exp_mat
).m
[2][1] = 0.0f
;
1672 U(exp_mat
).m
[3][1] = 6.401924f
;
1673 U(exp_mat
).m
[0][2] = 0.0f
;
1674 U(exp_mat
).m
[1][2] = 0.0f
;
1675 U(exp_mat
).m
[2][2] = 1.0f
;
1676 U(exp_mat
).m
[3][2] = 0.0f
;
1677 U(exp_mat
).m
[0][3] = 0.0f
;
1678 U(exp_mat
).m
[1][3] = 0.0f
;
1679 U(exp_mat
).m
[2][3] = 0.0f
;
1680 U(exp_mat
).m
[3][3] = 1.0f
;
1682 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, &position
);
1684 expect_mat(&exp_mat
, &got_mat
);
1691 angle
= D3DX_PI
/3.0f
;
1695 U(exp_mat
).m
[0][0] = 10.0f
;
1696 U(exp_mat
).m
[1][0] = -17.320507f
;
1697 U(exp_mat
).m
[2][0] = 0.0f
;
1698 U(exp_mat
).m
[3][0] = 4.964102f
;
1699 U(exp_mat
).m
[0][1] = 17.320507f
;
1700 U(exp_mat
).m
[1][1] = 10.0f
;
1701 U(exp_mat
).m
[2][1] = 0.0f
;
1702 U(exp_mat
).m
[3][1] = -0.598076f
;
1703 U(exp_mat
).m
[0][2] = 0.0f
;
1704 U(exp_mat
).m
[1][2] = 0.0f
;
1705 U(exp_mat
).m
[2][2] = 1.0f
;
1706 U(exp_mat
).m
[3][2] = 0.0f
;
1707 U(exp_mat
).m
[0][3] = 0.0f
;
1708 U(exp_mat
).m
[1][3] = 0.0f
;
1709 U(exp_mat
).m
[2][3] = 0.0f
;
1710 U(exp_mat
).m
[3][3] = 1.0f
;
1712 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, ¢er
, angle
, NULL
);
1714 expect_mat(&exp_mat
, &got_mat
);
1721 angle
= D3DX_PI
/3.0f
;
1725 U(exp_mat
).m
[0][0] = 10.0f
;
1726 U(exp_mat
).m
[1][0] = -17.320507f
;
1727 U(exp_mat
).m
[2][0] = 0.0f
;
1728 U(exp_mat
).m
[3][0] = -6.0f
;
1729 U(exp_mat
).m
[0][1] = 17.320507f
;
1730 U(exp_mat
).m
[1][1] = 10.0f
;
1731 U(exp_mat
).m
[2][1] = 0.0f
;
1732 U(exp_mat
).m
[3][1] = 7.0f
;
1733 U(exp_mat
).m
[0][2] = 0.0f
;
1734 U(exp_mat
).m
[1][2] = 0.0f
;
1735 U(exp_mat
).m
[2][2] = 1.0f
;
1736 U(exp_mat
).m
[3][2] = 0.0f
;
1737 U(exp_mat
).m
[0][3] = 0.0f
;
1738 U(exp_mat
).m
[1][3] = 0.0f
;
1739 U(exp_mat
).m
[2][3] = 0.0f
;
1740 U(exp_mat
).m
[3][3] = 1.0f
;
1742 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, &position
);
1744 expect_mat(&exp_mat
, &got_mat
);
1748 angle
= 5.0f
* D3DX_PI
/4.0f
;
1752 U(exp_mat
).m
[0][0] = 14.142133f
;
1753 U(exp_mat
).m
[1][0] = -14.142133f
;
1754 U(exp_mat
).m
[2][0] = 0.0f
;
1755 U(exp_mat
).m
[3][0] = 0.0f
;
1756 U(exp_mat
).m
[0][1] = 14.142133;
1757 U(exp_mat
).m
[1][1] = 14.142133f
;
1758 U(exp_mat
).m
[2][1] = 0.0f
;
1759 U(exp_mat
).m
[3][1] = 0.0f
;
1760 U(exp_mat
).m
[0][2] = 0.0f
;
1761 U(exp_mat
).m
[1][2] = 0.0f
;
1762 U(exp_mat
).m
[2][2] = 1.0f
;
1763 U(exp_mat
).m
[3][2] = 0.0f
;
1764 U(exp_mat
).m
[0][3] = 0.0f
;
1765 U(exp_mat
).m
[1][3] = 0.0f
;
1766 U(exp_mat
).m
[2][3] = 0.0f
;
1767 U(exp_mat
).m
[3][3] = 1.0f
;
1769 D3DXMatrixAffineTransformation2D(&got_mat
, scale
, NULL
, angle
, NULL
);
1771 expect_mat(&exp_mat
, &got_mat
);
1774 static void test_Matrix_Decompose(void)
1777 D3DXQUATERNION exp_rotation
, got_rotation
;
1778 D3DXVECTOR3 exp_scale
, got_scale
, exp_translation
, got_translation
;
1783 U(pm
).m
[0][0] = -0.9238790f
;
1784 U(pm
).m
[1][0] = -0.2705984f
;
1785 U(pm
).m
[2][0] = 0.2705984f
;
1786 U(pm
).m
[3][0] = -5.0f
;
1787 U(pm
).m
[0][1] = 0.2705984f
;
1788 U(pm
).m
[1][1] = 0.03806049f
;
1789 U(pm
).m
[2][1] = 0.9619395f
;
1790 U(pm
).m
[3][1] = 0.0f
;
1791 U(pm
).m
[0][2] = -0.2705984f
;
1792 U(pm
).m
[1][2] = 0.9619395f
;
1793 U(pm
).m
[2][2] = 0.03806049f
;
1794 U(pm
).m
[3][2] = 10.0f
;
1795 U(pm
).m
[0][3] = 0.0f
;
1796 U(pm
).m
[1][3] = 0.0f
;
1797 U(pm
).m
[2][3] = 0.0f
;
1798 U(pm
).m
[3][3] = 1.0f
;
1804 exp_rotation
.w
= 0.195091f
;
1805 exp_rotation
.x
= 0.0f
;
1806 exp_rotation
.y
= 0.693520f
;
1807 exp_rotation
.z
= 0.693520f
;
1809 exp_translation
.x
= -5.0f
;
1810 exp_translation
.y
= 0.0f
;
1811 exp_translation
.z
= 10.0f
;
1813 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1815 compare_scale(exp_scale
, got_scale
);
1816 compare_rotation(exp_rotation
, got_rotation
);
1817 compare_translation(exp_translation
, got_translation
);
1821 U(pm
).m
[0][0] = -2.255813f
;
1822 U(pm
).m
[1][0] = 1.302324f
;
1823 U(pm
).m
[2][0] = 1.488373f
;
1824 U(pm
).m
[3][0] = 1.0f
;
1825 U(pm
).m
[0][1] = 1.302327f
;
1826 U(pm
).m
[1][1] = -0.7209296f
;
1827 U(pm
).m
[2][1] = 2.60465f
;
1828 U(pm
).m
[3][1] = 2.0f
;
1829 U(pm
).m
[0][2] = 1.488371f
;
1830 U(pm
).m
[1][2] = 2.604651f
;
1831 U(pm
).m
[2][2] = -0.02325551f
;
1832 U(pm
).m
[3][2] = 3.0f
;
1833 U(pm
).m
[0][3] = 0.0f
;
1834 U(pm
).m
[1][3] = 0.0f
;
1835 U(pm
).m
[2][3] = 0.0f
;
1836 U(pm
).m
[3][3] = 1.0f
;
1842 exp_rotation
.w
= 0.0;
1843 exp_rotation
.x
= 0.352180f
;
1844 exp_rotation
.y
= 0.616316f
;
1845 exp_rotation
.z
= 0.704361f
;
1847 exp_translation
.x
= 1.0f
;
1848 exp_translation
.y
= 2.0f
;
1849 exp_translation
.z
= 3.0f
;
1851 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1853 compare_scale(exp_scale
, got_scale
);
1854 compare_rotation(exp_rotation
, got_rotation
);
1855 compare_translation(exp_translation
, got_translation
);
1859 U(pm
).m
[0][0] = 2.427051f
;
1860 U(pm
).m
[1][0] = 0.0f
;
1861 U(pm
).m
[2][0] = 1.763355f
;
1862 U(pm
).m
[3][0] = 5.0f
;
1863 U(pm
).m
[0][1] = 0.0f
;
1864 U(pm
).m
[1][1] = 3.0f
;
1865 U(pm
).m
[2][1] = 0.0f
;
1866 U(pm
).m
[3][1] = 5.0f
;
1867 U(pm
).m
[0][2] = -1.763355f
;
1868 U(pm
).m
[1][2] = 0.0f
;
1869 U(pm
).m
[2][2] = 2.427051f
;
1870 U(pm
).m
[3][2] = 5.0f
;
1871 U(pm
).m
[0][3] = 0.0f
;
1872 U(pm
).m
[1][3] = 0.0f
;
1873 U(pm
).m
[2][3] = 0.0f
;
1874 U(pm
).m
[3][3] = 1.0f
;
1880 exp_rotation
.w
= 0.951057f
;
1881 exp_rotation
.x
= 0.0f
;
1882 exp_rotation
.y
= 0.309017f
;
1883 exp_rotation
.z
= 0.0f
;
1885 exp_translation
.x
= 5.0f
;
1886 exp_translation
.y
= 5.0f
;
1887 exp_translation
.z
= 5.0f
;
1889 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1891 compare_scale(exp_scale
, got_scale
);
1892 compare_rotation(exp_rotation
, got_rotation
);
1893 compare_translation(exp_translation
, got_translation
);
1897 U(pm
).m
[0][0] = -0.9238790f
;
1898 U(pm
).m
[1][0] = -0.2705984f
;
1899 U(pm
).m
[2][0] = 0.2705984f
;
1900 U(pm
).m
[3][0] = -5.0f
;
1901 U(pm
).m
[0][1] = 0.2705984f
;
1902 U(pm
).m
[1][1] = 0.03806049f
;
1903 U(pm
).m
[2][1] = 0.9619395f
;
1904 U(pm
).m
[3][1] = 0.0f
;
1905 U(pm
).m
[0][2] = -0.2705984f
;
1906 U(pm
).m
[1][2] = 0.9619395f
;
1907 U(pm
).m
[2][2] = 0.03806049f
;
1908 U(pm
).m
[3][2] = 10.0f
;
1909 U(pm
).m
[0][3] = 0.0f
;
1910 U(pm
).m
[1][3] = 0.0f
;
1911 U(pm
).m
[2][3] = 0.0f
;
1912 U(pm
).m
[3][3] = 1.0f
;
1918 exp_rotation
.w
= 0.195091f
;
1919 exp_rotation
.x
= 0.0f
;
1920 exp_rotation
.y
= 0.693520f
;
1921 exp_rotation
.z
= 0.693520f
;
1923 exp_translation
.x
= -5.0f
;
1924 exp_translation
.y
= 0.0f
;
1925 exp_translation
.z
= 10.0f
;
1927 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1929 compare_scale(exp_scale
, got_scale
);
1930 compare_rotation(exp_rotation
, got_rotation
);
1931 compare_translation(exp_translation
, got_translation
);
1935 U(pm
).m
[0][0] = -0.9238790f
;
1936 U(pm
).m
[1][0] = -0.5411968f
;
1937 U(pm
).m
[2][0] = 0.8117952f
;
1938 U(pm
).m
[3][0] = -5.0f
;
1939 U(pm
).m
[0][1] = 0.2705984f
;
1940 U(pm
).m
[1][1] = 0.07612098f
;
1941 U(pm
).m
[2][1] = 2.8858185f
;
1942 U(pm
).m
[3][1] = 0.0f
;
1943 U(pm
).m
[0][2] = -0.2705984f
;
1944 U(pm
).m
[1][2] = 1.9238790f
;
1945 U(pm
).m
[2][2] = 0.11418147f
;
1946 U(pm
).m
[3][2] = 10.0f
;
1947 U(pm
).m
[0][3] = 0.0f
;
1948 U(pm
).m
[1][3] = 0.0f
;
1949 U(pm
).m
[2][3] = 0.0f
;
1950 U(pm
).m
[3][3] = 1.0f
;
1956 exp_rotation
.w
= 0.195091f
;
1957 exp_rotation
.x
= 0.0f
;
1958 exp_rotation
.y
= 0.693520f
;
1959 exp_rotation
.z
= 0.693520f
;
1961 exp_translation
.x
= -5.0f
;
1962 exp_translation
.y
= 0.0f
;
1963 exp_translation
.z
= 10.0f
;
1965 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
1967 compare_scale(exp_scale
, got_scale
);
1968 compare_rotation(exp_rotation
, got_rotation
);
1969 compare_translation(exp_translation
, got_translation
);
1973 U(pm
).m
[0][0] = 0.7156004f
;
1974 U(pm
).m
[1][0] = -0.5098283f
;
1975 U(pm
).m
[2][0] = -0.4774843f
;
1976 U(pm
).m
[3][0] = -5.0f
;
1977 U(pm
).m
[0][1] = -0.6612288f
;
1978 U(pm
).m
[1][1] = -0.7147621f
;
1979 U(pm
).m
[2][1] = -0.2277977f
;
1980 U(pm
).m
[3][1] = 0.0f
;
1981 U(pm
).m
[0][2] = -0.2251499f
;
1982 U(pm
).m
[1][2] = 0.4787385f
;
1983 U(pm
).m
[2][2] = -0.8485972f
;
1984 U(pm
).m
[3][2] = 10.0f
;
1985 U(pm
).m
[0][3] = 0.0f
;
1986 U(pm
).m
[1][3] = 0.0f
;
1987 U(pm
).m
[2][3] = 0.0f
;
1988 U(pm
).m
[3][3] = 1.0f
;
1994 exp_rotation
.w
= 0.195091f
;
1995 exp_rotation
.x
= 0.905395f
;
1996 exp_rotation
.y
= -0.323355f
;
1997 exp_rotation
.z
= -0.194013f
;
1999 exp_translation
.x
= -5.0f
;
2000 exp_translation
.y
= 0.0f
;
2001 exp_translation
.z
= 10.0f
;
2003 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2005 compare_scale(exp_scale
, got_scale
);
2006 compare_rotation(exp_rotation
, got_rotation
);
2007 compare_translation(exp_translation
, got_translation
);
2011 U(pm
).m
[0][0] = 0.06554436f
;
2012 U(pm
).m
[1][0] = -0.6873012f
;
2013 U(pm
).m
[2][0] = 0.7234092f
;
2014 U(pm
).m
[3][0] = -5.0f
;
2015 U(pm
).m
[0][1] = -0.9617381f
;
2016 U(pm
).m
[1][1] = -0.2367795f
;
2017 U(pm
).m
[2][1] = -0.1378230f
;
2018 U(pm
).m
[3][1] = 0.0f
;
2019 U(pm
).m
[0][2] = 0.2660144f
;
2020 U(pm
).m
[1][2] = -0.6866967f
;
2021 U(pm
).m
[2][2] = -0.6765233f
;
2022 U(pm
).m
[3][2] = 10.0f
;
2023 U(pm
).m
[0][3] = 0.0f
;
2024 U(pm
).m
[1][3] = 0.0f
;
2025 U(pm
).m
[2][3] = 0.0f
;
2026 U(pm
).m
[3][3] = 1.0f
;
2032 exp_rotation
.w
= -0.195091f
;
2033 exp_rotation
.x
= 0.703358f
;
2034 exp_rotation
.y
= -0.586131f
;
2035 exp_rotation
.z
= 0.351679f
;
2037 exp_translation
.x
= -5.0f
;
2038 exp_translation
.y
= 0.0f
;
2039 exp_translation
.z
= 10.0f
;
2041 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2043 compare_scale(exp_scale
, got_scale
);
2044 compare_rotation(exp_rotation
, got_rotation
);
2045 compare_translation(exp_translation
, got_translation
);
2049 U(pm
).m
[0][0] = 7.121047f
;
2050 U(pm
).m
[1][0] = -5.883487f
;
2051 U(pm
).m
[2][0] = 11.81843f
;
2052 U(pm
).m
[3][0] = -5.0f
;
2053 U(pm
).m
[0][1] = 5.883487f
;
2054 U(pm
).m
[1][1] = -10.60660f
;
2055 U(pm
).m
[2][1] = -8.825232f
;
2056 U(pm
).m
[3][1] = 0.0f
;
2057 U(pm
).m
[0][2] = 11.81843f
;
2058 U(pm
).m
[1][2] = 8.8252320f
;
2059 U(pm
).m
[2][2] = -2.727645f
;
2060 U(pm
).m
[3][2] = 2.0f
;
2061 U(pm
).m
[0][3] = 0.0f
;
2062 U(pm
).m
[1][3] = 0.0f
;
2063 U(pm
).m
[2][3] = 0.0f
;
2064 U(pm
).m
[3][3] = 1.0f
;
2066 exp_scale
.x
= 15.0f
;
2067 exp_scale
.y
= 15.0f
;
2068 exp_scale
.z
= 15.0f
;
2070 exp_rotation
.w
= 0.382684f
;
2071 exp_rotation
.x
= 0.768714f
;
2072 exp_rotation
.y
= 0.0f
;
2073 exp_rotation
.z
= 0.512476f
;
2075 exp_translation
.x
= -5.0f
;
2076 exp_translation
.y
= 0.0f
;
2077 exp_translation
.z
= 2.0f
;
2079 D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2081 compare_scale(exp_scale
, got_scale
);
2082 compare_rotation(exp_rotation
, got_rotation
);
2083 compare_translation(exp_translation
, got_translation
);
2087 U(pm
).m
[0][0] = 0.0f
;
2088 U(pm
).m
[1][0] = 4.0f
;
2089 U(pm
).m
[2][0] = 5.0f
;
2090 U(pm
).m
[3][0] = -5.0f
;
2091 U(pm
).m
[0][1] = 0.0f
;
2092 U(pm
).m
[1][1] = -10.60660f
;
2093 U(pm
).m
[2][1] = -8.825232f
;
2094 U(pm
).m
[3][1] = 6.0f
;
2095 U(pm
).m
[0][2] = 0.0f
;
2096 U(pm
).m
[1][2] = 8.8252320f
;
2097 U(pm
).m
[2][2] = 2.727645;
2098 U(pm
).m
[3][2] = 3.0f
;
2099 U(pm
).m
[0][3] = 0.0f
;
2100 U(pm
).m
[1][3] = 0.0f
;
2101 U(pm
).m
[2][3] = 0.0f
;
2102 U(pm
).m
[3][3] = 1.0f
;
2104 hr
= D3DXMatrixDecompose(&got_scale
, &got_rotation
, &got_translation
, &pm
);
2105 ok(hr
== D3DERR_INVALIDCALL
, "Expected D3DERR_INVALIDCALL, got %x\n", hr
);
2108 static void test_Matrix_Transformation2D(void)
2110 D3DXMATRIX exp_mat
, got_mat
;
2111 D3DXVECTOR2 rot_center
, sca
, sca_center
, trans
;
2114 rot_center
.x
= 3.0f
;
2115 rot_center
.y
= 4.0f
;
2120 sca_center
.x
= 9.0f
;
2121 sca_center
.y
= -5.0f
;
2128 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2130 U(exp_mat
).m
[0][0] = -4.245192f
;
2131 U(exp_mat
).m
[1][0] = -0.147116f
;
2132 U(exp_mat
).m
[2][0] = 0.0f
;
2133 U(exp_mat
).m
[3][0] = 45.265373f
;
2134 U(exp_mat
).m
[0][1] = 7.647113f
;
2135 U(exp_mat
).m
[1][1] = 8.745192f
;
2136 U(exp_mat
).m
[2][1] = 0.0f
;
2137 U(exp_mat
).m
[3][1] = -13.401899f
;
2138 U(exp_mat
).m
[0][2] = 0.0f
;
2139 U(exp_mat
).m
[1][2] = 0.0f
;
2140 U(exp_mat
).m
[2][2] = 1.0f
;
2141 U(exp_mat
).m
[3][2] = 0.0f
;
2142 U(exp_mat
).m
[0][3] = 0.0f
;
2143 U(exp_mat
).m
[1][3] = 0.0f
;
2144 U(exp_mat
).m
[2][3] = 0.0f
;
2145 U(exp_mat
).m
[3][3] = 1.0f
;
2147 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, &sca
, &rot_center
, rot
, &trans
);
2149 expect_mat(&exp_mat
, &got_mat
);
2153 sca_center
.x
= 9.0f
;
2154 sca_center
.y
= -5.0f
;
2161 sca_rot
= 5.0f
*D3DX_PI
/4.0f
;
2163 U(exp_mat
).m
[0][0] = 0.50f
;
2164 U(exp_mat
).m
[1][0] = -0.866025f
;
2165 U(exp_mat
).m
[2][0] = 0.0f
;
2166 U(exp_mat
).m
[3][0] = -6.0f
;
2167 U(exp_mat
).m
[0][1] = 0.866025f
;
2168 U(exp_mat
).m
[1][1] = 0.50f
;
2169 U(exp_mat
).m
[2][1] = 0.0f
;
2170 U(exp_mat
).m
[3][1] = 7.0f
;
2171 U(exp_mat
).m
[0][2] = 0.0f
;
2172 U(exp_mat
).m
[1][2] = 0.0f
;
2173 U(exp_mat
).m
[2][2] = 1.0f
;
2174 U(exp_mat
).m
[3][2] = 0.0f
;
2175 U(exp_mat
).m
[0][3] = 0.0f
;
2176 U(exp_mat
).m
[1][3] = 0.0f
;
2177 U(exp_mat
).m
[2][3] = 0.0f
;
2178 U(exp_mat
).m
[3][3] = 1.0f
;
2180 D3DXMatrixTransformation2D(&got_mat
, &sca_center
, sca_rot
, NULL
, NULL
, rot
, &trans
);
2182 expect_mat(&exp_mat
, &got_mat
);
2186 U(exp_mat
).m
[0][0] = 0.50f
;
2187 U(exp_mat
).m
[1][0] = -0.866025f
;
2188 U(exp_mat
).m
[2][0] = 0.0f
;
2189 U(exp_mat
).m
[3][0] = 0.0f
;
2190 U(exp_mat
).m
[0][1] = 0.866025f
;
2191 U(exp_mat
).m
[1][1] = 0.50f
;
2192 U(exp_mat
).m
[2][1] = 0.0f
;
2193 U(exp_mat
).m
[3][1] = 0.0f
;
2194 U(exp_mat
).m
[0][2] = 0.0f
;
2195 U(exp_mat
).m
[1][2] = 0.0f
;
2196 U(exp_mat
).m
[2][2] = 1.0f
;
2197 U(exp_mat
).m
[3][2] = 0.0f
;
2198 U(exp_mat
).m
[0][3] = 0.0f
;
2199 U(exp_mat
).m
[1][3] = 0.0f
;
2200 U(exp_mat
).m
[2][3] = 0.0f
;
2201 U(exp_mat
).m
[3][3] = 1.0f
;
2203 D3DXMatrixTransformation2D(&got_mat
, NULL
, sca_rot
, NULL
, NULL
, rot
, NULL
);
2205 expect_mat(&exp_mat
, &got_mat
);
2208 static void test_D3DXVec_Array(void)
2211 D3DVIEWPORT9 viewport
;
2212 D3DXMATRIX mat
, projection
, view
, world
;
2213 D3DXVECTOR4 inp_vec
[ARRAY_SIZE
];
2214 D3DXVECTOR4 out_vec
[ARRAY_SIZE
+ 2];
2215 D3DXVECTOR4 exp_vec
[ARRAY_SIZE
+ 2];
2216 D3DXPLANE inp_plane
[ARRAY_SIZE
];
2217 D3DXPLANE out_plane
[ARRAY_SIZE
+ 2];
2218 D3DXPLANE exp_plane
[ARRAY_SIZE
+ 2];
2220 viewport
.Width
= 800; viewport
.MinZ
= 0.2f
; viewport
.X
= 10;
2221 viewport
.Height
= 680; viewport
.MaxZ
= 0.9f
; viewport
.Y
= 5;
2223 for (i
= 0; i
< ARRAY_SIZE
+ 2; ++i
) {
2224 out_vec
[i
].x
= out_vec
[i
].y
= out_vec
[i
].z
= out_vec
[i
].w
= 0.0f
;
2225 exp_vec
[i
].x
= exp_vec
[i
].y
= exp_vec
[i
].z
= exp_vec
[i
].w
= 0.0f
;
2226 out_plane
[i
].a
= out_plane
[i
].b
= out_plane
[i
].c
= out_plane
[i
].d
= 0.0f
;
2227 exp_plane
[i
].a
= exp_plane
[i
].b
= exp_plane
[i
].c
= exp_plane
[i
].d
= 0.0f
;
2230 for (i
= 0; i
< ARRAY_SIZE
; ++i
) {
2231 inp_plane
[i
].a
= inp_plane
[i
].c
= inp_vec
[i
].x
= inp_vec
[i
].z
= i
;
2232 inp_plane
[i
].b
= inp_plane
[i
].d
= inp_vec
[i
].y
= inp_vec
[i
].w
= ARRAY_SIZE
- i
;
2235 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
;
2236 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
;
2237 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
;
2238 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
;
2240 D3DXMatrixPerspectiveFovLH(&projection
,D3DX_PI
/4.0f
,20.0f
/17.0f
,1.0f
,1000.0f
);
2242 U(view
).m
[0][1] = 5.0f
; U(view
).m
[0][2] = 7.0f
; U(view
).m
[0][3] = 8.0f
;
2243 U(view
).m
[1][0] = 11.0f
; U(view
).m
[1][2] = 16.0f
; U(view
).m
[1][3] = 33.0f
;
2244 U(view
).m
[2][0] = 19.0f
; U(view
).m
[2][1] = -21.0f
; U(view
).m
[2][3] = 43.0f
;
2245 U(view
).m
[3][0] = 2.0f
; U(view
).m
[3][1] = 3.0f
; U(view
).m
[3][2] = -4.0f
;
2246 U(view
).m
[0][0] = 10.0f
; U(view
).m
[1][1] = 20.0f
; U(view
).m
[2][2] = 30.0f
;
2247 U(view
).m
[3][3] = -40.0f
;
2249 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;
2250 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
;
2251 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
;
2252 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
;
2254 /* D3DXVec2TransformCoordArray */
2255 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
;
2256 exp_vec
[2].x
= 0.653846f
; exp_vec
[2].y
= 0.769231f
;
2257 exp_vec
[3].x
= 0.625f
; exp_vec
[3].y
= 0.75f
;
2258 exp_vec
[4].x
= 0.590909f
; exp_vec
[4].y
= 8.0f
/11.0f
;
2259 exp_vec
[5].x
= 0.55f
; exp_vec
[5].y
= 0.7f
;
2260 D3DXVec2TransformCoordArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2261 compare_vectors(exp_vec
, out_vec
);
2263 /* D3DXVec2TransformNormalArray */
2264 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
;
2265 exp_vec
[2].x
= 21.0f
; exp_vec
[2].y
= 26.0f
;
2266 exp_vec
[3].x
= 17.0f
; exp_vec
[3].y
= 22.0f
;
2267 exp_vec
[4].x
= 13.0f
; exp_vec
[4].y
= 18.0f
;
2268 exp_vec
[5].x
= 9.0f
; exp_vec
[5].y
= 14.0f
;
2269 D3DXVec2TransformNormalArray((D3DXVECTOR2
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2270 compare_vectors(exp_vec
, out_vec
);
2272 /* D3DXVec3TransformCoordArray */
2273 exp_vec
[1].x
= 0.678571f
; exp_vec
[1].y
= 0.785714f
; exp_vec
[1].z
= 0.892857f
;
2274 exp_vec
[2].x
= 0.671875f
; exp_vec
[2].y
= 0.78125f
; exp_vec
[2].z
= 0.890625f
;
2275 exp_vec
[3].x
= 6.0f
/9.0f
; exp_vec
[3].y
= 7.0f
/9.0f
; exp_vec
[3].z
= 8.0f
/9.0f
;
2276 exp_vec
[4].x
= 0.6625f
; exp_vec
[4].y
= 0.775f
; exp_vec
[4].z
= 0.8875f
;
2277 exp_vec
[5].x
= 0.659091f
; exp_vec
[5].y
= 0.772727f
; exp_vec
[5].z
= 0.886364f
;
2278 D3DXVec3TransformCoordArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2279 compare_vectors(exp_vec
, out_vec
);
2281 /* D3DXVec3TransformNormalArray */
2282 exp_vec
[1].x
= 25.0f
; exp_vec
[1].y
= 30.0f
; exp_vec
[1].z
= 35.0f
;
2283 exp_vec
[2].x
= 30.0f
; exp_vec
[2].y
= 36.0f
; exp_vec
[2].z
= 42.0f
;
2284 exp_vec
[3].x
= 35.0f
; exp_vec
[3].y
= 42.0f
; exp_vec
[3].z
= 49.0f
;
2285 exp_vec
[4].x
= 40.0f
; exp_vec
[4].y
= 48.0f
; exp_vec
[4].z
= 56.0f
;
2286 exp_vec
[5].x
= 45.0f
; exp_vec
[5].y
= 54.0f
; exp_vec
[5].z
= 63.0f
;
2287 D3DXVec3TransformNormalArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2288 compare_vectors(exp_vec
, out_vec
);
2290 /* D3DXVec3ProjectArray */
2291 exp_vec
[1].x
= 1089.554199f
; exp_vec
[1].y
= -226.590622f
; exp_vec
[1].z
= 0.215273f
;
2292 exp_vec
[2].x
= 1068.903320f
; exp_vec
[2].y
= 103.085129f
; exp_vec
[2].z
= 0.183050f
;
2293 exp_vec
[3].x
= 1051.778931f
; exp_vec
[3].y
= 376.462250f
; exp_vec
[3].z
= 0.156329f
;
2294 exp_vec
[4].x
= 1037.348877f
; exp_vec
[4].y
= 606.827393f
; exp_vec
[4].z
= 0.133813f
;
2295 exp_vec
[5].x
= 1025.023560f
; exp_vec
[5].y
= 803.591248f
; exp_vec
[5].z
= 0.114581f
;
2296 D3DXVec3ProjectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2297 compare_vectors(exp_vec
, out_vec
);
2299 /* D3DXVec3UnprojectArray */
2300 exp_vec
[1].x
= -6.124031f
; exp_vec
[1].y
= 3.225360f
; exp_vec
[1].z
= 0.620571f
;
2301 exp_vec
[2].x
= -3.807109f
; exp_vec
[2].y
= 2.046579f
; exp_vec
[2].z
= 0.446894f
;
2302 exp_vec
[3].x
= -2.922839f
; exp_vec
[3].y
= 1.596689f
; exp_vec
[3].z
= 0.380609f
;
2303 exp_vec
[4].x
= -2.456225f
; exp_vec
[4].y
= 1.359290f
; exp_vec
[4].z
= 0.345632f
;
2304 exp_vec
[5].x
= -2.167897f
; exp_vec
[5].y
= 1.212597f
; exp_vec
[5].z
= 0.324019f
;
2305 D3DXVec3UnprojectArray((D3DXVECTOR3
*)(out_vec
+ 1), sizeof(D3DXVECTOR4
), (const D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &viewport
, &projection
, &view
, &world
, ARRAY_SIZE
);
2306 compare_vectors(exp_vec
, out_vec
);
2308 /* D3DXVec2TransformArray */
2309 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2310 exp_vec
[2].x
= 34.0f
; exp_vec
[2].y
= 40.0f
; exp_vec
[2].z
= 46.0f
; exp_vec
[2].w
= 52.0f
;
2311 exp_vec
[3].x
= 30.0f
; exp_vec
[3].y
= 36.0f
; exp_vec
[3].z
= 42.0f
; exp_vec
[3].w
= 48.0f
;
2312 exp_vec
[4].x
= 26.0f
; exp_vec
[4].y
= 32.0f
; exp_vec
[4].z
= 38.0f
; exp_vec
[4].w
= 44.0f
;
2313 exp_vec
[5].x
= 22.0f
; exp_vec
[5].y
= 28.0f
; exp_vec
[5].z
= 34.0f
; exp_vec
[5].w
= 40.0f
;
2314 D3DXVec2TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR2
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2315 compare_vectors(exp_vec
, out_vec
);
2317 /* D3DXVec3TransformArray */
2318 exp_vec
[1].x
= 38.0f
; exp_vec
[1].y
= 44.0f
; exp_vec
[1].z
= 50.0f
; exp_vec
[1].w
= 56.0f
;
2319 exp_vec
[2].x
= 43.0f
; exp_vec
[2].y
= 50.0f
; exp_vec
[2].z
= 57.0f
; exp_vec
[2].w
= 64.0f
;
2320 exp_vec
[3].x
= 48.0f
; exp_vec
[3].y
= 56.0f
; exp_vec
[3].z
= 64.0f
; exp_vec
[3].w
= 72.0f
;
2321 exp_vec
[4].x
= 53.0f
; exp_vec
[4].y
= 62.0f
; exp_vec
[4].z
= 71.0f
; exp_vec
[4].w
= 80.0f
;
2322 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2323 D3DXVec3TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), (D3DXVECTOR3
*)inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2324 compare_vectors(exp_vec
, out_vec
);
2326 /* D3DXVec4TransformArray */
2327 exp_vec
[1].x
= 90.0f
; exp_vec
[1].y
= 100.0f
; exp_vec
[1].z
= 110.0f
; exp_vec
[1].w
= 120.0f
;
2328 exp_vec
[2].x
= 82.0f
; exp_vec
[2].y
= 92.0f
; exp_vec
[2].z
= 102.0f
; exp_vec
[2].w
= 112.0f
;
2329 exp_vec
[3].x
= 74.0f
; exp_vec
[3].y
= 84.0f
; exp_vec
[3].z
= 94.0f
; exp_vec
[3].w
= 104.0f
;
2330 exp_vec
[4].x
= 66.0f
; exp_vec
[4].y
= 76.0f
; exp_vec
[4].z
= 86.0f
; exp_vec
[4].w
= 96.0f
;
2331 exp_vec
[5].x
= 58.0f
; exp_vec
[5].y
= 68.0f
; exp_vec
[5].z
= 78.0f
; exp_vec
[5].w
= 88.0f
;
2332 D3DXVec4TransformArray(out_vec
+ 1, sizeof(D3DXVECTOR4
), inp_vec
, sizeof(D3DXVECTOR4
), &mat
, ARRAY_SIZE
);
2333 compare_vectors(exp_vec
, out_vec
);
2335 /* D3DXPlaneTransformArray */
2336 exp_plane
[1].a
= 90.0f
; exp_plane
[1].b
= 100.0f
; exp_plane
[1].c
= 110.0f
; exp_plane
[1].d
= 120.0f
;
2337 exp_plane
[2].a
= 82.0f
; exp_plane
[2].b
= 92.0f
; exp_plane
[2].c
= 102.0f
; exp_plane
[2].d
= 112.0f
;
2338 exp_plane
[3].a
= 74.0f
; exp_plane
[3].b
= 84.0f
; exp_plane
[3].c
= 94.0f
; exp_plane
[3].d
= 104.0f
;
2339 exp_plane
[4].a
= 66.0f
; exp_plane
[4].b
= 76.0f
; exp_plane
[4].c
= 86.0f
; exp_plane
[4].d
= 96.0f
;
2340 exp_plane
[5].a
= 58.0f
; exp_plane
[5].b
= 68.0f
; exp_plane
[5].c
= 78.0f
; exp_plane
[5].d
= 88.0f
;
2341 D3DXPlaneTransformArray(out_plane
+ 1, sizeof(D3DXPLANE
), inp_plane
, sizeof(D3DXPLANE
), &mat
, ARRAY_SIZE
);
2342 compare_planes(exp_plane
, out_plane
);
2345 static void test_D3DXFloat_Array(void)
2347 static const float z
= 0.0f
;
2348 /* Compilers set different sign bits on 0.0 / 0.0, pick the right ones for NaN and -NaN */
2349 float tmpnan
= 0.0f
/z
;
2350 float nnan
= copysignf(1, tmpnan
) < 0.0f
? tmpnan
: -tmpnan
;
2360 /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32/64 bit math), W7PRO (32 bit math) */
2361 WORD half_ver1
, half_ver2
;
2363 /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
2364 FLOAT single_out_ver1
, single_out_ver2
;
2366 { 80000.0f
, 0x7c00, 0x7ce2, 65536.0f
, 80000.0f
},
2367 { 65503.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2368 { 65504.0f
, 0x7bff, 0x7bff, 65504.0f
, 65504.0f
},
2369 { 65520.0f
, 0x7bff, 0x7c00, 65504.0f
, 65536.0f
},
2370 { 65521.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2371 { 65534.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2372 { 65535.0f
, 0x7c00, 0x7c00, 65535.0f
, 65536.0f
},
2373 { 65536.0f
, 0x7c00, 0x7c00, 65536.0f
, 65536.0f
},
2374 { -80000.0f
, 0xfc00, 0xfce2, -65536.0f
, -80000.0f
},
2375 { -65503.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2376 { -65504.0f
, 0xfbff, 0xfbff, -65504.0f
, -65504.0f
},
2377 { -65520.0f
, 0xfbff, 0xfc00, -65504.0f
, -65536.0f
},
2378 { -65521.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2379 { -65534.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2380 { -65535.0f
, 0xfc00, 0xfc00, -65535.0f
, -65536.0f
},
2381 { -65536.0f
, 0xfc00, 0xfc00, -65536.0f
, -65536.0f
},
2382 { 1.0f
/z
, 0x7c00, 0x7fff, 65536.0f
, 131008.0f
},
2383 { -1.0f
/z
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2384 { nan
, 0x7fff, 0xffff, 131008.0f
, -131008.0f
},
2385 { nnan
, 0xffff, 0xffff, -131008.0f
, -131008.0f
},
2386 { 0.0f
, 0x0, 0x0, 0.0f
, 0.0f
},
2387 { -0.0f
, 0x8000, 0x8000, 0.0f
, 0.0f
},
2388 { 2.9809595e-08f
, 0x0, 0x0, 0.0f
, 0.0f
},
2389 { -2.9809595e-08f
, 0x8000, 0x8000, -0.0f
, -0.0f
},
2390 { 2.9809598e-08f
, 0x1, 0x0, 5.96046e-08f
, 5.96046e-08f
},
2391 { -2.9809598e-08f
, 0x8001, 0x8000, -5.96046e-08f
, -5.96046e-08f
},
2392 { 8.9406967e-08f
, 0x2, 0x1, 1.19209e-07f
, 5.96046e-008 }
2395 /* exception on NULL out or in parameter */
2396 out
= D3DXFloat32To16Array(&half
, &single
, 0);
2397 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2399 out
= D3DXFloat16To32Array(&single
, &half
, 0);
2400 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2402 for (i
= 0; i
< sizeof(testdata
)/sizeof(testdata
[0]); i
++)
2404 out
= D3DXFloat32To16Array(&half
, &testdata
[i
].single_in
, 1);
2405 ok(out
== &half
, "Got %p, expected %p.\n", out
, &half
);
2406 ok(half
.value
== testdata
[i
].half_ver1
|| half
.value
== testdata
[i
].half_ver2
,
2407 "Got %x, expected %x or %x for index %d.\n", half
.value
, testdata
[i
].half_ver1
,
2408 testdata
[i
].half_ver2
, i
);
2410 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver1
, 1);
2411 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2412 ok(relative_error(single
, testdata
[i
].single_out_ver1
) < admitted_error
,
2413 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver1
, i
);
2415 out
= D3DXFloat16To32Array(&single
, (D3DXFLOAT16
*)&testdata
[i
].half_ver2
, 1);
2416 ok(out
== &single
, "Got %p, expected %p.\n", out
, &single
);
2417 ok(relative_error(single
, testdata
[i
].single_out_ver2
) < admitted_error
,
2418 "Got %g, expected %g for index %d.\n", single
, testdata
[i
].single_out_ver2
, i
);
2422 static void test_D3DXSHAdd(void)
2425 FLOAT
*ret
= (FLOAT
*)0xdeadbeef;
2426 const FLOAT in1
[50] =
2428 1.11f
, 1.12f
, 1.13f
, 1.14f
, 1.15f
, 1.16f
, 1.17f
, 1.18f
,
2429 1.19f
, 1.20f
, 1.21f
, 1.22f
, 1.23f
, 1.24f
, 1.25f
, 1.26f
,
2430 1.27f
, 1.28f
, 1.29f
, 1.30f
, 1.31f
, 1.32f
, 1.33f
, 1.34f
,
2431 1.35f
, 1.36f
, 1.37f
, 1.38f
, 1.39f
, 1.40f
, 1.41f
, 1.42f
,
2432 1.43f
, 1.44f
, 1.45f
, 1.46f
, 1.47f
, 1.48f
, 1.49f
, 1.50f
,
2433 1.51f
, 1.52f
, 1.53f
, 1.54f
, 1.55f
, 1.56f
, 1.57f
, 1.58f
,
2436 const FLOAT in2
[50] =
2438 2.11f
, 2.12f
, 2.13f
, 2.14f
, 2.15f
, 2.16f
, 2.17f
, 2.18f
,
2439 2.19f
, 2.20f
, 2.21f
, 2.22f
, 2.23f
, 2.24f
, 2.25f
, 2.26f
,
2440 2.27f
, 2.28f
, 2.29f
, 2.30f
, 2.31f
, 2.32f
, 2.33f
, 2.34f
,
2441 2.35f
, 2.36f
, 2.37f
, 2.38f
, 2.39f
, 2.40f
, 2.41f
, 2.42f
,
2442 2.43f
, 2.44f
, 2.45f
, 2.46f
, 2.47f
, 2.48f
, 2.49f
, 2.50f
,
2443 2.51f
, 2.52f
, 2.53f
, 2.54f
, 2.55f
, 2.56f
, 2.57f
, 2.58f
,
2446 FLOAT out
[50] = {0.0f
};
2449 * Order is not limited by D3DXSH_MINORDER and D3DXSH_MAXORDER!
2450 * All values will work, test from 0-7 [D3DXSH_MINORDER = 2, D3DXSH_MAXORDER = 6]
2451 * Exceptions will show up when out, in1 or in2 is NULL
2453 for (k
= 0; k
<= D3DXSH_MAXORDER
+ 1; k
++)
2457 ret
= D3DXSHAdd(&out
[0], k
, &in1
[0], &in2
[0]);
2458 ok(ret
== out
, "%u: D3DXSHAdd() failed, got %p, expected %p\n", k
, out
, ret
);
2460 for (i
= 0; i
< count
; ++i
)
2462 ok(relative_error(in1
[i
] + in2
[i
], out
[i
]) < admitted_error
,
2463 "%u-%u: D3DXSHAdd() failed, got %f, expected %f\n", k
, i
, out
[i
], in1
[i
] + in2
[i
]);
2465 ok(relative_error(out
[count
], 0.0f
) < admitted_error
, "%u-%u: D3DXSHAdd() failed, got %f, expected 0.0\n", k
, k
* k
, out
[count
]);
2469 static void test_D3DXSHDot(void)
2472 FLOAT a
[49], b
[49], got
;
2473 const FLOAT expected
[] =
2474 { 0.5f
, 0.5f
, 25.0f
, 262.5f
, 1428.0f
, 5362.0f
, 15873.0f
, 39812.0f
, };
2476 for (i
= 0; i
< 49; i
++)
2482 /* D3DXSHDot computes by using order * order elements */
2483 for (i
= 0; i
<= D3DXSH_MAXORDER
+ 1; i
++)
2485 got
= D3DXSHDot(i
, a
, b
);
2486 ok(relative_error(got
, expected
[i
]) < admitted_error
, "order %d: expected %f, received %f\n", i
, expected
[i
], got
);
2492 static void test_D3DXSHEvalConeLight(void)
2495 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2496 const FLOAT table
[] = {
2498 1.604815f
, -3.131381f
, 7.202175f
, -2.870432f
, 6.759296f
, -16.959688f
,
2499 32.303082f
, -15.546381f
, -0.588878f
, -5.902123f
, 40.084042f
, -77.423569f
,
2500 137.556320f
, -70.971603f
, -3.492171f
, 7.683092f
, -2.129311f
, -35.971344f
,
2501 183.086548f
, -312.414948f
, 535.091064f
, -286.380371f
, -15.950727f
, 46.825714f
,
2502 -12.127637f
, 11.289261f
, -12.417809f
, -155.039566f
, 681.182556f
, -1079.733643f
,
2503 1807.650513f
, -989.755798f
, -59.345467f
, 201.822815f
, -70.726486f
, 7.206529f
,
2505 3.101155f
, -3.128710f
, 7.196033f
, -2.867984f
, -0.224708f
, 0.563814f
,
2506 -1.073895f
, 0.516829f
, 0.019577f
, 2.059788f
, -13.988971f
, 27.020128f
,
2507 -48.005917f
, 24.768450f
, 1.218736f
, -2.681329f
, -0.088639f
, -1.497410f
,
2508 7.621501f
, -13.005165f
, 22.274696f
, -11.921401f
, -0.663995f
, 1.949254f
,
2509 -0.504848f
, 4.168484f
, -4.585193f
, -57.247314f
, 251.522095f
, -398.684387f
,
2510 667.462891f
, -365.460693f
, -21.912912f
, 74.521721f
, -26.115280f
, 2.660963f
,
2512 2.454422f
, -4.789170f
, 11.015091f
, -4.390072f
, 10.337747f
, -25.938347f
,
2513 49.404713f
, -23.776817f
, -0.900637f
, -9.026776f
, 61.305000f
, -118.412514f
,
2514 210.380249f
, -108.544792f
, -5.340967f
, 11.750610f
, -3.256593f
, -55.014996f
,
2515 280.014709f
, -477.811066f
, 818.374512f
, -437.993469f
, -24.395227f
, 71.615799f
,
2516 -18.548151f
, 17.265928f
, -18.991943f
, -237.119324f
, 1041.808594f
, -1651.357300f
,
2517 2764.642090f
, -1513.744141f
, -90.763657f
, 308.670197f
, -108.169922f
, 11.021750f
,
2519 4.742942f
, -4.785086f
, 11.005697f
, -4.386329f
, -0.343672f
, 0.862303f
,
2520 -1.642427f
, 0.790444f
, 0.029941f
, 3.150264f
, -21.394896f
, 41.324898f
,
2521 -73.420807f
, 37.881153f
, 1.863950f
, -4.100857f
, -0.135565f
, -2.290156f
,
2522 11.656413f
, -19.890251f
, 34.067181f
, -18.232729f
, -1.015521f
, 2.981212f
,
2523 -0.772120f
, 6.375328f
, -7.012648f
, -87.554710f
, 384.680817f
, -609.752563f
,
2524 1020.825500f
, -558.939819f
, -33.513863f
, 113.974388f
, -39.941013f
, 4.069707f
,
2526 3.304030f
, -6.446959f
, 14.828006f
, -5.909713f
, 13.916198f
, -34.917004f
,
2527 66.506340f
, -32.007256f
, -1.212396f
, -12.151429f
, 82.525963f
, -159.401459f
,
2528 283.204193f
, -146.117996f
, -7.189764f
, 15.818130f
, -4.383876f
, -74.058655f
,
2529 376.942871f
, -643.207214f
, 1101.658081f
, -589.606628f
, -32.839729f
, 96.405884f
,
2530 -24.968664f
, 23.242596f
, -25.566080f
, -319.199097f
, 1402.434692f
, -2222.980957f
,
2531 3721.633545f
, -2037.732544f
, -122.181847f
, 415.517578f
, -145.613358f
, 14.836972f
,
2533 6.384730f
, -6.441462f
, 14.815362f
, -5.904673f
, -0.462635f
, 1.160793f
,
2534 -2.210959f
, 1.064060f
, 0.040305f
, 4.240739f
, -28.800821f
, 55.629673f
,
2535 -98.835709f
, 50.993862f
, 2.509163f
, -5.520384f
, -0.182491f
, -3.082903f
,
2536 15.691326f
, -26.775339f
, 45.859665f
, -24.544060f
, -1.367048f
, 4.013170f
,
2537 -1.039392f
, 8.582172f
, -9.440103f
, -117.862114f
, 517.839600f
, -820.820740f
,
2538 1374.188232f
, -752.419067f
, -45.114819f
, 153.427063f
, -53.766754f
, 5.478452f
, };
2541 FLOAT
*red_received
, *green_received
, *blue_received
;
2542 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2543 FLOAT radius
, roffset
, goffset
, boffset
;
2545 { rout
, gout
, bout
, table
, &table
[72], &table
[144], 0.5f
, 1.01f
, 1.02f
, 1.03f
, },
2546 { rout
, gout
, bout
, &table
[36], &table
[108], &table
[180], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
2547 { rout
, rout
, rout
, &table
[144], &table
[144], &table
[144], 0.5f
, 1.03f
, 1.03f
, 1.03f
, },
2548 { rout
, rout
, bout
, &table
[72], &table
[72], &table
[144], 0.5, 1.02f
, 1.02f
, 1.03f
, },
2549 { rout
, gout
, gout
, table
, &table
[144], &table
[144], 0.5f
, 1.01f
, 1.03f
, 1.03f
, },
2550 { rout
, gout
, rout
, &table
[144], &table
[72], &table
[144], 0.5f
, 1.03f
, 1.02f
, 1.03f
, },
2551 /* D3DXSHEvalConeLight accepts NULL green or blue colour. */
2552 { rout
, NULL
, bout
, table
, NULL
, &table
[144], 0.5f
, 1.01f
, 0.0f
, 1.03f
, },
2553 { rout
, gout
, NULL
, table
, &table
[72], NULL
, 0.5f
, 1.01f
, 1.02f
, 0.0f
, },
2554 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 0.5f
, 1.01f
, 0.0f
, 0.0f
, }, };
2556 unsigned int j
, l
, order
;
2558 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2560 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2562 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2564 for (j
= 0; j
< 49; j
++)
2566 test
[l
].red_received
[j
] = 1.01f
+ j
;
2567 if (test
[l
].green_received
)
2568 test
[l
].green_received
[j
] = 1.02f
+ j
;
2569 if (test
[l
].blue_received
)
2570 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2573 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
);
2574 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2576 for (j
= 0; j
< 49; j
++)
2578 if (j
>= order
* order
)
2579 expected
= j
+ test
[l
].roffset
;
2581 expected
= test
[l
].red_expected
[j
];
2582 ok(relative_error(expected
, test
[l
].red_received
[j
]) < admitted_error
,
2583 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2585 if (test
[l
].green_received
)
2587 if (j
>= order
* order
)
2588 expected
= j
+ test
[l
].goffset
;
2590 expected
= test
[l
].green_expected
[j
];
2591 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2592 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2595 if (test
[l
].blue_received
)
2597 if (j
>= order
* order
)
2598 expected
= j
+ test
[l
].boffset
;
2600 expected
= test
[l
].blue_expected
[j
];
2601 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2602 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2608 /* Cone light with radius <= 0.0f behaves as a directional light */
2609 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2611 FLOAT blue
[49], green
[49], red
[49];
2613 for (j
= 0; j
< 49; j
++)
2615 rout
[j
] = 1.01f
+ j
;
2616 gout
[j
] = 1.02f
+ j
;
2617 bout
[j
] = 1.03f
+ j
;
2619 green
[j
] = 1.02f
+ j
;
2620 blue
[j
] = 1.03f
+ j
;
2623 hr
= D3DXSHEvalConeLight(order
, &dir
, -0.1f
, 1.7f
, 2.6f
, 3.5f
, rout
, gout
, bout
);
2624 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2625 D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red
, green
, blue
);
2627 for (j
= 0; j
< 49; j
++)
2630 ok(relative_error(expected
, rout
[j
]) < admitted_error
,
2631 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, rout
[j
]);
2633 expected
= green
[j
];
2634 ok(relative_error(expected
, gout
[j
]) < admitted_error
,
2635 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, gout
[j
]);
2638 ok(relative_error(expected
, bout
[j
]) < admitted_error
,
2639 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, bout
[j
]);
2643 /* D3DXSHEvalConeLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
2644 hr
= D3DXSHEvalConeLight(7, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2645 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2646 hr
= D3DXSHEvalConeLight(0, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2647 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2648 hr
= D3DXSHEvalConeLight(1, &dir
, 0.5f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2649 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2652 static void test_D3DXSHEvalDirection(void)
2654 unsigned int i
, order
;
2656 FLOAT a
[49], expected
[49], *received_ptr
;
2657 const FLOAT table
[36] =
2658 { 0.282095f
, -0.977205f
, 1.465808f
, -0.488603f
, 2.185097f
, -6.555291f
,
2659 8.200181f
, -3.277646f
, -1.638823f
, 1.180087f
, 17.343668f
, -40.220032f
,
2660 47.020218f
, -20.110016f
, -13.007751f
, 6.490479f
, -15.020058f
, 10.620785f
,
2661 117.325661f
, -240.856750f
, 271.657288f
, -120.428375f
, -87.994247f
, 58.414314f
,
2662 -4.380850f
, 24.942520f
, -149.447693f
, 78.278130f
, 747.791748f
, -1427.687866f
,
2663 1574.619141, -713.843933f
, -560.843811f
, 430.529724, -43.588909, -26.911665, };
2665 d
.x
= 1.0; d
.y
= 2.0f
; d
.z
= 3.0f
;
2667 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2669 for (i
= 0; i
< 49; i
++)
2672 received_ptr
= D3DXSHEvalDirection(a
, order
, &d
);
2673 ok(received_ptr
== a
, "Expected %p, received %p\n", a
, received_ptr
);
2675 for (i
= 0; i
< 49; i
++)
2677 /* 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 */
2678 if ( (order
< D3DXSH_MINORDER
) || (order
> D3DXSH_MAXORDER
) || (i
>= order
* order
) )
2679 expected
[i
] = 1.5f
+ i
;
2681 expected
[i
] = table
[i
];
2683 ok(relative_error(a
[i
], expected
[i
]) < admitted_error
, "order %u, index %u: expected %f, received %f\n", order
, i
, expected
[i
], a
[i
]);
2688 static void test_D3DXSHEvalDirectionalLight(void)
2691 FLOAT
*blue_out
, bout
[49], expected
, gout
[49], *green_out
, *red_out
, rout
[49];
2692 static const FLOAT table
[] = {
2694 2.008781f
, -4.175174f
, 9.602900f
, -3.827243f
, 1.417963f
, -2.947181f
,
2695 6.778517f
, -2.701583f
, 7.249108f
, -18.188671f
, 34.643921f
, -16.672949f
,
2696 -0.631551f
, 1.417963f
, -2.947181f
, 6.778517f
, -2.701583f
, 7.249108f
,
2697 -18.188671f
, 34.643921f
, -16.672949f
, -0.631551f
, -7.794341f
, 52.934967f
,
2698 -102.245529f
, 181.656815f
, -93.725060f
, -4.611760f
, 10.146287f
, 1.555186f
,
2699 -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
, 37.996559f
,
2700 -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
, 199.236496f
,
2701 -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
, 360.268829f
,
2702 -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
, -23.864176f
,
2703 1.555186f
, -3.232392f
, 7.434503f
, -2.963026f
, 7.950634f
, -19.948866f
,
2704 37.996559f
, -18.286459f
, -0.692669f
, -8.548632f
, 58.057705f
, -112.140251f
,
2705 199.236496f
, -102.795227f
, -5.058059f
, 11.128186f
, -4.189955f
, -70.782669f
,
2706 360.268829f
, -614.755005f
, 1052.926270f
, -563.525391f
, -31.387066f
, 92.141365f
,
2707 -23.864176f
, 34.868664f
, -38.354366f
, -478.864166f
, 2103.939941f
, -3334.927734f
,
2708 5583.213867f
, -3057.017090f
, -183.297836f
, 623.361633f
, -218.449921f
, 22.258503f
,
2710 3.072254f
, -6.385560f
, 14.686787f
, -5.853429f
, 2.168650f
, -4.507453f
,
2711 10.367143f
, -4.131832f
, 11.086870f
, -27.817965f
, 52.984818f
, -25.499800f
,
2712 -0.965902f
, 2.168650f
, -4.507453f
, 10.367143f
, -4.131832f
, 11.086870f
,
2713 -27.817965f
, 52.984818f
, -25.499800f
, -0.965902f
, -11.920755f
, 80.959351f
,
2714 -156.375488f
, 277.828033f
, -143.344193f
, -7.053278f
, 15.517849f
, 2.378519f
,
2715 -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
, 58.112385f
,
2716 -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
, 304.714630f
,
2717 -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
, 550.999390f
,
2718 -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
, -36.498150f
,
2719 2.378519f
, -4.943659f
, 11.370415f
, -4.531687f
, 12.159794f
, -30.510029f
,
2720 58.112385f
, -27.967525f
, -1.059376f
, -13.074378f
, 88.794136f
, -171.508621f
,
2721 304.714630f
, -157.216217f
, -7.735855f
, 17.019577f
, -6.408166f
, -108.255844f
,
2722 550.999390f
, -940.213501f
, 1610.357788f
, -861.862305f
, -48.003746f
, 140.922089f
,
2723 -36.498150f
, 53.328545f
, -58.659618f
, -732.380493f
, 3217.790283f
, -5100.477539f
,
2724 8539.033203f
, -4675.437500f
, -280.337860f
, 953.376587f
, -334.099884f
, 34.042416f
,
2726 4.135726f
, -8.595945f
, 19.770674f
, -7.879617f
, 2.919336f
, -6.067726f
,
2727 13.955770f
, -5.562082f
, 14.924634f
, -37.447262f
, 71.325722f
, -34.326656f
,
2728 -1.300252f
, 2.919336f
, -6.067726f
, 13.955770f
, -5.562082f
, 14.924634f
,
2729 -37.447262f
, 71.325722f
, -34.326656f
, -1.300252f
, -16.047173f
, 108.983749f
,
2730 -210.505493f
, 373.999298f
, -192.963348f
, -9.494799f
, 20.889414f
, 3.201853f
,
2731 -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
, 78.228210f
,
2732 -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
, 410.192780f
,
2733 -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
, 741.729919f
,
2734 -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
, -49.132126f
,
2735 3.201853f
, -6.654925f
, 15.306328f
, -6.100348f
, 16.368954f
, -41.071194f
,
2736 78.228210f
, -37.648590f
, -1.426083f
, -17.600124f
, 119.530563f
, -230.876984f
,
2737 410.192780f
, -211.637222f
, -10.413651f
, 22.910971f
, -8.626378f
, -145.729019f
,
2738 741.729919f
, -1265.671997f
, 2167.789307f
, -1160.199219f
, -64.620430f
, 189.702820f
,
2739 -49.132126f
, 71.788422f
, -78.964867f
, -985.896790f
, 4331.640625f
, -6866.027344f
,
2740 11494.852539f
, -6293.858398f
, -377.377899f
, 1283.391479f
, -449.749817f
, 45.826328f
, };
2743 FLOAT
*red_in
, *green_in
, *blue_in
;
2744 const FLOAT
*red_out
, *green_out
, *blue_out
;
2745 FLOAT roffset
, goffset
, boffset
;
2747 { { rout
, gout
, bout
, table
, &table
[90], &table
[180], 1.01f
, 1.02f
, 1.03f
, },
2748 { rout
, rout
, rout
, &table
[180], &table
[180], &table
[180], 1.03f
, 1.03f
, 1.03f
, },
2749 { rout
, rout
, bout
, &table
[90], &table
[90], &table
[180], 1.02f
, 1.02f
, 1.03f
, },
2750 { rout
, gout
, gout
, table
, &table
[180], &table
[180], 1.01f
, 1.03f
, 1.03f
, },
2751 { rout
, gout
, rout
, &table
[180], &table
[90], &table
[180], 1.03f
, 1.02f
, 1.03f
, },
2752 /* D3DXSHEvalDirectionaLight accepts NULL green or blue colour. */
2753 { rout
, NULL
, bout
, table
, NULL
, &table
[180], 1.01f
, 0.0f
, 1.03f
, },
2754 { rout
, gout
, NULL
, table
, &table
[90], NULL
, 1.01f
, 1.02f
, 0.0f
, },
2755 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 0.0f
, 0.0f
, }, };
2757 unsigned int j
, l
, order
, startindex
;
2759 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2761 for (l
= 0; l
< sizeof( test
) / sizeof( test
[0] ); l
++)
2765 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
2767 red_out
= test
[l
].red_in
;
2768 green_out
= test
[l
].green_in
;
2769 blue_out
= test
[l
].blue_in
;
2771 for (j
= 0; j
< 49; j
++)
2773 red_out
[j
] = 1.01f
+ j
;
2775 green_out
[j
] = 1.02f
+ j
;
2777 blue_out
[j
] = 1.03f
+ j
;
2780 hr
= D3DXSHEvalDirectionalLight(order
, &dir
, 1.7f
, 2.6f
, 3.5f
, red_out
, green_out
, blue_out
);
2781 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2783 for (j
= 0; j
< 49; j
++)
2785 if ( j
>= order
* order
)
2786 expected
= j
+ test
[l
].roffset
;
2788 expected
= test
[l
].red_out
[startindex
+ j
];
2789 ok(relative_error(expected
, red_out
[j
]) < admitted_error
,
2790 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, red_out
[j
]);
2794 if ( j
>= order
* order
)
2795 expected
= j
+ test
[l
].goffset
;
2797 expected
= test
[l
].green_out
[startindex
+ j
];
2798 ok(relative_error(expected
, green_out
[j
]) < admitted_error
,
2799 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, green_out
[j
]);
2804 if ( j
>= order
* order
)
2805 expected
= j
+ test
[l
].boffset
;
2807 expected
= test
[l
].blue_out
[startindex
+ j
];
2808 ok(relative_error(expected
, blue_out
[j
]) < admitted_error
,
2809 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, blue_out
[j
]);
2813 startindex
+= order
* order
;
2817 /* D3DXSHEvalDirectionalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set*/
2818 hr
= D3DXSHEvalDirectionalLight(7, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2819 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2820 hr
= D3DXSHEvalDirectionalLight(0, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2821 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2822 hr
= D3DXSHEvalDirectionalLight(1, &dir
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
2823 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2826 static void test_D3DXSHEvalHemisphereLight(void)
2828 D3DXCOLOR bottom
, top
;
2830 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2831 const FLOAT table
[] = {
2833 23.422981f
, 15.859521f
, -36.476898f
, 14.537894f
,
2835 19.966694f
, 6.096982f
, -14.023058f
, 5.588900f
,
2837 24.566214f
, 8.546826f
, -19.657701f
, 7.834591f
, };
2840 FLOAT
*red_received
, *green_received
, *blue_received
;
2841 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2842 const FLOAT roffset
, goffset
, boffset
;
2844 { rout
, gout
, bout
, table
, &table
[4], &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2845 { rout
, rout
, rout
, &table
[8], &table
[8], &table
[8], 1.03f
, 1.03f
, 1.03f
, },
2846 { rout
, rout
, bout
, &table
[4], &table
[4], &table
[8], 1.02f
, 1.02f
, 1.03f
, },
2847 { rout
, gout
, gout
, table
, &table
[8], &table
[8], 1.01f
, 1.03f
, 1.03f
, },
2848 { rout
, gout
, rout
, &table
[8], &table
[4], &table
[8], 1.03f
, 1.02f
, 1.03f
, },
2849 /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */
2850 { rout
, NULL
, bout
, table
, NULL
, &table
[8], 1.01f
, 1.02f
, 1.03f
, },
2851 { rout
, gout
, NULL
, table
, &table
[4], NULL
, 1.01f
, 1.02f
, 1.03f
, },
2852 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 1.01f
, 1.02f
, 1.03f
, }, };
2854 unsigned int j
, l
, order
;
2856 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
2857 top
.r
= 0.1f
; top
.g
= 2.1f
; top
.b
= 2.3f
; top
.a
= 4.3f
;
2858 bottom
.r
= 8.71f
; bottom
.g
= 5.41f
; bottom
.b
= 6.94f
; bottom
.a
= 8.43f
;
2860 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
2861 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
+ 1; order
++)
2863 for (j
= 0; j
< 49; j
++)
2865 test
[l
].red_received
[j
] = 1.01f
+ j
;
2866 if (test
[l
].green_received
)
2867 test
[l
].green_received
[j
] = 1.02f
+ j
;
2868 if (test
[l
].blue_received
)
2869 test
[l
].blue_received
[j
] = 1.03f
+ j
;
2872 hr
= D3DXSHEvalHemisphereLight(order
, &dir
, top
, bottom
, test
[l
].red_received
, test
[l
].green_received
, test
[l
].blue_received
);
2873 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
2875 for (j
= 0; j
< 49; j
++)
2878 expected
= test
[l
].red_expected
[j
];
2879 else if (j
< order
* order
)
2882 expected
= test
[l
].roffset
+ j
;
2883 ok(relative_error(test
[l
].red_received
[j
], expected
) < admitted_error
,
2884 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
2886 if (test
[l
].green_received
)
2889 expected
= test
[l
].green_expected
[j
];
2890 else if (j
< order
* order
)
2893 expected
= test
[l
].goffset
+ j
;
2894 ok(relative_error(expected
, test
[l
].green_received
[j
]) < admitted_error
,
2895 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
2898 if (test
[l
].blue_received
)
2901 expected
= test
[l
].blue_expected
[j
];
2902 else if (j
< order
* order
)
2905 expected
= test
[l
].boffset
+ j
;
2906 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < admitted_error
,
2907 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
2913 static void test_D3DXSHEvalSphericalLight(void)
2916 FLOAT bout
[49], expected
, gout
[49], rout
[49];
2917 const FLOAT table
[] = {
2919 3.01317239f
, -0.97724032f
, 2.24765277f
, -0.89580363f
, 0.0f
, 0.0f
,
2920 0.0f
, 0.0f
, 0.0f
, 0.06292814f
, -0.42737406f
, 0.61921263f
,
2921 -0.30450898f
, 0.56761158f
, 0.03723336f
, -0.08191673f
, 0.0f
, 0.0f
,
2922 0.0f
, 0.0f
, 0.0f
, -0.0f
, 0.0f
, 0.0f
,
2923 0.0f
, 0.01249927f
, -0.01374878f
, -0.14810932f
, 0.43434596f
, -0.24598616f
,
2924 -0.15175794f
, -0.22548729f
, -0.03784076f
, 0.19280137f
, -0.07830712f
, 0.00797894f
,
2926 0.40251964f
, -0.24365333f
, 0.56040263f
, -0.22334887f
, 0.16204689f
, -0.40659040f
,
2927 0.44600141f
, -0.37270784f
, -0.01411773f
, -0.04319951f
, 0.29338786f
, -0.42508304f
,
2928 0.20904225f
, -0.38965943f
, -0.02556031f
, 0.05623499f
, -0.00468823f
, -0.07920021f
,
2929 0.33171222f
, -0.30782884f
, 0.00052908f
, -0.28217643f
, -0.02889918f
, 0.10309891f
,
2930 -0.02670213f
, 0.00724340f
, -0.00796750f
, -0.08583023f
, 0.25170606f
, -0.14255044f
,
2931 -0.08794463f
, -0.13067122f
, -0.02192894f
, 0.11172954f
, -0.04537944f
, 0.00462384f
,
2933 1.95445275f
, -0.85659367f
, 1.97016549f
, -0.78521085f
, 0.23103346f
, -0.57968396f
,
2934 0.63587302f
, -0.53137696f
, -0.02012792f
, 0.02111043f
, -0.14337072f
, 0.20772660f
,
2935 -0.10215330f
, 0.19041604f
, 0.01249063f
, -0.02748052f
, 0.00633162f
, 0.10696279f
,
2936 -0.44798949f
, 0.41573414f
, -0.00071454f
, 0.38108963f
, 0.03902940f
, -0.13923886f
,
2937 0.03606220f
, -0.00447360f
, 0.00492081f
, 0.05300967f
, -0.15545636f
, 0.08804068f
,
2938 0.05431554f
, 0.08070395f
, 0.01354355f
, -0.06900536f
, 0.02802683f
, -0.00285574f
,
2940 4.60838127f
, -1.49460280f
, 3.43758631f
, -1.37005258f
, 0.0f
, 0.0f
,
2941 0.0f
, 0.0f
, 0.0f
, 0.09624302f
, -0.65363091f
, 0.94703102f
,
2942 -0.46571958f
, 0.86811179f
, 0.05694513f
, -0.12528442f
, -0.0f
, 0.0f
,
2943 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2944 0.0f
, 0.01911653f
, -0.02102755f
, -0.22652012f
, 0.66429377f
, -0.37621412f
,
2945 -0.23210037f
, -0.34486291f
, -0.05787410f
, 0.29487267f
, -0.11976383f
, 0.01220309f
,
2947 0.61561823f
, -0.37264627f
, 0.85708636f
, -0.34159240f
, 0.24783641f
, -0.62184411f
,
2948 0.68211979f
, -0.57002378f
, -0.02159182f
, -0.06606984f
, 0.44871080f
, -0.65012693f
,
2949 0.31971166f
, -0.59594971f
, -0.03909224f
, 0.08600645f
, -0.00717023f
, -0.12112973f
,
2950 0.50732452f
, -0.47079703f
, 0.00080918f
, -0.43156394f
, -0.04419874f
, 0.15768069f
,
2951 -0.04083854f
, 0.01107814f
, -0.01218559f
, -0.13126975f
, 0.38496217f
, -0.21801829f
,
2952 -0.13450353f
, -0.19985008f
, -0.03353838f
, 0.17088045f
, -0.06940385f
, 0.00707176f
,
2954 2.98916292f
, -1.31008446f
, 3.01319408f
, -1.20091069f
, 0.35334525f
, -0.88657540f
,
2955 0.97251165f
, -0.81269407f
, -0.03078388f
, 0.03228654f
, -0.21927285f
, 0.31769949f
,
2956 -0.15623444f
, 0.29122451f
, 0.01910332f
, -0.04202903f
, 0.00968366f
, 0.16359015f
,
2957 -0.68516040f
, 0.63582867f
, -0.00109283f
, 0.58284295f
, 0.05969203f
, -0.21295355f
,
2958 0.05515395f
, -0.00684198f
, 0.00752595f
, 0.08107361f
, -0.23775679f
, 0.13465045f
,
2959 0.08307083f
, 0.12342957f
, 0.02071366f
, -0.10553761f
, 0.04286456f
, -0.00436760f
,
2961 6.20359039f
, -2.01196527f
, 4.62752008f
, -1.84430146f
, 0.0f
, 0.0f
,
2962 0.0f
, 0.0f
, 0.0f
, 0.12955792f
, -0.87988776f
, 1.27484941f
,
2963 -0.62693024f
, 1.16861200f
, 0.07665691f
, -0.16865209f
, 0.0f
, 0.0f
,
2964 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
,
2965 0.0f
, 0.02573379f
, -0.02830632f
, -0.30493096f
, 0.89424169f
, -0.50644207f
,
2966 -0.31244281f
, -0.46423855f
, -0.07790744f
, 0.39694402f
, -0.16122055f
, 0.01642723f
,
2968 0.82871687f
, -0.50163919f
, 1.15377009f
, -0.45983589f
, 0.33362597f
, -0.83709794f
,
2969 0.91823828f
, -0.76733971f
, -0.02906591f
, -0.08894017f
, 0.60403383f
, -0.87517095f
,
2970 0.43038112f
, -0.80224001f
, -0.05262417f
, 0.11577792f
, -0.00965224f
, -0.16305926f
,
2971 0.68293691f
, -0.63376528f
, 0.00108928f
, -0.58095151f
, -0.05949831f
, 0.21226248f
,
2972 -0.05497497f
, 0.01491288f
, -0.01640368f
, -0.17670928f
, 0.51821834f
, -0.29348618f
,
2973 -0.18106246f
, -0.26902896f
, -0.04514782f
, 0.23003140f
, -0.09342826f
, 0.00951968f
,
2975 4.02387333f
, -1.76357520f
, 4.05622292f
, -1.61661065f
, 0.47565711f
, -1.19346702f
,
2976 1.30915034f
, -1.09401131f
, -0.04143983f
, 0.04346266f
, -0.29517499f
, 0.42767239f
,
2977 -0.21031560f
, 0.39203301f
, 0.02571601f
, -0.05657754f
, 0.01303570f
, 0.22021750f
,
2978 -0.92233127f
, 0.85592318f
, -0.00147112f
, 0.78459626f
, 0.08035465f
, -0.28666824f
,
2979 0.07424571f
, -0.00921036f
, 0.01013109f
, 0.10913756f
, -0.32005721f
, 0.18126021f
,
2980 0.11182612f
, 0.16615519f
, 0.02788378f
, -0.14206986f
, 0.05770230f
, -0.00587946f
, };
2983 FLOAT
*red_received
, *green_received
, *blue_received
;
2984 const FLOAT
*red_expected
, *green_expected
, *blue_expected
;
2985 FLOAT radius
, roffset
, goffset
, boffset
;
2987 { rout
, gout
, bout
, table
, &table
[108], &table
[216], 17.4f
, 1.01f
, 1.02f
, 1.03f
, },
2988 { rout
, gout
, bout
, &table
[36], &table
[144], &table
[252], 1.6f
, 1.01f
, 1.02f
, 1.03f
, },
2989 { rout
, gout
, bout
, &table
[72], &table
[180], &table
[288], -3.0f
, 1.01f
, 1.02f
, 1.03f
, },
2990 { rout
, rout
, rout
, &table
[216], &table
[216], &table
[216], 17.4f
, 1.03f
, 1.03f
, 1.03f
, },
2991 { rout
, rout
, bout
, &table
[108], &table
[108], &table
[216], 17.4, 1.02f
, 1.02f
, 1.03f
, },
2992 { rout
, gout
, gout
, table
, &table
[216], &table
[216], 17.4f
, 1.01f
, 1.03f
, 1.03f
, },
2993 { rout
, gout
, rout
, &table
[216], &table
[108], &table
[216], 17.4f
, 1.03f
, 1.02f
, 1.03f
, },
2994 /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
2995 { rout
, NULL
, bout
, table
, NULL
, &table
[216], 17.4f
, 1.01f
, 0.0f
, 1.03f
, },
2996 { rout
, gout
, NULL
, table
, &table
[108], NULL
, 17.4f
, 1.01f
, 1.02f
, 0.0f
, },
2997 { rout
, NULL
, NULL
, table
, NULL
, NULL
, 17.4f
, 1.01f
, 0.0f
, 0.0f
, }, };
2999 unsigned int j
, l
, order
;
3001 dir
.x
= 1.1f
; dir
.y
= 1.2f
; dir
.z
= 2.76f
;
3003 for (l
= 0; l
< sizeof(test
) / sizeof(test
[0]); l
++)
3005 for (order
= D3DXSH_MINORDER
; order
<= D3DXSH_MAXORDER
; order
++)
3007 for (j
= 0; j
< 49; j
++)
3009 test
[l
].red_received
[j
] = 1.01f
+ j
;
3010 if (test
[l
].green_received
)
3011 test
[l
].green_received
[j
] = 1.02f
+ j
;
3012 if (test
[l
].blue_received
)
3013 test
[l
].blue_received
[j
] = 1.03f
+ j
;
3016 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
);
3017 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3019 for (j
= 0; j
< 49; j
++)
3021 if (j
>= order
* order
)
3022 expected
= j
+ test
[l
].roffset
;
3024 expected
= test
[l
].red_expected
[j
];
3025 ok(relative_error(expected
, test
[l
].red_received
[j
]) < 0.0005f
,
3026 "Red: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].red_received
[j
]);
3028 if (test
[l
].green_received
)
3030 if (j
>= order
* order
)
3031 expected
= j
+ test
[l
].goffset
;
3033 expected
= test
[l
].green_expected
[j
];
3034 ok(relative_error(expected
, test
[l
].green_received
[j
]) < 0.0005f
,
3035 "Green: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].green_received
[j
]);
3038 if (test
[l
].blue_received
)
3040 if (j
>= order
* order
)
3041 expected
= j
+ test
[l
].boffset
;
3043 expected
= test
[l
].blue_expected
[j
];
3044 ok(relative_error(expected
, test
[l
].blue_received
[j
]) < 0.0005f
,
3045 "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l
, order
, j
, expected
, test
[l
].blue_received
[j
]);
3051 /* D3DXSHEvalSphericalLight accepts order < D3DXSH_MINORDER or order > D3DXSH_MAXORDER. But tests in native windows show that the colour outputs are not set */
3052 hr
= D3DXSHEvalSphericalLight(7, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3053 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3054 hr
= D3DXSHEvalSphericalLight(0, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3055 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3056 hr
= D3DXSHEvalSphericalLight(1, &dir
, 17.4f
, 1.0f
, 2.0f
, 3.0f
, rout
, gout
, bout
);
3057 ok(hr
== D3D_OK
, "Expected %#x, got %#x\n", D3D_OK
, hr
);
3060 static void test_D3DXSHMultiply2(void)
3063 FLOAT a
[20], b
[20], c
[20];
3064 /* D3DXSHMultiply2 only modifies the first 4 elements of the array */
3065 const FLOAT expected
[20] =
3066 { 3.418594f
, 1.698211f
, 1.703853f
, 1.709494f
, 4.0f
, 5.0f
,
3067 6.0f
, 7.0f
, 8.0f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3068 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
};
3070 for (i
= 0; i
< 20; i
++)
3072 a
[i
] = 1.0f
+ i
/ 100.0f
;
3073 b
[i
] = 3.0f
- i
/ 100.0f
;
3077 D3DXSHMultiply2(c
, a
, b
);
3078 for (i
= 0; i
< 20; i
++)
3079 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3082 static void test_D3DXSHMultiply3(void)
3085 FLOAT a
[20], b
[20], c
[20];
3086 /* D3DXSHMultiply3 only modifies the first 9 elements of the array */
3087 const FLOAT expected
[20] =
3088 { 7.813913f
, 2.256058f
, 5.9484005f
, 4.970894f
, 2.899858f
, 3.598946f
,
3089 1.726572f
, 5.573538f
, 0.622063f
, 9.0f
, 10.0f
, 11.0f
, 12.0f
, 13.0f
,
3090 14.0f
, 15.0f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
};
3092 for (i
= 0; i
< 20; i
++)
3094 a
[i
] = 1.0f
+ i
/ 100.0f
;
3095 b
[i
] = 3.0f
- i
/ 100.0f
;
3099 D3DXSHMultiply3(c
, a
, b
);
3100 for (i
= 0; i
< 20; i
++)
3101 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3104 static void test_D3DXSHMultiply4(void)
3107 FLOAT a
[20], b
[20], c
[20];
3108 /* D3DXSHMultiply4 only modifies the first 16 elements of the array */
3109 const FLOAT expected
[] =
3111 14.182599f
, 2.615703f
, 12.828601f
, 9.820596f
, 3.039696f
, 4.530442f
,
3112 5.820584f
, 12.249846f
, 2.194346f
, 3.900152f
, 5.416609f
, 5.601813f
,
3113 0.959982f
, 7.037550f
, 3.625230f
, 0.463601f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3115 -211441.265625f
, -2529.157715f
, -10023.393555f
, -441.277191f
, -163.994385f
,
3116 -526.305115f
, 29636.187500f
, -3931.830811f
, -13577.111328f
, -3978.973877f
,
3117 -10330.341797f
, -13779.787109f
, -16685.109375f
, -44981.375000f
, -73269.742188f
,
3118 -95237.335938f
, 16.0f
, 17.0f
, 18.0f
, 19.0f
,
3120 0.236682f
, -0.717649f
, -0.180500f
, -0.077124f
, 0.144831f
, 0.573286f
,
3121 -0.337959f
, 0.055694f
, -0.442100f
, 0.147702f
, -0.055157f
, 0.084337f
,
3122 0.179877f
, 0.009099f
, 0.232200f
, 0.074142f
, 1.6f
, 1.7f
, 1.8f
, 1.9f
, };
3124 for (i
= 0; i
< 20; i
++)
3126 a
[i
] = 1.0f
+ i
/ 100.0f
;
3127 b
[i
] = 3.0f
- i
/ 100.0f
;
3131 D3DXSHMultiply4(c
, a
, b
);
3132 for (i
= 0; i
< 20; i
++)
3133 ok(relative_error(c
[i
], expected
[i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[i
], c
[i
]);
3135 for (i
= 0; i
< 20; i
++)
3137 b
[i
] = 3.0f
- i
/ 100.0f
;
3141 D3DXSHMultiply4(c
, c
, b
);
3142 for (i
= 0; i
< 20; i
++)
3143 ok(relative_error(c
[i
], expected
[20 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[20 + i
], c
[i
]);
3145 for (i
= 0; i
< 20; i
++)
3148 D3DXSHMultiply4(c
, c
, c
);
3149 for (i
= 0; i
< 20; i
++)
3150 ok(relative_error(c
[i
], expected
[40 + i
]) < admitted_error
, "Expected[%d] = %f, received = %f\n", i
, expected
[40 + i
], c
[i
]);
3153 static void test_D3DXSHRotate(void)
3156 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3157 static const FLOAT table
[]=
3158 { /* Rotation around X-axis Pi/2 */
3159 1.01f
, -3.01f
, 2.01f
, 4.01f
, -8.01f
, -6.01f
,
3160 -11.307890f
, 5.01f
, -1.565839f
, 1.093598f
, -11.01f
, 19.833414f
,
3161 -15.268191f
, -19.004118f
, -3.364889f
, -9.562627f
, 12.099654f
, -0.272131f
,
3162 30.241013f
, 26.919991f
, 39.236877f
, -22.632446f
, 6.707388f
, -11.768282f
,
3163 3.443672f
, -6.07445f
, 11.61839f
, 1.527561f
, 37.89633f
, -56.9012f
,
3164 47.42289f
, 50.39153f
, 10.61819f
, 25.50101f
, 0.049241f
, 16.98330f
,
3166 1.01f
, -3.01f
, -3.01f
, 4.01f
, -8.01f
, -6.01f
, -11.307889f
, -8.01f
, 14.297919f
,
3167 /* Rotation around X-axis -Pi/2 */
3168 1.01f
, 3.01f
, -2.01f
, 4.01f
, 8.01f
, -6.01f
,
3169 -11.307890f
, -5.01f
, -1.565839f
, -1.093598f
, -11.01f
, -19.833414f
,
3170 15.268191f
, -19.004118f
, 3.364889f
, -9.562627f
, -12.099654f
, -0.272131f
,
3171 -30.241013f
, 26.919991f
, 39.236877f
, 22.632446f
, 6.707388f
, 11.768282f
,
3172 3.443672f
, 6.07445f
, 11.61839f
, -1.527561f
, 37.89633f
, 56.9012f
,
3173 -47.42289f
, 50.39153f
, -10.61819f
, 25.50101f
, -0.049248f
, 16.98330f
,
3175 1.01f
, 3.01f
, -3.01f
, 4.01f
, 8.01f
, -6.01f
, -11.307890f
, -8.01f
, 14.297919f
,
3176 /* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
3177 1.01f
, 4.944899f
, 1.442301f
, 1.627281f
, 0.219220f
, 10.540824f
,
3178 -9.136903f
, 2.763750f
, -7.30904f
, -5.875721f
, 5.303124f
, -8.682154f
,
3179 -25.683384f
, 1.680279f
, -18.808388f
, 7.653656f
, 16.939133f
, -17.328018f
,
3180 14.629795f
, -54.467102f
, -12.231035f
, -4.089857f
, -9.444222f
, 3.056035f
,
3181 0.179257f
, -10.041875f
, 23.090092f
, -23.188709f
, 11.727098f
, -65.183090f
,
3182 48.671577f
, -15.073209f
, 38.793171f
, -26.039536f
, 6.192769f
, -17.672247f
,
3184 1.01f
, 4.944899f
, -0.891142f
, 4.607695f
, 0.219218f
, 10.773325f
,
3185 -8.204769f
, 13.563829f
, -12.007767f
,
3186 /* Rotation around Z-axis Pi/6 */
3187 1.01f
, 3.745711f
, 3.01f
, 2.467762f
, 10.307889f
, 9.209813f
,
3188 7.01f
, 3.931864f
, 0.166212f
, 16.01f
, 18.504042f
, 17.405966f
,
3189 13.01f
, 6.128016f
, -2.029941f
, -10.01f
, 13.154292f
, 24.01f
,
3190 29.432245f
, 28.334167f
, 21.01f
, 9.056221f
, -4.958143f
, -18.01f
,
3191 -27.236094f
, -4.520332f
, 16.814543f
, 34.01f
, 43.092495f
, 41.994423f
,
3192 31.01f
, 12.716471f
, -8.618400f
, -28.01f
, -40.896347f
, -44.190571,
3194 1.01f
, 3.745711f
, 3.01f
, 1.599906f
, 10.307889f
, 9.209813f
,
3195 7.01f
, 2.331957f
, -4.421894f
, };
3196 unsigned int i
, j
, l
, order
;
3198 D3DXMatrixRotationX(&m
[0], -D3DX_PI
/ 2.0f
);
3199 D3DXMatrixRotationX(&m
[1], D3DX_PI
/ 2.0f
);
3200 D3DXMatrixRotationYawPitchRoll(&m
[2], D3DX_PI
/ 3.0f
, D3DX_PI
/ 4.0f
, D3DX_PI
/ 5.0f
);
3201 D3DXMatrixRotationZ(&m
[3], D3DX_PI
/ 6.0f
);
3203 for (l
= 0; l
< 2; l
++)
3210 for (j
= 0; j
< 4; j
++)
3212 for (order
= 0; order
<= D3DXSH_MAXORDER
; order
++)
3214 for (i
= 0; i
< 49; i
++)
3216 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3220 received_ptr
= D3DXSHRotate(out_temp
, order
, &m
[j
], in
);
3221 ok(received_ptr
== out_temp
, "Order %u, expected %p, received %p\n", order
, out
, received_ptr
);
3223 for (i
= 0; i
< 49; i
++)
3225 if ((i
> 0) && ((i
>= order
* order
) || (order
> D3DXSH_MAXORDER
)))
3228 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3230 expected
= i
+ 1.01f
;
3232 else if ((l
== 0) || (order
> 3))
3233 expected
= table
[45 * j
+ i
];
3235 expected
= table
[45 * j
+ 36 +i
];
3236 ok(relative_error(out_temp
[i
], expected
) < admitted_error
,
3237 "Order %u index %u, expected %f, received %f\n", order
, i
, expected
, out_temp
[i
]);
3244 static void test_D3DXSHRotateZ(void)
3246 unsigned int end
, i
, j
, l
, order
, square
;
3247 FLOAT expected
, in
[49], out
[49], *out_temp
, *received_ptr
;
3248 const FLOAT angle
[] = { D3DX_PI
/ 3.0f
, -D3DX_PI
/ 3.0f
, 4.0f
* D3DX_PI
/ 3.0f
, }, table
[] =
3249 { /* Angle = D3DX_PI / 3.0f */
3250 1.01f
, 4.477762f
, 3.010000f
, 0.264289f
, 5.297888f
, 9.941864f
,
3251 7.010000f
, -1.199813f
, -8.843789f
, -10.010002f
, 7.494040f
, 18.138016f
,
3252 13.010000, -3.395966f
, -17.039942f
, -16.009998f
, -30.164297f
, -18.010004f
,
3253 10.422242f
, 29.066219f
, 21.010000f
, -6.324171f
, -27.968145f
, -24.009998f
,
3254 2.226099f
, -18.180565, -43.824551f
, -28.010004f
, 14.082493f
, 42.726471f
,
3255 31.010000f
, -9.984426f
, -41.628399f
, -34.009995f
, 5.886358f
, 40.530331f
,
3257 1.01f
, 4.477762f
, 0.0f
, -5.816784f
, 5.297888f
, 6.936864f
,
3258 0.0f
, -9.011250f
, -2.294052f
, -10.010002f
, 12.999042f
, 12.133017f
,
3259 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, -30.164297f
, 0.0f
,
3260 19.927244f
, 19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3261 -13.061530f
, -18.180565f
, -30.319553f
, 0.0f
, 28.587496f
, 27.721474f
,
3262 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -23.617250f
,
3264 1.010000f
, 3.977762f
, 3.977762f
, 1.114195f
, 7.245791f
, 10.559759f
,
3265 10.559759f
, -0.995160f
, -0.467341f
, 0.467339f
, 12.765371f
, 18.515701f
,
3266 18.515701f
, -1.797287f
, 0.493916f
, -0.493916f
, -21.412342f
, 21.412338f
,
3267 9.221072f
, 23.671757f
, 23.671757f
, 3.850195f
, -20.468727f
, 20.468723f
,
3268 -10.662103f
, -36.516628f
, -12.061245f
, 12.061240f
, 22.556875f
, 38.999908f
,
3269 38.999908f
, -0.034875f
, -10.427902f
, 10.427900f
, -36.838284f
, -27.652803f
,
3270 /* Angle = -D3DX_PI / 3.0f */
3271 1.01f
, -2.467762f
, 3.010000f
, 3.745711f
, -10.307890f
, -3.931864f
,
3272 7.010000f
, 9.209813f
, -0.166214f
, -10.010002f
, -18.504044f
, -6.128017f
,
3273 13.010000f
, 17.405966f
, 2.029938f
, -16.009998f
, 13.154303f
, -18.010004f
,
3274 -29.432247f
, -9.056221f
, 21.010000f
, 28.334169f
, 4.958139f
, -24.010002f
,
3275 -27.236092f
, 44.190582f
, 16.814558f
, -28.009996f
, -43.092499f
, -12.716474f
,
3276 31.010000f
, 41.994423f
, 8.618393f
, -34.010002f
, -40.896347f
, -4.520310f
,
3278 1.01f
, -2.467762f
, 0.0f
, -3.205718f
, -10.307890f
, -6.936864f
,
3279 0.0f
, -9.011250f
, -4.463446f
, -10.009998f
, -12.999042f
, -12.133017f
,
3280 0.0f
, -15.761250f
, -5.628748f
, 0.0f
, 13.154303f
, 0.0f
,
3281 -19.927244f
, -19.061220f
, 0.0f
, -24.761251f
, -8.628748f
, 0.0f
,
3282 -5.695983f
, 44.190582f
, 30.319553f
, 0.0f
, -28.587496f
, -27.721474f
,
3283 0.0f
, -36.011253f
, -12.378746f
, 0.0f
, -13.128758f
, -57.405258f
,
3285 1.010000f
, -2.967762f
, -2.967762f
, -0.609195f
, -7.498291f
, -10.686009f
,
3286 -10.686009f
, -11.836716f
, 5.390780f
, -5.390779f
, -10.303651f
, -17.284842f
,
3287 -17.284842f
, -17.565643f
, 4.114273f
, -4.114273f
, 23.716436f
, -23.716433f
,
3288 -8.069025f
, -23.095732f
, -23.095732f
, -18.535847f
, -11.271107f
, 11.271104f
,
3289 -2.072484f
, 30.149330f
, 15.244893f
, -15.244888f
, -20.965050f
, -38.203999f
,
3290 -38.203999f
, -37.258266f
, 5.426677f
, -5.426679f
, -23.396751f
, -9.903559f
,
3291 /* Angle = 4.0f * D3DX_PI / 3.0f */
3292 1.01f
, -4.477762f
, 3.010000f
, -0.264289f
, 5.297887f
, -9.941864f
,
3293 7.010000f
, 1.199814f
, -8.843788f
, 10.010004f
, 7.494038f
, -18.138016f
,
3294 13.010000f
, 3.395967f
, -17.039940f
, 16.009996f
, -30.164293f
, 18.010006f
,
3295 10.422239f
, -29.066219f
, 21.010000f
, 6.324172f
, -27.968143f
, 24.009993f
,
3296 2.226105f
, 18.180552f
, -43.824543f
, 28.010008f
, 14.082489f
, -42.726471f
,
3297 31.010000f
, 9.984427f
, -41.628399f
, 34.009987f
, 5.886366f
, -40.530327f
,
3299 1.01f
, -4.477762f
, 0.0f
, -1.938928f
, 5.297887f
, -6.936864f
,
3300 0.0f
, -3.003751f
, -2.294051f
, 10.010004f
, 12.999040f
, -12.133017f
,
3301 0.0f
, -5.253751f
, -5.628747f
, 0.0f
, -30.164293f
, 0.0f
,
3302 19.927242f
, -19.061220f
, 0.0f
, -8.253753f
, -8.628746f
, 0.0f
,
3303 -13.061535f
, 18.180552f
, -30.319553f
, 0.0f
, 28.587492f
, -27.721474f
,
3304 0.0f
, -12.003753f
, -12.378742f
, 0.0f
, -13.128765f
, -7.872400f
,
3306 1.010000f
, -3.977762f
, -3.977762f
, 2.863566f
, 6.371104f
, -10.122416f
,
3307 -10.122416f
, 10.578746f
, -7.769295f
, -7.769290f
, 16.883686f
, -20.574858f
,
3308 -20.574858f
, 24.909130f
, -5.726166f
, -5.726164f
, -18.796221f
, -18.796211f
,
3309 29.325350f
, -33.723892f
, -33.723892f
, 42.258442f
, -4.851232f
, -4.851226f
,
3310 -2.533393f
, 32.452259f
, -46.545670f
, -46.545654f
, 51.860325f
, -53.651630f
,
3311 -53.651630f
, 71.738174f
, 4.440616f
, 4.440629f
, 25.884174f
, -10.748116f
, };
3313 for (l
= 0; l
< 3; l
++)
3318 out_temp
= &in
[l
- 1];
3325 for (j
= 0; j
< 3; j
++)
3327 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3329 for (i
= 0; i
< 49; i
++)
3331 out
[i
] = ( i
+ 1.0f
) * ( i
+ 1.0f
);
3335 received_ptr
= D3DXSHRotateZ(out_temp
, order
, angle
[j
], in
);
3336 ok(received_ptr
== out_temp
, "angle %f, order %u, expected %p, received %p\n", angle
[j
], order
, out_temp
, received_ptr
);
3338 for (i
= 0; i
< end
; i
++)
3340 /* order = 0 or order = 1 behaves like order = D3DXSH_MINORDER */
3341 square
= (order
<= D3DXSH_MINORDER
) ? D3DXSH_MINORDER
* D3DXSH_MINORDER
: order
* order
;
3342 if (i
>= square
|| ((order
>= D3DXSH_MAXORDER
) && (i
>= D3DXSH_MAXORDER
* D3DXSH_MAXORDER
)))
3344 expected
= i
+ l
+ 0.01f
;
3346 expected
= ( i
+ 1.0f
) * ( i
+ 1.0f
);
3348 expected
= table
[36 * (l
+ 3 * j
) + i
];
3349 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
]);
3356 static void test_D3DXSHScale(void)
3358 unsigned int i
, order
;
3359 FLOAT a
[49], b
[49], expected
, *received_array
;
3361 for (i
= 0; i
< 49; i
++)
3367 for (order
= 0; order
<= D3DXSH_MAXORDER
+ 1; order
++)
3369 received_array
= D3DXSHScale(b
, order
, a
, 5.0f
);
3370 ok(received_array
== b
, "Expected %p, received %p\n", b
, received_array
);
3372 for (i
= 0; i
< 49; i
++)
3374 if (i
< order
* order
)
3375 expected
= 5.0f
* a
[i
];
3376 /* D3DXSHScale does not modify the elements of the array after the order * order-th element */
3379 ok(relative_error(b
[i
], expected
) < admitted_error
, "order %d, element %d, expected %f, received %f\n", order
, i
, expected
, b
[i
]);
3390 D3DXQuaternionTest();
3394 test_matrix_stack();
3395 test_Matrix_AffineTransformation2D();
3396 test_Matrix_Decompose();
3397 test_Matrix_Transformation2D();
3398 test_D3DXVec_Array();
3399 test_D3DXFloat_Array();
3402 test_D3DXSHEvalConeLight();
3403 test_D3DXSHEvalDirection();
3404 test_D3DXSHEvalDirectionalLight();
3405 test_D3DXSHEvalHemisphereLight();
3406 test_D3DXSHEvalSphericalLight();
3407 test_D3DXSHMultiply2();
3408 test_D3DXSHMultiply3();
3409 test_D3DXSHMultiply4();
3410 test_D3DXSHRotate();
3411 test_D3DXSHRotateZ();