summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java76
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java22
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java (renamed from src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java)31
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceConfig.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java56
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java46
10 files changed, 218 insertions, 83 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
index b1a38ab06..8ecd8b8f7 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
@@ -189,10 +189,7 @@ public class StereoClientRenderer implements GLEventListener {
final int[] eyeOrder = deviceRenderer.getDevice().getEyeRenderOrder();
final int eyeCount = eyeOrder.length;
- // Update eye pos upfront to have same (almost) results
- for(int eyeNum=0; eyeNum<eyeCount; eyeNum++) {
- deviceRenderer.updateEyePose(eyeNum);
- }
+ final ViewerPose viewerPose = deviceRenderer.updateViewerPose();
if( 1 == fboCount ) {
fbos[0].bind(gl);
@@ -213,7 +210,7 @@ public class StereoClientRenderer implements GLEventListener {
public void run(final GLAutoDrawable drawable, final GLEventListener listener) {
final StereoGLEventListener sl = (StereoGLEventListener) listener;
sl.reshapeForEye(drawable, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight(),
- eye.getEyeParameter(), eye.getLastEyePose());
+ eye.getEyeParameter(), viewerPose);
sl.display(drawable, displayFlags);
} };
helper.runForAllGLEventListener(drawable, reshapeDisplayAction);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java
index d59863530..68d0f4b39 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDevice.java
@@ -41,10 +41,30 @@ public interface StereoDevice {
public static final boolean DEBUG = Debug.debug("StereoDevice");
public static final boolean DUMP_DATA = Debug.isPropertyDefined("jogl.debug.StereoDevice.DumpData", true);
+ /**
+ * Sensor Bit: Orientation tracking
+ */
+ public static final int SENSOR_ORIENTATION = 1 << 0;
+
+ /**
+ * Sensor Bit: Yaw correction
+ */
+ public static final int SENSOR_YAW_CORRECTION = 1 << 1;
+
+ /**
+ * Sensor Bit: Positional tracking
+ */
+ public static final int SENSOR_POSITION = 1 << 2;
+
/** Return the factory used to create this device. */
public StereoDeviceFactory getFactory();
- /** Disposes this {@link StereoDevice}, if {@link #isValid() valid}. */
+ /**
+ * Disposes this {@link StereoDevice}, if {@link #isValid() valid}.
+ * <p>
+ * Implementation shall {@link #stopSensors() stop sensors} and free all resources.
+ * </p>
+ */
public void dispose();
/**
@@ -96,13 +116,59 @@ public interface StereoDevice {
*/
public FovHVHalves[] getDefaultFOV();
- /** Start or stop sensors. Returns true if action was successful, otherwise false. */
- public boolean startSensors(boolean start);
+ /**
+ * Start desired and required sensors. Returns true if action was successful, otherwise false.
+ * <p>
+ * Method fails if required sensors are not {@link #getSupportedSensorBits() supported}.
+ * </p>
+ * @param desiredSensorBits the desired optional sensors
+ * @param requiredSensorBits the required sensors
+ * @see #stopSensors()
+ * @see #getSensorsStarted()
+ * @see #getSupportedSensorBits()
+ * @see #getEnabledSensorBits()
+ */
+ public boolean startSensors(int desiredSensorBits, int requiredSensorBits);
+
+ /**
+ * Stop sensors. Returns true if action was successful, otherwise false.
+ * @see #startSensors(int, int)
+ * @see #getSensorsStarted()
+ * @see #getSupportedSensorBits()
+ * @see #getEnabledSensorBits()
+ */
+ public boolean stopSensors();
- /** Return true if sensors have been started, false otherwise */
+ /**
+ * Return true if sensors have been started, false otherwise.
+ * @see #startSensors(int, int)
+ * @see #stopSensors()
+ * @see #getSupportedSensorBits()
+ * @see #getEnabledSensorBits()
+ */
public boolean getSensorsStarted();
/**
+ * Returns the supported sensor capability bits, e.g. {@link #SENSOR_ORIENTATION}, {@link #SENSOR_POSITION}
+ * of the {@link StereoDevice}.
+ * @see #startSensors(int, int)
+ * @see #stopSensors()
+ * @see #getSensorsStarted()
+ * @see #getEnabledSensorBits()
+ */
+ public int getSupportedSensorBits();
+
+ /**
+ * Returns the actual used sensor capability bits, e.g. {@link #SENSOR_ORIENTATION}, {@link #SENSOR_POSITION}
+ * in case the {@link #getSupportedSensorBits() device supports} them and if they are enabled.
+ * @see #startSensors(int, int)
+ * @see #stopSensors()
+ * @see #getSensorsStarted()
+ * @see #getSupportedSensorBits()
+ */
+ public int getEnabledSensorBits();
+
+ /**
* Returns an array of the preferred eye rendering order.
* The array length reflects the supported eye count.
* <p>
@@ -112,7 +178,7 @@ public interface StereoDevice {
public int[] getEyeRenderOrder();
/**
- * Returns the supported distortion compensation by the {@link StereoDeviceRenderer},
+ * Returns the supported distortion compensation of the {@link StereoDeviceRenderer},
* e.g. {@link StereoDeviceRenderer#DISTORTION_BARREL}, {@link StereoDeviceRenderer#DISTORTION_CHROMATIC}, etc.
* @see StereoDeviceRenderer#getDistortionBits()
* @see #createRenderer(int, int, float[], FovHVHalves[], float, int)
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java
index 2078a00a2..0d6539634 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoDeviceRenderer.java
@@ -42,10 +42,10 @@ import com.jogamp.opengl.math.FovHVHalves;
* <ul>
* <li>device.{@link #beginFrame(GL)}</li>
* <li>For both eyes:<ul>
- * <li>device.{@link #updateEyePose(int)}</li>
+ * <li>device.{@link #updateViewerPose(int)}</li>
* <li>if device.{@link #ppAvailable()}: Set the render target, e.g. FBO</li>
* <li>Set the viewport using {@link Eye#getViewport()}</li>
- * <li>{@link StereoGLEventListener#reshapeForEye(com.jogamp.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, EyePose) upstream.reshapeEye(..)}</li>
+ * <li>{@link StereoGLEventListener#reshapeForEye(com.jogamp.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, ViewerPose) upstream.reshapeEye(..)}</li>
* <li>{@link StereoGLEventListener#display(com.jogamp.opengl.GLAutoDrawable, int) upstream.display(..)}.</li>
* </ul></li>
* <li>Reset the viewport</li>
@@ -89,7 +89,7 @@ public interface StereoDeviceRenderer {
/**
* Distortion Bit: Timewarp distortion technique to predict
- * {@link EyePose} movement to reduce latency.
+ * {@link ViewerPose} movement to reduce latency.
* <p>
* FIXME: Explanation needs refinement!
* </p>
@@ -113,10 +113,6 @@ public interface StereoDeviceRenderer {
* Returns the {@link EyeParameter} of this eye.
*/
public EyeParameter getEyeParameter();
- /**
- * Returns the last {@link EyePose} of this eye.
- */
- public EyePose getLastEyePose();
}
/**
@@ -125,10 +121,14 @@ public interface StereoDeviceRenderer {
public Eye getEye(final int eyeNum);
/**
- * Updates the {@link Eye#getLastEyePose()}
- * for the denoted <code>eyeNum</code>.
+ * Updates the {@link ViewerPose} and returns it.
+ */
+ public ViewerPose updateViewerPose();
+
+ /**
+ * Returns the last {@link ViewerPose}.
*/
- public EyePose updateEyePose(final int eyeNum);
+ public ViewerPose getLastViewerPose();
/**
* Returns used distortion compensation bits, e.g. {@link #DISTORTION_BARREL},
@@ -219,7 +219,7 @@ public interface StereoDeviceRenderer {
/**
* Begin stereoscopic post-processing, see {@link #ppAvailable()}.
* <p>
- * {@link #updateEyePose(int)} for both eyes must be called upfront
+ * {@link #updateViewerPose(int)} for both eyes must be called upfront
* when rendering upstream {@link StereoGLEventListener}.
* </p>
*
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java
index c1a06796c..59f38f2af 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoGLEventListener.java
@@ -51,7 +51,7 @@ public interface StereoGLEventListener extends CustomGLEventListener {
* </p>
* <p>
* The client shall also update it's projection- and modelview matrices according
- * to the given {@link EyeParameter} and {@link EyePose}.
+ * to the given {@link EyeParameter} and {@link ViewerPose}.
* </p>
* <p>
* For efficiency the GL viewport has already been updated
@@ -64,11 +64,11 @@ public interface StereoGLEventListener extends CustomGLEventListener {
* @param width viewport width in pixel units
* @param height viewport height in pixel units
* @param eyeParam constant eye parameter, i.e. FOV and IPD
- * @param eyePose current eye position and orientation
+ * @param viewerPose current viewer position and orientation
* @see FloatUtil#makePerspective(float[], int, boolean, com.jogamp.opengl.math.FloatUtil.FovHVHalves, float, float)
*/
public void reshapeForEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height,
- final EyeParameter eyeParam, final EyePose eyePose);
+ final EyeParameter eyeParam, final ViewerPose viewerPose);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java
index b0ca4ddb2..b6f76a343 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoUtil.java
@@ -97,23 +97,51 @@ public class StereoUtil {
return sb.toString();
}
+ /** See {@link StereoDevice#getSupportedSensorBits()} and {@link StereoDevice#getEnabledSensorBits()}. */
+ public static boolean usesOrientationSensor(final int sensorBits) { return 0 != ( sensorBits & StereoDevice.SENSOR_ORIENTATION ) ; }
+ /** See {@link StereoDevice#getSupportedSensorBits()} and {@link StereoDevice#getEnabledSensorBits()}. */
+ public static boolean usesYawCorrectionSensor(final int sensorBits) { return 0 != ( sensorBits & StereoDevice.SENSOR_YAW_CORRECTION ) ; }
+ /** See {@link StereoDevice#getSupportedSensorBits()} and {@link StereoDevice#getEnabledSensorBits()}. */
+ public static boolean usesPositionSensor(final int sensorBits) { return 0 != ( sensorBits & StereoDevice.SENSOR_POSITION ) ; }
+
+ /** See {@link StereoDevice#getSupportedSensorBits()} and {@link StereoDevice#getEnabledSensorBits()}. */
+ public static String sensorBitsToString(final int sensorBits) {
+ boolean appendComma = false;
+ final StringBuilder sb = new StringBuilder();
+ if( usesOrientationSensor(sensorBits) ) {
+ if( appendComma ) { sb.append(", "); };
+ sb.append("orientation"); appendComma=true;
+ }
+ if( usesYawCorrectionSensor(sensorBits) ) {
+ if( appendComma ) { sb.append(", "); };
+ sb.append("yaw-corr"); appendComma=true;
+ }
+ if( usesPositionSensor(sensorBits) ) {
+ if( appendComma ) { sb.append(", "); };
+ sb.append("position"); appendComma=true;
+ }
+ return sb.toString();
+ }
+
/**
* Calculates the <i>Side By Side</i>, SBS, projection- and modelview matrix for one eye.
* <p>
- * {@link #updateEyePose(int)} must be called upfront.
+ * {@link #updateViewerPose(int)} must be called upfront.
* </p>
* <p>
* This method merely exist as an example implementation to compute the matrices,
* which shall be adopted by the
- * {@link CustomGLEventListener#reshape(com.jogamp.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, EyePose) upstream client code}.
+ * {@link CustomGLEventListener#reshape(com.jogamp.opengl.GLAutoDrawable, int, int, int, int, EyeParameter, ViewerPose) upstream client code}.
* </p>
- * @param eyeNum eye denominator
+ * @param viewerPose
+ * @param eye
* @param zNear frustum near value
* @param zFar frustum far value
* @param mat4Projection float[16] projection matrix result
* @param mat4Modelview float[16] modelview matrix result
*/
- public static void getSBSUpstreamPMV(final Eye eye, final float zNear, final float zFar,
+ public static void getSBSUpstreamPMV(final ViewerPose viewerPose, final Eye eye,
+ final float zNear, final float zFar,
final float[] mat4Projection, final float[] mat4Modelview) {
final float[] mat4Tmp1 = new float[16];
final float[] mat4Tmp2 = new float[16];
@@ -122,7 +150,6 @@ public class StereoUtil {
final float[] vec3Tmp3 = new float[3];
final EyeParameter eyeParam = eye.getEyeParameter();
- final EyePose eyePose = eye.getLastEyePose();
//
// Projection
@@ -135,10 +162,10 @@ public class StereoUtil {
final Quaternion rollPitchYaw = new Quaternion();
// private final float eyeYaw = FloatUtil.PI; // 180 degrees in radians
// rollPitchYaw.rotateByAngleY(eyeYaw);
- final float[] shiftedEyePos = rollPitchYaw.rotateVector(vec3Tmp1, 0, eyePose.position, 0);
+ final float[] shiftedEyePos = rollPitchYaw.rotateVector(vec3Tmp1, 0, viewerPose.position, 0);
VectorUtil.addVec3(shiftedEyePos, shiftedEyePos, eyeParam.positionOffset);
- rollPitchYaw.mult(eyePose.orientation);
+ rollPitchYaw.mult(viewerPose.orientation);
final float[] up = rollPitchYaw.rotateVector(vec3Tmp2, 0, VectorUtil.VEC3_UNIT_Y, 0);
final float[] forward = rollPitchYaw.rotateVector(vec3Tmp3, 0, VectorUtil.VEC3_UNIT_Z_NEG, 0);
final float[] center = VectorUtil.addVec3(forward, shiftedEyePos, forward);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java
index aa64ff130..40411ac88 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/EyePose.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/ViewerPose.java
@@ -30,29 +30,34 @@ package com.jogamp.opengl.util.stereo;
import com.jogamp.opengl.math.Quaternion;
/**
- * Position and orientation of one eye.
+ * Position and orientation of viewer.
*/
-public final class EyePose {
- /** Eye number, <code>0</code> for the left eye and <code>1</code> for the right eye. */
- public final int number;
-
- /** float[3] eye position vector. */
+public final class ViewerPose {
+ /**
+ * float[3] position of viewer in meter.
+ * <p>
+ * Apply the following to resolve the actual eye position:
+ * <ul>
+ * <li>{@link EyeParameter#positionOffset positionOffset} for head.</li>
+ * <li>[{@link EyeParameter#distNoseToPupilX distNoseToPupilX}, {@link EyeParameter#distMiddleToPupilY distMiddleToPupilY}, {@link EyeParameter#eyeReliefZ eyeReliefZ}] for pupil</li>
+ * </ul>
+ * </p>
+ */
public final float[] position;
- /** Eye orientation */
+ /** Orientation of viewer. */
public final Quaternion orientation;
- public EyePose(final int number) {
- this.number = number;
+ public ViewerPose() {
this.position = new float[3];
this.orientation = new Quaternion();
}
- public EyePose(final int number, final float[] position, final Quaternion orientation) {
- this(number);
+ public ViewerPose(final float[] position, final Quaternion orientation) {
+ this();
set(position, orientation);
}
- /** Set position and orientation of this instance. */
+ /** Set {@link #position} and {@link #orientation}. */
public final void set(final float[] position, final Quaternion orientation) {
System.arraycopy(position, 0, this.position, 0, 3);
this.orientation.set(orientation);
@@ -64,6 +69,6 @@ public final class EyePose {
position[2] = posZ;
}
public final String toString() {
- return "EyePose[num "+number+", pos["+position[0]+", "+position[1]+", "+position[2]+"], "+orientation+"]";
+ return "ViewerPose[pos["+position[0]+", "+position[1]+", "+position[2]+"], "+orientation+"]";
}
} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceConfig.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceConfig.java
index 04fd8343c..44129de02 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceConfig.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceConfig.java
@@ -37,6 +37,7 @@ import com.jogamp.opengl.util.stereo.EyeParameter;
import com.jogamp.opengl.util.stereo.StereoDeviceConfig;
import com.jogamp.opengl.util.stereo.StereoDeviceRenderer;
import com.jogamp.opengl.util.stereo.StereoUtil;
+import com.jogamp.opengl.util.stereo.StereoDevice;
/**
* Configuration for {@link GenericStereoDevice}s.
@@ -54,6 +55,7 @@ public class GenericStereoDeviceConfig extends StereoDeviceConfig {
final float interpupillaryDistanceInMeters,
final int[] eyeRenderOrder,
final EyeParameter[] defaultEyeParam,
+ final int supportedSensorBits,
final DistortionMesh.Producer distortionMeshProducer,
final int supportedDistortionBits,
final int recommendedDistortionBits,
@@ -71,6 +73,7 @@ public class GenericStereoDeviceConfig extends StereoDeviceConfig {
this.interpupillaryDistanceInMeters = interpupillaryDistanceInMeters;
this.eyeRenderOrder = eyeRenderOrder;
this.defaultEyeParam = defaultEyeParam;
+ this.supportedSensorBits = supportedSensorBits;
this.distortionMeshProducer = distortionMeshProducer;
this.supportedDistortionBits = supportedDistortionBits;
this.recommendedDistortionBits = recommendedDistortionBits;
@@ -92,6 +95,7 @@ public class GenericStereoDeviceConfig extends StereoDeviceConfig {
this.interpupillaryDistanceInMeters = source.interpupillaryDistanceInMeters;
this.eyeRenderOrder = source.eyeRenderOrder;
this.defaultEyeParam = source.defaultEyeParam;
+ this.supportedSensorBits = source.supportedSensorBits;
this.distortionMeshProducer = source.distortionMeshProducer;
this.supportedDistortionBits = source.supportedDistortionBits;
this.recommendedDistortionBits = source.recommendedDistortionBits;
@@ -141,7 +145,8 @@ public class GenericStereoDeviceConfig extends StereoDeviceConfig {
" [m], eyeParam "+Arrays.toString(defaultEyeParam)+
", distortionBits[supported ["+StereoUtil.distortionBitsToString(supportedDistortionBits)+
"], recommended ["+StereoUtil.distortionBitsToString(recommendedDistortionBits)+
- "], minimum ["+StereoUtil.distortionBitsToString(minimumDistortionBits)+"]]]";
+ "], minimum ["+StereoUtil.distortionBitsToString(minimumDistortionBits)+"]]"+
+ ", sensorBits[supported ["+StereoUtil.sensorBitsToString(supportedSensorBits)+"]]]";
}
/** Configuration Name */
@@ -164,9 +169,13 @@ public class GenericStereoDeviceConfig extends StereoDeviceConfig {
public final float[/*per-eye*/][/*xy*/] pupilCenterFromTopLeft;
public final int[] eyeRenderOrder;
public final EyeParameter[] defaultEyeParam;
+
+ /** Supported sensor bits, see {@link StereoDevice#SENSOR_ORIENTATION}. */
+ public final int supportedSensorBits;
+
public final DistortionMesh.Producer distortionMeshProducer;
- /** Supported distortion bits, see {@link StereoDeviceRenderer.DISTORTION_BARREL}. */
+ /** Supported distortion bits, see {@link StereoDeviceRenderer#DISTORTION_BARREL}. */
public final int supportedDistortionBits;
/** Recommended distortion bits, see {@link StereoDeviceRenderer.DISTORTION_BARREL}. */
public final int recommendedDistortionBits;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
index 6adb96ba4..957758e78 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/generic/GenericStereoDeviceFactory.java
@@ -70,6 +70,7 @@ public class GenericStereoDeviceFactory extends StereoDeviceFactory {
// degrees: 45/2 l, 45/2 r, 45/2 * aspect t, 45/2 * aspect b
FovHVHalves.byFovyRadianAndAspect(45f*d2r, 1280f / 800f),
0f /* distNoseToPupil */, 0f /* verticalDelta */, 0f /* eyeReliefInMeters */) },
+ 0, // supported sensor bits
null, // mash producer distortion bits
0, // supported distortion bits
0, // recommended distortion bits
@@ -114,6 +115,7 @@ public class GenericStereoDeviceFactory extends StereoDeviceFactory {
interpupillaryDistanceInMeters/2f /* distNoseToPupil */, 0f /* verticalDelta */, 0.010f /* eyeReliefInMeters */),
new EyeParameter(1, defaultEyePositionOffset, defaultSBSEyeFovRight,
-interpupillaryDistanceInMeters/2f /* distNoseToPupil */, 0f /* verticalDelta */, 0.010f /* eyeReliefInMeters */) },
+ 0, // supported sensor bits
null, // mash producer distortion bits
0, // supported distortion bits
0, // recommended distortion bits
@@ -171,6 +173,7 @@ public class GenericStereoDeviceFactory extends StereoDeviceFactory {
interpupillaryDistanceInMeters/2f /* distNoseToPupil */, 0f /* verticalDelta */, 0.010f /* eyeReliefInMeters */),
new EyeParameter(1, defaultEyePositionOffset, defaultSBSEyeFovRight,
-interpupillaryDistanceInMeters/2f /* distNoseToPupil */, 0f /* verticalDelta */, 0.010f /* eyeReliefInMeters */) },
+ 0, // supported sensor bits
lenseDistMeshProduce,
// supported distortion bits
StereoDeviceRenderer.DISTORTION_BARREL | StereoDeviceRenderer.DISTORTION_CHROMATIC | StereoDeviceRenderer.DISTORTION_VIGNETTE,
diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
index 9c0a5045b..491535dc1 100644
--- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
+++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java
@@ -39,6 +39,7 @@ import com.jogamp.opengl.util.stereo.EyeParameter;
import com.jogamp.opengl.util.stereo.StereoDevice;
import com.jogamp.opengl.util.stereo.StereoDeviceFactory;
import com.jogamp.opengl.util.stereo.StereoDeviceRenderer;
+import com.jogamp.opengl.util.stereo.StereoUtil;
import com.jogamp.opengl.util.stereo.generic.GenericStereoDeviceConfig;
import com.jogamp.opengl.util.stereo.generic.GenericStereoDeviceFactory;
@@ -117,6 +118,7 @@ public class GenericStereoDevice implements StereoDevice {
public final Point surfacePos;
private final FovHVHalves[] defaultEyeFov;
+ private int usedSensorBits;
private boolean sensorsStarted = false;
public GenericStereoDevice(final StereoDeviceFactory factory, final int deviceIndex, final StereoDeviceConfig customConfig) {
@@ -137,6 +139,9 @@ public class GenericStereoDevice implements StereoDevice {
for(int i=0; i<defaultEyeFov.length; i++) {
defaultEyeFov[i] = config.defaultEyeParam[i].fovhv;
}
+
+ // default
+ usedSensorBits = 0;
}
@Override
@@ -144,7 +149,8 @@ public class GenericStereoDevice implements StereoDevice {
@Override
public String toString() {
- return "GenericStereoDevice["+config+", surfacePos "+surfacePos+"]";
+ return "GenericStereoDevice["+config+", surfacePos "+surfacePos+
+ ", sensorBits[enabled ["+StereoUtil.sensorBitsToString(getEnabledSensorBits())+"]]]";
}
public void setSurfacePosition(final int x, final int y) {
@@ -153,7 +159,7 @@ public class GenericStereoDevice implements StereoDevice {
@Override
public final void dispose() {
- // NOP
+ stopSensors();
}
@Override
@@ -184,21 +190,42 @@ public class GenericStereoDevice implements StereoDevice {
}
@Override
- public final boolean startSensors(final boolean start) {
- if( start && !sensorsStarted ) {
- if( startSensorsImpl(true) ) {
+ public final boolean startSensors(final int desiredSensorBits, final int requiredSensorBits) {
+ if( !sensorsStarted ) {
+ if( requiredSensorBits != ( config.supportedSensorBits & requiredSensorBits ) ) {
+ // required sensors not available
+ return false;
+ }
+ if( 0 == ( config.supportedSensorBits & ( requiredSensorBits | desiredSensorBits ) ) ) {
+ // no sensors available
+ return false;
+ }
+ if( startSensorsImpl(true, desiredSensorBits, requiredSensorBits) ) {
sensorsStarted = true;
return true;
} else {
- sensorsStarted = false;
return false;
}
- } else if( sensorsStarted ) {
- if( startSensorsImpl(false) ) {
+ } else {
+ // No state change -> Success
+ return true;
+ }
+ }
+ protected boolean startSensorsImpl(final boolean start, final int desiredSensorBits, final int requiredSensorBits) {
+ // TODO: Add SPI for sensors
+ // TODO: start sensors in override / or SPI
+ // TODO: set usedSensorBits
+ return false;
+ }
+
+ @Override
+ public final boolean stopSensors() {
+ if( sensorsStarted ) {
+ if( startSensorsImpl(false, 0, 0) ) {
sensorsStarted = false;
+ usedSensorBits = 0;
return true;
} else {
- sensorsStarted = true;
return false;
}
} else {
@@ -206,12 +233,21 @@ public class GenericStereoDevice implements StereoDevice {
return true;
}
}
- private boolean startSensorsImpl(final boolean start) { return start; }
@Override
public boolean getSensorsStarted() { return sensorsStarted; }
@Override
+ public final int getSupportedSensorBits() {
+ return config.supportedSensorBits;
+ }
+
+ @Override
+ public final int getEnabledSensorBits() {
+ return usedSensorBits;
+ }
+
+ @Override
public int[] getEyeRenderOrder() { return config.eyeRenderOrder; }
@Override
diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
index 6650342e7..21567a0f1 100644
--- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
+++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java
@@ -49,7 +49,7 @@ import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.stereo.EyeParameter;
-import com.jogamp.opengl.util.stereo.EyePose;
+import com.jogamp.opengl.util.stereo.ViewerPose;
import com.jogamp.opengl.util.stereo.StereoDevice;
import com.jogamp.opengl.util.stereo.StereoDeviceRenderer;
import com.jogamp.opengl.util.stereo.StereoUtil;
@@ -82,7 +82,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
private final EyeParameter eyeParameter;
- private final EyePose eyePose;
@Override
public final RectangleImmutable getViewport() { return viewport; }
@@ -90,12 +89,9 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
@Override
public final EyeParameter getEyeParameter() { return eyeParameter; }
- @Override
- public final EyePose getLastEyePose() { return eyePose; }
-
- private GenericEye(final GenericStereoDevice device, final int distortionBits,
- final float[] eyePositionOffset, final EyeParameter eyeParam,
- final DimensionImmutable textureSize, final RectangleImmutable eyeViewport) {
+ /* pp */ GenericEye(final GenericStereoDevice device, final int distortionBits,
+ final float[] eyePositionOffset, final EyeParameter eyeParam,
+ final DimensionImmutable textureSize, final RectangleImmutable eyeViewport) {
this.eyeName = eyeParam.number;
this.distortionBits = distortionBits;
this.viewport = eyeViewport;
@@ -123,10 +119,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
this.eyeParameter = eyeParam;
- this.eyePose = new EyePose(eyeName);
-
- updateEyePose(device); // 1st init
-
// Setup: eyeToSourceUVScale, eyeToSourceUVOffset
if( usePP ) {
final ScaleAndOffset2D textureScaleAndOffset = new ScaleAndOffset2D(eyeParam.fovhv, textureSize, eyeViewport);
@@ -333,18 +325,18 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
indices.enableBuffer(gl, false);
}
- private void dispose(final GL2ES2 gl) {
+ /* pp */ void dispose(final GL2ES2 gl) {
if( null == iVBO ) return;
iVBO.destroy(gl);
indices.destroy(gl);
}
- private void enableVBO(final GL2ES2 gl, final boolean enable) {
+ /* pp */ void enableVBO(final GL2ES2 gl, final boolean enable) {
if( null == iVBO ) return;
iVBO.enableBuffer(gl, enable);
indices.bindBuffer(gl, enable); // keeps VBO binding if enable:=true
}
- private void updateUniform(final GL2ES2 gl, final ShaderProgram sp) {
+ /* pp */ void updateUniform(final GL2ES2 gl, final ShaderProgram sp) {
if( null == iVBO ) return;
gl.glUniform(eyeToSourceUVScale);
gl.glUniform(eyeToSourceUVOffset);
@@ -354,15 +346,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
}
}
- /**
- * Updates {@link #ovrEyePose} and it's extracted
- * {@link #eyeRenderPoseOrientation} and {@link #eyeRenderPosePosition}.
- * @param hmdCtx used get the {@link #ovrEyePose} via {@link OVR#ovrHmd_GetEyePose(OvrHmdContext, int)}
- */
- private EyePose updateEyePose(final GenericStereoDevice hmdCtx) {
- return eyePose;
- }
-
@Override
public String toString() {
final String ppTxt = null == iVBO ? ", no post-processing" :
@@ -373,12 +356,13 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
", "+eyeParameter+
", vertices "+vertexCount+", indices "+indexCount+
ppTxt+
- ", desc"+eyeParameter+", "+eyePose+"]";
+ ", desc "+eyeParameter+"]";
}
}
private final GenericStereoDevice device;
private final GenericEye[] eyes;
+ private final ViewerPose viewerPose;
private final int distortionBits;
private final int textureCount;
private final DimensionImmutable[] eyeTextureSizes;
@@ -445,9 +429,11 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
this.totalTextureSize = zeroSize;
texUnit0 = null;
}
+ viewerPose = new ViewerPose();
for(int i=0; i<eyeParam.length; i++) {
eyes[i] = new GenericEye(context, this.distortionBits, eyePositionOffset, eyeParam[i], textureSizes[i], eyeViewports[i]);
}
+
sp = null;
}
@@ -559,8 +545,14 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
}
@Override
- public final EyePose updateEyePose(final int eyeNum) {
- return eyes[eyeNum].updateEyePose(device);
+ public final ViewerPose updateViewerPose() {
+ // NOP
+ return viewerPose;
+ }
+
+ @Override
+ public final ViewerPose getLastViewerPose() {
+ return viewerPose;
}
@Override