mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
added methods
This commit is contained in:
@@ -27,17 +27,15 @@ TEST(UnitTestSourceEngine, UpVector)
|
||||
EXPECT_EQ(up, omath::source::kAbsUp);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, PerpectiveProjectionAtCenter)
|
||||
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||
|
||||
|
||||
const auto viewProjMatrix = cam.GetViewProjectionMatrix();
|
||||
|
||||
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
||||
{
|
||||
const auto projected = cam.WorldToScreen(viewProjMatrix, {distance, 0, 0});
|
||||
const auto projected = cam.WorldToScreen({distance, 0, 0});
|
||||
|
||||
EXPECT_TRUE(projected.has_value());
|
||||
|
||||
@@ -47,4 +45,25 @@ TEST(UnitTestSourceEngine, PerpectiveProjectionAtCenter)
|
||||
EXPECT_NEAR(projected->x, 960, 0.00001f);
|
||||
EXPECT_NEAR(projected->y, 540, 0.00001f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, CameraSetAndGetFov)
|
||||
{
|
||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
|
||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
|
||||
TEST(UnitTestSourceEngine, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::source::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
||||
|
||||
EXPECT_EQ(cam.GetOrigin(), omath::Vector3{});
|
||||
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
|
||||
|
||||
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
|
||||
}
|
||||
Reference in New Issue
Block a user