aboutsummaryrefslogtreecommitdiffstats
path: root/src/oculusvr
diff options
context:
space:
mode:
Diffstat (limited to 'src/oculusvr')
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java27
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java45
-rw-r--r--src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java16
3 files changed, 61 insertions, 27 deletions
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
index 1b85e8450..6269ce4e9 100644
--- a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
@@ -107,20 +107,23 @@ public class OVRVersion extends JogampVersion {
if(null==sb) {
sb = new StringBuilder();
}
- sb.append("\thmd."+ovrHmdIndex+".productName:\t"+hmdDesc.getProductNameAsString()).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".vendorName:\t"+hmdDesc.getManufacturerAsString()).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".deviceName:\t"+hmdDesc.getDisplayDeviceNameAsString()).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".productId:\t0x"+Integer.toHexString(hmdDesc.getProductId())).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".vendorId:\t0x"+Integer.toHexString(hmdDesc.getVendorId())).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".serial:\t"+hmdDesc.getSerialNumberAsString()).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+toHexString(hmdDesc.getHmdCaps())).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+toHexString(hmdDesc.getDistortionCaps())).append(Platform.getNewline());
- sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+toHexString(hmdDesc.getTrackingCaps())).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".productName: "+hmdDesc.getProductNameAsString()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".vendorName: "+hmdDesc.getManufacturerAsString()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".deviceName: "+hmdDesc.getDisplayDeviceNameAsString()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".productId: 0x"+Integer.toHexString(hmdDesc.getProductId())).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".vendorId: 0x"+Integer.toHexString(hmdDesc.getVendorId())).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".serial: "+hmdDesc.getSerialNumberAsString()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".firmware: "+hmdDesc.getFirmwareMajor()+"."+hmdDesc.getFirmwareMinor()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".type: "+hmdDesc.getType()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".hmdCaps: "+toHexString(hmdDesc.getHmdCaps())).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".distorCaps: "+toHexString(hmdDesc.getDistortionCaps())).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".sensorCaps: "+toHexString(hmdDesc.getTrackingCaps())).append(Platform.getNewline());
final ovrSizei resolution = hmdDesc.getResolution();
- sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".resolution: "+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
final ovrVector2i winPos = hmdDesc.getWindowsPos();
- sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".winPos: "+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".cameraFrustum.Z: "+hmdDesc.getCameraFrustumNearZInMeters()+" - "+hmdDesc.getCameraFrustumFarZInMeters()+" meter").append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".cameraFrustum.Fov: H "+hmdDesc.getCameraFrustumHFovInRadians()+" rad, V "+hmdDesc.getCameraFrustumVFovInRadians()+" rad").append(Platform.getNewline());
return sb;
}
private static String toHexString(final int v) { return "0x"+Integer.toHexString(v); }
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java
index fc46a9aab..5025e80c5 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,7 @@ public class OVRStereoDevice implements StereoDevice {
this.handle = nativeContext;
this.deviceIndex = deviceIndex;
this.hmdDesc = hmdDesc;
+
final ovrFovPort[] defaultOVREyeFov = hmdDesc.getDefaultEyeFov(0, new ovrFovPort[ovrHmdDesc.getEyeRenderOrderArrayLength()]);
defaultEyeFov = new FovHVHalves[defaultOVREyeFov.length];
for(int i=0; i<defaultEyeFov.length; i++) {
@@ -95,6 +100,21 @@ public class OVRStereoDevice implements StereoDevice {
usedSensorBits = 0;
supportedSensorBits = OVRUtil.ovrTrackingCaps2SensorBits(hmdDesc.getTrackingCaps());
+ LocationSensorParameter _locationSensorParams = null;
+ if( StereoUtil.usesPositionSensor(supportedSensorBits)) {
+ try {
+ 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));
+ } catch (final IllegalArgumentException iae) {
+ // probably zNear/zFar issue ..
+ System.err.println(iae.getMessage());
+ }
+ }
+ locationSensorParams = _locationSensorParams;
+
// DK1 delivers unrotated resolution in target orientation
// DK2 delivers rotated resolution in target orientation, monitor screen is rotated 90deg clockwise
deviceName = hmdDesc.getDisplayDeviceNameAsString();
@@ -132,7 +152,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();
}
@@ -160,16 +181,22 @@ public class OVRStereoDevice implements StereoDevice {
public int getRequiredRotation() { return requiredRotation; }
@Override
- public float[] getDefaultEyePositionOffset() {
- return DEFAULT_EYE_POSITION_OFFSET;
- }
+ public float[] getDefaultEyePositionOffset() { return DEFAULT_EYE_POSITION_OFFSET; }
@Override
- public final FovHVHalves[] getDefaultFOV() {
- return defaultEyeFov;
+ 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);
+ }
}
- public void updateUsedSensorBits(final ovrTrackingState trackingState) {
+ /* pp */ void updateUsedSensorBits(final ovrTrackingState trackingState) {
final int pre = usedSensorBits;
if( sensorsStarted && null != trackingState ) {
usedSensorBits = StereoDevice.SENSOR_ORIENTATION |
@@ -188,7 +215,7 @@ public class OVRStereoDevice implements StereoDevice {
@Override
public final boolean startSensors(final int desiredSensorBits, final int requiredSensorBits) {
- if( !sensorsStarted ) {
+ if( isValid() && !sensorsStarted ) {
if( requiredSensorBits != ( supportedSensorBits & requiredSensorBits ) ) {
// required sensors not available
if( StereoDevice.DEBUG ) {
@@ -228,7 +255,7 @@ public class OVRStereoDevice implements StereoDevice {
}
@Override
public final boolean stopSensors() {
- if( sensorsStarted ) {
+ if( isValid() && sensorsStarted ) {
OVR.ovrHmd_ConfigureTracking(hmdDesc, 0, 0); // STOP
sensorsStarted = false;
usedSensorBits = 0;
diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
index 7d05bb7ac..95565dd0f 100644
--- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
+++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java
@@ -357,7 +357,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer {
private final OVREye[] eyes;
private final ovrPosef[] ovrEyePoses;
private final ovrVector3f[] hmdToEyeViewOffset;
- private final ViewerPose eyePoses;
+ private final ViewerPose viewerPose;
private final ovrTrackingState trackingState;
private final int distortionBits;
private final int textureCount;
@@ -431,7 +431,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer {
hmdToEyeViewOffset = new ovrVector3f[2];
hmdToEyeViewOffset[0] = eyes[0].ovrEyeDesc.getHmdToEyeViewOffset();
hmdToEyeViewOffset[1] = eyes[1].ovrEyeDesc.getHmdToEyeViewOffset();
- eyePoses = new ViewerPose();
+ viewerPose = new ViewerPose();
trackingState = ovrTrackingState.create();
sp = null;
@@ -551,14 +551,18 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer {
// where ovrEyePoses already have hmdToEyeViewOffset applied (IPD .. etc).
final ovrPosef pose = trackingState.getHeadPose().getThePose();
final ovrVector3f pos = pose.getPosition();
- eyePoses.setPosition(pos.getX(), pos.getY(), pos.getZ());
- OVRUtil.copyToQuaternion(pose.getOrientation(), eyePoses.orientation);
- return eyePoses;
+ viewerPose.setPosition(pos.getX(), pos.getY(), pos.getZ());
+ OVRUtil.copyToQuaternion(pose.getOrientation(), viewerPose.orientation);
+
+ // System.err.println("Viewer: "+OVRUtil.toString(pos));
+ // System.err.println("Camera: "+OVRUtil.toString(trackingState.getCameraPose().getPosition()));
+ // System.err.println("Leveld: "+OVRUtil.toString(trackingState.getLeveledCameraPose().getPosition()));
+ return viewerPose;
}
@Override
public final ViewerPose getLastViewerPose() {
- return eyePoses;
+ return viewerPose;
}
@Override