From 279fe685ec25bf815719d0b08007756a351f8e56 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 6 May 2022 19:53:21 +0200 Subject: [PATCH] nilrider:: VR support --- rogueviz/nilrider/nilrider.cpp | 4 ++++ rogueviz/nilrider/timestamp.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/rogueviz/nilrider/nilrider.cpp b/rogueviz/nilrider/nilrider.cpp index 1380e367..85662fb0 100644 --- a/rogueviz/nilrider/nilrider.cpp +++ b/rogueviz/nilrider/nilrider.cpp @@ -344,6 +344,7 @@ void settings() { dialog::add_action_push(nil_projection); dialog::addItem("configure keys", 'k'); dialog::add_action_push(multi::get_key_configurer(1, move_names, "Nilrider keys")); + vrhr::vr_enable_button(); dialog::addItem("RogueViz settings", 'r'); dialog::add_key_action('r', [] { pushScreen(showSettings); @@ -525,6 +526,9 @@ void initialize_all() { initialize(); poly_outline = 0xFF; pushScreen(pick_game); + vrhr::hsm = vrhr::eHeadset::reference; + vrhr::eyes = vrhr::eEyes::equidistant; + vrhr::absolute_unit_in_meters = 6; } auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", [] { planning_mode = true; }) + arg::add3("-viewsim", [] { view_replay = true; }) diff --git a/rogueviz/nilrider/timestamp.cpp b/rogueviz/nilrider/timestamp.cpp index 87343d38..f17c5f85 100644 --- a/rogueviz/nilrider/timestamp.cpp +++ b/rogueviz/nilrider/timestamp.cpp @@ -166,6 +166,18 @@ bool timestamp::tick(level *lev) { void timestamp::centerview(level *lev) { // static bool once = false; if(once) return; once = true; + + if(vrhr::active()) { + transmatrix Ta = cspin(0, 1, -heading_angle); + transmatrix Tb = cspin(0, 2, -slope); + + hyperpoint base = Ta * Tb * point31(0, 0, whrad); + hyperpoint refpoint = rgpushxto0(where) * rgpushxto0(base) * point31(0, 0, whrad+whrad); + centerover = cwt.at; playermoved = false; + View = cspin(0, 2, heading_angle-90*degree) * cspin(1, 2, -90*degree) * gpushxto0(refpoint); + return; + } + auto w = where; w[2] += 0.2 * lev->scale; hyperpoint front = rgpushxto0(w) * sym_to_heis(hyperpoint(1e-3 * cos(heading_angle), 1e-3*sin(heading_angle), 0, 1));