diff --git a/rogueviz/qtm.cpp b/rogueviz/qtm.cpp index efc58559..8e5bfa4e 100644 --- a/rogueviz/qtm.cpp +++ b/rogueviz/qtm.cpp @@ -1,4 +1,4 @@ -#include "../hyper.h" +#include "rogueviz.h" // Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details @@ -21,7 +21,7 @@ namespace hybrid { extern hrmap *pmap; } namespace qtm { -int mode; +int qmode; color_t rainbow_color_at(hyperpoint h) { ld sat = 1 - 1 / h[2]; @@ -38,11 +38,11 @@ void set_cell(cell *c) { c->landparam = c1->landparam; c->item = itNone; c->monst = moNone; - if(mode == 1) { + if(qmode == 1) { if(hybrid::get_where(c).second == 0) c->landparam = 0xFFFFFF; } - if(mode == 2) { + if(qmode == 2) { if(hybrid::get_where(c).second != 0) c->wall = waNone; } @@ -73,29 +73,31 @@ void set_cell(cell *c) { } } -bool qtm_on; - bool may_set_cell(cell *c, int d, cell *from) { - if(qtm_on) set_cell(c); + set_cell(c); return false; } +void enable() { + addHook(hooks_cellgen, 100, may_set_cell); + } + int args() { using namespace arg; if(0) ; else if(argis("-qtm-stripe")) { - mode = 1; + qmode = 1; } else if(argis("-qtm-no-stripe")) { - mode = 0; + qmode = 0; } else if(argis("-qtm-stripe-only")) { - mode = 2; + qmode = 2; } else if(argis("-qtm")) { PHASEFROM(2); - qtm_on = true; + enable(); } else if(argis("-spheredemo")) { @@ -188,10 +190,67 @@ int args() { return 0; } - - -auto hooks = addHook(hooks_cellgen, 100, may_set_cell) - + addHook(hooks_args, 100, args); +auto hooks = + addHook(hooks_args, 100, args) + + addHook(rogueviz::pres::hooks_build_rvtour, 180, [] (string s, vector& v) { + if(s != "mixed") return; + using namespace tour; + for(int m: {1,2}) { + string ex = m == 1 ? " (A)" : " (B)"; + string bonus = m == 2 ? "\n\nTo make stretching more interesting, only the 'stripes' are filled now." : ""; + v.push_back(slide{ + "rotations/isometries of 2-sphere"+ex, 10, LEGAL::NONE | QUICKGEO, + "3D engines often represent rotations as unit quaternions. These form a 3D elliptic space. What if we could fly through this space of rotations?\n\n" + "Rotation matching the current camera position shown in the corner. Beams in the rotation space correspond to bumps on the sphere.\n\n" + "You can also obtain a different geometry (Berger sphere) by stretching along the fibers. Press 5 to stretch."+bonus + , + [m] (presmode mode) { + setCanvas(mode, '0'); + slide_url(mode, 't', "Twitter link", "https://twitter.com/ZenoRogue/status/1166723332840001536"); + slide_url(mode, 's', "stretched Twitter link", "https://twitter.com/ZenoRogue/status/1258035231996682244"); + if(mode == pmStart) { + set_geometry(gSphere); + set_variation(eVariation::bitruncated); + set_geometry(gRotSpace); + slide_backup(rots::underlying_scale, .25); + slide_backup(qmode, m); + slide_backup(ray::max_cells, 32768); + slide_backup(ray::fixed_map, true); + slide_backup(smooth_scrolling, true); + slide_backup(camera_speed, .1); + enable(); + start_game(); + } + if(mode == pmKey) + edit_stretch(); + }}); + v.push_back(slide{ + "rotations/isometries of the hyperbolic plane"+ex, 10, LEGAL::NONE | QUICKGEO, + "The hyperbolic analog of the previous slide. The space is PSL(2,R) now, which has a non-isotropic geometry. It can be represented using split quaternions.\n\n" + "Again, press 5 to stretch."+bonus + , + [m] (presmode mode) { + setCanvas(mode, '0'); + slide_url(mode, 's', "stretched Twitter link", "https://twitter.com/ZenoRogue/status/1259143275115687936"); + if(mode == pmStart) { + set_geometry(gKleinQuartic); + set_variation(eVariation::bitruncated); + set_geometry(gRotSpace); + slide_backup(rots::underlying_scale, .25); + slide_backup(qmode, m); + slide_backup(ray::max_cells, 32768); + slide_backup(ray::fixed_map, true); + slide_backup(ray::want_use, 2); + slide_backup(smooth_scrolling, true); + slide_backup(camera_speed, .1); + enable(); + start_game(); + } + if(mode == pmKey) + edit_stretch(); + }}); + } + }); }