Created
April 1, 2017 06:31
-
-
Save demonixis/279327770795293a448cf0b0e531521a to your computer and use it in GitHub Desktop.
A function to get the distortion parameters for an OSVR Application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Vector3[] GetDistortionParams() | |
{ | |
var displayConfig = _context.GetDisplayConfig(); | |
var numViewers = displayConfig.GetNumViewers(); | |
var distortionParams = new Vector3[2]; | |
if (numViewers != 1) | |
return -1; | |
for (uint viewer = 0; viewer < numViewers; viewer++) | |
{ | |
var numEyes = displayConfig.GetNumEyesForViewer(viewer); | |
if (numEyes != 2) | |
return -2; | |
for (byte eye = 0; eye < numEyes; eye++) | |
{ | |
var numSurfaces = displayConfig.GetNumSurfacesForViewerEye(viewer, eye); | |
if (numSurfaces != 1) | |
return -3; | |
for (uint surface = 0; surface < numSurfaces; surface++) | |
{ | |
var distortionCorrectionRequired = displayConfig.DoesViewerEyeSurfaceWantDistortion(viewer, eye, surface); | |
if (distortionCorrectionRequired) | |
{ | |
var radialDistortionPriority = displayConfig.GetViewerEyeSurfaceRadialDistortionPriority(viewer, eye, surface); | |
if (radialDistortionPriority >= 0) | |
{ | |
var dist = displayConfig.GetViewerEyeSurfaceRadialDistortion(viewer, eye, surface); | |
distortionParams[eye].X = (float)dist.k1.x; | |
distortionParams[eye].Y = (float)dist.k1.y; | |
distortionParams[eye].Z = (float)dist.k1.z; | |
} | |
} | |
} | |
} | |
} | |
return distortionParams; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment