2007-10-14 00:39:54 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2007 David Adam
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2007-10-26 18:01:49 +02:00
|
|
|
#include "d3dx8.h"
|
2007-10-14 00:39:54 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2007-11-12 11:27:13 +01:00
|
|
|
#define admitted_error 0.0001f
|
2007-10-14 00:39:54 +02:00
|
|
|
|
2007-10-23 11:30:55 +02:00
|
|
|
#define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(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);
|
|
|
|
|
2007-10-30 14:46:19 +01:00
|
|
|
#define expect_mat(expectedmat,gotmat)\
|
|
|
|
{ \
|
|
|
|
int i,j,equal=1; \
|
|
|
|
for (i=0; i<4; i++)\
|
|
|
|
{\
|
|
|
|
for (j=0; j<4; j++)\
|
|
|
|
{\
|
2007-11-09 12:38:58 +01:00
|
|
|
if (fabs(U(expectedmat).m[i][j]-U(gotmat).m[i][j])>admitted_error) \
|
2007-10-30 14:46:19 +01:00
|
|
|
{\
|
|
|
|
equal=0;\
|
|
|
|
}\
|
|
|
|
}\
|
|
|
|
}\
|
|
|
|
ok(equal, "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" \
|
|
|
|
"Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
|
2007-11-09 12:38:58 +01:00
|
|
|
U(expectedmat).m[0][0],U(expectedmat).m[0][1],U(expectedmat).m[0][2],U(expectedmat).m[0][3], \
|
|
|
|
U(expectedmat).m[1][0],U(expectedmat).m[1][1],U(expectedmat).m[1][2],U(expectedmat).m[1][3], \
|
|
|
|
U(expectedmat).m[2][0],U(expectedmat).m[2][1],U(expectedmat).m[2][2],U(expectedmat).m[2][3], \
|
|
|
|
U(expectedmat).m[3][0],U(expectedmat).m[3][1],U(expectedmat).m[3][2],U(expectedmat).m[3][3], \
|
|
|
|
U(gotmat).m[0][0],U(gotmat).m[0][1],U(gotmat).m[0][2],U(gotmat).m[0][3], \
|
|
|
|
U(gotmat).m[1][0],U(gotmat).m[1][1],U(gotmat).m[1][2],U(gotmat).m[1][3], \
|
|
|
|
U(gotmat).m[2][0],U(gotmat).m[2][1],U(gotmat).m[2][2],U(gotmat).m[2][3], \
|
|
|
|
U(gotmat).m[3][0],U(gotmat).m[3][1],U(gotmat).m[3][2],U(gotmat).m[3][3]); \
|
2007-10-30 14:46:19 +01:00
|
|
|
}
|
|
|
|
|
2007-11-15 11:27:19 +01:00
|
|
|
#define expect_plane(expectedplane,gotplane) ok((fabs(expectedplane.a-gotplane.a)<admitted_error)&&(fabs(expectedplane.b-gotplane.b)<admitted_error)&&(fabs(expectedplane.c-gotplane.c)<admitted_error)&&(fabs(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);
|
|
|
|
|
2007-10-14 19:06:20 +02:00
|
|
|
#define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
|
|
|
|
|
2007-10-26 21:02:30 +02:00
|
|
|
#define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(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);
|
2007-10-18 18:32:17 +02:00
|
|
|
|
|
|
|
#define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(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);
|
|
|
|
|
2007-10-23 11:30:55 +02:00
|
|
|
static void D3DXColorTest(void)
|
|
|
|
{
|
2007-10-23 12:09:02 +02:00
|
|
|
D3DXCOLOR color, color1, color2, expected, got;
|
2007-10-23 11:30:55 +02:00
|
|
|
LPD3DXCOLOR funcpointer;
|
2007-10-23 11:54:32 +02:00
|
|
|
FLOAT scale;
|
2007-10-23 11:30:55 +02:00
|
|
|
|
|
|
|
color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
|
2007-10-23 12:09:02 +02:00
|
|
|
color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
|
|
|
|
color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
|
2007-10-23 11:54:32 +02:00
|
|
|
scale = 0.3f;
|
|
|
|
|
2007-10-23 13:14:19 +02:00
|
|
|
/*_______________D3DXColorAdd________________*/
|
|
|
|
expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
|
|
|
|
D3DXColorAdd(&got,&color1,&color2);
|
|
|
|
expect_color(expected,got);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorAdd(&got,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorAdd(NULL,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorAdd(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-23 11:54:32 +02:00
|
|
|
/*_______________D3DXColorLerp________________*/
|
|
|
|
expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
|
|
|
|
D3DXColorLerp(&got,&color,&color1,scale);
|
|
|
|
expect_color(expected,got);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
2007-10-23 11:30:55 +02:00
|
|
|
|
2007-10-23 12:09:02 +02:00
|
|
|
/*_______________D3DXColorModulate________________*/
|
|
|
|
expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
|
|
|
|
D3DXColorModulate(&got,&color1,&color2);
|
|
|
|
expect_color(expected,got);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorModulate(&got,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorModulate(NULL,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorModulate(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-23 11:30:55 +02:00
|
|
|
/*_______________D3DXColorNegative________________*/
|
|
|
|
expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
|
|
|
|
D3DXColorNegative(&got,&color);
|
|
|
|
expect_color(got,expected);
|
|
|
|
/* Test the greater than 1 case */
|
|
|
|
color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
|
|
|
|
expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
|
|
|
|
D3DXColorNegative(&got,&color1);
|
|
|
|
expect_color(got,expected);
|
|
|
|
/* Test the negative case */
|
|
|
|
color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
|
|
|
|
expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
|
|
|
|
D3DXColorNegative(&got,&color1);
|
|
|
|
expect_color(got,expected);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorNegative(&got,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorNegative(NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
2007-10-23 13:06:51 +02:00
|
|
|
|
|
|
|
/*_______________D3DXColorScale________________*/
|
|
|
|
expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
|
|
|
|
D3DXColorScale(&got,&color,scale);
|
|
|
|
expect_color(expected,got);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorScale(&got,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorScale(NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
2007-10-23 13:19:27 +02:00
|
|
|
|
|
|
|
/*_______________D3DXColorSubtract_______________*/
|
|
|
|
expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
|
|
|
|
D3DXColorSubtract(&got,&color,&color2);
|
|
|
|
expect_color(expected,got);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXColorSubtract(&got,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
2007-10-23 11:30:55 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 14:12:25 +02:00
|
|
|
static void D3DXMatrixTest(void)
|
|
|
|
{
|
2007-10-30 14:46:19 +01:00
|
|
|
D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
|
2007-11-11 17:16:22 +01:00
|
|
|
LPD3DXMATRIX funcpointer;
|
2007-11-03 09:26:14 +01:00
|
|
|
D3DXQUATERNION q;
|
2007-11-03 09:33:51 +01:00
|
|
|
D3DXVECTOR3 at, axis, eye;
|
2007-10-23 14:12:25 +02:00
|
|
|
BOOL expected, got;
|
2007-11-11 17:16:22 +01:00
|
|
|
FLOAT angle, determinant, expectedfloat, gotfloat;
|
2007-10-30 14:30:58 +01:00
|
|
|
|
|
|
|
U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
|
|
|
|
U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
|
|
|
|
U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
|
|
|
|
U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
|
|
|
|
U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
|
|
|
|
U(mat).m[3][3] = -40.0f;
|
|
|
|
|
2007-11-09 12:38:58 +01:00
|
|
|
U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
|
|
|
|
U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
|
|
|
|
U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
|
|
|
|
U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
|
|
|
|
U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
|
|
|
|
U(mat2).m[3][3] = -1.0f;
|
2007-10-30 14:46:19 +01:00
|
|
|
|
2007-11-03 09:26:14 +01:00
|
|
|
q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
|
|
|
|
|
2007-11-03 09:33:51 +01:00
|
|
|
at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
|
2007-10-30 16:04:32 +01:00
|
|
|
axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
|
2007-11-03 09:33:51 +01:00
|
|
|
eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
|
2007-10-30 16:04:32 +01:00
|
|
|
|
|
|
|
angle = D3DX_PI/3.0f;
|
2007-10-30 15:38:50 +01:00
|
|
|
|
2007-11-12 11:27:13 +01:00
|
|
|
/*____________D3DXMatrixAffineTransformation______*/
|
|
|
|
expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f;
|
|
|
|
expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f;
|
|
|
|
expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f;
|
|
|
|
expectedmat.m[3][0] = -1239.0f; expectedmat.m[3][1] = 667.0f; expectedmat.m[3][2] = 567.0f; expectedmat.m[3][3] = 1.0f;
|
|
|
|
D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
/* Test the NULL case */
|
|
|
|
expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f;
|
|
|
|
expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f;
|
|
|
|
expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f;
|
|
|
|
expectedmat.m[3][0] = 1.0f; expectedmat.m[3][1] = -3.0f; expectedmat.m[3][2] = 7.0f; expectedmat.m[3][3] = 1.0f;
|
|
|
|
D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 14:30:58 +01:00
|
|
|
/*____________D3DXMatrixfDeterminant_____________*/
|
|
|
|
expectedfloat = -147888.0f;
|
|
|
|
gotfloat = D3DXMatrixfDeterminant(&mat);
|
|
|
|
ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
|
2007-10-23 14:12:25 +02:00
|
|
|
|
2007-11-11 17:16:22 +01:00
|
|
|
/*____________D3DXMatrixInverse______________*/
|
|
|
|
expectedmat.m[0][0] = 16067.0f/73944.0f; expectedmat.m[0][1] = -10165.0f/147888.0f; expectedmat.m[0][2] = -2729.0f/147888.0f; expectedmat.m[0][3] = -1631.0f/49296.0f;
|
|
|
|
expectedmat.m[1][0] = -565.0f/36972.0f; expectedmat.m[1][1] = 2723.0f/73944.0f; expectedmat.m[1][2] = -1073.0f/73944.0f; expectedmat.m[1][3] = 289.0f/24648.0f;
|
|
|
|
expectedmat.m[2][0] = -389.0f/2054.0f; expectedmat.m[2][1] = 337.0f/4108.0f; expectedmat.m[2][2] = 181.0f/4108.0f; expectedmat.m[2][3] = 317.0f/4108.0f;
|
|
|
|
expectedmat.m[3][0] = 163.0f/5688.0f; expectedmat.m[3][1] = -101.0f/11376.0f; expectedmat.m[3][2] = -73.0f/11376.0f; expectedmat.m[3][3] = -127.0f/3792.0f;
|
|
|
|
expectedfloat = -147888.0f;
|
|
|
|
D3DXMatrixInverse(&gotmat,&determinant,&mat);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
ok(fabs( determinant - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
|
|
|
|
funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-23 14:12:25 +02:00
|
|
|
/*____________D3DXMatrixIsIdentity______________*/
|
|
|
|
expected = FALSE;
|
2007-10-30 14:46:19 +01:00
|
|
|
got = D3DXMatrixIsIdentity(&mat3);
|
2007-10-23 14:12:25 +02:00
|
|
|
ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
|
2007-10-30 14:46:19 +01:00
|
|
|
D3DXMatrixIdentity(&mat3);
|
2007-10-23 14:12:25 +02:00
|
|
|
expected = TRUE;
|
2007-10-30 14:46:19 +01:00
|
|
|
got = D3DXMatrixIsIdentity(&mat3);
|
2007-10-23 14:12:25 +02:00
|
|
|
ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
|
2007-10-30 14:46:19 +01:00
|
|
|
U(mat3).m[0][0] = 0.000009f;
|
2007-10-30 14:18:51 +01:00
|
|
|
expected = FALSE;
|
2007-10-30 14:46:19 +01:00
|
|
|
got = D3DXMatrixIsIdentity(&mat3);
|
2007-10-30 14:18:51 +01:00
|
|
|
ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
|
2007-10-23 14:12:25 +02:00
|
|
|
/* Test the NULL case */
|
|
|
|
expected = FALSE;
|
|
|
|
got = D3DXMatrixIsIdentity(NULL);
|
|
|
|
ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
|
2007-10-30 14:46:19 +01:00
|
|
|
|
2007-11-03 09:39:30 +01:00
|
|
|
/*____________D3DXMatrixLookatLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:39:30 +01:00
|
|
|
D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:33:51 +01:00
|
|
|
/*____________D3DXMatrixLookatRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:33:51 +01:00
|
|
|
D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 14:46:19 +01:00
|
|
|
/*____________D3DXMatrixMultiply______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 14:46:19 +01:00
|
|
|
D3DXMatrixMultiply(&gotmat,&mat,&mat2);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
2007-10-30 15:16:12 +01:00
|
|
|
|
2007-11-11 17:24:43 +01:00
|
|
|
/*____________D3DXMatrixMultiplyTranspose____*/
|
|
|
|
expectedmat.m[0][0] = 73.0f; expectedmat.m[0][1] = 231.0f; expectedmat.m[0][2] = 239.0f; expectedmat.m[0][3] = -164.0f;
|
|
|
|
expectedmat.m[1][0] = 193.0f; expectedmat.m[1][1] = 551.0f; expectedmat.m[1][2] = 523.0f; expectedmat.m[1][3] = -320.0;
|
|
|
|
expectedmat.m[2][0] = -197.0f; expectedmat.m[2][1] = -489.0f; expectedmat.m[2][2] = -400.0f; expectedmat.m[2][3] = 187.0f;
|
|
|
|
expectedmat.m[3][0] = -77.0f; expectedmat.m[3][1] = -169.0f; expectedmat.m[3][2] = -116.0f; expectedmat.m[3][3] = 31.0f;
|
|
|
|
D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:59:33 +01:00
|
|
|
/*____________D3DXMatrixOrthoLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:59:33 +01:00
|
|
|
D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-05 19:34:34 +01:00
|
|
|
/*____________D3DXMatrixOrthoOffCenterLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-05 19:34:34 +01:00
|
|
|
D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-05 19:30:49 +01:00
|
|
|
/*____________D3DXMatrixOrthoOffCenterRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-05 19:30:49 +01:00
|
|
|
D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:57:33 +01:00
|
|
|
/*____________D3DXMatrixOrthoRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:57:33 +01:00
|
|
|
D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:50:53 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveFovLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:50:53 +01:00
|
|
|
D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:48:43 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveFovRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:48:43 +01:00
|
|
|
D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:46:37 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:46:37 +01:00
|
|
|
D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:54:39 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:54:39 +01:00
|
|
|
D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:52:45 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:52:45 +01:00
|
|
|
D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:43:11 +01:00
|
|
|
/*____________D3DXMatrixPerspectiveRH_______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:43:11 +01:00
|
|
|
D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
|
|
|
/*____________D3DXMatrixRotationAxis_____*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 16:04:32 +01:00
|
|
|
D3DXMatrixRotationAxis(&gotmat,&axis,angle);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:26:14 +01:00
|
|
|
/*____________D3DXMatrixRotationQuaternion______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:26:14 +01:00
|
|
|
D3DXMatrixRotationQuaternion(&gotmat,&q);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:38:50 +01:00
|
|
|
/*____________D3DXMatrixRotationX______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:38:50 +01:00
|
|
|
D3DXMatrixRotationX(&gotmat,angle);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:47:07 +01:00
|
|
|
/*____________D3DXMatrixRotationY______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:47:07 +01:00
|
|
|
D3DXMatrixRotationY(&gotmat,angle);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-11-03 09:30:14 +01:00
|
|
|
/*____________D3DXMatrixRotationYawPitchRoll____*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-11-03 09:30:14 +01:00
|
|
|
D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:53:19 +01:00
|
|
|
/*____________D3DXMatrixRotationZ______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:53:19 +01:00
|
|
|
D3DXMatrixRotationZ(&gotmat,angle);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:24:17 +01:00
|
|
|
/*____________D3DXMatrixScaling______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:24:17 +01:00
|
|
|
D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:31:18 +01:00
|
|
|
/*____________D3DXMatrixTranslation______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:31:18 +01:00
|
|
|
D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
|
|
|
|
2007-10-30 15:16:12 +01:00
|
|
|
/*____________D3DXMatrixTranspose______________*/
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-30 15:16:12 +01:00
|
|
|
D3DXMatrixTranspose(&gotmat,&mat);
|
|
|
|
expect_mat(expectedmat,gotmat);
|
2007-10-23 14:12:25 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 10:58:41 +02:00
|
|
|
static void D3DXPlaneTest(void)
|
|
|
|
{
|
2007-11-15 11:27:19 +01:00
|
|
|
D3DXPLANE expectedplane, gotplane, nulplane, plane;
|
2007-10-23 10:58:41 +02:00
|
|
|
D3DXVECTOR4 vec;
|
|
|
|
FLOAT expected, got;
|
|
|
|
|
|
|
|
plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
|
|
|
|
vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
|
|
|
|
|
|
|
|
/*_______________D3DXPlaneDot________________*/
|
|
|
|
expected = 42.0f;
|
|
|
|
got = D3DXPlaneDot(&plane,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDot(NULL,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDot(NULL,NULL),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
2007-10-23 11:01:43 +02:00
|
|
|
|
|
|
|
/*_______________D3DXPlaneDotCoord________________*/
|
|
|
|
expected = -28.0f;
|
|
|
|
got = D3DXPlaneDotCoord(&plane,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDotCoord(NULL,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDotCoord(NULL,NULL),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
2007-10-23 11:06:33 +02:00
|
|
|
|
|
|
|
/*_______________D3DXPlaneDotNormal______________*/
|
|
|
|
expected = -35.0f;
|
|
|
|
got = D3DXPlaneDotNormal(&plane,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDotNormal(NULL,&vec),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
|
|
|
expected = 0.0f;
|
|
|
|
got = D3DXPlaneDotNormal(NULL,NULL),
|
|
|
|
ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
|
2007-11-15 11:27:19 +01:00
|
|
|
|
|
|
|
/*_______________D3DXPlaneDotNormalize______________*/
|
|
|
|
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);
|
|
|
|
D3DXPlaneNormalize(&gotplane, &plane);
|
|
|
|
expect_plane(expectedplane, gotplane);
|
|
|
|
nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
|
|
|
|
expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
|
|
|
|
D3DXPlaneNormalize(&gotplane, &nulplane);
|
|
|
|
expect_plane(expectedplane, gotplane);
|
|
|
|
nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
|
|
|
|
expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
|
|
|
|
D3DXPlaneNormalize(&gotplane, &nulplane);
|
|
|
|
expect_plane(expectedplane, gotplane);
|
2007-10-23 10:58:41 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 14:03:03 +02:00
|
|
|
static void D3X8QuaternionTest(void)
|
|
|
|
{
|
2007-10-26 18:01:49 +02:00
|
|
|
D3DXQUATERNION expectedquat, gotquat, nul, q, r, s;
|
2007-10-18 20:28:36 +02:00
|
|
|
LPD3DXQUATERNION funcpointer;
|
2007-10-18 14:03:03 +02:00
|
|
|
FLOAT expected, got;
|
2007-10-18 23:15:18 +02:00
|
|
|
BOOL expectedbool, gotbool;
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
|
2007-10-18 14:03:03 +02:00
|
|
|
q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
|
2007-10-18 18:06:37 +02:00
|
|
|
r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
|
|
|
|
|
2007-10-18 20:28:36 +02:00
|
|
|
/*_______________D3DXQuaternionConjugate________________*/
|
|
|
|
expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
|
|
|
|
D3DXQuaternionConjugate(&gotquat,&q);
|
|
|
|
expect_vec4(expectedquat,gotquat);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXQuaternionConjugate(NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 18:06:37 +02:00
|
|
|
/*_______________D3DXQuaternionDot______________________*/
|
|
|
|
expected = 55.0f;
|
|
|
|
got = D3DXQuaternionDot(&q,&r);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXQuaternionDot(NULL,&r);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXQuaternionDot(NULL,NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-18 21:01:24 +02:00
|
|
|
/*_______________D3DXQuaternionIdentity________________*/
|
|
|
|
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
|
|
|
|
D3DXQuaternionIdentity(&gotquat);
|
|
|
|
expect_vec4(expectedquat,gotquat);
|
|
|
|
/* Test the NULL case */
|
|
|
|
funcpointer = D3DXQuaternionIdentity(NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 23:15:18 +02:00
|
|
|
/*_______________D3DXQuaternionIsIdentity________________*/
|
|
|
|
s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
|
|
|
|
expectedbool = TRUE;
|
|
|
|
gotbool = D3DXQuaternionIsIdentity(&s);
|
|
|
|
ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
|
|
|
|
s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
|
|
|
|
expectedbool = FALSE;
|
|
|
|
gotbool = D3DXQuaternionIsIdentity(&q);
|
|
|
|
ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
|
|
|
|
/* Test the NULL case */
|
|
|
|
gotbool = D3DXQuaternionIsIdentity(NULL);
|
|
|
|
ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
|
|
|
|
|
2007-10-18 14:03:03 +02:00
|
|
|
/*_______________D3DXQuaternionLength__________________________*/
|
|
|
|
expected = 11.0f;
|
|
|
|
got = D3DXQuaternionLength(&q);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXQuaternionLength(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 17:47:50 +02:00
|
|
|
|
|
|
|
/*_______________D3DXQuaternionLengthSq________________________*/
|
|
|
|
expected = 121.0f;
|
|
|
|
got = D3DXQuaternionLengthSq(&q);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXQuaternionLengthSq(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-26 18:01:49 +02:00
|
|
|
|
|
|
|
/*_______________D3DXQuaternionNormalize________________________*/
|
|
|
|
expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
|
|
|
|
D3DXQuaternionNormalize(&gotquat,&q);
|
|
|
|
expect_vec4(expectedquat,gotquat);
|
|
|
|
/* Test the nul quaternion */
|
|
|
|
expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
|
|
|
|
D3DXQuaternionNormalize(&gotquat,&nul);
|
|
|
|
expect_vec4(expectedquat,gotquat);
|
2007-10-18 14:03:03 +02:00
|
|
|
}
|
|
|
|
|
2007-10-14 00:39:54 +02:00
|
|
|
static void D3X8Vector2Test(void)
|
|
|
|
{
|
2007-10-27 11:54:25 +02:00
|
|
|
D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
|
2007-10-14 19:06:20 +02:00
|
|
|
LPD3DXVECTOR2 funcpointer;
|
2007-10-27 11:00:07 +02:00
|
|
|
D3DXVECTOR4 expectedtrans, gottrans;
|
|
|
|
D3DXMATRIX mat;
|
2007-10-26 18:58:28 +02:00
|
|
|
FLOAT coeff1, coeff2, expected, got, scale;
|
2007-10-14 00:39:54 +02:00
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
nul.x = 0.0f; nul.y = 0.0f;
|
2007-10-26 18:58:28 +02:00
|
|
|
u.x = 3.0f; u.y = 4.0f;
|
|
|
|
v.x = -7.0f; v.y = 9.0f;
|
|
|
|
w.x = 4.0f; w.y = -3.0f;
|
2007-10-26 21:02:30 +02:00
|
|
|
x.x = 2.0f; x.y = -11.0f;
|
2007-10-26 18:58:28 +02:00
|
|
|
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-27 11:00:07 +02:00
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
coeff1 = 2.0f; coeff2 = 5.0f;
|
2007-10-14 20:20:01 +02:00
|
|
|
scale = -6.5f;
|
2007-10-14 18:24:33 +02:00
|
|
|
|
2007-10-14 19:06:20 +02:00
|
|
|
/*_______________D3DXVec2Add__________________________*/
|
2007-10-26 18:58:28 +02:00
|
|
|
expectedvec.x = -4.0f; expectedvec.y = 13.0f;
|
|
|
|
D3DXVec2Add(&gotvec,&u,&v);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
2007-10-14 19:06:20 +02:00
|
|
|
funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Add(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
/*_______________D3DXVec2BaryCentric___________________*/
|
|
|
|
expectedvec.x = -12.0f; expectedvec.y = -21.0f;
|
|
|
|
D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
|
2007-10-26 21:43:46 +02:00
|
|
|
/*_______________D3DXVec2CatmullRom____________________*/
|
|
|
|
expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
|
|
|
|
D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
|
2007-10-14 18:33:25 +02:00
|
|
|
/*_______________D3DXVec2CCW__________________________*/
|
|
|
|
expected = 55.0f;
|
|
|
|
got = D3DXVec2CCW(&u,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec2CCW(NULL,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec2CCW(NULL,NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
|
2007-10-14 18:24:33 +02:00
|
|
|
/*_______________D3DXVec2Dot__________________________*/
|
2007-10-26 21:02:30 +02:00
|
|
|
expected = 15.0f;
|
|
|
|
got = D3DXVec2Dot(&u,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
2007-10-14 18:24:33 +02:00
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec2Dot(NULL,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec2Dot(NULL,NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-14 00:39:54 +02:00
|
|
|
|
2007-10-26 21:02:30 +02:00
|
|
|
/*_______________D3DXVec2Hermite__________________________*/
|
|
|
|
expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
|
|
|
|
D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
|
2007-10-14 00:39:54 +02:00
|
|
|
/*_______________D3DXVec2Length__________________________*/
|
|
|
|
expected = 5.0f;
|
|
|
|
got = D3DXVec2Length(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
2007-10-14 18:24:33 +02:00
|
|
|
got = D3DXVec2Length(NULL);
|
2007-10-14 00:39:54 +02:00
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-14 01:15:30 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec2LengthSq________________________*/
|
|
|
|
expected = 25.0f;
|
|
|
|
got = D3DXVec2LengthSq(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
2007-10-14 18:24:33 +02:00
|
|
|
got = D3DXVec2LengthSq(NULL);
|
2007-10-14 01:15:30 +02:00
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
|
2007-10-14 20:31:58 +02:00
|
|
|
/*_______________D3DXVec2Lerp__________________________*/
|
|
|
|
expectedvec.x = 68.0f; expectedvec.y = -28.5f;
|
|
|
|
D3DXVec2Lerp(&gotvec,&u,&v,scale);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-14 20:04:59 +02:00
|
|
|
/*_______________D3DXVec2Maximize__________________________*/
|
|
|
|
expectedvec.x = 3.0f; expectedvec.y = 9.0f;
|
|
|
|
D3DXVec2Maximize(&gotvec,&u,&v);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-14 19:28:03 +02:00
|
|
|
/*_______________D3DXVec2Minimize__________________________*/
|
2007-10-26 18:01:49 +02:00
|
|
|
expectedvec.x = -7.0f; expectedvec.y = 4.0f;
|
|
|
|
D3DXVec2Minimize(&gotvec,&u,&v);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
2007-10-14 19:28:03 +02:00
|
|
|
funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
/*_______________D3DXVec2Normalize_________________________*/
|
|
|
|
expectedvec.x = 0.6f; expectedvec.y = 0.8f;
|
|
|
|
D3DXVec2Normalize(&gotvec,&u);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Test the nul vector */
|
|
|
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f;
|
|
|
|
D3DXVec2Normalize(&gotvec,&nul);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
|
2007-10-14 20:20:01 +02:00
|
|
|
/*_______________D3DXVec2Scale____________________________*/
|
|
|
|
expectedvec.x = -19.5f; expectedvec.y = -26.0f;
|
|
|
|
D3DXVec2Scale(&gotvec,&u,scale);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Scale(NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-14 19:22:17 +02:00
|
|
|
/*_______________D3DXVec2Subtract__________________________*/
|
|
|
|
expectedvec.x = 10.0f; expectedvec.y = -5.0f;
|
|
|
|
D3DXVec2Subtract(&gotvec,&u,&v);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-27 11:00:07 +02:00
|
|
|
/*_______________D3DXVec2Transform_______________________*/
|
|
|
|
expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
|
|
|
|
D3DXVec2Transform(&gottrans,&u,&mat);
|
|
|
|
expect_vec4(expectedtrans,gottrans);
|
2007-10-27 11:54:25 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec2TransformCoord_______________________*/
|
|
|
|
expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
|
|
|
|
D3DXVec2TransformCoord(&gotvec,&u,&mat);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
|
|
|
/* Test the nul projected vector */
|
|
|
|
nulproj.x = -2.0f; nulproj.y = -1.0f;
|
|
|
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f;
|
|
|
|
D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
2007-10-27 12:21:47 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec2TransformNormal______________________*/
|
|
|
|
expectedvec.x = 23.0f; expectedvec.y = 30.0f;
|
|
|
|
D3DXVec2TransformNormal(&gotvec,&u,&mat);
|
|
|
|
expect_vec(expectedvec,gotvec);
|
2007-10-14 00:39:54 +02:00
|
|
|
}
|
2007-10-14 01:15:30 +02:00
|
|
|
|
2007-10-18 14:03:03 +02:00
|
|
|
static void D3X8Vector3Test(void)
|
|
|
|
{
|
2007-11-11 17:33:45 +01:00
|
|
|
D3DVIEWPORT8 viewport;
|
2007-10-27 11:54:25 +02:00
|
|
|
D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
|
2007-10-18 18:32:17 +02:00
|
|
|
LPD3DXVECTOR3 funcpointer;
|
2007-10-27 11:00:07 +02:00
|
|
|
D3DXVECTOR4 expectedtrans, gottrans;
|
2007-11-11 17:33:45 +01:00
|
|
|
D3DXMATRIX mat, projection, view, world;
|
2007-10-26 18:58:28 +02:00
|
|
|
FLOAT coeff1, coeff2, expected, got, scale;
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
|
2007-10-18 14:03:03 +02:00
|
|
|
u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
|
2007-10-18 18:06:37 +02:00
|
|
|
v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
|
2007-10-26 18:58:28 +02:00
|
|
|
w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
|
2007-10-26 21:02:30 +02:00
|
|
|
x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
|
2007-10-26 18:58:28 +02:00
|
|
|
|
2007-11-11 17:33:45 +01:00
|
|
|
viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
|
|
|
|
viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
|
|
|
|
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-27 11:00:07 +02:00
|
|
|
|
2007-11-11 17:33:45 +01:00
|
|
|
view.m[0][1] = 5.0f; view.m[0][2] = 7.0f; view.m[0][3] = 8.0f;
|
|
|
|
view.m[1][0] = 11.0f; view.m[1][2] = 16.0f; view.m[1][3] = 33.0f;
|
|
|
|
view.m[2][0] = 19.0f; view.m[2][1] = -21.0f; view.m[2][3] = 43.0f;
|
|
|
|
view.m[3][0] = 2.0f; view.m[3][1] = 3.0f; view.m[3][2] = -4.0f;
|
|
|
|
view.m[0][0] = 10.0f; view.m[1][1] = 20.0f; view.m[2][2] = 30.0f;
|
|
|
|
view.m[3][3] = -40.0f;
|
|
|
|
|
|
|
|
world.m[0][0] = 21.0f; world.m[0][1] = 2.0f; world.m[0][2] = 3.0f; world.m[0][3] = 4.0;
|
|
|
|
world.m[1][0] = 5.0f; world.m[1][1] = 23.0f; world.m[1][2] = 7.0f; world.m[1][3] = 8.0f;
|
|
|
|
world.m[2][0] = -8.0f; world.m[2][1] = -7.0f; world.m[2][2] = 25.0f; world.m[2][3] = -5.0f;
|
|
|
|
world.m[3][0] = -4.0f; world.m[3][1] = -3.0f; world.m[3][2] = -2.0f; world.m[3][3] = 27.0f;
|
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
coeff1 = 2.0f; coeff2 = 5.0f;
|
2007-10-18 19:01:57 +02:00
|
|
|
scale = -6.5f;
|
2007-10-18 18:06:37 +02:00
|
|
|
|
2007-10-18 18:32:17 +02:00
|
|
|
/*_______________D3DXVec3Add__________________________*/
|
|
|
|
expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
|
|
|
|
D3DXVec3Add(&gotvec,&u,&v);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Add(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
/*_______________D3DXVec3BaryCentric___________________*/
|
|
|
|
expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
|
|
|
|
D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
|
2007-10-26 21:43:46 +02:00
|
|
|
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
|
|
|
|
/*_______________D3DXVec3CatmullRom____________________*/
|
|
|
|
expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
|
|
|
|
D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
|
2007-10-26 18:58:28 +02:00
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 20:12:29 +02:00
|
|
|
/*_______________D3DXVec3Cross________________________*/
|
2007-10-26 21:46:32 +02:00
|
|
|
expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
|
2007-10-18 20:12:29 +02:00
|
|
|
D3DXVec3Cross(&gotvec,&u,&v);
|
2007-10-26 21:46:32 +02:00
|
|
|
expect_vec3(expectedvec,gotvec);
|
2007-10-18 20:12:29 +02:00
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 18:06:37 +02:00
|
|
|
/*_______________D3DXVec3Dot__________________________*/
|
|
|
|
expected = -8.0f;
|
|
|
|
got = D3DXVec3Dot(&u,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec3Dot(NULL,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec3Dot(NULL,NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-26 21:02:30 +02:00
|
|
|
/*_______________D3DXVec3Hermite__________________________*/
|
|
|
|
expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
|
|
|
|
D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 14:03:03 +02:00
|
|
|
/*_______________D3DXVec3Length__________________________*/
|
|
|
|
expected = 11.0f;
|
|
|
|
got = D3DXVec3Length(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec3Length(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 17:47:50 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec3LengthSq________________________*/
|
|
|
|
expected = 121.0f;
|
|
|
|
got = D3DXVec3LengthSq(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec3LengthSq(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 18:38:32 +02:00
|
|
|
|
2007-10-18 19:01:57 +02:00
|
|
|
/*_______________D3DXVec3Lerp__________________________*/
|
|
|
|
expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
|
|
|
|
D3DXVec3Lerp(&gotvec,&u,&v,scale);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 19:29:21 +02:00
|
|
|
/*_______________D3DXVec3Maximize__________________________*/
|
|
|
|
expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
|
|
|
|
D3DXVec3Maximize(&gotvec,&u,&v);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 19:35:52 +02:00
|
|
|
/*_______________D3DXVec3Minimize__________________________*/
|
|
|
|
expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
|
|
|
|
D3DXVec3Minimize(&gotvec,&u,&v);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
/*_______________D3DXVec3Normalize_________________________*/
|
|
|
|
expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
|
|
|
|
D3DXVec3Normalize(&gotvec,&u);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Test the nul vector */
|
|
|
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
|
|
|
|
D3DXVec3Normalize(&gotvec,&nul);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
|
2007-11-11 17:33:45 +01:00
|
|
|
/*_______________D3DXVec3Project_________________________*/
|
|
|
|
expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
|
|
|
|
D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
|
|
|
|
D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 19:53:30 +02:00
|
|
|
/*_______________D3DXVec3Scale____________________________*/
|
|
|
|
expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
|
|
|
|
D3DXVec3Scale(&gotvec,&u,scale);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Scale(NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 18:38:32 +02:00
|
|
|
/*_______________D3DXVec3Subtract_______________________*/
|
|
|
|
expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
|
|
|
|
D3DXVec3Subtract(&gotvec,&u,&v);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-27 11:00:07 +02:00
|
|
|
/*_______________D3DXVec3Transform_______________________*/
|
|
|
|
expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
|
|
|
|
D3DXVec3Transform(&gottrans,&u,&mat);
|
|
|
|
expect_vec4(expectedtrans,gottrans);
|
2007-10-27 11:54:25 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec3TransformCoord_______________________*/
|
|
|
|
expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
|
|
|
|
D3DXVec3TransformCoord(&gotvec,&u,&mat);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
|
|
|
/* Test the nul projected vector */
|
|
|
|
nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
|
|
|
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
|
|
|
|
D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
2007-10-27 12:21:47 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec3TransformNormal______________________*/
|
|
|
|
expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
|
|
|
|
D3DXVec3TransformNormal(&gotvec,&u,&mat);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
2007-11-11 17:38:20 +01:00
|
|
|
|
|
|
|
/*_______________D3DXVec3Unproject_________________________*/
|
|
|
|
expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
|
|
|
|
D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
|
|
|
|
D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
|
|
|
|
expect_vec3(expectedvec,gotvec);
|
2007-10-18 14:03:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void D3X8Vector4Test(void)
|
|
|
|
{
|
2007-10-26 21:02:30 +02:00
|
|
|
D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
|
2007-10-18 18:32:17 +02:00
|
|
|
LPD3DXVECTOR4 funcpointer;
|
2007-10-27 11:00:07 +02:00
|
|
|
D3DXVECTOR4 expectedtrans, gottrans;
|
|
|
|
D3DXMATRIX mat;
|
2007-10-26 18:58:28 +02:00
|
|
|
FLOAT coeff1, coeff2, expected, got, scale;
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
|
2007-10-18 14:03:03 +02:00
|
|
|
u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
|
2007-10-18 18:06:37 +02:00
|
|
|
v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
|
2007-10-26 18:58:28 +02:00
|
|
|
w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
|
2007-10-26 21:02:30 +02:00
|
|
|
x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
|
2007-10-27 11:00:07 +02:00
|
|
|
|
2007-11-09 12:38:58 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
2007-10-27 11:00:07 +02:00
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
coeff1 = 2.0f; coeff2 = 5.0;
|
2007-10-26 18:01:49 +02:00
|
|
|
scale = -6.5f;
|
2007-10-18 18:06:37 +02:00
|
|
|
|
2007-10-18 19:01:57 +02:00
|
|
|
/*_______________D3DXVec4Add__________________________*/
|
2007-10-18 18:38:32 +02:00
|
|
|
expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
|
2007-10-18 18:32:17 +02:00
|
|
|
D3DXVec4Add(&gotvec,&u,&v);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Add(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:58:28 +02:00
|
|
|
/*_______________D3DXVec4BaryCentric____________________*/
|
|
|
|
expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
|
|
|
|
D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
|
2007-10-26 21:43:46 +02:00
|
|
|
/*_______________D3DXVec4CatmullRom____________________*/
|
|
|
|
expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
|
|
|
|
D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
|
2007-10-27 14:23:25 +02:00
|
|
|
/*_______________D3DXVec4Cross_________________________*/
|
|
|
|
expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
|
|
|
|
D3DXVec4Cross(&gotvec,&u,&v,&w);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 18:06:37 +02:00
|
|
|
/*_______________D3DXVec4Dot__________________________*/
|
|
|
|
expected = 55.0f;
|
|
|
|
got = D3DXVec4Dot(&u,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec4Dot(NULL,&v);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec4Dot(NULL,NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 14:03:03 +02:00
|
|
|
|
2007-10-26 21:02:30 +02:00
|
|
|
/*_______________D3DXVec4Hermite_________________________*/
|
|
|
|
expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
|
|
|
|
D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 14:03:03 +02:00
|
|
|
/*_______________D3DXVec4Length__________________________*/
|
|
|
|
expected = 11.0f;
|
|
|
|
got = D3DXVec4Length(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec4Length(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 17:47:50 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec4LengthSq________________________*/
|
|
|
|
expected = 121.0f;
|
|
|
|
got = D3DXVec4LengthSq(&u);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
expected=0.0f;
|
|
|
|
got = D3DXVec4LengthSq(NULL);
|
|
|
|
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
|
2007-10-18 18:38:32 +02:00
|
|
|
|
2007-10-18 19:01:57 +02:00
|
|
|
/*_______________D3DXVec4Lerp__________________________*/
|
|
|
|
expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
|
|
|
|
D3DXVec4Lerp(&gotvec,&u,&v,scale);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 19:29:21 +02:00
|
|
|
/*_______________D3DXVec4Maximize__________________________*/
|
|
|
|
expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
|
|
|
|
D3DXVec4Maximize(&gotvec,&u,&v);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 19:35:52 +02:00
|
|
|
/*_______________D3DXVec4Minimize__________________________*/
|
|
|
|
expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
|
|
|
|
D3DXVec4Minimize(&gotvec,&u,&v);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-26 18:01:49 +02:00
|
|
|
/*_______________D3DXVec4Normalize_________________________*/
|
|
|
|
expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
|
|
|
|
D3DXVec4Normalize(&gotvec,&u);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Test the nul vector */
|
|
|
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
|
|
|
|
D3DXVec4Normalize(&gotvec,&nul);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
|
2007-10-18 19:53:30 +02:00
|
|
|
/*_______________D3DXVec4Scale____________________________*/
|
|
|
|
expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
|
|
|
|
D3DXVec4Scale(&gotvec,&u,scale);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Scale(NULL,NULL,scale);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
|
2007-10-18 19:01:57 +02:00
|
|
|
/*_______________D3DXVec4Subtract__________________________*/
|
2007-10-18 18:38:32 +02:00
|
|
|
expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
|
|
|
|
D3DXVec4Subtract(&gotvec,&u,&v);
|
|
|
|
expect_vec4(expectedvec,gotvec);
|
|
|
|
/* Tests the case NULL */
|
|
|
|
funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
|
|
|
funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
|
|
|
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
2007-10-27 11:00:07 +02:00
|
|
|
|
|
|
|
/*_______________D3DXVec4Transform_______________________*/
|
|
|
|
expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
|
|
|
|
D3DXVec4Transform(&gottrans,&u,&mat);
|
|
|
|
expect_vec4(expectedtrans,gottrans);
|
2007-10-18 14:03:03 +02:00
|
|
|
}
|
|
|
|
|
2007-10-14 00:39:54 +02:00
|
|
|
START_TEST(math)
|
|
|
|
{
|
2007-10-23 11:30:55 +02:00
|
|
|
D3DXColorTest();
|
2007-10-23 14:12:25 +02:00
|
|
|
D3DXMatrixTest();
|
2007-10-23 10:58:41 +02:00
|
|
|
D3DXPlaneTest();
|
2007-10-18 14:03:03 +02:00
|
|
|
D3X8QuaternionTest();
|
2007-10-14 00:39:54 +02:00
|
|
|
D3X8Vector2Test();
|
2007-10-18 14:03:03 +02:00
|
|
|
D3X8Vector3Test();
|
|
|
|
D3X8Vector4Test();
|
2007-10-14 00:39:54 +02:00
|
|
|
}
|