diff options
author | Sven Gothel <[email protected]> | 2015-07-20 02:59:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-07-20 02:59:54 +0200 |
commit | d99b7bf16fe316a10784e9588408ab28b204e506 (patch) | |
tree | fe631eecaef1a3e3d3522f21e471f3bc5c524b7c /src/oculusvr/classes/jogamp/opengl | |
parent | d9674620bc4f03dff9611a785a27dd41b1b72648 (diff) |
StereoDevice (Generic/OVR): Add knowledge about LocationSensorParameter and allow reset origin of location-sensor
Diffstat (limited to 'src/oculusvr/classes/jogamp/opengl')
-rw-r--r-- | src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java index b22aecab8..44bf13cd3 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java @@ -40,6 +40,8 @@ import com.jogamp.oculusvr.ovrHmdDesc; import com.jogamp.oculusvr.ovrSizei; import com.jogamp.oculusvr.ovrTrackingState; import com.jogamp.opengl.math.FovHVHalves; +import com.jogamp.opengl.math.geom.Frustum; +import com.jogamp.opengl.util.stereo.LocationSensorParameter; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceFactory; import com.jogamp.opengl.util.stereo.StereoDeviceRenderer; @@ -69,6 +71,8 @@ public class OVRStereoDevice implements StereoDevice { private final PointImmutable position; private final int dkVersion; + private final LocationSensorParameter locationSensorParams; + public OVRStereoDevice(final StereoDeviceFactory factory, final ovrHmdDesc hmdDesc, final int deviceIndex) { if( null == hmdDesc ) { throw new IllegalArgumentException("Passed null hmdDesc"); @@ -81,6 +85,15 @@ public class OVRStereoDevice implements StereoDevice { this.handle = nativeContext; this.deviceIndex = deviceIndex; this.hmdDesc = hmdDesc; + + { + final FovHVHalves posFov = FovHVHalves.byRadians(hmdDesc.getCameraFrustumHFovInRadians(), + hmdDesc.getCameraFrustumVFovInRadians()); + final float posZNear = hmdDesc.getCameraFrustumNearZInMeters(); + final float posZFar = hmdDesc.getCameraFrustumFarZInMeters(); + locationSensorParams = new LocationSensorParameter(new Frustum.FovDesc(posFov, posZNear, posZFar)); + } + final ovrFovPort[] defaultOVREyeFov = hmdDesc.getDefaultEyeFov(0, new ovrFovPort[ovrHmdDesc.getEyeRenderOrderArrayLength()]); defaultEyeFov = new FovHVHalves[defaultOVREyeFov.length]; for(int i=0; i<defaultEyeFov.length; i++) { @@ -132,7 +145,8 @@ public class OVRStereoDevice implements StereoDevice { "], recommended ["+StereoUtil.distortionBitsToString(getRecommendedDistortionBits())+ "], minimum ["+StereoUtil.distortionBitsToString(getMinimumDistortionBits())+"]]"); sb.append(", sensorBits[supported ["+StereoUtil.sensorBitsToString(getSupportedSensorBits())+ - "], enabled ["+StereoUtil.sensorBitsToString(getEnabledSensorBits())+"]]]"); + "], enabled ["+StereoUtil.sensorBitsToString(getEnabledSensorBits())+"]]"); + sb.append(", "+locationSensorParams+"]"); return sb.toString(); } @@ -164,6 +178,15 @@ public class OVRStereoDevice implements StereoDevice { @Override public final FovHVHalves[] getDefaultFOV() { return defaultEyeFov; } + + @Override + public final LocationSensorParameter getLocationSensorParams() { return locationSensorParams; } + + @Override + public final void resetLocationSensorOrigin() { + if( isValid() && sensorsStarted && StereoUtil.usesPositionSensor(supportedSensorBits)) { + OVR.ovrHmd_RecenterPose(hmdDesc); + } } /* pp */ void updateUsedSensorBits(final ovrTrackingState trackingState) { |