use of com.sun.jna.ptr.FloatByReference in project jmonkeyengine by jMonkeyEngine.
the class VRBounds method init.
/**
* Initialize the VR bounds.
* @return <code>true</code> if the initialization is a success and <code>false</code> otherwise.
*/
public static boolean init() {
logger.config("Initialize VR bounds...");
if (vrChaperone == null) {
vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, OpenVR.hmdErrorStore).getPointer());
if (vrChaperone != null) {
vrChaperone.setAutoSynch(false);
vrChaperone.read();
FloatByReference fbX = new FloatByReference();
FloatByReference fbZ = new FloatByReference();
vrChaperone.GetPlayAreaSize.apply(fbX, fbZ);
playSize = new Vector2f(fbX.getValue(), fbZ.getValue());
logger.config("Initialize VR bounds [SUCCESS]");
// init success
return true;
}
logger.warning("Initialize VR bounds [FAILED].");
// failed to init
return false;
}
logger.config("Initialize VR bounds already done.");
// already initialized
return true;
}
use of com.sun.jna.ptr.FloatByReference in project jmonkeyengine by jMonkeyEngine.
the class OpenVR method initialize.
@Override
public boolean initialize() {
logger.config("Initializing OpenVR system...");
hmdErrorStore = new IntByReference();
vrsystemFunctions = null;
JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene);
if (hmdErrorStore.getValue() == 0) {
vrsystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer());
}
if (vrsystemFunctions == null || hmdErrorStore.getValue() != 0) {
logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0));
logger.severe("Initializing OpenVR system [FAILED]");
return false;
} else {
logger.config("OpenVR initialized & VR connected.");
vrsystemFunctions.setAutoSynch(false);
vrsystemFunctions.read();
tlastVsync = new FloatByReference();
_tframeCount = new LongByReference();
hmdDisplayFrequency = IntBuffer.allocate(1);
hmdDisplayFrequency.put((int) JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float);
hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference();
hmdTrackedDevicePoses = (TrackedDevicePose_t[]) hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount);
poseMatrices = new Matrix4f[JOpenVRLibrary.k_unMaxTrackedDeviceCount];
for (int i = 0; i < poseMatrices.length; i++) poseMatrices[i] = new Matrix4f();
timePerFrame = 1.0 / hmdDisplayFrequency.get(0);
// disable all this stuff which kills performance
hmdTrackedDevicePoseReference.setAutoRead(false);
hmdTrackedDevicePoseReference.setAutoWrite(false);
hmdTrackedDevicePoseReference.setAutoSynch(false);
for (int i = 0; i < JOpenVRLibrary.k_unMaxTrackedDeviceCount; i++) {
hmdTrackedDevicePoses[i].setAutoRead(false);
hmdTrackedDevicePoses[i].setAutoWrite(false);
hmdTrackedDevicePoses[i].setAutoSynch(false);
}
// init controllers for the first time
VRinput = new OpenVRInput(environment);
VRinput.init();
VRinput.updateConnectedControllers();
// init bounds & chaperone info
VRBounds.init();
logger.config("Initializing OpenVR system [SUCCESS]");
initSuccess = true;
return true;
}
}
use of com.sun.jna.ptr.FloatByReference in project jna by java-native-access.
the class ByReferenceArgumentsTest method testFloatByReference.
public void testFloatByReference() {
FloatByReference fref = new FloatByReference(1f);
lib.complementFloatByReference(fref);
assertEquals("Float argument not modified", -1f, fref.getValue(), 0.0);
}
Aggregations