public static Matrix4x4 GetAlternateLandscapeProjectionMatrix() { //Debug.Log("landscape hfov=" + Constants.CAM_LARGE_FOV + " vfov=" + Constants.CAM_SMALL_FOV); float[] mat_data = new float[16]; PikkartARCore.GetProjectionMatrix(mat_data); /*alternateLandscapeProjectionMatrix.m00 = mat_data[0]; * alternateLandscapeProjectionMatrix.m01 = mat_data[1]; * alternateLandscapeProjectionMatrix.m02 = mat_data[2]; * alternateLandscapeProjectionMatrix.m03 = mat_data[3]; * * alternateLandscapeProjectionMatrix.m10 = mat_data[4]; * alternateLandscapeProjectionMatrix.m11 = mat_data[5]; * alternateLandscapeProjectionMatrix.m12 = mat_data[6]; * alternateLandscapeProjectionMatrix.m13 = mat_data[7]; * * alternateLandscapeProjectionMatrix.m20 = mat_data[8]; * alternateLandscapeProjectionMatrix.m21 = mat_data[9]; * alternateLandscapeProjectionMatrix.m22 = mat_data[10]; * alternateLandscapeProjectionMatrix.m23 = mat_data[11]; * * alternateLandscapeProjectionMatrix.m30 = mat_data[12]; * alternateLandscapeProjectionMatrix.m31 = mat_data[13]; * alternateLandscapeProjectionMatrix.m32 = mat_data[14]; * alternateLandscapeProjectionMatrix.m33 = mat_data[15];*/ //horizontal field of view = 2 atan(0.5 width / focallength) double v = 1.0 / (double)(mat_data[0]); double at = Math.Atan(v); double hfov = 2.0 * at; float camera_ar = Constants.CAMERA_REQUESTED_WIDTH / Constants.CAMERA_REQUESTED_HEIGHT; float t = ScreenUtilities.GetPortraitAspectRatio() * camera_ar * (float)Math.Tan(hfov / 2.0); float a = 2.0f * (float)Math.Atan((double)(t)) * 57.2958f; alternateLandscapeProjectionMatrix = Matrix4x4.Perspective( a, ScreenUtilities.GetLandscapeAspectRatio(), Constants.NEAR_CLIP_PLANE, Constants.FAR_CLIP_PLANE); return(alternateLandscapeProjectionMatrix); }
public static Matrix4x4 GetAlternatePortraitProjectionMatrix() { //Debug.Log("portrait hfov=" + Constants.CAM_LARGE_FOV + " vfov=" + Constants.CAM_SMALL_FOV); float[] mat_data = new float[16]; PikkartARCore.GetProjectionMatrix(mat_data); /*alternateLandscapeProjectionMatrix.m00 = mat_data[0]; * alternateLandscapeProjectionMatrix.m01 = mat_data[1]; * alternateLandscapeProjectionMatrix.m02 = mat_data[2]; * alternateLandscapeProjectionMatrix.m03 = mat_data[3]; * * alternateLandscapeProjectionMatrix.m10 = mat_data[4]; * alternateLandscapeProjectionMatrix.m11 = mat_data[5]; * alternateLandscapeProjectionMatrix.m12 = mat_data[6]; * alternateLandscapeProjectionMatrix.m13 = mat_data[7]; * * alternateLandscapeProjectionMatrix.m20 = mat_data[8]; * alternateLandscapeProjectionMatrix.m21 = mat_data[9]; * alternateLandscapeProjectionMatrix.m22 = mat_data[10]; * alternateLandscapeProjectionMatrix.m23 = mat_data[11]; * * alternateLandscapeProjectionMatrix.m30 = mat_data[12]; * alternateLandscapeProjectionMatrix.m31 = mat_data[13]; * alternateLandscapeProjectionMatrix.m32 = mat_data[14]; * alternateLandscapeProjectionMatrix.m33 = mat_data[15];*/ double v = 1.0 / (double)(mat_data[0]); double at = Math.Atan(v); double hfov = 2.0 * at * 57.2958; alternatePortraitProjectionMatrix = Matrix4x4.Perspective( (float)hfov, ScreenUtilities.GetPortraitAspectRatio(), Constants.NEAR_CLIP_PLANE, Constants.FAR_CLIP_PLANE); return(alternatePortraitProjectionMatrix); }
public bool IsResolutionLandscape() { return(ScreenUtilities.IsLandscapeResolution(resolution)); }
/// <summary> /// Initializes a new instance of the <see cref="PikkartAR.RecognitionManager"/> class. /// </summary> /// <param name="width">Frame Width.</param> /// <param name="height">Frame Height.</param> /// <param name="localRecognitionService">Object that implements the communication interface.</param> public RecognitionManager(IMarkerObjectListener markerObjectListener) { _markerObjectListener = markerObjectListener; _recognitionRunning = false; #if UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject context = jc.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject assetManager = context.Call <AndroidJavaObject>("getAssets"); #endif _deviceId = RecognitionManager.GetDeviceId(); // Native Recognition Service Initialization if (!_nativeWrapperInitialized) { int res = PikkartARCore.InitRecognition( #if UNITY_ANDROID && !UNITY_EDITOR assetManager.GetRawObject(), #endif _localMarkerNotFoundEventMinIntervalMillisecs, #if UNITY_EDITOR_OSX || (UNITY_IOS && !UNITY_EDITOR_WIN) GetAppDataPath(), #else new StringBuilder(GetAppDataPath()), #endif #if UNITY_EDITOR_WIN new StringBuilder(Application.streamingAssetsPath), #if UNITY_5_6_OR_NEWER new StringBuilder(PlayerSettings.applicationIdentifier), #else new StringBuilder(PlayerSettings.bundleIdentifier), #endif #elif UNITY_EDITOR_OSX Application.streamingAssetsPath, #if UNITY_5_6_OR_NEWER PlayerSettings.applicationIdentifier, #else PlayerSettings.bundleIdentifier, #endif #endif Constants.PROCESS_WIDTH, Constants.PROCESS_HEIGHT, ScreenUtilities.GetScreenInches(), Constants.CAMERA_REQUESTED_WIDTH, Constants.CAMERA_REQUESTED_HEIGHT, false); if (res > 0) { _licenceChecked = true; } else { _licenceChecked = false; } if (res == 0) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR if (MonoBehaviour.FindObjectOfType <LicenseMessage>() != null) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(true); } if (MonoBehaviour.FindObjectOfType <TrialMessage>() != null) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false); } #elif UNITY_EDITOR if (MonoBehaviour.FindObjectOfType <TrialMessage>() != null) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false); } if (MonoBehaviour.FindObjectOfType <LicenseMessage>() != null) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false); } if (EditorUtility.DisplayDialog("Licence error!", "You cannot use our sdk without a valid licence UNLESS you are in a trial!\n" + "Please register to developer.pikkart.com to obtain your own licence or set your application identifier to 'com.pikkart.trial' to evaluate our SDK.", "Ok")) { EditorApplication.isPlaying = false; } #endif } else if (res == 1) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR if (MonoBehaviour.FindObjectOfType <TrialMessage>()) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(true); } if (MonoBehaviour.FindObjectOfType <LicenseMessage>()) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false); } #elif UNITY_EDITOR if (MonoBehaviour.FindObjectOfType <TrialMessage>()) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false); } if (MonoBehaviour.FindObjectOfType <LicenseMessage>()) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false); } if (EditorUtility.DisplayDialog("No valid license", "No valid license or running as com.pikkart.trial, press Ok to run in trial mode", "Ok")) { EditorApplication.isPlaying = true; } #endif } else { if (MonoBehaviour.FindObjectOfType <TrialMessage>()) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false); } if (MonoBehaviour.FindObjectOfType <LicenseMessage>()) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false); } } PikkartARCore.SetProjectionMatrix(Constants.CAM_LARGE_FOV, Constants.CAM_SMALL_FOV); _nativeWrapperInitialized = true; //_nativeArray = Marshal.AllocHGlobal(Constants.BASE_RES_WIDTH * Constants.BASE_RES_HEIGHT * 3); } else { if (MonoBehaviour.FindObjectOfType <TrialMessage>()) { MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false); } if (MonoBehaviour.FindObjectOfType <LicenseMessage>()) { MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false); } } _dataProvider = new RecognitionDataProvider(null, this, _deviceId); }