void OnScreenDataChange(ScreenData screen) { int angle = 0; switch (DeviceOrientationChange.GetDeviceOrientation()) { case DeviceOrientation.LandscapeLeft: RotateLandscapeLeft(); angle = 0; break; case DeviceOrientation.LandscapeRight: RotateLandscapeRight(); angle = 180; break; case DeviceOrientation.Portrait: RotatePortrait(); angle = 90; break; case DeviceOrientation.PortraitUpsideDown: RotatePortaitUpsideDown(); angle = 270; break; } PikkartARCore.UpdateViewport((int)screen.resolution.x, (int)screen.resolution.y, angle); }
public void InitWebcam(bool front_facing) { if (rawImage == null) { rawImage = GetComponent <RawImage>(); if (rawImage != null) { rawImage.texture = Texture2D.blackTexture; } } if (textureToShow == null) { textureToShow = new Texture2D(Constants.CAMERA_REQUESTED_WIDTH, Constants.CAMERA_REQUESTED_HEIGHT, TextureFormat.RGBA32, false); textureToShow.Apply(); } #if !UNITY_EDITOR PikkartARCore.CameraUpdateUnityTextureId_GL(textureToShow.GetNativeTexturePtr()); #endif #if UNITY_EDITOR PikkartARCore.UpdateViewport((int)Constants.CAMERA_REQUESTED_WIDTH, (int)Constants.CAMERA_REQUESTED_HEIGHT, 0); #endif DeviceOrientationChange.OnScreenDataChange += OnScreenDataChange; portraitScale = new Vector3( (float)Constants.CAMERA_REQUESTED_HEIGHT / (float)Constants.CAMERA_REQUESTED_WIDTH, (float)Constants.CAMERA_REQUESTED_HEIGHT / (float)Constants.CAMERA_REQUESTED_WIDTH, 1.0f); data = null; imagePtr_send = IntPtr.Zero; imagePtr_receive = Marshal.AllocHGlobal(Constants.CAMERA_REQUESTED_WIDTH * Constants.CAMERA_REQUESTED_HEIGHT * 4); webcamTexture = GetManagedWebCamTexture(front_facing); if (rawImage != null) { rawImage.texture = textureToShow; } initialized_manager = true; OnScreenDataChange(DeviceOrientationChange.GetUpdatedDeviceOrientation()); }
public static Matrix4x4 GetRotationMatrixForOrientation() { switch (DeviceOrientationChange.GetDeviceOrientation()) { case DeviceOrientation.Portrait: return(GetRotationMatrixPortrait()); case DeviceOrientation.PortraitUpsideDown: return(GetRotationMatrixPortraitUpsideDown()); case DeviceOrientation.LandscapeRight: return(GetRotationLandscapeRight()); default: return(GetRotationLandscapeLeft()); } }