diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-assetFactory.cpp | 32 | ||||
-rw-r--r-- | test/test-render.cpp | 59 |
2 files changed, 31 insertions, 60 deletions
diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index c8183df..8341fbf 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -9,6 +9,8 @@ #include "assetFactory/object.h" #include "assetFactory/texturePacker.h" #include "game/scenary/foliage.h" +#include "game/scenary/illuminator.h" +#include "game/scenary/light.h" #include "game/scenary/plant.h" #include "game/vehicles/railVehicle.h" #include "game/vehicles/railVehicleClass.h" @@ -46,7 +48,7 @@ public: void lights(const SceneShader & shader) const override { - shader.pointLight.add({-3, 1, 5}, {1, 1, 1}, .1F); + objects.apply(&Renderable::lights, shader); } void @@ -125,6 +127,34 @@ BOOST_AUTO_TEST_CASE(foliage, *boost::unit_test::timeout(5)) render(6000); } +BOOST_AUTO_TEST_CASE(lights, *boost::unit_test::timeout(5)) +{ + auto mf = AssetFactory::loadXML(RESDIR "/lights.xml"); + BOOST_REQUIRE(mf); + auto rlight = mf->assets.at("r-light"); + BOOST_REQUIRE(rlight); + auto oldlamp = mf->assets.at("old-lamp"); + BOOST_REQUIRE(oldlamp); + auto rlight_f = std::dynamic_pointer_cast<Illuminator>(rlight); + BOOST_REQUIRE(rlight_f); + auto oldlamp_f = std::dynamic_pointer_cast<Illuminator>(oldlamp); + BOOST_REQUIRE(oldlamp_f); + + auto light1 = std::make_shared<Light>(oldlamp_f, Location {{0, 0, 0}, {0, 0, 0}}); + auto light2 = std::make_shared<Light>(rlight_f, Location {{-4000, 0, 0}, {0, 2, 0}}); + auto light3 = std::make_shared<Light>(rlight_f, Location {{-4000, -4000, 0}, {0, 1, 0}}); + auto light4 = std::make_shared<Light>(oldlamp_f, Location {{3000, 4600, 0}, {0, 2, 0}}); + objects.objects.push_back(rlight_f); + objects.objects.push_back(oldlamp_f); + + // yes I'm hacking some floor to light up as though its a bush + auto floorf = std::dynamic_pointer_cast<Foliage>(mf->assets.at("floor")); + auto floor = std::make_shared<Plant>(floorf, Location {}); + objects.objects.push_back(floorf); + + render(6000); +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE(loadall) diff --git a/test/test-render.cpp b/test/test-render.cpp index 66b4d46..41731dd 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -158,63 +158,4 @@ BOOST_AUTO_TEST_CASE(terrain) Texture::save(outImage, "/tmp/terrain.tga"); } -BOOST_AUTO_TEST_CASE(pointlight) -{ - SceneRenderer ss {size, output}; - ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); - - class PointLightScene : public TestScene { - public: - void - environment(const SceneShader &, const SceneRenderer & r) const override - { - r.setAmbientLight({0.2F, 0.2F, 0.2F}); - r.setDirectionalLight({0.2F, 0.2F, 0.2F}, west + down, *this); - } - - void - lights(const SceneShader & shader) const override - { - for (int x = 50000; x < 100000; x += 20000) { - for (int y = 50000; y < 2000000; y += 20000) { - shader.pointLight.add({x, y, 4000}, {1.0, 1.0, 1.0}, 0.1F); - } - } - } - }; - - const PointLightScene scene; - ss.render(scene); - Texture::save(outImage, "/tmp/pointlight.tga"); -} - -BOOST_AUTO_TEST_CASE(spotlight) -{ - SceneRenderer ss {size, output}; - ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); - - class PointLightScene : public TestScene { - public: - void - environment(const SceneShader &, const SceneRenderer & r) const override - { - r.setAmbientLight({0.2F, 0.2F, 0.2F}); - r.setDirectionalLight({0.2F, 0.2F, 0.2F}, west + down, *this); - } - - void - lights(const SceneShader & shader) const override - { - shader.spotLight.add({50000, 50000, 15000}, down, {1.0, 1.0, 1.0}, 0.01F, 1); - shader.spotLight.add({51000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({53000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({60000, 50000, 3000}, north + east, {1.0, 1.0, 1.0}, 0.0001F, .7F); - } - }; - - const PointLightScene scene; - ss.render(scene); - Texture::save(outImage, "/tmp/spotlight.tga"); -} - BOOST_AUTO_TEST_SUITE_END(); |