diff options
-rw-r--r-- | res/lights.xml | 16 | ||||
-rw-r--r-- | test/test-assetFactory.cpp | 25 |
2 files changed, 41 insertions, 0 deletions
diff --git a/res/lights.xml b/res/lights.xml new file mode 100644 index 0000000..137137d --- /dev/null +++ b/res/lights.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<ilt p.id="assetFactory"> + <asset p.typeid="Illuminator" id="r-light" name="r-light"> + <bodyMesh id="body"> + <use type="cylinder" scale="0.12,0.12,1" colour="lightslategray"/> + <use type="cylinder" scale="0.07,0.07,3" position="0,0,1" colour="lightslategray"/> + <use type="cylinder" scale="0.05,0.05,1.5" position="0,0.1,4" rotation="1.5,0,0" colour="lightslategray"/> + </bodyMesh> + </asset> + <!-- yes I'm hacking some floor to light up as though its a bush --> + <asset p.typeid="Foliage" id="floor" name="floor"> + <bodyMesh id="body"> + <use type="plane" scale="10,10,0" colour="#aaaaaa"/> + </bodyMesh> + </asset> +</ilt> diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index c8183df..e7ba19c 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" @@ -125,6 +127,29 @@ 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 rlight_f = std::dynamic_pointer_cast<Illuminator>(rlight); + BOOST_REQUIRE(rlight_f); + + auto light1 = std::make_shared<Light>(rlight_f, Location {{0, 0, 0}, {0, 0, 0}}); + auto light2 = std::make_shared<Light>(rlight_f, Location {{-4000, 0, 0}, {0, -1, 0}}); + auto light3 = std::make_shared<Light>(rlight_f, Location {{-4000, -4000, 0}, {0, -3, 0}}); + auto light4 = std::make_shared<Light>(rlight_f, Location {{3000, 4600, 0}, {0, 1, 0}}); + objects.objects.push_back(rlight_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) |