2013-11-10 20:14:10 +00:00
|
|
|
#include "BaseTestCase.h"
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
#include "CameraDefinition.h"
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST(Camera, Definition)
|
2013-04-27 19:41:57 +00:00
|
|
|
{
|
2013-11-14 17:47:03 +00:00
|
|
|
CameraDefinition cam;
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
cam.setLocationCoords(0.0, 1.0, 1.0);
|
|
|
|
cam.setTargetCoords(0.0, 0.0, 0.0);
|
2013-04-27 19:41:57 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
EXPECT_VECTOR3_COORDS(cam.getLocation(), 0.0, 1.0, 1.0);
|
|
|
|
EXPECT_VECTOR3_COORDS(cam.getTarget(), 0.0, 0.0, 0.0);
|
2013-04-27 19:41:57 +00:00
|
|
|
}
|
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST(Camera, Projection)
|
2013-06-11 10:07:17 +00:00
|
|
|
{
|
2013-11-14 17:47:03 +00:00
|
|
|
CameraDefinition cam;
|
2013-06-11 10:07:17 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
cam.setLocationCoords(0.0, 1.0, 1.0);
|
|
|
|
cam.setTargetCoords(0.0, 0.0, 0.0);
|
2013-06-11 10:07:17 +00:00
|
|
|
|
|
|
|
/* Test the reversibility of projection */
|
2013-11-14 17:47:03 +00:00
|
|
|
Vector3 point = cam.project(Vector3(12.0, 5.2, -6.3));
|
|
|
|
point = cam.unproject(point);
|
2013-11-10 20:14:10 +00:00
|
|
|
EXPECT_VECTOR3_COORDS(point, 12.0, 5.2, -6.3);
|
2013-11-14 17:47:03 +00:00
|
|
|
point = cam.project(Vector3(-25.1, 8.3, 1.3));
|
|
|
|
point = cam.unproject(point);
|
2013-11-10 20:14:10 +00:00
|
|
|
EXPECT_VECTOR3_COORDS(point, -25.1, 8.3, 1.3);
|
2013-06-11 10:07:17 +00:00
|
|
|
}
|
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST(Camera, Depth)
|
2013-06-11 10:07:17 +00:00
|
|
|
{
|
2013-11-14 17:47:03 +00:00
|
|
|
CameraDefinition cam;
|
2013-06-11 10:07:17 +00:00
|
|
|
|
2013-11-14 17:47:03 +00:00
|
|
|
cam.setLocationCoords(0.0, 0.0, 0.0);
|
|
|
|
cam.setTargetCoords(1.0, 0.0, 0.0);
|
2013-06-11 10:07:17 +00:00
|
|
|
|
|
|
|
/* Test the real depth getter */
|
2013-11-14 17:47:03 +00:00
|
|
|
Vector3 point = cam.project(Vector3(12.5, 0.0, 0.0));
|
|
|
|
ASSERT_DOUBLE_EQ(cam.getRealDepth(point), 12.5);
|
|
|
|
point = cam.project(Vector3(12.5, 8.0, -3.0));
|
|
|
|
ASSERT_DOUBLE_EQ(cam.getRealDepth(point), 12.5);
|
|
|
|
point = cam.project(Vector3(12.5, 12.0, 58.0));
|
|
|
|
ASSERT_DOUBLE_EQ(cam.getRealDepth(point), 12.5);
|
2013-06-11 10:07:17 +00:00
|
|
|
}
|