1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include "RadiantTest.h"
#include "icameraview.h"
#include "icommandsystem.h"
#include "render/View.h"
namespace test
{
TEST_F(RadiantTest, SetCameraPositionAndAngles)
{
// Assume that we don't have any camera at first
bool exceptionThrown = false;
try
{
GlobalCameraManager().getActiveView();
}
catch (const std::runtime_error&)
{
exceptionThrown = true;
}
ASSERT_TRUE(exceptionThrown);
render::View view;
auto allocatedCam = GlobalCameraManager().createCamera(view, [](bool) {});
// We should be able to get an active camera now
exceptionThrown = false;
try
{
auto& camera = GlobalCameraManager().getActiveView();
auto oldPosition = camera.getCameraOrigin();
auto oldAngles = camera.getCameraAngles();
// Run the command, and compare the camera's angles
GlobalCommandSystem().executeCommand("SetActiveCameraPosition", cmd::Argument(oldPosition + Vector3(50,50,50)));
auto newPosition = camera.getCameraOrigin();
ASSERT_TRUE(oldPosition != newPosition); // position changed
ASSERT_TRUE(camera.getCameraAngles() == oldAngles); // angles unchanged
GlobalCommandSystem().executeCommand("SetActiveCameraAngles", cmd::Argument(oldAngles + Vector3(10,10,10)));
ASSERT_TRUE(camera.getCameraOrigin() == newPosition); // position unchanged
ASSERT_TRUE(camera.getCameraAngles() != oldAngles); // angles changed
}
catch (const std::runtime_error&)
{
exceptionThrown = true;
}
ASSERT_TRUE(exceptionThrown == false);
GlobalCameraManager().destroyCamera(allocatedCam);
}
}
|