From 79bb11413ce9f13fc81bf041f31e79b27855d8ab Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 10 Feb 2019 10:43:28 +0100 Subject: [PATCH] rogueviz:: added cvl --- rogueviz-cvl.cpp | 112 +++++++++++++++++++++++++++++++++++++++++++++++ rogueviz.cpp | 1 + 2 files changed, 113 insertions(+) create mode 100644 rogueviz-cvl.cpp diff --git a/rogueviz-cvl.cpp b/rogueviz-cvl.cpp new file mode 100644 index 000000000..9e6822fb7 --- /dev/null +++ b/rogueviz-cvl.cpp @@ -0,0 +1,112 @@ +// Copyright (C) 2018 Zeno and Tehora Rogue, see 'hyper.cpp' for details +// this is a plugin which generates branched tilings for newconformist +// https://github.com/zenorogue/newconformist (see the option '-cvl') + +namespace hr { + +struct location { + transmatrix lView; + heptspin lviewctr; + }; + +struct lineinfo { + vector locs; + int plus_matrices; + int minus_matrices; + }; + +map lines; + +location loc_multiply(location orig, transmatrix T) { + dynamicval dv(View, orig.lView); + dynamicval dc(viewctr, orig.lviewctr); + View = inverse(T) * View; + for(int a=0; a<10; a++) optimizeview(); + return location{View, viewctr}; + } + +bool show_map = false; + +void cvl_marker() { + if(show_map) for(auto& l: lines) { + int id = 0; + for(auto& loc: l.second.locs) { + if(gmatrix.count(loc.lviewctr.at->c7)) { + transmatrix T = gmatrix[loc.lviewctr.at->c7] * inverse(spin(loc.lviewctr.spin*2*M_PI/S7 + master_to_c7_angle())) * inverse(loc.lView); + queuepoly(T, shAsymmetric, 0xFF00FFFF); + queuestr(T, 1.0, its(l.first)+"/"+its(id), 0xFFFFFF); + } + id++; + } + } + } + +int readArgs() { + using namespace arg; + + if(0) ; + else if(argis("-cvlbuild")) { + PHASEFROM(3); + start_game(); + shift(); FILE *f = fopen(argcs(), "rt"); + if(!f) { shift(); printf("failed to open file\n"); return 0; } + int id; + lineinfo l0; + fscanf(f, "%d%d%d", &id, &l0.plus_matrices, &l0.minus_matrices); + l0.locs.push_back(location{View, viewctr}); + for(int i=1; i dv(View, loc.lView); + dynamicval dc(viewctr, loc.lviewctr); + shot::take(format(s.c_str(), p.first, i++)); + } + } + } + else return 1; + return 0; + } + +auto magichook = addHook(hooks_args, 100, readArgs) + addHook(hooks_frame, 100, cvl_marker); + + + +} diff --git a/rogueviz.cpp b/rogueviz.cpp index e5b2fde72..6a4aa9a84 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -2280,3 +2280,4 @@ auto hooks = #include "rogueviz-sunflower.cpp" #include "rogueviz-flocking.cpp" #include "rogueviz-magiccube.cpp" +#include "rogueviz-cvl.cpp"