Example #1
0
        public override void Render(ZView zView, IntPtr connection, IntPtr receivedFrame)
        {
            // Check to see if the image width or height changed and update them
            // accordingly.
            this.UpdateImageResolution(zView, connection);

            // Cache the camera's culling mask to be restored after it renders the frame.
            int cullingMask = _camera.cullingMask;

            // Copy the center eye camera's attributes to the standard mode primary camera.
            if (CoreCamera != null)
            {
                _camera.CopyFrom(CoreCamera.GetComponent <Camera>());
                _camera.transform.position = CoreCamera.transform.position;
                _camera.transform.rotation = CoreCamera.transform.rotation;
                _camera.projectionMatrix   = CoreCamera.projectionMatrix;
            }

            // Render the scene.
            _camera.cullingMask   = cullingMask & ~(zView.StandardModeIgnoreLayers);
            _camera.targetTexture = _renderTexture;
            _camera.Render();

            // Restore the camera's culling mask.
            _camera.cullingMask = cullingMask;
        }
Example #2
0
        private void TorchFab_Click(object sender, EventArgs e)
        {
            if (CoreCamera == null)
            {
                var javaCam = MCameraSource.JavaCast <Java.Lang.Object>();
                var fields  = javaCam.Class.GetDeclaredFields();
                foreach (Field field in fields)
                {
                    if (!field.Type.CanonicalName.Equals("android.hardware.camera", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    field.Accessible = true;
                    Object camera = field.Get(javaCam);
                    CoreCamera = (Camera)camera;
                }
            }

            if (!IsFlashOn)
            {
                if (CoreCamera != null)
                {
                    Camera.Parameters prams = CoreCamera.GetParameters();
                    prams.FlashMode = Camera.Parameters.FlashModeTorch;
                    CoreCamera.SetParameters(prams);
                }

                IsFlashOn = true;
            }
            else
            {
                Camera.Parameters prams = CoreCamera.GetParameters();
                prams.FlashMode = Camera.Parameters.FlashModeOff;
                CoreCamera.SetParameters(prams);
                IsFlashOn = false;
            }
        }