commit
a8b2ad0869
@ -0,0 +1,459 @@ |
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import com.jme3.app.VREnvironment; |
||||
import com.jme3.input.vr.HmdType; |
||||
import com.jme3.input.vr.VRAPI; |
||||
import com.jme3.math.Matrix4f; |
||||
import com.jme3.math.Quaternion; |
||||
import com.jme3.math.Vector2f; |
||||
import com.jme3.math.Vector3f; |
||||
import com.jme3.renderer.Camera; |
||||
import com.jme3.util.VRUtil; |
||||
|
||||
import java.nio.IntBuffer; |
||||
import java.util.Locale; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
import org.lwjgl.BufferUtils; |
||||
import org.lwjgl.openvr.HmdMatrix34; |
||||
import org.lwjgl.openvr.HmdMatrix44; |
||||
import org.lwjgl.openvr.TrackedDevicePose; |
||||
import org.lwjgl.openvr.VR; |
||||
import org.lwjgl.openvr.VRCompositor; |
||||
import org.lwjgl.openvr.VRSystem; |
||||
|
||||
/** |
||||
* A class that wraps an <a href="https://github.com/ValveSoftware/openvr/wiki/API-Documentation">OpenVR</a> system. |
||||
* @author reden - phr00t |
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
* @author Rickard Edén |
||||
*/ |
||||
public class LWJGLOpenVR implements VRAPI { |
||||
|
||||
private static final Logger logger = Logger.getLogger(LWJGLOpenVR.class.getName()); |
||||
|
||||
private static boolean initSuccess = false; |
||||
private static boolean flipEyes = false; |
||||
|
||||
private IntBuffer hmdDisplayFrequency; |
||||
private TrackedDevicePose.Buffer trackedDevicePose; |
||||
protected TrackedDevicePose[] hmdTrackedDevicePoses; |
||||
|
||||
protected IntBuffer hmdErrorStore = BufferUtils.createIntBuffer(1); |
||||
|
||||
private final Quaternion rotStore = new Quaternion(); |
||||
private final Vector3f posStore = new Vector3f(); |
||||
|
||||
// for debugging latency
|
||||
private int frames = 0; |
||||
|
||||
protected Matrix4f[] poseMatrices; |
||||
|
||||
private final Matrix4f hmdPose = Matrix4f.IDENTITY.clone(); |
||||
private Matrix4f hmdProjectionLeftEye; |
||||
private Matrix4f hmdProjectionRightEye; |
||||
private Matrix4f hmdPoseLeftEye; |
||||
private Matrix4f hmdPoseRightEye; |
||||
|
||||
private Vector3f hmdPoseLeftEyeVec, hmdPoseRightEyeVec, hmdSeatToStand; |
||||
|
||||
private float vsyncToPhotons; |
||||
private double timePerFrame, frameCountRun; |
||||
private long frameCount; |
||||
private LWJGLOpenVRInput VRinput; |
||||
|
||||
|
||||
private VREnvironment environment = null; |
||||
|
||||
|
||||
/** |
||||
* Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34} into JME {@link Matrix4f Matrix4f} |
||||
* @param hmdMatrix the input matrix |
||||
* @param mat the converted matrix |
||||
* @return the converted matrix |
||||
*/ |
||||
public static Matrix4f convertSteamVRMatrix3ToMatrix4f(org.lwjgl.openvr.HmdMatrix34 hmdMatrix, Matrix4f mat){ |
||||
mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), |
||||
hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), |
||||
hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), |
||||
0f, 0f, 0f, 1f); |
||||
return mat; |
||||
} |
||||
|
||||
/** |
||||
* Convert specific OpenVR {@link org.lwjgl.openvr.HmdMatrix34 HmdMatrix34_t} into JME {@link Matrix4f Matrix4f} |
||||
* @param hmdMatrix the input matrix |
||||
* @param mat the converted matrix |
||||
* @return the converted matrix |
||||
*/ |
||||
public static Matrix4f convertSteamVRMatrix4ToMatrix4f(org.lwjgl.openvr.HmdMatrix44 hmdMatrix, Matrix4f mat){ |
||||
mat.set(hmdMatrix.m(0), hmdMatrix.m(1), hmdMatrix.m(2), hmdMatrix.m(3), |
||||
hmdMatrix.m(4), hmdMatrix.m(5), hmdMatrix.m(6), hmdMatrix.m(7), |
||||
hmdMatrix.m(8), hmdMatrix.m(9), hmdMatrix.m(10), hmdMatrix.m(11), |
||||
hmdMatrix.m(12), hmdMatrix.m(13), hmdMatrix.m(14), hmdMatrix.m(15)); |
||||
return mat; |
||||
} |
||||
|
||||
/** |
||||
* Create a new <a href="https://github.com/ValveSoftware/openvr/wiki/API-Documentation">OpenVR</a> system |
||||
* attached to the given {@link VREnvironment VR environment}. |
||||
* @param environment the VR environment to which this API is attached. |
||||
*/ |
||||
public LWJGLOpenVR(VREnvironment environment){ |
||||
this.environment = environment; |
||||
} |
||||
|
||||
@Override |
||||
public LWJGLOpenVRInput getVRinput() { |
||||
return VRinput; |
||||
} |
||||
|
||||
@Override |
||||
public Object getVRSystem() { |
||||
throw new UnsupportedOperationException("Not yet implemented!"); |
||||
} |
||||
|
||||
@Override |
||||
public Object getCompositor() { |
||||
throw new UnsupportedOperationException("Not yet implemented!"); |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return "OpenVR/LWJGL"; |
||||
} |
||||
|
||||
private static long latencyWaitTime = 0; |
||||
|
||||
@Override |
||||
public void setFlipEyes(boolean set) { |
||||
flipEyes = set; |
||||
} |
||||
|
||||
private boolean enableDebugLatency = false; |
||||
|
||||
@Override |
||||
public void printLatencyInfoToConsole(boolean set) { |
||||
enableDebugLatency = set; |
||||
} |
||||
|
||||
@Override |
||||
public int getDisplayFrequency() { |
||||
if( hmdDisplayFrequency == null ) return 0; |
||||
return hmdDisplayFrequency.get(0); |
||||
} |
||||
|
||||
@Override |
||||
public boolean initialize() { |
||||
|
||||
logger.config("Initializing OpenVR system..."); |
||||
|
||||
// Init the native linking to the OpenVR library.
|
||||
|
||||
int result = VR.VR_InitInternal(hmdErrorStore, VR.EVRApplicationType_VRApplication_Scene); |
||||
|
||||
if(hmdErrorStore.get(0) != VR.EVRInitError_VRInitError_None) { |
||||
logger.severe("OpenVR Initialize Result: " + VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))); |
||||
logger.severe("Initializing OpenVR system [FAILED]"); |
||||
return false; |
||||
} else { |
||||
logger.config("OpenVR initialized & VR connected."); |
||||
org.lwjgl.openvr.OpenVR.create(result); |
||||
logger.info("Model Number : " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( |
||||
VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_ModelNumber_String, hmdErrorStore)); |
||||
logger.info("Serial Number: " + VRSystem.VRSystem_GetStringTrackedDeviceProperty( |
||||
VR.k_unTrackedDeviceIndex_Hmd, VR.ETrackedDeviceProperty_Prop_SerialNumber_String, hmdErrorStore)); |
||||
|
||||
hmdDisplayFrequency = BufferUtils.createIntBuffer(1); |
||||
hmdDisplayFrequency.put( (int) VR.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); |
||||
|
||||
trackedDevicePose = TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); |
||||
hmdTrackedDevicePoses = new TrackedDevicePose[VR.k_unMaxTrackedDeviceCount]; |
||||
poseMatrices = new Matrix4f[VR.k_unMaxTrackedDeviceCount]; |
||||
for(int i=0;i<poseMatrices.length;i++){ |
||||
poseMatrices[i] = new Matrix4f(); |
||||
hmdTrackedDevicePoses[i] = trackedDevicePose.get(i); |
||||
} |
||||
timePerFrame = 1.0 / hmdDisplayFrequency.get(0); |
||||
TrackedDevicePose.create(VR.k_unMaxTrackedDeviceCount); |
||||
// init controllers for the first time
|
||||
VRinput = new LWJGLOpenVRInput(environment); |
||||
VRinput.init(); |
||||
VRinput.updateConnectedControllers(); |
||||
|
||||
// init bounds & chaperone info
|
||||
LWJGLOpenVRBounds bounds = new LWJGLOpenVRBounds(); |
||||
// bounds.init(this);
|
||||
environment.setVRBounds(bounds); |
||||
VRCompositor.VRCompositor_SetExplicitTimingMode(VR.EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff); |
||||
logger.info("Initializing OpenVR system [SUCCESS]"); |
||||
initSuccess = true; |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean initVRCompositor(boolean allowed) { |
||||
hmdErrorStore.put(0, VR.EVRInitError_VRInitError_None); // clear the error store
|
||||
if( allowed) { |
||||
long result = VR.VR_GetGenericInterface(VR.IVRCompositor_Version, hmdErrorStore); |
||||
if (result > 0){ |
||||
if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None){ |
||||
setTrackingSpace(environment.isSeatedExperience() ); |
||||
logger.config("OpenVR Compositor initialized"); |
||||
} else { |
||||
logger.severe("OpenVR Compositor error: " + hmdErrorStore.get(0)); |
||||
} |
||||
} else { |
||||
logger.log(Level.SEVERE, "Cannot get generic interface for \""+VR.IVRCompositor_Version+"\", "+VR.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0))+" ("+hmdErrorStore.get(0)+")"); |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Initialize the headset camera. |
||||
* @param allowed <code>true</code> is the use of the headset camera is allowed and <code>false</code> otherwise. |
||||
* @return token for camera |
||||
*/ |
||||
public long initCamera(boolean allowed) { |
||||
hmdErrorStore.put(0, VR.EVRInitError_VRInitError_None); // clear the error store
|
||||
if( allowed) { |
||||
|
||||
long result = VR.VR_GetGenericInterface(VR.IVRTrackedCamera_Version, hmdErrorStore); |
||||
if (result > 0){ |
||||
if(hmdErrorStore.get(0) == VR.EVRInitError_VRInitError_None ){ |
||||
logger.config("OpenVR Camera initialized"); |
||||
} |
||||
return result; |
||||
} else { |
||||
logger.severe("Failed to initialize camera"); |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void destroy() { |
||||
VR.VR_ShutdownInternal(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isInitialized() { |
||||
return initSuccess; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
VRSystem.VRSystem_ResetSeatedZeroPose(); |
||||
hmdSeatToStand = null; |
||||
} |
||||
|
||||
@Override |
||||
public void getRenderSize(Vector2f store) { |
||||
IntBuffer w = BufferUtils.createIntBuffer(1); |
||||
IntBuffer h = BufferUtils.createIntBuffer(1); |
||||
VRSystem.VRSystem_GetRecommendedRenderTargetSize(w, h); |
||||
logger.config("Recommended render width : " + w.get(0)); |
||||
logger.config("Recommended render height: " + h.get(0)); |
||||
store.x = w.get(0); |
||||
store.y = h.get(0); |
||||
} |
||||
|
||||
@Override |
||||
public float getInterpupillaryDistance() { |
||||
throw new UnsupportedOperationException("Not yet implemented!"); |
||||
} |
||||
|
||||
@Override |
||||
public Quaternion getOrientation() { |
||||
VRUtil.convertMatrix4toQuat(hmdPose, rotStore); |
||||
return rotStore; |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getPosition() { |
||||
// the hmdPose comes in rotated funny, fix that here
|
||||
hmdPose.toTranslationVector(posStore); |
||||
posStore.x = -posStore.x; |
||||
posStore.z = -posStore.z; |
||||
return posStore; |
||||
} |
||||
|
||||
@Override |
||||
public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot) { |
||||
hmdPose.toTranslationVector(storePos); |
||||
storePos.x = -storePos.x; |
||||
storePos.z = -storePos.z; |
||||
storeRot.set(getOrientation()); |
||||
} |
||||
|
||||
@Override |
||||
public void updatePose(){ |
||||
int result = VRCompositor.nVRCompositor_WaitGetPoses(trackedDevicePose.address(), trackedDevicePose.remaining(), 0, 0); |
||||
// NPE when calling without a gamePoseArray. Issue filed with lwjgl #418
|
||||
// int result = VRCompositor.VRCompositor_WaitGetPoses(trackedDevicePose, null);
|
||||
environment.getVRinput().updateControllerStates(); |
||||
|
||||
// read pose data from native
|
||||
for (int nDevice = 0; nDevice < VR.k_unMaxTrackedDeviceCount; ++nDevice ){ |
||||
if( hmdTrackedDevicePoses[nDevice].bPoseIsValid() ){ |
||||
convertSteamVRMatrix3ToMatrix4f(hmdTrackedDevicePoses[nDevice].mDeviceToAbsoluteTracking(), poseMatrices[nDevice]); |
||||
} |
||||
} |
||||
|
||||
if ( hmdTrackedDevicePoses[VR.k_unTrackedDeviceIndex_Hmd].bPoseIsValid()){ |
||||
hmdPose.set(poseMatrices[VR.k_unTrackedDeviceIndex_Hmd]); |
||||
} else { |
||||
hmdPose.set(Matrix4f.IDENTITY); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam){ |
||||
if( hmdProjectionLeftEye != null ) { |
||||
return hmdProjectionLeftEye; |
||||
} else { |
||||
HmdMatrix44 mat = HmdMatrix44.create(); |
||||
mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Left, cam.getFrustumNear(), cam.getFrustumFar(), mat); |
||||
hmdProjectionLeftEye = new Matrix4f(); |
||||
convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionLeftEye); |
||||
return hmdProjectionLeftEye; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Matrix4f getHMDMatrixProjectionRightEye(Camera cam){ |
||||
if( hmdProjectionRightEye != null ) { |
||||
return hmdProjectionRightEye; |
||||
} else { |
||||
HmdMatrix44 mat = HmdMatrix44.create(); |
||||
mat = VRSystem.VRSystem_GetProjectionMatrix(VR.EVREye_Eye_Right, cam.getFrustumNear(), cam.getFrustumFar(), mat); |
||||
hmdProjectionRightEye = new Matrix4f(); |
||||
convertSteamVRMatrix4ToMatrix4f(mat, hmdProjectionRightEye); |
||||
return hmdProjectionRightEye; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getHMDVectorPoseLeftEye() { |
||||
if( hmdPoseLeftEyeVec == null ) { |
||||
hmdPoseLeftEyeVec = getHMDMatrixPoseLeftEye().toTranslationVector(); |
||||
// set default IPD if none or broken
|
||||
if( hmdPoseLeftEyeVec.x <= 0.080f * -0.5f || hmdPoseLeftEyeVec.x >= 0.040f * -0.5f ) { |
||||
hmdPoseLeftEyeVec.x = 0.065f * -0.5f; |
||||
} |
||||
if( flipEyes == false ) hmdPoseLeftEyeVec.x *= -1f; // it seems these need flipping
|
||||
} |
||||
return hmdPoseLeftEyeVec; |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getHMDVectorPoseRightEye() { |
||||
if( hmdPoseRightEyeVec == null ) { |
||||
hmdPoseRightEyeVec = getHMDMatrixPoseRightEye().toTranslationVector(); |
||||
// set default IPD if none or broken
|
||||
if( hmdPoseRightEyeVec.x >= 0.080f * 0.5f || hmdPoseRightEyeVec.x <= 0.040f * 0.5f ) { |
||||
hmdPoseRightEyeVec.x = 0.065f * 0.5f; |
||||
} |
||||
if( flipEyes == false ) hmdPoseRightEyeVec.x *= -1f; // it seems these need flipping
|
||||
} |
||||
return hmdPoseRightEyeVec; |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getSeatedToAbsolutePosition() { |
||||
if( environment.isSeatedExperience() == false ) return Vector3f.ZERO; |
||||
if( hmdSeatToStand == null ) { |
||||
hmdSeatToStand = new Vector3f(); |
||||
|
||||
HmdMatrix34 mat = HmdMatrix34.create(); |
||||
VRSystem.VRSystem_GetSeatedZeroPoseToStandingAbsoluteTrackingPose(mat); |
||||
Matrix4f tempmat = new Matrix4f(); |
||||
convertSteamVRMatrix3ToMatrix4f(mat, tempmat); |
||||
tempmat.toTranslationVector(hmdSeatToStand); |
||||
} |
||||
return hmdSeatToStand; |
||||
} |
||||
|
||||
@Override |
||||
public Matrix4f getHMDMatrixPoseLeftEye(){ |
||||
if( hmdPoseLeftEye != null ) { |
||||
return hmdPoseLeftEye; |
||||
} else { |
||||
HmdMatrix34 mat = HmdMatrix34.create(); |
||||
VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Left, mat); |
||||
hmdPoseLeftEye = new Matrix4f(); |
||||
return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseLeftEye); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public Matrix4f getHMDMatrixPoseRightEye(){ |
||||
if( hmdPoseRightEye != null ) { |
||||
return hmdPoseRightEye; |
||||
} else { |
||||
HmdMatrix34 mat = HmdMatrix34.create(); |
||||
VRSystem.VRSystem_GetEyeToHeadTransform(VR.EVREye_Eye_Right, mat); |
||||
hmdPoseRightEye = new Matrix4f(); |
||||
return convertSteamVRMatrix3ToMatrix4f(mat, hmdPoseRightEye); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HmdType getType() { |
||||
String completeName = ""; |
||||
String name = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, |
||||
VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, |
||||
128, hmdErrorStore); |
||||
if( hmdErrorStore.get(0) == 0 ) completeName += name; |
||||
String number = VRSystem.VRSystem_GetStringTrackedDeviceProperty(VR.k_unTrackedDeviceIndex_Hmd, |
||||
VR.ETrackedDeviceProperty_Prop_ModelNumber_String, |
||||
128, hmdErrorStore); |
||||
if( hmdErrorStore.get(0) == 0 ) completeName += " " + number; |
||||
if( completeName.length() > 0 ) { |
||||
completeName = completeName.toLowerCase(Locale.ENGLISH).trim(); |
||||
if( completeName.contains("htc") || completeName.contains("vive") ) { |
||||
return HmdType.HTC_VIVE; |
||||
} else if( completeName.contains("osvr") ) { |
||||
return HmdType.OSVR; |
||||
} else if( completeName.contains("oculus") || completeName.contains("rift") || |
||||
completeName.contains("dk1") || completeName.contains("dk2") || completeName.contains("cv1") ) { |
||||
return HmdType.OCULUS_RIFT; |
||||
} else if( completeName.contains("fove") ) { |
||||
return HmdType.FOVE; |
||||
} else if( completeName.contains("game") && completeName.contains("face") ) { |
||||
return HmdType.GAMEFACE; |
||||
} else if( completeName.contains("morpheus") ) { |
||||
return HmdType.MORPHEUS; |
||||
} else if( completeName.contains("gear") ) { |
||||
return HmdType.GEARVR; |
||||
} else if( completeName.contains("star") ) { |
||||
return HmdType.STARVR; |
||||
} else if( completeName.contains("null") ) { |
||||
return HmdType.NULL; |
||||
} |
||||
} |
||||
return HmdType.OTHER; |
||||
} |
||||
|
||||
public void setTrackingSpace(boolean isSeated){ |
||||
if( isSeated) { |
||||
VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseSeated); |
||||
} else { |
||||
VRCompositor.VRCompositor_SetTrackingSpace(VR.ETrackingUniverseOrigin_TrackingUniverseStanding); |
||||
} |
||||
} |
||||
|
||||
|
||||
public Matrix4f[] getPoseMatrices() { |
||||
return poseMatrices; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import com.jme3.input.vr.VRAPI; |
||||
import com.jme3.input.vr.VRBounds; |
||||
import com.jme3.math.Vector2f; |
||||
import com.jme3.util.BufferUtils; |
||||
import java.nio.FloatBuffer; |
||||
|
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* A class that represents VR world bounds. |
||||
* @author reden - phr00t - https://github.com/phr00t
|
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
* @author Rickard Edén |
||||
*/ |
||||
public class LWJGLOpenVRBounds implements VRBounds { |
||||
|
||||
private static Logger logger = Logger.getLogger(LWJGLOpenVRBounds.class.getName()); |
||||
|
||||
private Vector2f playSize; |
||||
private boolean setup = false; |
||||
|
||||
/** |
||||
* Initialize the VR bounds. |
||||
* @return <code>true</code> if the initialization is a success and <code>false</code> otherwise. |
||||
*/ |
||||
public boolean init(VRAPI api) { |
||||
|
||||
logger.config("Initialize VR bounds..."); |
||||
|
||||
if( !setup ) { |
||||
// vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer());
|
||||
FloatBuffer fbX = BufferUtils.createFloatBuffer(1); |
||||
FloatBuffer fbZ = BufferUtils.createFloatBuffer(1); |
||||
org.lwjgl.openvr.VRChaperone.VRChaperone_GetPlayAreaSize(fbX, fbZ); |
||||
|
||||
playSize = new Vector2f(fbX.get(0), fbZ.get(0)); |
||||
setup = true; |
||||
logger.config("Initialize VR bounds [SUCCESS]"); |
||||
return true; // init success
|
||||
} |
||||
|
||||
logger.config("Initialize VR bounds already done."); |
||||
return true; // already initialized
|
||||
} |
||||
|
||||
@Override |
||||
public Vector2f getPlaySize() { |
||||
return playSize; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,498 @@ |
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.logging.Logger; |
||||
|
||||
import com.jme3.app.VREnvironment; |
||||
import com.jme3.input.vr.VRInputAPI; |
||||
import com.jme3.input.vr.VRInputType; |
||||
import com.jme3.input.vr.VRTrackedController; |
||||
import com.jme3.input.vr.VRViewManager; |
||||
import com.jme3.math.Quaternion; |
||||
import com.jme3.math.Vector2f; |
||||
import com.jme3.math.Vector3f; |
||||
import com.jme3.renderer.Camera; |
||||
import com.jme3.scene.Spatial; |
||||
import com.jme3.util.VRUtil; |
||||
import java.nio.IntBuffer; |
||||
import org.lwjgl.BufferUtils; |
||||
import org.lwjgl.openvr.HmdVector3; |
||||
import org.lwjgl.openvr.VR; |
||||
import org.lwjgl.openvr.VRControllerState; |
||||
import org.lwjgl.openvr.VRSystem; |
||||
|
||||
/* |
||||
make helper functions to pull the following easily from raw data (DONE) |
||||
trigger: |
||||
Controller#1, Axis#0 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#1 X: 1.0, Y: 0.0 |
||||
Controller#1, Axis#2 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#3 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#4 X: 0.0, Y: 0.0 |
||||
Button press: 8589934592 (when full), touch: 8589934592 |
||||
touchpad (upper left): |
||||
Controller#1, Axis#0 X: -0.6059755, Y: 0.2301706 |
||||
Controller#1, Axis#1 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#2 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#3 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#4 X: 0.0, Y: 0.0 |
||||
Button press: 4294967296 (when pressed in), touch: 4294967296 |
||||
grip: |
||||
Controller#1, Axis#0 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#1 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#2 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#3 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#4 X: 0.0, Y: 0.0 |
||||
Button press: 4, touch: 4 |
||||
thumb: |
||||
Controller#1, Axis#0 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#1 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#2 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#3 X: 0.0, Y: 0.0 |
||||
Controller#1, Axis#4 X: 0.0, Y: 0.0 |
||||
Button press: 2, touch: 2 |
||||
*/ |
||||
/** |
||||
* A class that wraps an |
||||
* <a href="https://github.com/ValveSoftware/openvr/wiki/API-Documentation">OpenVR</a> |
||||
* input.<br> |
||||
* <code>null</code> values will be returned if no valid pose exists, or that |
||||
* input device isn't available user code should check for <code>null</code> |
||||
* values. |
||||
* |
||||
* @author reden - phr00t |
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
* @author Rickard Edén |
||||
*/ |
||||
public class LWJGLOpenVRInput implements VRInputAPI { |
||||
|
||||
private static final Logger logger = Logger.getLogger(LWJGLOpenVRInput.class.getName()); |
||||
|
||||
private final VRControllerState[] cStates = new VRControllerState[VR.k_unMaxTrackedDeviceCount]; |
||||
|
||||
private final Quaternion[] rotStore = new Quaternion[VR.k_unMaxTrackedDeviceCount]; |
||||
|
||||
private final Vector3f[] posStore = new Vector3f[VR.k_unMaxTrackedDeviceCount]; |
||||
|
||||
private static final int[] controllerIndex = new int[VR.k_unMaxTrackedDeviceCount]; |
||||
|
||||
private int controllerCount = 0; |
||||
|
||||
private final Vector2f tempAxis = new Vector2f(), temp2Axis = new Vector2f(); |
||||
|
||||
private final Vector2f lastCallAxis[] = new Vector2f[VR.k_unMaxTrackedDeviceCount]; |
||||
|
||||
private final boolean buttonDown[][] = new boolean[VR.k_unMaxTrackedDeviceCount][16]; |
||||
|
||||
private float axisMultiplier = 1f; |
||||
|
||||
private final Vector3f tempVel = new Vector3f(); |
||||
|
||||
private final Quaternion tempq = new Quaternion(); |
||||
|
||||
private final VREnvironment environment; |
||||
|
||||
private List<VRTrackedController> trackedControllers = null; |
||||
|
||||
/** |
||||
* Create a new |
||||
* <a href="https://github.com/ValveSoftware/openvr/wiki/API-Documentation">OpenVR</a> |
||||
* input attached to the given VR environment. |
||||
* |
||||
* @param environment the VR environment to which the input is attached. |
||||
*/ |
||||
public LWJGLOpenVRInput(VREnvironment environment) { |
||||
this.environment = environment; |
||||
} |
||||
|
||||
@Override |
||||
public float getAxisMultiplier() { |
||||
return axisMultiplier; |
||||
} |
||||
|
||||
@Override |
||||
public void setAxisMultiplier(float set) { |
||||
axisMultiplier = set; |
||||
} |
||||
|
||||
@Override |
||||
public void swapHands() { |
||||
if (controllerCount != 2) { |
||||
return; |
||||
} |
||||
int temp = controllerIndex[0]; |
||||
controllerIndex[0] = controllerIndex[1]; |
||||
controllerIndex[1] = temp; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isButtonDown(int controllerIndex, VRInputType checkButton) { |
||||
VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; |
||||
switch (checkButton) { |
||||
default: |
||||
return false; |
||||
case ViveGripButton: |
||||
return (cs.ulButtonPressed() & 4) != 0; |
||||
case ViveMenuButton: |
||||
return (cs.ulButtonPressed() & 2) != 0; |
||||
case ViveTrackpadAxis: |
||||
return (cs.ulButtonPressed() & 4294967296l) != 0; |
||||
case ViveTriggerAxis: |
||||
return (cs.ulButtonPressed() & 8589934592l) != 0; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean wasButtonPressedSinceLastCall(int controllerIndex, VRInputType checkButton) { |
||||
boolean buttonDownNow = isButtonDown(controllerIndex, checkButton); |
||||
int checkButtonValue = checkButton.getValue(); |
||||
int cIndex = LWJGLOpenVRInput.controllerIndex[controllerIndex]; |
||||
boolean retval = buttonDownNow == true && buttonDown[cIndex][checkButtonValue] == false; |
||||
buttonDown[cIndex][checkButtonValue] = buttonDownNow; |
||||
return retval; |
||||
} |
||||
|
||||
@Override |
||||
public void resetInputSinceLastCall() { |
||||
for (int i = 0; i < lastCallAxis.length; i++) { |
||||
lastCallAxis[i].x = 0f; |
||||
lastCallAxis[i].y = 0f; |
||||
} |
||||
for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { |
||||
for (int j = 0; j < 16; j++) { |
||||
buttonDown[i][j] = false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Vector2f getAxisDeltaSinceLastCall(int controllerIndex, VRInputType forAxis) { |
||||
int axisIndex = forAxis.getValue(); |
||||
temp2Axis.set(lastCallAxis[axisIndex]); |
||||
lastCallAxis[axisIndex].set(getAxis(controllerIndex, forAxis)); |
||||
if ((temp2Axis.x != 0f || temp2Axis.y != 0f) && (lastCallAxis[axisIndex].x != 0f || lastCallAxis[axisIndex].y != 0f)) { |
||||
temp2Axis.subtractLocal(lastCallAxis[axisIndex]); |
||||
} else { |
||||
// move made from rest, don't count as a delta move
|
||||
temp2Axis.x = 0f; |
||||
temp2Axis.y = 0f; |
||||
} |
||||
return temp2Axis; |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getVelocity(int controllerIndex) { |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; |
||||
// if( needsNewVelocity[index] ) {
|
||||
HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity(); |
||||
// needsNewVelocity[index] = false;
|
||||
// }
|
||||
tempVel.x = tempVec.v(0); |
||||
tempVel.y = tempVec.v(1); |
||||
tempVel.z = tempVec.v(2); |
||||
return tempVel; |
||||
} else { |
||||
throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getAngularVelocity(int controllerIndex) { |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
|
||||
int index = LWJGLOpenVRInput.controllerIndex[controllerIndex]; |
||||
HmdVector3 tempVec = ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity(); |
||||
// needsNewVelocity[index] = false;
|
||||
// }
|
||||
tempVel.x = tempVec.v(0); |
||||
tempVel.y = tempVec.v(1); |
||||
tempVel.z = tempVec.v(2); |
||||
return tempVel; |
||||
} else { |
||||
throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Vector2f getAxisRaw(int controllerIndex, VRInputType forAxis) { |
||||
VRControllerState cs = cStates[LWJGLOpenVRInput.controllerIndex[controllerIndex]]; |
||||
switch (forAxis) { |
||||
default: |
||||
return null; |
||||
case ViveTriggerAxis: |
||||
tempAxis.x = cs.rAxis(1).x(); |
||||
tempAxis.y = tempAxis.x; |
||||
break; |
||||
case ViveTrackpadAxis: |
||||
tempAxis.x = cs.rAxis(0).x(); |
||||
tempAxis.y = cs.rAxis(0).y(); |
||||
break; |
||||
} |
||||
return tempAxis; |
||||
} |
||||
|
||||
@Override |
||||
public Vector2f getAxis(int controllerIndex, VRInputType forAxis) { |
||||
getAxisRaw(controllerIndex, forAxis); |
||||
tempAxis.x *= axisMultiplier; |
||||
tempAxis.y *= axisMultiplier; |
||||
return tempAxis; |
||||
} |
||||
|
||||
@Override |
||||
public boolean init() { |
||||
|
||||
logger.config("Initialize OpenVR input."); |
||||
|
||||
for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { |
||||
rotStore[i] = new Quaternion(); |
||||
posStore[i] = new Vector3f(); |
||||
cStates[i] = VRControllerState.create(); |
||||
lastCallAxis[i] = new Vector2f(); |
||||
logger.config(" Input " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " binded."); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public VRTrackedController getTrackedController(int index) { |
||||
if (trackedControllers != null) { |
||||
if ((trackedControllers.size() > 0) && (index < trackedControllers.size())) { |
||||
return trackedControllers.get(index); |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public int getTrackedControllerCount() { |
||||
return controllerCount; |
||||
} |
||||
|
||||
@Override |
||||
public VRControllerState getRawControllerState(int index) { |
||||
if (isInputDeviceTracking(index) == false) { |
||||
return null; |
||||
} |
||||
return cStates[controllerIndex[index]]; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isInputFocused() { |
||||
if (environment != null){ |
||||
// not a 100% match, but the closest i can find in lwjgl. Doc seems to confirm this too.
|
||||
return VRSystem.VRSystem_IsInputAvailable(); |
||||
//return ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).IsInputFocusCapturedByAnotherProcess.apply() == 0;
|
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean isInputDeviceTracking(int index) { |
||||
if (index < 0 || index >= controllerCount) { |
||||
return false; |
||||
} |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
return ((LWJGLOpenVR) environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid(); |
||||
} else { |
||||
throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Quaternion getOrientation(int index) { |
||||
if (isInputDeviceTracking(index) == false) { |
||||
return null; |
||||
} |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
index = controllerIndex[index]; |
||||
VRUtil.convertMatrix4toQuat(((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index], rotStore[index]); |
||||
return rotStore[index]; |
||||
} else { |
||||
throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getPosition(int index) { |
||||
if (isInputDeviceTracking(index) == false) { |
||||
return null; |
||||
} |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
// the hmdPose comes in rotated funny, fix that here
|
||||
index = controllerIndex[index]; |
||||
((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]); |
||||
posStore[index].x = -posStore[index].x; |
||||
posStore[index].z = -posStore[index].z; |
||||
return posStore[index]; |
||||
} else { |
||||
throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Quaternion getFinalObserverRotation(int index) { |
||||
|
||||
if (environment != null) { |
||||
VRViewManager vrvm = environment.getVRViewManager(); |
||||
|
||||
if (vrvm != null) { |
||||
if (isInputDeviceTracking(index) == false) { |
||||
return null; |
||||
} |
||||
|
||||
Object obs = environment.getObserver(); |
||||
if (obs instanceof Camera) { |
||||
tempq.set(((Camera) obs).getRotation()); |
||||
} else { |
||||
tempq.set(((Spatial) obs).getWorldRotation()); |
||||
} |
||||
|
||||
return tempq.multLocal(getOrientation(index)); |
||||
} else { |
||||
throw new IllegalStateException("VR environment has no valid view manager."); |
||||
} |
||||
|
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Vector3f getFinalObserverPosition(int index) { |
||||
|
||||
if (environment != null) { |
||||
VRViewManager vrvm = (VRViewManager) environment.getVRViewManager(); |
||||
|
||||
if (vrvm != null) { |
||||
if (isInputDeviceTracking(index) == false) { |
||||
return null; |
||||
} |
||||
Object obs = environment.getObserver(); |
||||
Vector3f pos = getPosition(index); |
||||
if (obs instanceof Camera) { |
||||
((Camera) obs).getRotation().mult(pos, pos); |
||||
return pos.addLocal(((Camera) obs).getLocation()); |
||||
} else { |
||||
((Spatial) obs).getWorldRotation().mult(pos, pos); |
||||
return pos.addLocal(((Spatial) obs).getWorldTranslation()); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR environment has no valid view manager."); |
||||
} |
||||
|
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void triggerHapticPulse(int controllerIndex, float seconds) { |
||||
if (environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false) { |
||||
return; |
||||
} |
||||
|
||||
// apparently only axis ID of 0 works
|
||||
VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], |
||||
0, (short) Math.round(3f * seconds / 1e-3f)); |
||||
} |
||||
|
||||
@Override |
||||
public void updateConnectedControllers() { |
||||
logger.config("Updating connected controllers."); |
||||
|
||||
if (environment != null) { |
||||
controllerCount = 0; |
||||
for (int i = 0; i < VR.k_unMaxTrackedDeviceCount; i++) { |
||||
int classCallback = VRSystem.VRSystem_GetTrackedDeviceClass(i); |
||||
if (classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == VR.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) { |
||||
IntBuffer error = BufferUtils.createIntBuffer(1); |
||||
String controllerName = "Unknown"; |
||||
String manufacturerName = "Unknown"; |
||||
controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_TrackingSystemName_String, error); |
||||
manufacturerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ManufacturerName_String, error); |
||||
|
||||
if (error.get(0) != 0) { |
||||
logger.warning("Error getting controller information " + controllerName + " " + manufacturerName + "Code (" + error.get(0) + ")"); |
||||
} |
||||
controllerIndex[controllerCount] = i; |
||||
|
||||
// Adding tracked controller to control.
|
||||
if (trackedControllers == null) { |
||||
trackedControllers = new ArrayList<VRTrackedController>(VR.k_unMaxTrackedDeviceCount); |
||||
} |
||||
trackedControllers.add(new LWJGLOpenVRTrackedController(i, this, controllerName, manufacturerName, environment)); |
||||
|
||||
// Send a Haptic pulse to the controller
|
||||
triggerHapticPulse(controllerCount, 1.0f); |
||||
|
||||
controllerCount++; |
||||
logger.config(" Tracked controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " " + controllerName + " (" + manufacturerName + ") attached."); |
||||
} else { |
||||
logger.config(" Controller " + (i + 1) + "/" + VR.k_unMaxTrackedDeviceCount + " ignored."); |
||||
} |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void updateControllerStates() { |
||||
|
||||
if (environment != null) { |
||||
for (int i = 0; i < controllerCount; i++) { |
||||
int index = controllerIndex[i]; |
||||
VRSystem.VRSystem_GetControllerState(index, cStates[index], 64); |
||||
cStates[index].ulButtonPressed(); |
||||
cStates[index].rAxis(); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR input is not attached to a VR environment."); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,114 @@ |
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import com.jme3.app.VREnvironment; |
||||
import com.jme3.input.controls.AnalogListener; |
||||
import com.jme3.input.vr.AbstractVRMouseManager; |
||||
import com.jme3.input.vr.VRInputType; |
||||
import com.jme3.math.Vector2f; |
||||
|
||||
|
||||
/** |
||||
* A class dedicated to the handling of the mouse within VR environment. |
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
*/ |
||||
public class LWJGLOpenVRMouseManager extends AbstractVRMouseManager { |
||||
|
||||
private final int AVERAGE_AMNT = 4; |
||||
|
||||
private int avgCounter; |
||||
|
||||
private final float[] lastXmv = new float[AVERAGE_AMNT]; |
||||
|
||||
private final float[] lastYmv = new float[AVERAGE_AMNT]; |
||||
|
||||
/** |
||||
* Create a new VR mouse manager within the given {@link VREnvironment VR environment}. |
||||
* @param environment the VR environment of the mouse manager. |
||||
*/ |
||||
public LWJGLOpenVRMouseManager(VREnvironment environment){ |
||||
super(environment); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void updateAnalogAsMouse(int inputIndex, AnalogListener mouseListener, String mouseXName, String mouseYName, float tpf) { |
||||
|
||||
if (getVREnvironment() != null){ |
||||
if (getVREnvironment().getApplication() != null){ |
||||
// got a tracked controller to use as the "mouse"
|
||||
if( getVREnvironment().isInVR() == false || |
||||
getVREnvironment().getVRinput() == null || |
||||
getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){ |
||||
return; |
||||
} |
||||
|
||||
Vector2f tpDelta; |
||||
// TODO option to use Touch joysticks
|
||||
if( isThumbstickMode() ) { |
||||
tpDelta = getVREnvironment().getVRinput().getAxis(inputIndex, VRInputType.ViveTrackpadAxis); |
||||
} else { |
||||
tpDelta = getVREnvironment().getVRinput().getAxisDeltaSinceLastCall(inputIndex, VRInputType.ViveTrackpadAxis); |
||||
} |
||||
|
||||
float Xamount = (float)Math.pow(Math.abs(tpDelta.x) * getSpeedSensitivity(), getSpeedAcceleration()); |
||||
float Yamount = (float)Math.pow(Math.abs(tpDelta.y) * getSpeedSensitivity(), getSpeedAcceleration()); |
||||
|
||||
if( tpDelta.x < 0f ){ |
||||
Xamount = -Xamount; |
||||
} |
||||
|
||||
if( tpDelta.y < 0f ){ |
||||
Yamount = -Yamount; |
||||
} |
||||
|
||||
Xamount *= getMouseMoveScale(); |
||||
Yamount *= getMouseMoveScale(); |
||||
|
||||
if( mouseListener != null ) { |
||||
if( tpDelta.x != 0f && mouseXName != null ) mouseListener.onAnalog(mouseXName, Xamount * 0.2f, tpf); |
||||
if( tpDelta.y != 0f && mouseYName != null ) mouseListener.onAnalog(mouseYName, Yamount * 0.2f, tpf); |
||||
} |
||||
|
||||
if( getVREnvironment().getApplication().getInputManager().isCursorVisible() ) { |
||||
int index = (avgCounter+1) % AVERAGE_AMNT; |
||||
lastXmv[index] = Xamount * 133f; |
||||
lastYmv[index] = Yamount * 133f; |
||||
cursorPos.x -= avg(lastXmv); |
||||
cursorPos.y -= avg(lastYmv); |
||||
Vector2f maxsize = getVREnvironment().getVRGUIManager().getCanvasSize(); |
||||
|
||||
if( cursorPos.x > maxsize.x ){ |
||||
cursorPos.x = maxsize.x; |
||||
} |
||||
|
||||
if( cursorPos.x < 0f ){ |
||||
cursorPos.x = 0f; |
||||
} |
||||
|
||||
if( cursorPos.y > maxsize.y ){ |
||||
cursorPos.y = maxsize.y; |
||||
} |
||||
|
||||
if( cursorPos.y < 0f ){ |
||||
cursorPos.y = 0f; |
||||
} |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
private float avg(float[] arr) { |
||||
float amt = 0f; |
||||
for(float f : arr) amt += f; |
||||
return amt / arr.length; |
||||
} |
||||
} |
@ -0,0 +1,100 @@ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import com.jme3.app.VREnvironment; |
||||
import com.jme3.input.vr.VRInputAPI; |
||||
import com.jme3.input.vr.VRTrackedController; |
||||
import com.jme3.math.Matrix4f; |
||||
import com.jme3.math.Quaternion; |
||||
import com.jme3.math.Vector3f; |
||||
|
||||
/** |
||||
* A controller that is tracked within the VR environment. Such a controller can provide its position within the VR space. |
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
* @author Rickard Edén |
||||
*/ |
||||
public class LWJGLOpenVRTrackedController implements VRTrackedController{ |
||||
|
||||
/** |
||||
* The index of the controller within the unserlying VR API. |
||||
*/ |
||||
private int controllerIndex = -1; |
||||
|
||||
/** |
||||
* The underlying VRAPI. |
||||
*/ |
||||
private VRInputAPI hardware = null; |
||||
|
||||
/** |
||||
* The name of the controller. |
||||
*/ |
||||
private String name; |
||||
|
||||
private VREnvironment environment; |
||||
|
||||
/** |
||||
* Wrap a new VR tracked controller on an OpenVR system. |
||||
* @param controllerIndex the index of the controller within the underlying VR system. |
||||
* @param hardware the underlying VR system. |
||||
* @param name the name of the controller. |
||||
* @param manufacturer the manufacturer of the controller. |
||||
* @param environment the VR environment. |
||||
*/ |
||||
public LWJGLOpenVRTrackedController(int controllerIndex, VRInputAPI hardware, String name, String manufacturer, VREnvironment environment){ |
||||
this.controllerIndex = controllerIndex; |
||||
this.hardware = hardware; |
||||
|
||||
this.name = name; |
||||
this.manufacturer = manufacturer; |
||||
|
||||
this.environment = environment; |
||||
} |
||||
|
||||
/** |
||||
* The manufacturer of the controller. |
||||
*/ |
||||
private String manufacturer; |
||||
|
||||
@Override |
||||
public Vector3f getPosition() { |
||||
if (hardware != null){ |
||||
return hardware.getPosition(controllerIndex); |
||||
} else { |
||||
throw new IllegalStateException("No underlying VR API."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Quaternion getOrientation() { |
||||
if (hardware != null){ |
||||
return hardware.getOrientation(controllerIndex); |
||||
} else { |
||||
throw new IllegalStateException("No underlying VR API."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Matrix4f getPose(){ |
||||
|
||||
if (environment != null){ |
||||
if (hardware != null){ |
||||
return ((LWJGLOpenVR)environment.getVRHardware()).getPoseMatrices()[controllerIndex]; |
||||
} else { |
||||
throw new IllegalStateException("No underlying VR API."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("VR tracked device is not attached to any environment."); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getControllerName() { |
||||
return name; |
||||
} |
||||
|
||||
@Override |
||||
public String getControllerManufacturer() { |
||||
return manufacturer; |
||||
} |
||||
} |
@ -0,0 +1,573 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.input.vr.lwjgl_openvr; |
||||
|
||||
import com.jme3.app.VREnvironment; |
||||
import com.jme3.input.vr.AbstractVRViewManager; |
||||
import com.jme3.input.vr.VRAPI; |
||||
import com.jme3.math.ColorRGBA; |
||||
import com.jme3.math.Quaternion; |
||||
import com.jme3.math.Vector2f; |
||||
import com.jme3.math.Vector3f; |
||||
import com.jme3.renderer.Camera; |
||||
import com.jme3.renderer.ViewPort; |
||||
import com.jme3.renderer.queue.RenderQueue.Bucket; |
||||
import com.jme3.scene.Spatial; |
||||
import com.jme3.texture.FrameBuffer; |
||||
import com.jme3.texture.Image; |
||||
import com.jme3.texture.Texture2D; |
||||
import com.jme3.ui.Picture; |
||||
import com.jme3.util.VRGUIPositioningMode; |
||||
|
||||
import java.util.Iterator; |
||||
import java.util.logging.Logger; |
||||
import org.lwjgl.openvr.VRTextureBounds; |
||||
import org.lwjgl.openvr.Texture; |
||||
import org.lwjgl.openvr.VR; |
||||
import org.lwjgl.openvr.VRCompositor; |
||||
|
||||
/** |
||||
* A VR view manager based on OpenVR. This class enable to submit 3D views to |
||||
* the VR compositor. |
||||
* |
||||
* @author reden - phr00t |
||||
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
|
||||
* @author Rickard Edén |
||||
*/ |
||||
public class LWJGLOpenVRViewManager extends AbstractVRViewManager { |
||||
|
||||
private static final Logger logger = Logger.getLogger(LWJGLOpenVRViewManager.class.getName()); |
||||
|
||||
// OpenVR values
|
||||
private VRTextureBounds leftTextureBounds; |
||||
private Texture leftTextureType; |
||||
|
||||
private VRTextureBounds rightTextureBounds; |
||||
private Texture rightTextureType; |
||||
|
||||
private Texture2D dualEyeTex; |
||||
|
||||
//final & temp values for camera calculations
|
||||
private final Vector3f finalPosition = new Vector3f(); |
||||
private final Quaternion finalRotation = new Quaternion(); |
||||
private final Vector3f hmdPos = new Vector3f(); |
||||
private final Quaternion hmdRot = new Quaternion(); |
||||
|
||||
/** |
||||
* Create a new VR view manager attached to the given |
||||
* {@link VREnvironment VR environment}. |
||||
* |
||||
* @param environment the {@link VREnvironment VR environment} to which this |
||||
* view manager is attached. |
||||
*/ |
||||
public LWJGLOpenVRViewManager(VREnvironment environment) { |
||||
this.environment = environment; |
||||
} |
||||
|
||||
/** |
||||
* Get the identifier of the left eye texture. |
||||
* |
||||
* @return the identifier of the left eye texture. |
||||
* @see #getRightTexId() |
||||
* @see #getFullTexId() |
||||
*/ |
||||
protected int getLeftTexId() { |
||||
return (int) getLeftTexture().getImage().getId(); |
||||
} |
||||
|
||||
/** |
||||
* Get the identifier of the right eye texture. |
||||
* |
||||
* @return the identifier of the right eye texture. |
||||
* @see #getLeftTexId() |
||||
* @see #getFullTexId() |
||||
*/ |
||||
protected int getRightTexId() { |
||||
return (int) getRightTexture().getImage().getId(); |
||||
} |
||||
|
||||
/** |
||||
* Get the identifier of the full (dual eye) texture. |
||||
* |
||||
* @return the identifier of the full (dual eye) texture. |
||||
* @see #getLeftTexId() |
||||
* @see #getRightTexId() |
||||
*/ |
||||
private int getFullTexId() { |
||||
return (int) dualEyeTex.getImage().getId(); |
||||
} |
||||
|
||||
/** |
||||
* Initialize the system binds of the textures. |
||||
*/ |
||||
private void initTextureSubmitStructs() { |
||||
leftTextureType = Texture.create(); |
||||
rightTextureType = Texture.create(); |
||||
|
||||
if (environment != null) { |
||||
if (environment.getVRHardware() instanceof LWJGLOpenVR) { |
||||
leftTextureBounds = VRTextureBounds.create(); |
||||
rightTextureBounds = VRTextureBounds.create(); |
||||
// left eye
|
||||
leftTextureBounds.set(0f, 0f, 0.5f, 1f); |
||||
// right eye
|
||||
rightTextureBounds.set(0.5f, 0f, 1f, 1f); |
||||
// texture type
|
||||
leftTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); |
||||
rightTextureType.set(-1, VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma); |
||||
|
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* updatePose can be called here because appstates are always called before the main renderer. This way we get the latest pose close to when it's supposed to render |
||||
*/ |
||||
public void render() { |
||||
if (environment != null) { |
||||
// grab the observer
|
||||
Object obs = environment.getObserver(); |
||||
Quaternion objRot; |
||||
Vector3f objPos; |
||||
if (obs instanceof Camera) { |
||||
objRot = ((Camera) obs).getRotation(); |
||||
objPos = ((Camera) obs).getLocation(); |
||||
} else { |
||||
objRot = ((Spatial) obs).getWorldRotation(); |
||||
objPos = ((Spatial) obs).getWorldTranslation(); |
||||
} |
||||
// grab the hardware handle
|
||||
VRAPI dev = environment.getVRHardware(); |
||||
if (dev != null) { |
||||
|
||||
// update the HMD's position & orientation
|
||||
dev.updatePose(); |
||||
dev.getPositionAndOrientation(hmdPos, hmdRot); |
||||
|
||||
if (obs != null) { |
||||
// update hmdPos based on obs rotation
|
||||
finalRotation.set(objRot); |
||||
finalRotation.mult(hmdPos, hmdPos); |
||||
finalRotation.multLocal(hmdRot); |
||||
} |
||||
|
||||
finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera()); |
||||
finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera()); |
||||
} else { |
||||
getLeftCamera().setFrame(objPos, objRot); |
||||
getRightCamera().setFrame(objPos, objRot); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void postRender() { |
||||
|
||||
if (environment != null) { |
||||
if (environment.isInVR()) { |
||||
VRAPI api = environment.getVRHardware(); |
||||
// using the compositor...
|
||||
int errl = 0, errr = 0; |
||||
if (environment.isInstanceRendering()) { |
||||
if (leftTextureType.handle() == -1 || leftTextureType.handle() != getFullTexId()) { |
||||
leftTextureType.set(getFullTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); |
||||
} else { |
||||
if (api instanceof LWJGLOpenVR) { |
||||
int submitFlag = VR.EVRSubmitFlags_Submit_Default; |
||||
errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, rightTextureBounds, submitFlag); |
||||
errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, leftTextureBounds, submitFlag); |
||||
} |
||||
} |
||||
} else if (leftTextureType.handle() == -1 || rightTextureType.handle() == -1 |
||||
|| leftTextureType.handle() != getLeftTexId() || rightTextureType.handle() != getRightTexId()) { |
||||
leftTextureType.set(getLeftTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); |
||||
rightTextureType.set(getRightTexId(), leftTextureType.eType(), leftTextureType.eColorSpace()); |
||||
} else { |
||||
if (api instanceof LWJGLOpenVR) { |
||||
int submitFlag = VR.EVRSubmitFlags_Submit_Default; |
||||
errr = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, rightTextureType, null, submitFlag); |
||||
errl = VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, leftTextureType, null, submitFlag); |
||||
} else { |
||||
|
||||
} |
||||
} |
||||
|
||||
if (errl != 0) { |
||||
logger.severe("Submit to left compositor error: " + " (" + Integer.toString(errl) + ")"); |
||||
logger.severe(" Texture handle: " + leftTextureType.handle()); |
||||
|
||||
logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")"); |
||||
logger.severe(" Type: " + leftEyeTexture.getType()); |
||||
logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight()); |
||||
logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth()); |
||||
logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat()); |
||||
logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace()); |
||||
|
||||
} |
||||
|
||||
if (errr != 0) { |
||||
logger.severe("Submit to right compositor error: " + " (" + Integer.toString(errl) + ")"); |
||||
// logger.severe(" Texture color space: "+OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace));
|
||||
// logger.severe(" Texture type: "+OpenVRUtil.getETextureTypeString(rightTextureType.eType));
|
||||
logger.severe(" Texture handle: " + rightTextureType.handle()); |
||||
|
||||
logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")"); |
||||
logger.severe(" Type: " + rightEyeTexture.getType()); |
||||
logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight()); |
||||
logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth()); |
||||
logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat()); |
||||
logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace()); |
||||
} |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
|
||||
VRCompositor.VRCompositor_PostPresentHandoff(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void initialize() { |
||||
|
||||
logger.config("Initializing VR view manager."); |
||||
|
||||
if (environment != null) { |
||||
|
||||
initTextureSubmitStructs(); |
||||
setupCamerasAndViews(); |
||||
setupVRScene(); |
||||
moveScreenProcessingToEyes(); |
||||
|
||||
if (environment.hasTraditionalGUIOverlay()) { |
||||
|
||||
environment.getVRMouseManager().initialize(); |
||||
|
||||
// update the pose to position the gui correctly on start
|
||||
update(0f); |
||||
environment.getVRGUIManager().positionGui(); |
||||
} |
||||
|
||||
logger.config("Initialized VR view manager [SUCCESS]"); |
||||
|
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Prepare the size of the given {@link Camera camera} to adapt it to the |
||||
* underlying rendering context. |
||||
* |
||||
* @param cam the {@link Camera camera} to prepare. |
||||
* @param xMult the camera width multiplier. |
||||
*/ |
||||
private void prepareCameraSize(Camera cam, float xMult) { |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.getApplication() != null) { |
||||
Vector2f size = new Vector2f(); |
||||
VRAPI vrhmd = environment.getVRHardware(); |
||||
|
||||
if (vrhmd == null) { |
||||
size.x = 1280f; |
||||
size.y = 720f; |
||||
} else { |
||||
vrhmd.getRenderSize(size); |
||||
} |
||||
|
||||
if (size.x < environment.getApplication().getContext().getSettings().getWidth()) { |
||||
size.x = environment.getApplication().getContext().getSettings().getWidth(); |
||||
} |
||||
if (size.y < environment.getApplication().getContext().getSettings().getHeight()) { |
||||
size.y = environment.getApplication().getContext().getSettings().getHeight(); |
||||
} |
||||
|
||||
if (environment.isInstanceRendering()) { |
||||
size.x *= 2f; |
||||
} |
||||
|
||||
// other adjustments
|
||||
size.x *= xMult; |
||||
size.x *= getResolutionMuliplier(); |
||||
size.y *= getResolutionMuliplier(); |
||||
|
||||
if (cam.getWidth() != size.x || cam.getHeight() != size.y) { |
||||
cam.resize((int) size.x, (int) size.y, false); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
|
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Replaces rootNode as the main cameras scene with the distortion mesh |
||||
*/ |
||||
private void setupVRScene() { |
||||
|
||||
if (environment != null) { |
||||
if (environment.getApplication() != null) { |
||||
// no special scene to setup if we are doing instancing
|
||||
if (environment.isInstanceRendering()) { |
||||
// distortion has to be done with compositor here... we want only one pass on our end!
|
||||
if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { |
||||
setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); |
||||
} |
||||
return; |
||||
} |
||||
|
||||
leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); |
||||
rightEyeTexture = (Texture2D) getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); |
||||
leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); |
||||
rightEyeDepth = (Texture2D) getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); |
||||
|
||||
// main viewport is either going to be a distortion scene or nothing
|
||||
// mirroring is handled by copying framebuffers
|
||||
Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); |
||||
while (spatialIter.hasNext()) { |
||||
environment.getApplication().getViewPort().detachScene(spatialIter.next()); |
||||
} |
||||
|
||||
spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); |
||||
while (spatialIter.hasNext()) { |
||||
environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); |
||||
} |
||||
|
||||
// only setup distortion scene if compositor isn't running (or using custom mesh distortion option)
|
||||
if (environment.getApplication().getContext().getSettings().isSwapBuffers()) { |
||||
setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); |
||||
|
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void update(float tpf) { |
||||
|
||||
if (environment != null) { |
||||
|
||||
if (environment.hasTraditionalGUIOverlay()) { |
||||
// update the mouse?
|
||||
environment.getVRMouseManager().update(tpf); |
||||
|
||||
// update GUI position?
|
||||
if (environment.getVRGUIManager().isWantsReposition() || environment.getVRGUIManager().getPositioningMode() != VRGUIPositioningMode.MANUAL) { |
||||
environment.getVRGUIManager().positionGuiNow(tpf); |
||||
environment.getVRGUIManager().updateGuiQuadGeometricState(); |
||||
} |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Place the camera within the scene. |
||||
* |
||||
* @param eyePos the eye position. |
||||
* @param obsPosition the observer position. |
||||
* @param cam the camera to place. |
||||
*/ |
||||
private void finalizeCamera(Vector3f eyePos, Vector3f obsPosition, Camera cam) { |
||||
finalRotation.mult(eyePos, finalPosition); |
||||
finalPosition.addLocal(hmdPos); |
||||
if (obsPosition != null) { |
||||
finalPosition.addLocal(obsPosition); |
||||
} |
||||
finalPosition.y += getHeightAdjustment(); |
||||
cam.setFrame(finalPosition, finalRotation); |
||||
} |
||||
|
||||
private void setupCamerasAndViews() { |
||||
|
||||
if (environment != null) { |
||||
// get desired frustum from original camera
|
||||
Camera origCam = environment.getCamera(); |
||||
float fFar = origCam.getFrustumFar(); |
||||
float fNear = origCam.getFrustumNear(); |
||||
|
||||
// restore frustum on distortion scene cam, if needed
|
||||
if (environment.isInstanceRendering()) { |
||||
leftCamera = origCam; |
||||
} else if (environment.compositorAllowed() == false) { |
||||
origCam.setFrustumFar(100f); |
||||
origCam.setFrustumNear(1f); |
||||
leftCamera = origCam.clone(); |
||||
prepareCameraSize(origCam, 2f); |
||||
} else { |
||||
leftCamera = origCam.clone(); |
||||
} |
||||
|
||||
getLeftCamera().setFrustumPerspective(environment.getDefaultFOV(), environment.getDefaultAspect(), fNear, fFar); |
||||
|
||||
prepareCameraSize(getLeftCamera(), 1f); |
||||
if (environment.getVRHardware() != null) { |
||||
getLeftCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionLeftEye(getLeftCamera())); |
||||
} |
||||
//org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
if (!environment.isInstanceRendering()) { |
||||
leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME); |
||||
rightCamera = getLeftCamera().clone(); |
||||
if (environment.getVRHardware() != null) { |
||||
getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); |
||||
} |
||||
rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME); |
||||
} else { |
||||
|
||||
if (environment.getApplication() != null) { |
||||
|
||||
logger.severe("THIS CODE NEED CHANGES !!!"); |
||||
leftViewPort = environment.getApplication().getViewPort(); |
||||
//leftViewport.attachScene(app.getRootNode());
|
||||
rightCamera = getLeftCamera().clone(); |
||||
if (environment.getVRHardware() != null) { |
||||
getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera())); |
||||
} |
||||
|
||||
org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_CLIP_DISTANCE0); |
||||
|
||||
//FIXME: [jme-vr] Fix with JMonkey next release
|
||||
//RenderManager._VRInstancing_RightCamProjection = camRight.getViewProjectionMatrix();
|
||||
setupFinalFullTexture(environment.getApplication().getViewPort().getCamera()); |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
|
||||
} |
||||
|
||||
// setup gui
|
||||
environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort()); |
||||
|
||||
if (environment.getVRHardware() != null) { |
||||
// call these to cache the results internally
|
||||
environment.getVRHardware().getHMDMatrixPoseLeftEye(); |
||||
environment.getVRHardware().getHMDMatrixPoseRightEye(); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
private ViewPort setupMirrorBuffers(Camera cam, Texture2D tex, boolean expand) { |
||||
|
||||
if (environment != null) { |
||||
if (environment.getApplication() != null) { |
||||
Camera clonecam = cam.clone(); |
||||
ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam); |
||||
clonecam.setParallelProjection(true); |
||||
viewPort.setClearFlags(true, true, true); |
||||
viewPort.setBackgroundColor(ColorRGBA.Black); |
||||
Picture pic = new Picture("fullscene"); |
||||
pic.setLocalTranslation(-0.75f, -0.5f, 0f); |
||||
if (expand) { |
||||
pic.setLocalScale(3f, 1f, 1f); |
||||
} else { |
||||
pic.setLocalScale(1.5f, 1f, 1f); |
||||
} |
||||
pic.setQueueBucket(Bucket.Opaque); |
||||
pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D) tex, false); |
||||
viewPort.attachScene(pic); |
||||
viewPort.setOutputFrameBuffer(null); |
||||
|
||||
pic.updateGeometricState(); |
||||
|
||||
return viewPort; |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
private void setupFinalFullTexture(Camera cam) { |
||||
|
||||
if (environment != null) { |
||||
if (environment.getApplication() != null) { |
||||
// create offscreen framebuffer
|
||||
FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); |
||||
//offBuffer.setSrgb(true);
|
||||
|
||||
//setup framebuffer's texture
|
||||
dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); |
||||
dualEyeTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); |
||||
dualEyeTex.setMagFilter(Texture2D.MagFilter.Bilinear); |
||||
|
||||
logger.config("Dual eye texture " + dualEyeTex.getName() + " (" + dualEyeTex.getImage().getId() + ")"); |
||||
logger.config(" Type: " + dualEyeTex.getType()); |
||||
logger.config(" Size: " + dualEyeTex.getImage().getWidth() + "x" + dualEyeTex.getImage().getHeight()); |
||||
logger.config(" Image depth: " + dualEyeTex.getImage().getDepth()); |
||||
logger.config(" Image format: " + dualEyeTex.getImage().getFormat()); |
||||
logger.config(" Image color space: " + dualEyeTex.getImage().getColorSpace()); |
||||
|
||||
//setup framebuffer to use texture
|
||||
out.setDepthBuffer(Image.Format.Depth); |
||||
out.setColorTexture(dualEyeTex); |
||||
|
||||
ViewPort viewPort = environment.getApplication().getViewPort(); |
||||
viewPort.setClearFlags(true, true, true); |
||||
viewPort.setBackgroundColor(ColorRGBA.Black); |
||||
viewPort.setOutputFrameBuffer(out); |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
private ViewPort setupViewBuffers(Camera cam, String viewName) { |
||||
|
||||
if (environment != null) { |
||||
if (environment.getApplication() != null) { |
||||
// create offscreen framebuffer
|
||||
FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); |
||||
//offBufferLeft.setSrgb(true);
|
||||
|
||||
//setup framebuffer's texture
|
||||
Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); |
||||
offTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); |
||||
offTex.setMagFilter(Texture2D.MagFilter.Bilinear); |
||||
|
||||
//setup framebuffer to use texture
|
||||
offBufferLeft.setDepthBuffer(Image.Format.Depth); |
||||
offBufferLeft.setColorTexture(offTex); |
||||
|
||||
ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); |
||||
viewPort.setClearFlags(true, true, true); |
||||
viewPort.setBackgroundColor(ColorRGBA.Black); |
||||
|
||||
Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); |
||||
while (spatialIter.hasNext()) { |
||||
viewPort.attachScene(spatialIter.next()); |
||||
} |
||||
|
||||
//set viewport to render to offscreen framebuffer
|
||||
viewPort.setOutputFrameBuffer(offBufferLeft); |
||||
return viewPort; |
||||
} else { |
||||
throw new IllegalStateException("This VR environment is not attached to any application."); |
||||
} |
||||
} else { |
||||
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,210 +0,0 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.post; |
||||
|
||||
import com.jme3.app.VRApplication; |
||||
import com.jme3.asset.AssetManager; |
||||
import com.jme3.material.Material; |
||||
import com.jme3.post.Filter; |
||||
import com.jme3.renderer.RenderManager; |
||||
import com.jme3.renderer.Renderer; |
||||
import com.jme3.renderer.ViewPort; |
||||
import com.jme3.scene.Mesh; |
||||
import com.jme3.scene.VertexBuffer; |
||||
import com.jme3.system.jopenvr.DistortionCoordinates_t; |
||||
import com.jme3.system.jopenvr.JOpenVRLibrary; |
||||
import com.jme3.system.jopenvr.VR_IVRSystem_FnTable; |
||||
import com.jme3.texture.FrameBuffer; |
||||
|
||||
/** |
||||
* DO NOT USE |
||||
* @author phr00t |
||||
* @deprecated DO NOT USE |
||||
*/ |
||||
@Deprecated |
||||
public class OpenVRFilter extends Filter { |
||||
|
||||
private Mesh distortionMesh; |
||||
|
||||
private VRApplication application = null; |
||||
|
||||
/** |
||||
* DO NOT USE |
||||
* @param application the VR application. |
||||
*/ |
||||
public OpenVRFilter(VRApplication application) { |
||||
this.application = application; |
||||
} |
||||
|
||||
/** |
||||
* DO NOT USE |
||||
* @return the distortion mesh. |
||||
*/ |
||||
public Mesh getDistortionMesh() { |
||||
return distortionMesh; |
||||
} |
||||
|
||||
@Override |
||||
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { |
||||
material = new Material(manager, "Common/MatDefs/VR/OpenVR.j3md"); |
||||
configureDistortionMesh(); |
||||
} |
||||
|
||||
@Override |
||||
protected Material getMaterial() { |
||||
return material; |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected void preFrame(float tpf) { |
||||
super.preFrame(tpf); |
||||
} |
||||
|
||||
@Override |
||||
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { |
||||
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer); |
||||
} |
||||
|
||||
@Override |
||||
protected void postFilter(Renderer r, FrameBuffer buffer) { |
||||
super.postFilter(r, buffer); |
||||
} |
||||
|
||||
/* |
||||
function converted from: |
||||
https://github.com/ValveSoftware/openvr/blob/master/samples/hellovr_opengl/hellovr_opengl_main.cpp#L1335
|
||||
*/ |
||||
private void configureDistortionMesh() { |
||||
float m_iLensGridSegmentCountH = 43, m_iLensGridSegmentCountV = 43; |
||||
|
||||
float w = 1f / m_iLensGridSegmentCountH - 1f; |
||||
float h = 1f / m_iLensGridSegmentCountV - 1f; |
||||
|
||||
float u, v; |
||||
|
||||
distortionMesh = new Mesh(); |
||||
float verts[] = new float[(int)(m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 3]; |
||||
|
||||
float texcoordR[] = new float[(int)(m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; |
||||
float texcoordG[] = new float[(int)(m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; |
||||
float texcoordB[] = new float[(int)(m_iLensGridSegmentCountV * m_iLensGridSegmentCountH) * 2]; |
||||
|
||||
int vertPos = 0, coordPos = 0; |
||||
|
||||
//left eye distortion verts
|
||||
float Xoffset = -1f; |
||||
for( int y=0; y<m_iLensGridSegmentCountV; y++ ) |
||||
{ |
||||
for( int x=0; x<m_iLensGridSegmentCountH; x++ ) |
||||
{ |
||||
u = x*w; v = 1-y*h; |
||||
verts[vertPos] = Xoffset+u; // x
|
||||
verts[vertPos+1] = -1+2*y*h; // y
|
||||
verts[vertPos+2] = 0f; // z
|
||||
vertPos += 3; |
||||
|
||||
DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); |
||||
((VR_IVRSystem_FnTable)application.getVRHardware().getVRSystem()).ComputeDistortion.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Left, u, v, dc0); |
||||
|
||||
texcoordR[coordPos] = dc0.rfRed[0]; |
||||
texcoordR[coordPos+1] = 1 - dc0.rfRed[1]; |
||||
texcoordG[coordPos] = dc0.rfGreen[0]; |
||||
texcoordG[coordPos+1] = 1 - dc0.rfGreen[1]; |
||||
texcoordB[coordPos] = dc0.rfBlue[0]; |
||||
texcoordB[coordPos+1] = 1 - dc0.rfBlue[1]; |
||||
coordPos+=2; |
||||
} |
||||
} |
||||
|
||||
//right eye distortion verts
|
||||
Xoffset = 0; |
||||
for( int y=0; y<m_iLensGridSegmentCountV; y++ ) |
||||
{ |
||||
for( int x=0; x<m_iLensGridSegmentCountH; x++ ) |
||||
{ |
||||
u = x*w; v = 1-y*h; |
||||
verts[vertPos] = Xoffset+u; // x
|
||||
verts[vertPos+1] = -1+2*y*h; // y
|
||||
verts[vertPos+2] = 0f; // z
|
||||
vertPos += 3; |
||||
|
||||
DistortionCoordinates_t dc0 = new DistortionCoordinates_t(); |
||||
((VR_IVRSystem_FnTable)application.getVRHardware().getVRSystem()).ComputeDistortion.apply(JOpenVRLibrary.EVREye.EVREye_Eye_Right, u, v, dc0); |
||||
|
||||
texcoordR[coordPos] = dc0.rfRed[0]; |
||||
texcoordR[coordPos+1] = 1 - dc0.rfRed[1]; |
||||
texcoordG[coordPos] = dc0.rfGreen[0]; |
||||
texcoordG[coordPos+1] = 1 - dc0.rfGreen[1]; |
||||
texcoordB[coordPos] = dc0.rfBlue[0]; |
||||
texcoordB[coordPos+1] = 1 - dc0.rfBlue[1]; |
||||
coordPos+=2; |
||||
} |
||||
} |
||||
|
||||
// have UV coordinates & positions, now to setup indices
|
||||
|
||||
//std::vector<GLushort> vIndices;
|
||||
int[] indices = new int[(int)((m_iLensGridSegmentCountV - 1) * (m_iLensGridSegmentCountH - 1)) * 6]; |
||||
int indexPos = 0; |
||||
int a,b,c,d; |
||||
|
||||
int offset = 0; |
||||
for( int y=0; y<m_iLensGridSegmentCountV-1; y++ ) |
||||
{ |
||||
for( int x=0; x<m_iLensGridSegmentCountH-1; x++ ) |
||||
{ |
||||
a = (int)(m_iLensGridSegmentCountH*y+x +offset); |
||||
b = (int)(m_iLensGridSegmentCountH*y+x+1 +offset); |
||||
c = (int)((y+1)*m_iLensGridSegmentCountH+x+1 +offset); |
||||
d = (int)((y+1)*m_iLensGridSegmentCountH+x +offset); |
||||
|
||||
indices[indexPos] = a; |
||||
indices[indexPos+1] = b; |
||||
indices[indexPos+2] = c; |
||||
|
||||
indices[indexPos+3] = a; |
||||
indices[indexPos+4] = c; |
||||
indices[indexPos+5] = d; |
||||
|
||||
indexPos += 6; |
||||
} |
||||
} |
||||
|
||||
offset = (int)(m_iLensGridSegmentCountH * m_iLensGridSegmentCountV); |
||||
for( int y=0; y<m_iLensGridSegmentCountV-1; y++ ) |
||||
{ |
||||
for( int x=0; x<m_iLensGridSegmentCountH-1; x++ ) |
||||
{ |
||||
a = (int)(m_iLensGridSegmentCountH*y+x +offset); |
||||
b = (int)(m_iLensGridSegmentCountH*y+x+1 +offset); |
||||
c = (int)((y+1)*m_iLensGridSegmentCountH+x+1 +offset); |
||||
d = (int)((y+1)*m_iLensGridSegmentCountH+x +offset); |
||||
|
||||
indices[indexPos] = a; |
||||
indices[indexPos+1] = b; |
||||
indices[indexPos+2] = c; |
||||
|
||||
indices[indexPos+3] = a; |
||||
indices[indexPos+4] = c; |
||||
indices[indexPos+5] = d; |
||||
|
||||
indexPos += 6; |
||||
} |
||||
} |
||||
|
||||
// OK, create the mesh
|
||||
distortionMesh.setBuffer(VertexBuffer.Type.Position, 3, verts); |
||||
distortionMesh.setBuffer(VertexBuffer.Type.Index, 1, indices); |
||||
distortionMesh.setBuffer(VertexBuffer.Type.TexCoord, 2, texcoordR); |
||||
|
||||
// TODO: are TexCoord2 & TexCoord3 even implemented in jME3?
|
||||
distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); |
||||
distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); |
||||
|
||||
// TODO: make sure this distortion mesh is used instead of the fullscreen quad
|
||||
// when filter gets rendered.. might require changes to jME3 core..?
|
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1592</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class CVRSettingHelper extends Structure { |
||||
/** |
||||
* class vr::IVRSettings *<br> |
||||
* C type : intptr_t |
||||
*/ |
||||
public IntByReference m_pSettings; |
||||
public CVRSettingHelper() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("m_pSettings"); |
||||
} |
||||
/** |
||||
* @param m_pSettings class vr::IVRSettings *<br> |
||||
* C type : intptr_t |
||||
*/ |
||||
public CVRSettingHelper(IntByReference m_pSettings) { |
||||
super(); |
||||
this.m_pSettings = m_pSettings; |
||||
} |
||||
public CVRSettingHelper(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends CVRSettingHelper implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends CVRSettingHelper implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1473</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class DriverDirectMode_FrameTiming extends Structure { |
||||
public int m_nSize; |
||||
public int m_nNumFramePresents; |
||||
public int m_nNumMisPresented; |
||||
public int m_nNumDroppedFrames; |
||||
public int m_nReprojectionFlags; |
||||
public DriverDirectMode_FrameTiming() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("m_nSize", "m_nNumFramePresents", "m_nNumMisPresented", "m_nNumDroppedFrames", "m_nReprojectionFlags"); |
||||
} |
||||
public DriverDirectMode_FrameTiming(int m_nSize, int m_nNumFramePresents, int m_nNumMisPresented, int m_nNumDroppedFrames, int m_nReprojectionFlags) { |
||||
super(); |
||||
this.m_nSize = m_nSize; |
||||
this.m_nNumFramePresents = m_nNumFramePresents; |
||||
this.m_nNumMisPresented = m_nNumMisPresented; |
||||
this.m_nNumDroppedFrames = m_nNumDroppedFrames; |
||||
this.m_nReprojectionFlags = m_nReprojectionFlags; |
||||
} |
||||
public DriverDirectMode_FrameTiming(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends DriverDirectMode_FrameTiming implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends DriverDirectMode_FrameTiming implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1183</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class HmdMatrix33_t extends Structure { |
||||
/** |
||||
* float[3][3]<br> |
||||
* C type : float[3][3] |
||||
*/ |
||||
public float[] m = new float[((3) * (3))]; |
||||
public HmdMatrix33_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("m"); |
||||
} |
||||
/** |
||||
* @param m float[3][3]<br> |
||||
* C type : float[3][3] |
||||
*/ |
||||
public HmdMatrix33_t(float m[]) { |
||||
super(); |
||||
if ((m.length != this.m.length)) |
||||
throw new IllegalArgumentException("Wrong array size !"); |
||||
this.m = m; |
||||
} |
||||
public HmdMatrix33_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends HmdMatrix33_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends HmdMatrix33_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1215</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class HmdQuaternionf_t extends Structure { |
||||
public float w; |
||||
public float x; |
||||
public float y; |
||||
public float z; |
||||
public HmdQuaternionf_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("w", "x", "y", "z"); |
||||
} |
||||
public HmdQuaternionf_t(float w, float x, float y, float z) { |
||||
super(); |
||||
this.w = w; |
||||
this.x = x; |
||||
this.y = y; |
||||
this.z = z; |
||||
} |
||||
public HmdQuaternionf_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends HmdQuaternionf_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends HmdQuaternionf_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,45 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1479</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class ImuSample_t extends Structure { |
||||
public double fSampleTime; |
||||
/** C type : HmdVector3d_t */ |
||||
public HmdVector3d_t vAccel; |
||||
/** C type : HmdVector3d_t */ |
||||
public HmdVector3d_t vGyro; |
||||
public int unOffScaleFlags; |
||||
public ImuSample_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("fSampleTime", "vAccel", "vGyro", "unOffScaleFlags"); |
||||
} |
||||
/** |
||||
* @param vAccel C type : HmdVector3d_t<br> |
||||
* @param vGyro C type : HmdVector3d_t |
||||
*/ |
||||
public ImuSample_t(double fSampleTime, HmdVector3d_t vAccel, HmdVector3d_t vGyro, int unOffScaleFlags) { |
||||
super(); |
||||
this.fSampleTime = fSampleTime; |
||||
this.vAccel = vAccel; |
||||
this.vGyro = vGyro; |
||||
this.unOffScaleFlags = unOffScaleFlags; |
||||
} |
||||
public ImuSample_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends ImuSample_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends ImuSample_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,51 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1603</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class InputAnalogActionData_t extends Structure { |
||||
public byte bActive; |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long activeOrigin; |
||||
public float x; |
||||
public float y; |
||||
public float z; |
||||
public float deltaX; |
||||
public float deltaY; |
||||
public float deltaZ; |
||||
public float fUpdateTime; |
||||
public InputAnalogActionData_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("bActive", "activeOrigin", "x", "y", "z", "deltaX", "deltaY", "deltaZ", "fUpdateTime"); |
||||
} |
||||
/** @param activeOrigin C type : VRInputValueHandle_t */ |
||||
public InputAnalogActionData_t(byte bActive, long activeOrigin, float x, float y, float z, float deltaX, float deltaY, float deltaZ, float fUpdateTime) { |
||||
super(); |
||||
this.bActive = bActive; |
||||
this.activeOrigin = activeOrigin; |
||||
this.x = x; |
||||
this.y = y; |
||||
this.z = z; |
||||
this.deltaX = deltaX; |
||||
this.deltaY = deltaY; |
||||
this.deltaZ = deltaZ; |
||||
this.fUpdateTime = fUpdateTime; |
||||
} |
||||
public InputAnalogActionData_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends InputAnalogActionData_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends InputAnalogActionData_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1610</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class InputDigitalActionData_t extends Structure { |
||||
public byte bActive; |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long activeOrigin; |
||||
public byte bState; |
||||
public byte bChanged; |
||||
public float fUpdateTime; |
||||
public InputDigitalActionData_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("bActive", "activeOrigin", "bState", "bChanged", "fUpdateTime"); |
||||
} |
||||
/** @param activeOrigin C type : VRInputValueHandle_t */ |
||||
public InputDigitalActionData_t(byte bActive, long activeOrigin, byte bState, byte bChanged, float fUpdateTime) { |
||||
super(); |
||||
this.bActive = bActive; |
||||
this.activeOrigin = activeOrigin; |
||||
this.bState = bState; |
||||
this.bChanged = bChanged; |
||||
this.fUpdateTime = fUpdateTime; |
||||
} |
||||
public InputDigitalActionData_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends InputDigitalActionData_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends InputDigitalActionData_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,51 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1626</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class InputOriginInfo_t extends Structure { |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long devicePath; |
||||
/** C type : TrackedDeviceIndex_t */ |
||||
public int trackedDeviceIndex; |
||||
/** |
||||
* char[128]<br> |
||||
* C type : char*[128] |
||||
*/ |
||||
public Pointer[] rchRenderModelComponentName = new Pointer[128]; |
||||
public InputOriginInfo_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("devicePath", "trackedDeviceIndex", "rchRenderModelComponentName"); |
||||
} |
||||
/** |
||||
* @param devicePath C type : VRInputValueHandle_t<br> |
||||
* @param trackedDeviceIndex C type : TrackedDeviceIndex_t<br> |
||||
* @param rchRenderModelComponentName char[128]<br> |
||||
* C type : char*[128] |
||||
*/ |
||||
public InputOriginInfo_t(long devicePath, int trackedDeviceIndex, Pointer rchRenderModelComponentName[]) { |
||||
super(); |
||||
this.devicePath = devicePath; |
||||
this.trackedDeviceIndex = trackedDeviceIndex; |
||||
if ((rchRenderModelComponentName.length != this.rchRenderModelComponentName.length)) |
||||
throw new IllegalArgumentException("Wrong array size !"); |
||||
this.rchRenderModelComponentName = rchRenderModelComponentName; |
||||
} |
||||
public InputOriginInfo_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends InputOriginInfo_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends InputOriginInfo_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1615</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class InputPoseActionData_t extends Structure { |
||||
public byte bActive; |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long activeOrigin; |
||||
/** C type : TrackedDevicePose_t */ |
||||
public TrackedDevicePose_t pose; |
||||
public InputPoseActionData_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("bActive", "activeOrigin", "pose"); |
||||
} |
||||
/** |
||||
* @param activeOrigin C type : VRInputValueHandle_t<br> |
||||
* @param pose C type : TrackedDevicePose_t |
||||
*/ |
||||
public InputPoseActionData_t(byte bActive, long activeOrigin, TrackedDevicePose_t pose) { |
||||
super(); |
||||
this.bActive = bActive; |
||||
this.activeOrigin = activeOrigin; |
||||
this.pose = pose; |
||||
} |
||||
public InputPoseActionData_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends InputPoseActionData_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends InputPoseActionData_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1620</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class InputSkeletalActionData_t extends Structure { |
||||
public byte bActive; |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long activeOrigin; |
||||
public int boneCount; |
||||
public InputSkeletalActionData_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("bActive", "activeOrigin", "boneCount"); |
||||
} |
||||
/** @param activeOrigin C type : VRInputValueHandle_t */ |
||||
public InputSkeletalActionData_t(byte bActive, long activeOrigin, int boneCount) { |
||||
super(); |
||||
this.bActive = bActive; |
||||
this.activeOrigin = activeOrigin; |
||||
this.boneCount = boneCount; |
||||
} |
||||
public InputSkeletalActionData_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends InputSkeletalActionData_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends InputSkeletalActionData_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1636</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class SpatialAnchorPose_t extends Structure { |
||||
/** C type : HmdMatrix34_t */ |
||||
public HmdMatrix34_t mAnchorToAbsoluteTracking; |
||||
public SpatialAnchorPose_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("mAnchorToAbsoluteTracking"); |
||||
} |
||||
/** @param mAnchorToAbsoluteTracking C type : HmdMatrix34_t */ |
||||
public SpatialAnchorPose_t(HmdMatrix34_t mAnchorToAbsoluteTracking) { |
||||
super(); |
||||
this.mAnchorToAbsoluteTracking = mAnchorToAbsoluteTracking; |
||||
} |
||||
public SpatialAnchorPose_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends SpatialAnchorPose_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends SpatialAnchorPose_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1633</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRActiveActionSet_t extends Structure { |
||||
/** C type : VRActionSetHandle_t */ |
||||
public long ulActionSet; |
||||
/** C type : VRInputValueHandle_t */ |
||||
public long ulRestrictedToDevice; |
||||
/** C type : VRActionSetHandle_t */ |
||||
public long ulSecondaryActionSet; |
||||
public int unPadding; |
||||
public int nPriority; |
||||
public VRActiveActionSet_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("ulActionSet", "ulRestrictedToDevice", "ulSecondaryActionSet", "unPadding", "nPriority"); |
||||
} |
||||
/** |
||||
* @param ulActionSet C type : VRActionSetHandle_t<br> |
||||
* @param ulRestrictedToDevice C type : VRInputValueHandle_t<br> |
||||
* @param ulSecondaryActionSet C type : VRActionSetHandle_t |
||||
*/ |
||||
public VRActiveActionSet_t(long ulActionSet, long ulRestrictedToDevice, long ulSecondaryActionSet, int unPadding, int nPriority) { |
||||
super(); |
||||
this.ulActionSet = ulActionSet; |
||||
this.ulRestrictedToDevice = ulRestrictedToDevice; |
||||
this.ulSecondaryActionSet = ulSecondaryActionSet; |
||||
this.unPadding = unPadding; |
||||
this.nPriority = nPriority; |
||||
} |
||||
public VRActiveActionSet_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRActiveActionSet_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRActiveActionSet_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1456</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRBoneTransform_t extends Structure { |
||||
/** C type : HmdVector4_t */ |
||||
public HmdVector4_t position; |
||||
/** C type : HmdQuaternionf_t */ |
||||
public HmdQuaternionf_t orientation; |
||||
public VRBoneTransform_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("position", "orientation"); |
||||
} |
||||
/** |
||||
* @param position C type : HmdVector4_t<br> |
||||
* @param orientation C type : HmdQuaternionf_t |
||||
*/ |
||||
public VRBoneTransform_t(HmdVector4_t position, HmdQuaternionf_t orientation) { |
||||
super(); |
||||
this.position = position; |
||||
this.orientation = orientation; |
||||
} |
||||
public VRBoneTransform_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRBoneTransform_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRBoneTransform_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1395</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_DualAnalog_t extends Structure { |
||||
public float x; |
||||
public float y; |
||||
public float transformedX; |
||||
public float transformedY; |
||||
/** |
||||
* @see EDualAnalogWhich<br> |
||||
* C type : EDualAnalogWhich |
||||
*/ |
||||
public int which; |
||||
public VREvent_DualAnalog_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("x", "y", "transformedX", "transformedY", "which"); |
||||
} |
||||
/** |
||||
* @param which @see EDualAnalogWhich<br> |
||||
* C type : EDualAnalogWhich |
||||
*/ |
||||
public VREvent_DualAnalog_t(float x, float y, float transformedX, float transformedY, int which) { |
||||
super(); |
||||
this.x = x; |
||||
this.y = y; |
||||
this.transformedX = transformedX; |
||||
this.transformedY = transformedY; |
||||
this.which = which; |
||||
} |
||||
public VREvent_DualAnalog_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_DualAnalog_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_DualAnalog_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1402</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_HapticVibration_t extends Structure { |
||||
public long containerHandle; |
||||
public long componentHandle; |
||||
public float fDurationSeconds; |
||||
public float fFrequency; |
||||
public float fAmplitude; |
||||
public VREvent_HapticVibration_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("containerHandle", "componentHandle", "fDurationSeconds", "fFrequency", "fAmplitude"); |
||||
} |
||||
public VREvent_HapticVibration_t(long containerHandle, long componentHandle, float fDurationSeconds, float fFrequency, float fAmplitude) { |
||||
super(); |
||||
this.containerHandle = containerHandle; |
||||
this.componentHandle = componentHandle; |
||||
this.fDurationSeconds = fDurationSeconds; |
||||
this.fFrequency = fFrequency; |
||||
this.fAmplitude = fAmplitude; |
||||
} |
||||
public VREvent_HapticVibration_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_HapticVibration_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_HapticVibration_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1417</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_InputActionManifestLoad_t extends Structure { |
||||
public long pathAppKey; |
||||
public long pathMessage; |
||||
public long pathMessageParam; |
||||
public long pathManifestPath; |
||||
public VREvent_InputActionManifestLoad_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("pathAppKey", "pathMessage", "pathMessageParam", "pathManifestPath"); |
||||
} |
||||
public VREvent_InputActionManifestLoad_t(long pathAppKey, long pathMessage, long pathMessageParam, long pathManifestPath) { |
||||
super(); |
||||
this.pathAppKey = pathAppKey; |
||||
this.pathMessage = pathMessage; |
||||
this.pathMessageParam = pathMessageParam; |
||||
this.pathManifestPath = pathManifestPath; |
||||
} |
||||
public VREvent_InputActionManifestLoad_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_InputActionManifestLoad_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_InputActionManifestLoad_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1411</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_InputBindingLoad_t extends Structure { |
||||
/** C type : PropertyContainerHandle_t */ |
||||
public long ulAppContainer; |
||||
public long pathMessage; |
||||
public long pathUrl; |
||||
public long pathControllerType; |
||||
public VREvent_InputBindingLoad_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("ulAppContainer", "pathMessage", "pathUrl", "pathControllerType"); |
||||
} |
||||
/** @param ulAppContainer C type : PropertyContainerHandle_t */ |
||||
public VREvent_InputBindingLoad_t(long ulAppContainer, long pathMessage, long pathUrl, long pathControllerType) { |
||||
super(); |
||||
this.ulAppContainer = ulAppContainer; |
||||
this.pathMessage = pathMessage; |
||||
this.pathUrl = pathUrl; |
||||
this.pathControllerType = pathControllerType; |
||||
} |
||||
public VREvent_InputBindingLoad_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_InputBindingLoad_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_InputBindingLoad_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1420</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_SpatialAnchor_t extends Structure { |
||||
/** C type : SpatialAnchorHandle_t */ |
||||
public int unHandle; |
||||
public VREvent_SpatialAnchor_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("unHandle"); |
||||
} |
||||
/** @param unHandle C type : SpatialAnchorHandle_t */ |
||||
public VREvent_SpatialAnchor_t(int unHandle) { |
||||
super(); |
||||
this.unHandle = unHandle; |
||||
} |
||||
public VREvent_SpatialAnchor_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_SpatialAnchor_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_SpatialAnchor_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1405</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VREvent_WebConsole_t extends Structure { |
||||
/** C type : WebConsoleHandle_t */ |
||||
public long webConsoleHandle; |
||||
public VREvent_WebConsole_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("webConsoleHandle"); |
||||
} |
||||
/** @param webConsoleHandle C type : WebConsoleHandle_t */ |
||||
public VREvent_WebConsole_t(long webConsoleHandle) { |
||||
super(); |
||||
this.webConsoleHandle = webConsoleHandle; |
||||
} |
||||
public VREvent_WebConsole_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VREvent_WebConsole_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VREvent_WebConsole_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1272</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRTextureDepthInfo_t extends Structure { |
||||
/** |
||||
* void *<br> |
||||
* C type : void* |
||||
*/ |
||||
public Pointer handle; |
||||
/** C type : HmdMatrix44_t */ |
||||
public HmdMatrix44_t mProjection; |
||||
/** C type : HmdVector2_t */ |
||||
public HmdVector2_t vRange; |
||||
public VRTextureDepthInfo_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("handle", "mProjection", "vRange"); |
||||
} |
||||
/** |
||||
* @param handle void *<br> |
||||
* C type : void*<br> |
||||
* @param mProjection C type : HmdMatrix44_t<br> |
||||
* @param vRange C type : HmdVector2_t |
||||
*/ |
||||
public VRTextureDepthInfo_t(Pointer handle, HmdMatrix44_t mProjection, HmdVector2_t vRange) { |
||||
super(); |
||||
this.handle = handle; |
||||
this.mProjection = mProjection; |
||||
this.vRange = vRange; |
||||
} |
||||
public VRTextureDepthInfo_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRTextureDepthInfo_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRTextureDepthInfo_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1275</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRTextureWithDepth_t extends Structure { |
||||
/** C type : VRTextureDepthInfo_t */ |
||||
public VRTextureDepthInfo_t depth; |
||||
public VRTextureWithDepth_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("depth"); |
||||
} |
||||
/** @param depth C type : VRTextureDepthInfo_t */ |
||||
public VRTextureWithDepth_t(VRTextureDepthInfo_t depth) { |
||||
super(); |
||||
this.depth = depth; |
||||
} |
||||
public VRTextureWithDepth_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRTextureWithDepth_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRTextureWithDepth_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1278</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRTextureWithPoseAndDepth_t extends Structure { |
||||
/** C type : VRTextureDepthInfo_t */ |
||||
public VRTextureDepthInfo_t depth; |
||||
public VRTextureWithPoseAndDepth_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("depth"); |
||||
} |
||||
/** @param depth C type : VRTextureDepthInfo_t */ |
||||
public VRTextureWithPoseAndDepth_t(VRTextureDepthInfo_t depth) { |
||||
super(); |
||||
this.depth = depth; |
||||
} |
||||
public VRTextureWithPoseAndDepth_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRTextureWithPoseAndDepth_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRTextureWithPoseAndDepth_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.jme3.system.jopenvr; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.Structure; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
/** |
||||
* <i>native declaration : headers\openvr_capi.h:1266</i><br> |
||||
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br> |
||||
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br> |
||||
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>. |
||||
*/ |
||||
public class VRTextureWithPose_t extends Structure { |
||||
/** C type : HmdMatrix34_t */ |
||||
public HmdMatrix34_t mDeviceToAbsoluteTracking; |
||||
public VRTextureWithPose_t() { |
||||
super(); |
||||
} |
||||
protected List<String> getFieldOrder() { |
||||
return Arrays.asList("mDeviceToAbsoluteTracking"); |
||||
} |
||||
/** @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t */ |
||||
public VRTextureWithPose_t(HmdMatrix34_t mDeviceToAbsoluteTracking) { |
||||
super(); |
||||
this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; |
||||
} |
||||
public VRTextureWithPose_t(Pointer peer) { |
||||
super(peer); |
||||
} |
||||
public static class ByReference extends VRTextureWithPose_t implements Structure.ByReference { |
||||
|
||||
}; |
||||
public static class ByValue extends VRTextureWithPose_t implements Structure.ByValue { |
||||
|
||||
}; |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue