28package com.jogamp.opengl.util.stereo;
30import com.jogamp.math.Matrix4f;
31import com.jogamp.math.Quaternion;
32import com.jogamp.math.Vec3f;
33import com.jogamp.opengl.util.CustomGLEventListener;
34import com.jogamp.opengl.util.stereo.StereoDeviceRenderer.Eye;
43 return pupilCenterFromScreenTopInMeters / screenHeightInMeters;
61 final float visibleWidthOfOneEye = 0.5f * screenWidthInMeters;
62 final float leftPupilCenterFromLeftInMeters = ( screenWidthInMeters - interpupillaryDistanceInMeters ) * 0.5f;
63 final float rightPupilCenterFromMiddleInMeters = leftPupilCenterFromLeftInMeters + interpupillaryDistanceInMeters - visibleWidthOfOneEye;
64 return new float[] { leftPupilCenterFromLeftInMeters / visibleWidthOfOneEye,
65 rightPupilCenterFromMiddleInMeters / visibleWidthOfOneEye };
69 public static boolean usesBarrelDistortion(
final int distortionBits) {
return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_BARREL ) ; }
71 public static boolean usesTimewarpDistortion(
final int distortionBits) {
return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_TIMEWARP ) ; }
73 public static boolean usesChromaticDistortion(
final int distortionBits) {
return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_CHROMATIC ) ; }
75 public static boolean usesVignetteDistortion(
final int distortionBits) {
return 0 != ( distortionBits & StereoDeviceRenderer.DISTORTION_VIGNETTE ) ; }
79 boolean appendComma =
false;
80 final StringBuilder sb =
new StringBuilder();
82 if( appendComma ) { sb.append(
", "); };
83 sb.append(
"barrel"); appendComma=
true;
86 if( appendComma ) { sb.append(
", "); };
87 sb.append(
"vignette"); appendComma=
true;
90 if( appendComma ) { sb.append(
", "); };
91 sb.append(
"chroma"); appendComma=
true;
94 if( appendComma ) { sb.append(
", "); };
95 sb.append(
"timewarp"); appendComma=
true;
101 public static boolean usesOrientationSensor(
final int sensorBits) {
return 0 != ( sensorBits & StereoDevice.SENSOR_ORIENTATION ) ; }
103 public static boolean usesYawCorrectionSensor(
final int sensorBits) {
return 0 != ( sensorBits & StereoDevice.SENSOR_YAW_CORRECTION ) ; }
105 public static boolean usesPositionSensor(
final int sensorBits) {
return 0 != ( sensorBits & StereoDevice.SENSOR_POSITION ) ; }
109 boolean appendComma =
false;
110 final StringBuilder sb =
new StringBuilder();
112 if( appendComma ) { sb.append(
", "); };
113 sb.append(
"orientation"); appendComma=
true;
116 if( appendComma ) { sb.append(
", "); };
117 sb.append(
"yaw-corr"); appendComma=
true;
120 if( appendComma ) { sb.append(
", "); };
121 sb.append(
"position"); appendComma=
true;
123 return sb.toString();
144 final float zNear,
final float zFar,
170 final Vec3f center = forward.
add(shiftedEyePos);
Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).
final Matrix4f mul(final Matrix4f b)
Multiply matrix: [this] = [this] x [b].
Matrix4f setToPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Set this matrix to perspective frustum projection.
Matrix4f setToLookAt(final Vec3f eye, final Vec3f center, final Vec3f up, final Matrix4f tmp)
Set this matrix to the look-at matrix based on given parameters.
final Matrix4f setToTranslation(final float x, final float y, final float z)
Set this matrix to translation.
Quaternion implementation supporting Gimbal-Lock free rotations.
final Vec3f rotateVector(final Vec3f vecIn, final Vec3f vecOut)
final Quaternion mult(final Quaternion q)
Multiply this quaternion by the param quaternion.
3D Vector based upon three float components.
static final Vec3f UNIT_Z_NEG
static final Vec3f UNIT_Y
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
Constant single eye parameter of the viewer, relative to its ViewerPose.
final float distNoseToPupilX
IPD related horizontal distance from nose to pupil in meter.
final FovHVHalves fovhv
Field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians.
final float distMiddleToPupilY
Vertical distance from middle-line to pupil in meter.
final Vec3f positionOffset
eye position vector used to define eye height in meter relative to actor.
final float eyeReliefZ
Z-axis eye relief in meter.
static float[] getHorizPupilCenterFromLeft(final float screenWidthInMeters, final float interpupillaryDistanceInMeters)
Return the horizontal pupil center from the left side for both eyes in the range [0....
static float getVertPupilCenterFromTop(final float screenHeightInMeters, final float pupilCenterFromScreenTopInMeters)
Return the vertical pupil center from the screen top in the range [0..1].
static String distortionBitsToString(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
static boolean usesYawCorrectionSensor(final int sensorBits)
See StereoDevice#getSupportedSensorBits() and StereoDevice#getEnabledSensorBits().
static boolean usesOrientationSensor(final int sensorBits)
See StereoDevice#getSupportedSensorBits() and StereoDevice#getEnabledSensorBits().
static boolean usesTimewarpDistortion(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
static boolean usesPositionSensor(final int sensorBits)
See StereoDevice#getSupportedSensorBits() and StereoDevice#getEnabledSensorBits().
static void getSBSUpstreamPMV(final ViewerPose viewerPose, final Eye eye, final float zNear, final float zFar, final Matrix4f mat4Projection, final Matrix4f mat4Modelview)
Calculates the Side By Side, SBS, projection- and modelview matrix for one eye.
static boolean usesBarrelDistortion(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
static boolean usesVignetteDistortion(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
static boolean usesChromaticDistortion(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
static String sensorBitsToString(final int sensorBits)
See StereoDevice#getSupportedSensorBits() and StereoDevice#getEnabledSensorBits().
position and orientation of viewer.
final Quaternion orientation
Orientation of viewer.
final Vec3f position
position of viewer in meter.
Interface describing one eye of the stereoscopic device, see StereoDeviceRenderer#getEye(int).
EyeParameter getEyeParameter()
Returns the EyeParameter of this eye.