added functionality to use front mounted vive camera
This commit is contained in:
parent
54061124a9
commit
ae7a134f1e
@ -18,6 +18,7 @@ import com.jme3.system.jopenvr.OpenVRUtil;
|
|||||||
import com.jme3.system.jopenvr.TrackedDevicePose_t;
|
import com.jme3.system.jopenvr.TrackedDevicePose_t;
|
||||||
import com.jme3.system.jopenvr.VR_IVRCompositor_FnTable;
|
import com.jme3.system.jopenvr.VR_IVRCompositor_FnTable;
|
||||||
import com.jme3.system.jopenvr.VR_IVRSystem_FnTable;
|
import com.jme3.system.jopenvr.VR_IVRSystem_FnTable;
|
||||||
|
import com.jme3.system.jopenvr.VR_IVRTrackedCamera_FnTable;
|
||||||
import com.jme3.util.VRUtil;
|
import com.jme3.util.VRUtil;
|
||||||
import com.sun.jna.Memory;
|
import com.sun.jna.Memory;
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Pointer;
|
||||||
@ -41,19 +42,20 @@ public class OpenVR implements VRAPI {
|
|||||||
private static final Logger logger = Logger.getLogger(OpenVR.class.getName());
|
private static final Logger logger = Logger.getLogger(OpenVR.class.getName());
|
||||||
|
|
||||||
private static VR_IVRCompositor_FnTable compositorFunctions;
|
private static VR_IVRCompositor_FnTable compositorFunctions;
|
||||||
|
private static VR_IVRTrackedCamera_FnTable cameraFunctions;
|
||||||
private static VR_IVRSystem_FnTable vrsystemFunctions;
|
private static VR_IVRSystem_FnTable vrsystemFunctions;
|
||||||
|
|
||||||
private static boolean initSuccess = false;
|
private static boolean initSuccess = false;
|
||||||
private static boolean flipEyes = false;
|
private static boolean flipEyes = false;
|
||||||
|
|
||||||
private IntBuffer hmdDisplayFrequency;
|
private static IntBuffer hmdDisplayFrequency;
|
||||||
private TrackedDevicePose_t.ByReference hmdTrackedDevicePoseReference;
|
private static TrackedDevicePose_t.ByReference hmdTrackedDevicePoseReference;
|
||||||
protected TrackedDevicePose_t[] hmdTrackedDevicePoses;
|
protected static TrackedDevicePose_t[] hmdTrackedDevicePoses;
|
||||||
|
|
||||||
protected IntByReference hmdErrorStore;
|
protected static IntByReference hmdErrorStore;
|
||||||
|
|
||||||
private final Quaternion rotStore = new Quaternion();
|
private static final Quaternion rotStore = new Quaternion();
|
||||||
private final Vector3f posStore = new Vector3f();
|
private static final Vector3f posStore = new Vector3f();
|
||||||
|
|
||||||
private static FloatByReference tlastVsync;
|
private static FloatByReference tlastVsync;
|
||||||
|
|
||||||
@ -65,21 +67,20 @@ public class OpenVR implements VRAPI {
|
|||||||
// for debugging latency
|
// for debugging latency
|
||||||
private int frames = 0;
|
private int frames = 0;
|
||||||
|
|
||||||
protected Matrix4f[] poseMatrices;
|
protected static Matrix4f[] poseMatrices;
|
||||||
|
|
||||||
private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone();
|
private static final Matrix4f hmdPose = Matrix4f.IDENTITY.clone();
|
||||||
private Matrix4f hmdProjectionLeftEye;
|
private static Matrix4f hmdProjectionLeftEye;
|
||||||
private Matrix4f hmdProjectionRightEye;
|
private static Matrix4f hmdProjectionRightEye;
|
||||||
private Matrix4f hmdPoseLeftEye;
|
private static Matrix4f hmdPoseLeftEye;
|
||||||
private Matrix4f hmdPoseRightEye;
|
private static Matrix4f hmdPoseRightEye;
|
||||||
|
|
||||||
private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand;
|
private static Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand;
|
||||||
|
|
||||||
private float vsyncToPhotons;
|
|
||||||
private double timePerFrame, frameCountRun;
|
|
||||||
private long frameCount;
|
|
||||||
private OpenVRInput VRinput;
|
|
||||||
|
|
||||||
|
private static float vsyncToPhotons;
|
||||||
|
private static double timePerFrame, frameCountRun;
|
||||||
|
private static long frameCount;
|
||||||
|
private static OpenVRInput VRinput;
|
||||||
|
|
||||||
private VREnvironment environment = null;
|
private VREnvironment environment = null;
|
||||||
|
|
||||||
@ -107,6 +108,10 @@ public class OpenVR implements VRAPI {
|
|||||||
return compositorFunctions;
|
return compositorFunctions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VR_IVRTrackedCamera_FnTable getTrackedCamera(){
|
||||||
|
return cameraFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "OpenVR";
|
return "OpenVR";
|
||||||
@ -236,6 +241,21 @@ public class OpenVR implements VRAPI {
|
|||||||
return compositorFunctions != null;
|
return compositorFunctions != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initCamera(boolean allowed) {
|
||||||
|
hmdErrorStore.setValue(0); // clear the error store
|
||||||
|
if( allowed && vrsystemFunctions != null ) {
|
||||||
|
IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRTrackedCamera_Version, hmdErrorStore);
|
||||||
|
if (intptr != null){
|
||||||
|
cameraFunctions = new VR_IVRTrackedCamera_FnTable(intptr.getPointer());
|
||||||
|
if(cameraFunctions != null && hmdErrorStore.getValue() == 0 ){
|
||||||
|
cameraFunctions.setAutoSynch(false);
|
||||||
|
cameraFunctions.read();
|
||||||
|
logger.config("OpenVR Camera initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
JOpenVRLibrary.VR_ShutdownInternal();
|
JOpenVRLibrary.VR_ShutdownInternal();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user