2007-04-19 21:03:53 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Vijay Kiran Kamuju
|
|
|
|
* 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>
|
|
|
|
#include "d3drmdef.h"
|
|
|
|
#include <math.h>
|
|
|
|
|
2007-04-30 02:07:42 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2007-05-31 13:59:16 +02:00
|
|
|
#define PI (4.0f*atanf(1.0f))
|
|
|
|
#define admit_error 0.000001f
|
2007-04-19 21:03:53 +02:00
|
|
|
|
2007-04-19 21:12:40 +02:00
|
|
|
#define expect_mat( expectedmat, gotmat)\
|
|
|
|
{ \
|
|
|
|
int i,j,equal=1; \
|
|
|
|
for (i=0; i<4; i++)\
|
|
|
|
{\
|
|
|
|
for (j=0; j<4; j++)\
|
|
|
|
{\
|
|
|
|
if (fabs(expectedmat[i][j]-gotmat[i][j])>admit_error)\
|
|
|
|
{\
|
|
|
|
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", \
|
|
|
|
expectedmat[0][0],expectedmat[0][1],expectedmat[0][2],expectedmat[0][3], \
|
|
|
|
expectedmat[1][0],expectedmat[1][1],expectedmat[1][2],expectedmat[1][3], \
|
|
|
|
expectedmat[2][0],expectedmat[2][1],expectedmat[2][2],expectedmat[2][3], \
|
|
|
|
expectedmat[3][0],expectedmat[3][1],expectedmat[3][2],expectedmat[3][3], \
|
|
|
|
gotmat[0][0],gotmat[0][1],gotmat[0][2],gotmat[0][3], \
|
|
|
|
gotmat[1][0],gotmat[1][1],gotmat[1][2],gotmat[1][3], \
|
|
|
|
gotmat[2][0],gotmat[2][1],gotmat[2][2],gotmat[2][3], \
|
|
|
|
gotmat[3][0],gotmat[3][1],gotmat[3][2],gotmat[3][3] ); \
|
|
|
|
}
|
|
|
|
|
2007-04-19 21:13:51 +02:00
|
|
|
#define expect_quat(expectedquat,gotquat) \
|
2007-04-30 02:07:42 +02:00
|
|
|
ok( (fabs(U1(expectedquat.v).x-U1(gotquat.v).x)<admit_error) && \
|
|
|
|
(fabs(U2(expectedquat.v).y-U2(gotquat.v).y)<admit_error) && \
|
|
|
|
(fabs(U3(expectedquat.v).z-U3(gotquat.v).z)<admit_error) && \
|
2007-04-19 21:13:51 +02:00
|
|
|
(fabs(expectedquat.s-gotquat.s)<admit_error), \
|
|
|
|
"Expected Quaternion %f %f %f %f , Got Quaternion %f %f %f %f\n", \
|
2007-04-30 02:07:42 +02:00
|
|
|
expectedquat.s,U1(expectedquat.v).x,U2(expectedquat.v).y,U3(expectedquat.v).z, \
|
|
|
|
gotquat.s,U1(gotquat.v).x,U2(gotquat.v).y,U3(gotquat.v).z);
|
2007-04-19 21:13:51 +02:00
|
|
|
|
2007-04-19 21:03:53 +02:00
|
|
|
#define expect_vec(expectedvec,gotvec) \
|
2007-04-30 02:07:42 +02:00
|
|
|
ok( ((fabs(U1(expectedvec).x-U1(gotvec).x)<admit_error)&&(fabs(U2(expectedvec).y-U2(gotvec).y)<admit_error)&&(fabs(U3(expectedvec).z-U3(gotvec).z)<admit_error)), \
|
2007-04-19 21:03:53 +02:00
|
|
|
"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", \
|
2007-04-30 02:07:42 +02:00
|
|
|
U1(expectedvec).x,U2(expectedvec).y,U3(expectedvec).z, U1(gotvec).x, U2(gotvec).y, U3(gotvec).z);
|
2007-04-19 21:03:53 +02:00
|
|
|
|
2007-05-11 13:22:57 +02:00
|
|
|
static HMODULE d3drm_handle = 0;
|
|
|
|
|
|
|
|
static void (WINAPI * pD3DRMMatrixFromQuaternion)(D3DRMMATRIX4D, LPD3DRMQUATERNION);
|
|
|
|
static LPD3DVECTOR (WINAPI* pD3DRMVectorAdd)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR);
|
|
|
|
static LPD3DVECTOR (WINAPI* pD3DRMVectorCrossProduct)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR);
|
|
|
|
static D3DVALUE (WINAPI* pD3DRMVectorDotProduct)(LPD3DVECTOR, LPD3DVECTOR);
|
|
|
|
static D3DVALUE (WINAPI* pD3DRMVectorModulus)(LPD3DVECTOR);
|
|
|
|
static LPD3DVECTOR (WINAPI * pD3DRMVectorNormalize)(LPD3DVECTOR);
|
|
|
|
static LPD3DVECTOR (WINAPI * pD3DRMVectorReflect)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR);
|
|
|
|
static LPD3DVECTOR (WINAPI * pD3DRMVectorRotate)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR, D3DVALUE);
|
|
|
|
static LPD3DVECTOR (WINAPI * pD3DRMVectorScale)(LPD3DVECTOR, LPD3DVECTOR, D3DVALUE);
|
|
|
|
static LPD3DVECTOR (WINAPI * pD3DRMVectorSubtract)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR);
|
|
|
|
static LPD3DRMQUATERNION (WINAPI * pD3DRMQuaternionFromRotation)(LPD3DRMQUATERNION, LPD3DVECTOR, D3DVALUE);
|
|
|
|
static LPD3DRMQUATERNION (WINAPI * pD3DRMQuaternionSlerp)(LPD3DRMQUATERNION, LPD3DRMQUATERNION, LPD3DRMQUATERNION, D3DVALUE);
|
2007-05-20 16:27:30 +02:00
|
|
|
static D3DCOLOR (WINAPI * pD3DRMCreateColorRGB)(D3DVALUE, D3DVALUE, D3DVALUE);
|
2007-05-20 16:26:44 +02:00
|
|
|
static D3DCOLOR (WINAPI * pD3DRMCreateColorRGBA)(D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE);
|
2007-05-20 12:27:13 +02:00
|
|
|
static D3DVALUE (WINAPI * pD3DRMColorGetAlpha)(D3DCOLOR);
|
2007-05-20 12:26:21 +02:00
|
|
|
static D3DVALUE (WINAPI * pD3DRMColorGetBlue)(D3DCOLOR);
|
2007-05-20 12:25:17 +02:00
|
|
|
static D3DVALUE (WINAPI * pD3DRMColorGetGreen)(D3DCOLOR);
|
2007-05-20 12:24:30 +02:00
|
|
|
static D3DVALUE (WINAPI * pD3DRMColorGetRed)(D3DCOLOR);
|
2007-05-11 13:22:57 +02:00
|
|
|
|
|
|
|
#define D3DRM_GET_PROC(func) \
|
|
|
|
p ## func = (void*)GetProcAddress(d3drm_handle, #func); \
|
|
|
|
if(!p ## func) { \
|
|
|
|
trace("GetProcAddress(%s) failed\n", #func); \
|
|
|
|
FreeLibrary(d3drm_handle); \
|
|
|
|
return FALSE; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL InitFunctionPtrs(void)
|
|
|
|
{
|
|
|
|
d3drm_handle = LoadLibraryA("d3drm.dll");
|
|
|
|
|
|
|
|
if(!d3drm_handle)
|
|
|
|
{
|
|
|
|
skip("Could not load d3drm.dll\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
D3DRM_GET_PROC(D3DRMMatrixFromQuaternion)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorAdd)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorCrossProduct)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorDotProduct)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorModulus)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorNormalize)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorReflect)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorRotate)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorScale)
|
|
|
|
D3DRM_GET_PROC(D3DRMVectorSubtract)
|
|
|
|
D3DRM_GET_PROC(D3DRMQuaternionFromRotation)
|
|
|
|
D3DRM_GET_PROC(D3DRMQuaternionSlerp)
|
2007-05-20 16:27:30 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMCreateColorRGB)
|
2007-05-20 16:26:44 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMCreateColorRGBA)
|
2007-05-20 12:27:13 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMColorGetAlpha)
|
2007-05-20 12:26:21 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMColorGetBlue)
|
2007-05-20 12:25:17 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMColorGetGreen)
|
2007-05-20 12:24:30 +02:00
|
|
|
D3DRM_GET_PROC(D3DRMColorGetRed)
|
2007-05-11 13:22:57 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 21:12:40 +02:00
|
|
|
static void VectorTest(void)
|
2007-04-19 21:03:53 +02:00
|
|
|
{
|
2007-04-19 21:12:00 +02:00
|
|
|
D3DVALUE mod,par,theta;
|
2009-02-14 14:35:42 +01:00
|
|
|
D3DVECTOR e,r,u,v,w,axis,casnul,norm,ray,self;
|
2007-04-19 21:03:53 +02:00
|
|
|
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(u).x=2.0f; U2(u).y=2.0f; U3(u).z=1.0f;
|
|
|
|
U1(v).x=4.0f; U2(v).y=4.0f; U3(v).z=0.0f;
|
2007-04-19 21:03:53 +02:00
|
|
|
|
2009-02-14 14:35:42 +01:00
|
|
|
|
2007-04-19 21:03:53 +02:00
|
|
|
/*______________________VectorAdd_________________________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorAdd(&r,&u,&v);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=6.0f; U2(e).y=6.0f; U3(e).z=1.0f;
|
2007-04-19 21:03:53 +02:00
|
|
|
expect_vec(e,r);
|
2007-04-19 21:05:56 +02:00
|
|
|
|
2009-08-31 11:52:50 +02:00
|
|
|
U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f;
|
2009-02-14 14:35:42 +01:00
|
|
|
pD3DRMVectorAdd(&self,&self,&u);
|
|
|
|
U1(e).x=11.0f; U2(e).y=20.0f; U3(e).z=28.0f;
|
|
|
|
expect_vec(e,self);
|
|
|
|
|
2007-04-19 21:05:56 +02:00
|
|
|
/*_______________________VectorSubtract__________________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorSubtract(&r,&u,&v);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=-2.0f; U2(e).y=-2.0f; U3(e).z=1.0f;
|
2007-04-19 21:05:56 +02:00
|
|
|
expect_vec(e,r);
|
2007-04-19 21:06:54 +02:00
|
|
|
|
2009-08-31 11:52:50 +02:00
|
|
|
U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f;
|
2009-02-14 14:35:42 +01:00
|
|
|
pD3DRMVectorSubtract(&self,&self,&u);
|
|
|
|
U1(e).x=7.0f; U2(e).y=16.0f; U3(e).z=26.0f;
|
|
|
|
expect_vec(e,self);
|
|
|
|
|
2007-04-19 21:06:54 +02:00
|
|
|
/*_______________________VectorCrossProduct_______________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorCrossProduct(&r,&u,&v);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=-4.0f; U2(e).y=4.0f; U3(e).z=0.0f;
|
2007-04-19 21:06:54 +02:00
|
|
|
expect_vec(e,r);
|
2007-04-19 21:07:54 +02:00
|
|
|
|
2009-08-31 11:52:50 +02:00
|
|
|
U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f;
|
2009-02-14 14:35:42 +01:00
|
|
|
pD3DRMVectorCrossProduct(&self,&self,&u);
|
|
|
|
U1(e).x=-36.0f; U2(e).y=45.0f; U3(e).z=-18.0f;
|
|
|
|
expect_vec(e,self);
|
|
|
|
|
2007-04-19 21:07:54 +02:00
|
|
|
/*_______________________VectorDotProduct__________________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
mod=pD3DRMVectorDotProduct(&u,&v);
|
2007-05-31 13:59:16 +02:00
|
|
|
ok((mod == 16.0f), "Expected 16.0f, Got %f\n", mod);
|
2007-04-19 21:08:56 +02:00
|
|
|
|
|
|
|
/*_______________________VectorModulus_____________________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
mod=pD3DRMVectorModulus(&u);
|
2007-05-31 13:59:16 +02:00
|
|
|
ok((mod == 3.0f), "Expected 3.0f, Got %f\n", mod);
|
2007-04-19 21:09:48 +02:00
|
|
|
|
2007-04-19 21:10:46 +02:00
|
|
|
/*_______________________VectorNormalize___________________________*/
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorNormalize(&u);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=2.0f/3.0f; U2(e).y=2.0f/3.0f; U3(e).z=1.0f/3.0f;
|
2007-04-19 21:10:46 +02:00
|
|
|
expect_vec(e,u);
|
|
|
|
|
|
|
|
/* If u is the NULL vector, MSDN says that the return vector is NULL. In fact, the returned vector is (1,0,0). The following test case prove it. */
|
|
|
|
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(casnul).x=0.0f; U2(casnul).y=0.0f; U3(casnul).z=0.0f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorNormalize(&casnul);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=1.0f; U2(e).y=0.0f; U3(e).z=0.0f;
|
2007-04-19 21:10:46 +02:00
|
|
|
expect_vec(e,casnul);
|
|
|
|
|
2007-04-19 21:11:38 +02:00
|
|
|
/*____________________VectorReflect_________________________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(ray).x=3.0f; U2(ray).y=-4.0f; U3(ray).z=5.0f;
|
|
|
|
U1(norm).x=1.0f; U2(norm).y=-2.0f; U3(norm).z=6.0f;
|
|
|
|
U1(e).x=79.0f; U2(e).y=-160.0f; U3(e).z=487.0f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorReflect(&r,&ray,&norm);
|
2007-04-19 21:11:38 +02:00
|
|
|
expect_vec(e,r);
|
|
|
|
|
2007-04-19 21:12:00 +02:00
|
|
|
/*_______________________VectorRotate_______________________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(w).x=3.0f; U2(w).y=4.0f; U3(w).z=0.0f;
|
|
|
|
U1(axis).x=0.0f; U2(axis).y=0.0f; U3(axis).z=1.0f;
|
|
|
|
theta=2.0f*PI/3.0f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorRotate(&r,&w,&axis,theta);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=-0.3f-0.4f*sqrtf(3.0f); U2(e).y=0.3f*sqrtf(3.0f)-0.4f; U3(e).z=0.0f;
|
2007-04-19 21:12:00 +02:00
|
|
|
expect_vec(e,r);
|
|
|
|
|
|
|
|
/* The same formula gives D3DRMVectorRotate, for theta in [-PI/2;+PI/2] or not. The following test proves this fact.*/
|
2007-05-31 13:59:16 +02:00
|
|
|
theta=-PI/4.0f;
|
|
|
|
pD3DRMVectorRotate(&r,&w,&axis,theta);
|
|
|
|
U1(e).x=1.4f/sqrtf(2.0f); U2(e).y=0.2f/sqrtf(2.0f); U3(e).z=0.0f;
|
2007-04-19 21:12:00 +02:00
|
|
|
expect_vec(e,r);
|
|
|
|
|
2009-02-14 14:35:42 +01:00
|
|
|
theta=PI/8.0f;
|
|
|
|
pD3DRMVectorRotate(&self,&self,&axis,theta);
|
|
|
|
U1(e).x=0.989950; U2(e).y=0.141421f; U3(e).z=0.0f;
|
|
|
|
expect_vec(e,r);
|
|
|
|
|
2007-04-19 21:09:48 +02:00
|
|
|
/*_______________________VectorScale__________________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
par=2.5f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMVectorScale(&r,&v,par);
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(e).x=10.0f; U2(e).y=10.0f; U3(e).z=0.0f;
|
2007-04-19 21:09:48 +02:00
|
|
|
expect_vec(e,r);
|
2009-02-14 14:35:42 +01:00
|
|
|
|
2009-08-31 11:52:50 +02:00
|
|
|
U1(self).x=9.0f; U2(self).y=18.0f; U3(self).z=27.0f;
|
2009-02-14 14:35:42 +01:00
|
|
|
pD3DRMVectorScale(&self,&self,2);
|
|
|
|
U1(e).x=18.0f; U2(e).y=36.0f; U3(e).z=54.0f;
|
|
|
|
expect_vec(e,self);
|
2007-04-19 21:03:53 +02:00
|
|
|
}
|
|
|
|
|
2007-04-19 21:12:40 +02:00
|
|
|
static void MatrixTest(void)
|
|
|
|
{
|
|
|
|
D3DRMQUATERNION q;
|
|
|
|
D3DRMMATRIX4D exp,mat;
|
|
|
|
|
2007-05-31 13:59:16 +02:00
|
|
|
exp[0][0]=-49.0f; exp[0][1]=4.0f; exp[0][2]=22.0f; exp[0][3]=0.0f;
|
|
|
|
exp[1][0]=20.0f; exp[1][1]=-39.0f; exp[1][2]=20.0f; exp[1][3]=0.0f;
|
|
|
|
exp[2][0]=10.0f; exp[2][1]=28.0f; exp[2][2]=-25.0f; exp[2][3]=0.0f;
|
|
|
|
exp[3][0]=0.0f; exp[3][1]=0.0f; exp[3][2]=0.0f; exp[3][3]=1.0f;
|
|
|
|
q.s=1.0f; U1(q.v).x=2.0f; U2(q.v).y=3.0f; U3(q.v).z=4.0f;
|
2007-04-19 21:12:40 +02:00
|
|
|
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMMatrixFromQuaternion(mat,&q);
|
2007-04-19 21:12:40 +02:00
|
|
|
expect_mat(exp,mat);
|
|
|
|
}
|
|
|
|
|
2007-04-19 21:13:51 +02:00
|
|
|
static void QuaternionTest(void)
|
|
|
|
{
|
|
|
|
D3DVECTOR axis;
|
2009-02-16 17:39:12 +01:00
|
|
|
D3DVALUE par,theta;
|
2007-04-19 21:16:57 +02:00
|
|
|
D3DRMQUATERNION q,q1,q2,r;
|
2007-04-19 21:13:51 +02:00
|
|
|
|
|
|
|
/*_________________QuaternionFromRotation___________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
U1(axis).x=1.0f; U2(axis).y=1.0f; U3(axis).z=1.0f;
|
|
|
|
theta=2.0f*PI/3.0f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMQuaternionFromRotation(&r,&axis,theta);
|
2007-05-31 13:59:16 +02:00
|
|
|
q.s=0.5f; U1(q.v).x=0.5f; U2(q.v).y=0.5f; U3(q.v).z=0.5f;
|
2007-04-19 21:13:51 +02:00
|
|
|
expect_quat(q,r);
|
2007-04-19 21:16:57 +02:00
|
|
|
|
|
|
|
/*_________________QuaternionSlerp_________________________*/
|
2009-02-14 13:56:00 +01:00
|
|
|
/* If the angle of the two quaternions is in ]PI/2;3PI/2[, QuaternionSlerp
|
2009-02-16 17:39:12 +01:00
|
|
|
* interpolates between the first quaternion and the opposite of the second one.
|
|
|
|
* The test proves this fact. */
|
2007-05-31 13:59:16 +02:00
|
|
|
par=0.31f;
|
|
|
|
q1.s=1.0f; U1(q1.v).x=2.0f; U2(q1.v).y=3.0f; U3(q1.v).z=50.0f;
|
|
|
|
q2.s=-4.0f; U1(q2.v).x=6.0f; U2(q2.v).y=7.0f; U3(q2.v).z=8.0f;
|
2007-04-19 21:16:57 +02:00
|
|
|
/* The angle between q1 and q2 is in [-PI/2,PI/2]. So, one interpolates between q1 and q2. */
|
2009-02-16 17:39:12 +01:00
|
|
|
q.s = -0.55f; U1(q.v).x=3.24f; U2(q.v).y=4.24f; U3(q.v).z=36.98f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMQuaternionSlerp(&r,&q1,&q2,par);
|
2007-04-19 21:16:57 +02:00
|
|
|
expect_quat(q,r);
|
|
|
|
|
2007-05-31 13:59:16 +02:00
|
|
|
q1.s=1.0f; U1(q1.v).x=2.0f; U2(q1.v).y=3.0f; U3(q1.v).z=50.0f;
|
|
|
|
q2.s=-94.0f; U1(q2.v).x=6.0f; U2(q2.v).y=7.0f; U3(q2.v).z=-8.0f;
|
2007-04-19 21:16:57 +02:00
|
|
|
/* The angle between q1 and q2 is not in [-PI/2,PI/2]. So, one interpolates between q1 and -q2. */
|
2009-02-16 17:39:12 +01:00
|
|
|
q.s=29.83f; U1(q.v).x=-0.48f; U2(q.v).y=-0.10f; U3(q.v).z=36.98f;
|
2007-05-11 13:22:57 +02:00
|
|
|
pD3DRMQuaternionSlerp(&r,&q1,&q2,par);
|
2007-04-19 21:16:57 +02:00
|
|
|
expect_quat(q,r);
|
2009-02-14 13:56:00 +01:00
|
|
|
|
|
|
|
/* Test the spherical interpolation part */
|
|
|
|
q1.s=0.1f; U1(q1.v).x=0.2f; U2(q1.v).y=0.3f; U3(q1.v).z=0.4f;
|
|
|
|
q2.s=0.5f; U1(q2.v).x=0.6f; U2(q2.v).y=0.7f; U3(q2.v).z=0.8f;
|
|
|
|
q.s = 0.243943f; U1(q.v).x = 0.351172f; U2(q.v).y = 0.458401f; U3(q.v).z = 0.565629f;
|
|
|
|
pD3DRMQuaternionSlerp(&r,&q1,&q2,par);
|
|
|
|
expect_quat(q,r);
|
2007-04-19 21:13:51 +02:00
|
|
|
}
|
|
|
|
|
2007-05-20 12:24:30 +02:00
|
|
|
static void ColorTest(void)
|
|
|
|
{
|
2007-05-20 16:26:44 +02:00
|
|
|
D3DCOLOR color, expected_color, got_color;
|
|
|
|
D3DVALUE expected, got, red, green, blue, alpha;
|
|
|
|
|
2007-05-20 16:27:30 +02:00
|
|
|
/*___________D3DRMCreateColorRGB_________________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
red=0.8f;
|
|
|
|
green=0.3f;
|
|
|
|
blue=0.55f;
|
2007-05-20 16:27:30 +02:00
|
|
|
expected_color=0xffcc4c8c;
|
|
|
|
got_color=pD3DRMCreateColorRGB(red,green,blue);
|
|
|
|
ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color);
|
|
|
|
|
2007-05-20 16:26:44 +02:00
|
|
|
/*___________D3DRMCreateColorRGBA________________________*/
|
2007-05-31 13:59:16 +02:00
|
|
|
red=0.1f;
|
|
|
|
green=0.4f;
|
|
|
|
blue=0.7f;
|
|
|
|
alpha=0.58f;
|
2007-05-20 16:26:44 +02:00
|
|
|
expected_color=0x931966b2;
|
|
|
|
got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha);
|
|
|
|
ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color);
|
|
|
|
|
2008-03-01 21:10:38 +01:00
|
|
|
/* if a component is <0 then, then one considers this component as 0. The following test proves this fact (test only with the red component). */
|
2007-05-31 13:59:16 +02:00
|
|
|
red=-0.88f;
|
|
|
|
green=0.4f;
|
|
|
|
blue=0.6f;
|
|
|
|
alpha=0.41f;
|
2007-05-20 16:26:44 +02:00
|
|
|
expected_color=0x68006699;
|
|
|
|
got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha);
|
|
|
|
ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color);
|
|
|
|
|
2008-03-01 21:10:38 +01:00
|
|
|
/* if a component is >1 then, then one considers this component as 1. The following test proves this fact (test only with the red component). */
|
2007-05-31 13:59:16 +02:00
|
|
|
red=2.37f;
|
|
|
|
green=0.4f;
|
|
|
|
blue=0.6f;
|
|
|
|
alpha=0.41f;
|
2007-05-20 16:26:44 +02:00
|
|
|
expected_color=0x68ff6699;
|
|
|
|
got_color=pD3DRMCreateColorRGBA(red,green,blue,alpha);
|
|
|
|
ok((expected_color==got_color),"Expected color=%x, Got color=%x\n",expected_color,got_color);
|
2007-05-20 12:24:30 +02:00
|
|
|
|
2007-05-20 12:27:13 +02:00
|
|
|
/*___________D3DRMColorGetAlpha_________________________*/
|
|
|
|
color=0x0e4921bf;
|
2007-05-31 13:59:16 +02:00
|
|
|
expected=14.0f/255.0f;
|
2007-05-20 12:27:13 +02:00
|
|
|
got=pD3DRMColorGetAlpha(color);
|
|
|
|
ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got);
|
|
|
|
|
2007-05-20 12:26:21 +02:00
|
|
|
/*___________D3DRMColorGetBlue__________________________*/
|
|
|
|
color=0xc82a1455;
|
2007-05-31 13:59:16 +02:00
|
|
|
expected=1.0f/3.0f;
|
2007-05-20 12:26:21 +02:00
|
|
|
got=pD3DRMColorGetBlue(color);
|
|
|
|
ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got);
|
|
|
|
|
2007-05-20 12:25:17 +02:00
|
|
|
/*___________D3DRMColorGetGreen_________________________*/
|
|
|
|
color=0xad971203;
|
2007-05-31 13:59:16 +02:00
|
|
|
expected=6.0f/85.0f;
|
2007-05-20 12:25:17 +02:00
|
|
|
got=pD3DRMColorGetGreen(color);
|
|
|
|
ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got);
|
|
|
|
|
2007-05-20 12:24:30 +02:00
|
|
|
/*___________D3DRMColorGetRed__________________________*/
|
|
|
|
color=0xb62d7a1c;
|
2007-05-31 13:59:16 +02:00
|
|
|
expected=3.0f/17.0f;
|
2007-05-20 12:24:30 +02:00
|
|
|
got=pD3DRMColorGetRed(color);
|
|
|
|
ok((fabs(expected-got)<admit_error),"Expected=%f, Got=%f\n",expected,got);
|
|
|
|
}
|
|
|
|
|
2007-04-19 21:03:53 +02:00
|
|
|
START_TEST(vector)
|
|
|
|
{
|
2007-05-11 13:22:57 +02:00
|
|
|
if(!InitFunctionPtrs())
|
|
|
|
return;
|
|
|
|
|
2007-04-19 21:03:53 +02:00
|
|
|
VectorTest();
|
2007-04-19 21:12:40 +02:00
|
|
|
MatrixTest();
|
2007-04-19 21:13:51 +02:00
|
|
|
QuaternionTest();
|
2007-05-20 12:24:30 +02:00
|
|
|
ColorTest();
|
2007-05-11 13:22:57 +02:00
|
|
|
|
|
|
|
FreeLibrary(d3drm_handle);
|
2007-04-19 21:03:53 +02:00
|
|
|
}
|