From 50e14974053bd93042c5d99c9474a985c6bf2612 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 27 Feb 2022 14:53:22 +0100 Subject: [PATCH] rv:: portal demos now organized into a separate presentation --- intra.cpp | 2 +- rogueviz/intra-demos.cpp | 71 ++++++++++++--------- rogueviz/notknot.cpp | 133 ++++++++++++++++++++++++--------------- 3 files changed, 125 insertions(+), 81 deletions(-) diff --git a/intra.cpp b/intra.cpp index 1471d1b9..ac710b42 100644 --- a/intra.cpp +++ b/intra.cpp @@ -627,7 +627,7 @@ void erase_unconnected(cellwalker cw) { int edit_spin; -void show_portals() { +EX void show_portals() { gamescreen(1); dialog::init(XLAT("manage portals")); diff --git a/rogueviz/intra-demos.cpp b/rogueviz/intra-demos.cpp index dbc3d916..e9e4a695 100644 --- a/rogueviz/intra-demos.cpp +++ b/rogueviz/intra-demos.cpp @@ -481,34 +481,49 @@ auto hooks = 0xFFFDD0, 0xFFD080 }; }) -+ addHook_rvslides(191, [] (string s, vector& v) { - if(s != "mixed") return; - v.push_back(tour::slide{ - "inter-geometric portals", 10, tour::LEGAL::NONE | tour::QUICKSKIP | tour::QUICKGEO, - "Portals between different geometries.\n" - "These levels take some time to load, so you need to load them using the buttons below." - , - [] (tour::presmode mode) { - setCanvas(mode, '0'); - slide_url(mode, 'y', "portals (YouTube)", "https://youtu.be/yqUv2JO2BCs"); - slide_url(mode, 't', "portals (Twitter)", "https://twitter.com/ZenoRogue/status/1496867204419452935"); - using namespace tour; - auto load = [&] (string s, ld x) { - return [s, x] { - slide_backup(vid.cells_drawn_limit, 100); - slide_backup(smooth_scrolling, true); - slide_backup(ray::max_cells, 999999); - slide_backup(walking::on, true); - slide_backup(walking::eye_level, x); - mapstream::loadMap(s); - }; - }; - slide_action(mode, 'p', "load portals", load("portalscene3.lev", 0.2174492)); - slide_url(mode, 'C', "curved landscape (Twitter)", "https://twitter.com/ZenoRogue/status/1446127100516130826"); - slide_action(mode, 'c', "load curved landscape", load("solv-h3-scene.lev", 0.05)); - } - }); - }); ++ addHook_rvslides(10, ([] (string s, vector& v) { + println(hlog, "called with s='", s, "'"); + if(s != "portal") return; + + using namespace tour; + auto load = [] (string s, ld x, int y) { + return [s, x, y] { + slide_backup(vid.cells_drawn_limit, 100); + slide_backup(smooth_scrolling, true); + slide_backup(ray::max_cells, 999999); + slide_backup(walking::on, true); + slide_backup(walking::eye_level, x); + mapstream::loadMap(s); + slide_backup(ray::fixed_map, true); + slide_backup(ray::max_iter_intra, y); + }; + }; + + auto add = [&] (string s, string desc, string youtube, string twitter, reaction_t loader) { + v.push_back(tour::slide{ + s, 10, tour::LEGAL::NONE | tour::QUICKSKIP | tour::QUICKGEO, desc, + [=] (tour::presmode mode) { + setCanvas(mode, '0'); + if(youtube != "") + slide_url(mode, 'y', "YouTube link", youtube); + if(twitter != "") + slide_url(mode, 't', "Twitter link", twitter); + slide_action(mode, 'r', "run this visualization", loader); + if(mode == tour::pmKey) pushScreen(intra::show_portals); + } + }); + }; + + add("inter-geometric portals", + "In this world we can find portals between six different geometries. The camera is in 'walking mode' i.e. restricted to keep close to the floor (this can be disabled with '5').", + "https://youtu.be/yqUv2JO2BCs", "https://twitter.com/ZenoRogue/status/1496867204419452935", + load("portalscene3.lev", 0.2174492, 600) + ); + add("curved landscape", + "Here we create portals between Solv and H3 geometries, resulting in a scene looking a bit like a curved landscape.", + "", "https://twitter.com/ZenoRogue/status/1446127100516130826", + load("solv-h3-scene.lev", 0.05, 3000)); + })); } diff --git a/rogueviz/notknot.cpp b/rogueviz/notknot.cpp index c1a6ef30..ad5d918d 100644 --- a/rogueviz/notknot.cpp +++ b/rogueviz/notknot.cpp @@ -1417,6 +1417,85 @@ void nk_launch() { #endif } +void portal_slideshow(tour::ss::slideshow_callback cb) { + + using namespace rogueviz::pres; + using namespace tour; + static vector portal_slides; + + if(portal_slides.empty()) { + + portal_slides.emplace_back(slide{"portal collection", 100, LEGAL::NONE | QUICKSKIP, + "This is a collection of portals. We start with knotted portals in Euclidean geometry, " + "then we visit portals in other geometries, and finally, we explore portals between different " + "geometries.\n\nLoading these may take some time, so you need to press 'r' to run them. In most slides you can also press '5' to change various parameters.", + [] (presmode mode) {} + }); + + auto add = [&] (string s, string text, string youtube, reaction_t act) { + + portal_slides.emplace_back( + tour::slide{s, 100, LEGAL::NONE | QUICKGEO | QUICKSKIP, text, + [=] (presmode mode) { + setCanvas(mode, '0'); + if(youtube != "") + slide_url(mode, 'y', "YouTube link", youtube); + slide_action(mode, 'r', "run", [=] { + slide_backup(margin); + slide_backup(mapeditor::drawplayer); + slide_backup(firstland); + slide_backup(specialland); + slide_backup(ray::max_cells, 600000); + slide_backup(smooth_scrolling, 1); + slide_backup(camera_speed, 10); + slide_backup(ray::exp_decay_poly, 30); + slide_backup(ray::fixed_map, true); + slide_backup(ray::max_iter_iso, 80); + #if CAP_VR + slide_backup(vrhr::hsm); + slide_backup(vrhr::eyes); + slide_backup(vrhr::cscr); + slide_backup(vrhr::absolute_unit_in_meters); + #endif + + on_restore([] { nilv::set_flags(); asonov::set_flags(); }); + + slide_backup(nilv::nilwidth); + slide_backup(nilv::nilperiod); + + slide_backup(vid.binary_width); + slide_backup(asonov::period_xy); + slide_backup(asonov::period_z); + + act(); + start_game(); + loop = 2; + }); + + if(mode == tour::pmKey) pushScreen(show); + }}); + }; + + auto launch_euc_with = [] (bool b) { + return [b] { + self_hiding = b; + launch_euc(); + }; + }; + add("knotted portal", "This is a knotted portal in Euclidean space.", "https://www.youtube.com/watch?v=eb2DhCcGH7U", launch_euc_with(false)); + add("self-hiding portal", "This knotted portal is 'self-hiding'. It appears that the portal enters itself and disappears!", "https://www.youtube.com/watch?v=vFLZ2NGtuGw", launch_euc_with(true)); + add("non-Euclidean portal in Nil", "A portal in Nil geometry.", "https://www.youtube.com/watch?v=2K-v8tK68AE", launch_nil); + add("spherical portal", "A portal in spherical geometry. Such a portal lets us create a space with spherical geometry that has more volume than the sphere.", "https://www.youtube.com/watch?v=PerPeQFu5gw", launch_sphereknot); + add("Cat Portal in Solv", "A portal in Solv geometry. The honeycomb is based on the mapping torus of Arnold's cat mapping.", "https://www.youtube.com/watch?v=CGiSxC9B6i0", launch_solv); + + callhooks(rogueviz::pres::hooks_build_rvtour, "portal", portal_slides); + + add_end(portal_slides); + } + + cb(XLAT("portal collection"), &portal_slides[0], 'p'); + } + auto shot_hooks = addHook(hooks_initialize, 100, create_notknot) + addHook(hooks_welcome_message, 100, [] { if(geometry == gNotKnot) { @@ -1496,59 +1575,9 @@ auto shot_hooks = addHook(hooks_initialize, 100, create_notknot) param_i(loop_any, "nk_loopany"); }) #ifndef NOTKNOT - + addHook_rvslides(180, [] (string s, vector& v) { - if(s != "mixed") return; - v.push_back(tour::slide{ - "weird portals", 10, tour::LEGAL::NONE | tour::QUICKSKIP, - "Some experiments with weird portals. Press '5' to change between available experiments.\n" - , - [] (tour::presmode mode) { - slide_url(mode, 'k', "knotted portal (YouTube)", "https://www.youtube.com/watch?v=eb2DhCcGH7U"); - slide_url(mode, 'h', "self-hiding knot portal (YouTube)", "https://www.youtube.com/watch?v=vFLZ2NGtuGw"); - slide_url(mode, 'n', "non-Euclidean portal in Nil (YouTube)", "https://www.youtube.com/watch?v=2K-v8tK68AE"); - slide_url(mode, 's', "spherical portal (YouTube)", "https://www.youtube.com/watch?v=PerPeQFu5gw"); - slide_url(mode, 'c', "Cat Portal in Solv (YouTube)", "https://www.youtube.com/watch?v=CGiSxC9B6i0"); - setCanvas(mode, '0'); - using namespace tour; - if(mode == pmStart) { - slide_backup(margin); - slide_backup(mapeditor::drawplayer); - slide_backup(firstland); - slide_backup(specialland); - slide_backup(ray::max_cells); - slide_backup(smooth_scrolling); - slide_backup(camera_speed); - slide_backup(ray::exp_decay_poly); - slide_backup(ray::fixed_map); - slide_backup(ray::max_iter_iso); - #if CAP_VR - slide_backup(vrhr::hsm); - slide_backup(vrhr::eyes); - slide_backup(vrhr::cscr); - slide_backup(vrhr::absolute_unit_in_meters); - #endif - - on_restore([] { nilv::set_flags(); asonov::set_flags(); }); - - slide_backup(nilv::nilwidth); - slide_backup(nilv::nilperiod); - - slide_backup(vid.binary_width); - slide_backup(asonov::period_xy); - slide_backup(asonov::period_z); - - nk_launch(); - start_game(); - loop = 2; - } - if(mode == tour::pmKey) { - pushScreen(show); - } - } - }); - }) ++ addHook_slideshows(120, portal_slideshow) #endif - ; + ; #ifdef NOTKNOT auto hook1=