public static Matrix4x4 GetRenderRotationMatrixFromUnityToVL(VLRenderRotation rotation) { switch (rotation) { case VLRenderRotation.CCW0: return(rotationZ0); case VLRenderRotation.CCW90: return(rotationZ270); case VLRenderRotation.CCW180: return(rotationZ180); case VLRenderRotation.CCW270: return(rotationZ90); } throw new System.ArgumentException("Enum value not in enum", "orientation"); }
/// <summary> /// Computed the projection matrix from the intrinsic camera parameters. /// </summary> /// <remarks> /// The returned matrix is stored in the following order /// (column-major order): /// \f[ /// \begin{bmatrix} /// 0 & 4 & 8 & 12\\ /// 1 & 5 & 9 & 13\\ /// 2 & 6 & 10 & 14\\ /// 3 & 7 & 11 & 15\\ /// \end{bmatrix} /// \f] /// </remarks> /// <returns> /// <c>true</c>, if the projection matrix was gotten successfully; /// <c>false</c> otherwise. /// </returns> /// <param name="nearFact"> /// Value for the near clipping plane. /// </param> /// <param name="farFact"> /// Value for the far clipping plane. /// </param> /// <param name="screenWidth"> /// Width of the screen. /// </param> /// <param name="screenHeight"> /// Height of the screen. /// </param> /// <param name="renderRotation"> /// How the rendering is rotated relative to the orientation of the images /// received from the VisionLib. E.g., if the rendering happens in /// landscape-left mode and the images are also in landscape-left mode, /// then VLRenderRotation.CCW0 should be used. If the rendering happens in /// portrait mode, but the images are in landscape-left mode, then /// VLRenderRotation.CCW270 should be used. A default rotation for a given /// ScreenRotation can be obtained from VLUnityCameraHelper.GetRenderRotation. /// </param> /// <param name="mode"> /// The mode defines how to handle mismatching aspect ratios. Right now /// the mode value is ignored, but later we will support different modes /// like 'cover' (scale the projection surface up until it covers the /// whole screen) and 'contain' (scale the projection surface down until /// it is completely contained inside the screen). /// </param> /// <param name="matrix"> /// Float array with 16 elements for storing the projection matrix. /// </param> public bool GetProjectionMatrix(float nearFact, float farFact, int screenWidth, int screenHeight, VLRenderRotation renderRotation, int mode, float[] matrix) { if (this.disposed) { throw new ObjectDisposedException("VLIntrinsicDataWrapper"); } bool result = false; GCHandle matrixHandle = GCHandle.Alloc(matrix, GCHandleType.Pinned); try { uint orientation = Convert.ToUInt32(renderRotation); result = vlIntrinsicDataWrapper_GetProjectionMatrix( this.handle, nearFact, farFact, Convert.ToUInt32(screenWidth), Convert.ToUInt32(screenHeight), orientation, Convert.ToUInt32(mode), matrixHandle.AddrOfPinnedObject(), Convert.ToUInt32(matrix.Length) ); } finally { matrixHandle.Free(); } return(result); }
private void OnOrientationChange(ScreenOrientation orientation) { this.renderRotation = VLUnityCameraHelper.GetRenderRotation(orientation); this.invRotCamera = VLUnityCameraHelper.GetRenderRotationMatrixFromVLToUnity(this.renderRotation); this.rotCamera = VLUnityCameraHelper.GetRenderRotationMatrixFromUnityToVL(this.renderRotation); }
private void OnOrientationChange(ScreenOrientation orientation) { this.renderRotation = VLUnityCameraHelper.GetRenderRotation(orientation); this.UpdateBackgroundSize(); }