Sweden-Number/dlls/d3dx8/tests/mesh.c

101 lines
4.6 KiB
C

/*
* Copyright 2008 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 "d3dx8.h"
#include "wine/test.h"
static void D3DXBoundProbeTest(void)
{
BOOL result;
D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
FLOAT radius;
/*____________Test the Box case___________________________*/
bottom_point.x = -3.0f; bottom_point.y = -2.0f; bottom_point.z = -1.0f;
top_point.x = 7.0f; top_point.y = 8.0f; top_point.z = 9.0f;
raydirection.x = -4.0f; raydirection.y = -5.0f; raydirection.z = -6.0f;
rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == TRUE, "expected TRUE, received FALSE\n");
raydirection.x = 4.0f; raydirection.y = 5.0f; raydirection.z = 6.0f;
rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
rayposition.x = -4.0f; rayposition.y = 1.0f; rayposition.z = -2.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == TRUE, "expected TRUE, received FALSE\n");
bottom_point.x = 1.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
top_point.x = 1.0f; top_point.y = 0.0f; top_point.z = 0.0f;
rayposition.x = 0.0f; rayposition.y = 1.0f; rayposition.z = 0.0f;
raydirection.x = 0.0f; raydirection.y = 3.0f; raydirection.z = 0.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
bottom_point.x = 1.0f; bottom_point.y = 2.0f; bottom_point.z = 3.0f;
top_point.x = 10.0f; top_point.y = 15.0f; top_point.z = 20.0f;
raydirection.x = 7.0f; raydirection.y = 8.0f; raydirection.z = 9.0f;
rayposition.x = 3.0f; rayposition.y = 7.0f; rayposition.z = -6.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == TRUE, "expected TRUE, received FALSE\n");
bottom_point.x = 0.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
top_point.x = 1.0f; top_point.y = 1.0f; top_point.z = 1.0f;
raydirection.x = 0.0f; raydirection.y = 1.0f; raydirection.z = .0f;
rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
raydirection.x = 1.0f; raydirection.y = 0.0f; raydirection.z = .0f;
rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
ok(result == TRUE, "expected TRUE, received FALSE\n");
/*____________Test the Sphere case________________________*/
radius = sqrt(77.0f);
center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
ok(result == TRUE, "expected TRUE, received FALSE\n");
rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
rayposition.x = 5.0f; rayposition.y = 7.0f; rayposition.z = 9.0f;
result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
ok(result == FALSE, "expected FALSE, received TRUE\n");
}
START_TEST(mesh)
{
D3DXBoundProbeTest();
}