use of com.jme3.system.jopenvr.TrackedDevicePose_t in project jmonkeyengine by jMonkeyEngine.
the class OpenVR method initialize.
@Override
public boolean initialize() {
logger.config("Initializing OpenVR system...");
hmdErrorStore = new IntByReference();
vrsystemFunctions = null;
JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene);
if (hmdErrorStore.getValue() == 0) {
vrsystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer());
}
if (vrsystemFunctions == null || hmdErrorStore.getValue() != 0) {
logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0));
logger.severe("Initializing OpenVR system [FAILED]");
return false;
} else {
logger.config("OpenVR initialized & VR connected.");
vrsystemFunctions.setAutoSynch(false);
vrsystemFunctions.read();
tlastVsync = new FloatByReference();
_tframeCount = new LongByReference();
hmdDisplayFrequency = IntBuffer.allocate(1);
hmdDisplayFrequency.put((int) JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float);
hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference();
hmdTrackedDevicePoses = (TrackedDevicePose_t[]) hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount);
poseMatrices = new Matrix4f[JOpenVRLibrary.k_unMaxTrackedDeviceCount];
for (int i = 0; i < poseMatrices.length; i++) poseMatrices[i] = new Matrix4f();
timePerFrame = 1.0 / hmdDisplayFrequency.get(0);
// disable all this stuff which kills performance
hmdTrackedDevicePoseReference.setAutoRead(false);
hmdTrackedDevicePoseReference.setAutoWrite(false);
hmdTrackedDevicePoseReference.setAutoSynch(false);
for (int i = 0; i < JOpenVRLibrary.k_unMaxTrackedDeviceCount; i++) {
hmdTrackedDevicePoses[i].setAutoRead(false);
hmdTrackedDevicePoses[i].setAutoWrite(false);
hmdTrackedDevicePoses[i].setAutoSynch(false);
}
// init controllers for the first time
VRinput = new OpenVRInput(environment);
VRinput.init();
VRinput.updateConnectedControllers();
// init bounds & chaperone info
VRBounds.init();
logger.config("Initializing OpenVR system [SUCCESS]");
initSuccess = true;
return true;
}
}
Aggregations