summaryrefslogtreecommitdiff
path: root/test/test-render.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-24 00:46:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-24 00:46:57 +0000
commit17aa6053e641d006649f94bb60a834ce945f351e (patch)
treeb76f6fc642b749ee69d4be4b2e3f60e80c0ed7bc /test/test-render.cpp
parentAdd traits wrapper for setting uniforms (diff)
parentFix network population of position in gBuffer (diff)
downloadilt-17aa6053e641d006649f94bb60a834ce945f351e.tar.bz2
ilt-17aa6053e641d006649f94bb60a834ce945f351e.tar.xz
ilt-17aa6053e641d006649f94bb60a834ce945f351e.zip
Merge remote-tracking branch 'origin/instanced-networks'
Diffstat (limited to 'test/test-render.cpp')
-rw-r--r--test/test-render.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/test-render.cpp b/test/test-render.cpp
index 41731dd..6c20a23 100644
--- a/test/test-render.cpp
+++ b/test/test-render.cpp
@@ -8,6 +8,7 @@
#include <assetFactory/assetFactory.h>
#include <game/geoData.h>
+#include <game/network/rail.h>
#include <game/terrain.h>
#include <game/vehicles/railVehicle.h>
#include <game/vehicles/railVehicleClass.h>
@@ -24,6 +25,7 @@ class TestScene : public SceneProvider {
const RailVehicleClassPtr brush47rvc = std::dynamic_pointer_cast<RailVehicleClass>(
AssetFactory::loadXML(RESDIR "/brush47.xml")->assets.at("brush-47"));
std::shared_ptr<RailVehicle> train1, train2;
+ RailLinks rail;
Terrain terrain {[]() {
auto gd = std::make_shared<GeoData>(GeoData::createFlat({0, 0}, {1000000, 1000000}, 1));
@@ -41,6 +43,8 @@ public:
train2->location.setPosition({52000, 30000, 2000});
train2->bogies.front().setPosition(train2->bogies.front().position() + train2->location.position());
train2->bogies.back().setPosition(train2->bogies.back().position() + train2->location.position());
+ rail.addLinksBetween({42000, 50000, 1000}, {65000, 50000, 1000});
+ rail.addLinksBetween({65000, 50000, 1000}, {75000, 45000, 2000});
}
void
@@ -48,6 +52,7 @@ public:
{
terrain.render(shader);
brush47rvc->render(shader);
+ rail.render(shader);
}
void
@@ -158,4 +163,50 @@ BOOST_AUTO_TEST_CASE(terrain)
Texture::save(outImage, "/tmp/terrain.tga");
}
+BOOST_AUTO_TEST_CASE(railnet)
+{
+ SceneRenderer ss {size, output};
+ ss.camera.setView({0, 0, 10000}, glm::normalize(glm::vec3 {1, 1, -0.5F}));
+
+ class TestRail : public SceneProvider {
+ RailLinks net;
+
+ public:
+ TestRail()
+ {
+ net.addLinksBetween({20000, 10000, 0}, {100000, 100000, 0});
+ net.addLinksBetween({20000, 10000, 0}, {10000, 10000, 0});
+ net.addLinksBetween({10000, 20000, 0}, {100000, 120000, 0});
+ net.addLinksBetween({10000, 20000, 0}, {10000, 10000, 0});
+ net.addLinksBetween({100000, 100000, 0}, {100000, 120000, 0});
+ }
+
+ void
+ content(const SceneShader & shader) const override
+ {
+ net.render(shader);
+ }
+
+ void
+ environment(const SceneShader &, const SceneRenderer & sr) const override
+ {
+ sr.setAmbientLight({0.1, 0.1, 0.1});
+ sr.setDirectionalLight({1, 1, 1}, south + down, *this);
+ }
+
+ void
+ lights(const SceneShader &) const override
+ {
+ }
+
+ void
+ shadows(const ShadowMapper &) const override
+ {
+ }
+ };
+
+ ss.render(TestRail {});
+ Texture::save(outImage, "/tmp/railnet.tga");
+}
+
BOOST_AUTO_TEST_SUITE_END();