I'm currently working on a project where my aim is to run a headset center calibration using OpenVR before launching any games. The calibration process is initiated through a launcher developed collaboratively by a friend and myself. We've implemented code that utilizes openvr.h and openvr_api.dll to perform a center calibration using the ResetZeroPose method within the OpenVR library.
The calibration seems to adjust the directional arrow in the headset's view to the front of the user. However, it doesn’t seem to rotate the base square or affect the base calibration of the headset. Activating the recenter button in the SteamVR UI restores the calibration to its original state.
I'm seeking advice on whether this method is the correct approach for our objective and if there are better or more effective ways to accomplish this task. Specifically, I'd like to understand if there's a way to recenter the base calibration or swiftly create a new room calibration, bypassing the UI process and pre-programming factors like height.
My project’s file structure includes:
- Files from the OpenVR project:
openvr_api.dllopenvr.h
- My implementation files:
vr.hvr.cppvr.dll(compiled from the above files, used across projects to invoke the specific function for recentering)
Here’s the code used for recentering:
// vr.h code
#pragma once
#include "./openvr.h"
extern "C" {
__declspec(dllexport) std::string doRecenter();
}
// vr.cpp code
#include "vr.h"
// Function to initialize OpenVR
vr::IVRSystem* init() {
// Initialization of OpenVR
vr::IVRSystem* vrSystem = vr::VR_Init(nullptr, vr::EVRApplicationType::VRApplication_Scene);
if (!vrSystem) {
return nullptr;
}
return vrSystem;
}
// Function to perform recentering
void recenter() {
vr::VRChaperone()->ResetZeroPose(vr::TrackingUniverseStanding);
}
// Function to shut down OpenVR
void shutdown() {
vr::VR_Shutdown();
}
// Function to trigger recentering
std::string doRecenter() {
auto vrSys = init();
if (vrSys == nullptr) {
return "Failed to initialize VR";
}
recenter();
shutdown();
return "";
}
I'm also looking for guidance on how to execute the recentering code without terminating the current game. Presently, executing the above code disrupts the current VR game before recentering. It's possible that I might not be calling the functions correctly or that there are better approaches to handle this situation.
My ultimate goal is to launch the VR game in the background, hidden from the user's view, while displaying another program to guide them through the calibration process. This might necessitate managing two VR games simultaneously, potentially through threading, while controlling which one is visible.
I really appreciate any guidance or insights. I've explored various methods, and I believe this approach might be the right direction, but I'm open to learning and improving. Thank you so much for your assistance; your expertise is invaluable to me as I try to solve this challenge.
TLDR:
I've tried implementing code that utilizes openvr.h and openvr_api.dll to perform a center calibration using the ResetZeroPose method within the OpenVR library.
This doesn't fully solve our issue, specifically on Unity games which seem to use the base room center, and not the new direction set by the above code. In Unreal Engine it works well (as far as I've tested)
Any help will be much appreciated. Thank you.