private void App_CompositionTargertRenderingHandler(object source, EventArgs e)
        {
            if (CameraInteraction == null)
            {
                return;
            }

            var updateRequiredAfterCameraInteraction = CameraInteraction.UpdateAndCheckIfRedrawRequired();

            if (!updateRequiredAfterCameraInteraction)
            {
                /**
                 * If the current camera is an operator, and its parameter have been modified from
                 * the outside (e.g. through animation or in the ParameterView) we have to update
                 * the CameraSetup and the interaction. */
                var shouldUpdateFromCamOp = _camSetupProvider.SelectedOperatorIsCamProvider && !CameraInteraction.SmoothedMovementInProgress;
                if (shouldUpdateFromCamOp)
                {
                    var newPos    = _camSetupProvider.OperatorCameraProvider.GetLastPosition();
                    var newTarget = _camSetupProvider.OperatorCameraProvider.GetLastTarget();
                    CameraInteraction.SetCameraAfterExternalChanges(newPos, newTarget);
                    _camSetupProvider.ActiveCameraSetup.SetCameraAfterExternalChanges(newPos, newTarget);
                }
                return;
            }

            // Trigger update of other UI Elements like ParameterView
            // Because this will eventually triggere a RenderContent, we can skip rendering it here.
            if (_camSetupProvider.SelectedOperatorIsCamProvider)
            {
                App.Current.UpdateRequiredAfterUserInteraction = true;
            }

            RenderContent();
        }
 private void KeyDown_Handler(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (!e.IsRepeat)
     {
         CameraInteraction.HandleKeyDown(e);
     }
 }
Пример #3
0
 private void Start()
 {
     gameMain          = GetComponent <GameMain>();
     cameraInteraction = GetComponent <CameraInteraction>();
     leftDragDetector  = new DragDetector(dragStartDistance);
     rightDragDetector = new DragDetector(dragStartDistance);
 }
Пример #4
0
        private void MouseDown_Handler(object sender, MouseButtonEventArgs e)
        {
            Focus();
            CameraInteraction.HandleMouseDown(e.ChangedButton);

            Mouse.Capture(this);
            e.Handled = true;
        }
        private void MouseUp_Handler(object sender, MouseButtonEventArgs e)
        {
            var wasRightMouseClick = CameraInteraction.HandleMouseUp(e.ChangedButton);

            // Release captured mouse
            if (!CameraInteraction.AnyMouseButtonPressed())
            {
                Mouse.Capture(null);
            }

            if (!wasRightMouseClick)
            {
                e.Handled = true;
            }
        }
        /* This requires ShowSceneControl to have been loaded */
        private void LateInit()
        {
            RenderConfiguration = new RenderViewConfiguration()
            {
                ShowGridAndGizmos = true,
                TransformGizmo    = new TransformGizmo(),
            };


            _camSetupProvider = new ViewCameraSetupProvider(RenderConfiguration);
            _renderSetup      = new D3DRenderSetup(RenderConfiguration);
            SetupRenderer();

            CameraInteraction = new CameraInteraction(
                RenderConfiguration,
                this);
        }
        private void KeyUp_Handler(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (RenderConfiguration.Operator == null)
            {
                return;
            }

            if (e.Key == Key.Return || Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
            {
                SwitchToFullscreenMode();
            }

            if (CameraInteraction.HandleKeyUp(e))
            {
                return;
            }
        }
Пример #8
0
        private void App_CompositionTargertRenderingHandler(object source, EventArgs e)
        {
            if (CameraInteraction == null || !CameraInteraction.UpdateAndCheckIfRedrawRequired())
            {
                return;
            }

            // Check wether this is a basic op and works as a Camera
            if (_operator != null && _operator.InternalParts.Count > 0 && _operator.InternalParts[0].Func is ICameraProvider)
            {
                App.Current.UpdateRequiredAfterUserInteraction = true;
            }
            else
            {
                RenderContent();
            }
        }
Пример #9
0
    private void MoveCamera(Character character)
    {
        if (!CameraInteraction.InstaceNotNull())
        {
            return;
        }
        Personne tar1 = CameraInteraction.GetFocusedTarget(0);
        Personne tar2 = CameraInteraction.GetFocusedTarget(1);

        if (tar1 != null && tar1.focus == character)
        {
            CameraInteraction.FocusCharacter(0, (Personne)character);
        }
        if (tar2 != null && tar2.focus == character)
        {
            CameraInteraction.FocusCharacter(1, (Personne)character);
        }
    }
Пример #10
0
        private void OnUnloadedHandler(object sender, RoutedEventArgs e)
        {
            KeyDown -= KeyDown_Handler;
            KeyUp   -= KeyUp_Handler;

            App.Current.MainWindow.GotFocus        -= MainWindow_GotFocusHandler;
            App.Current.MainWindow.ContentRendered -= MainWindow_ContentRendered_Handler;

            LostFocus -= LostFocus_Handler;

            if (App.Current != null)
            {
                App.Current.UpdateAfterUserInteractionEvent  -= App_UpdateAfterUserInteractionHandler;
                App.Current.CompositionTargertRenderingEvent -= App_CompositionTargertRenderingHandler;

                CameraInteraction.Discard();
            }
            CleanUp();
        }
Пример #11
0
        private void OnLoadedHandler(object sender, RoutedEventArgs e)
        {
            App.Current.MainWindow.GotFocus             += MainWindow_GotFocusHandler;
            App.Current.MainWindow.ContentRendered      += MainWindow_ContentRendered_Handler;
            App.Current.UpdateAfterUserInteractionEvent += App_UpdateAfterUserInteractionHandler;

            KeyDown   += KeyDown_Handler;
            KeyUp     += KeyUp_Handler;
            LostFocus += LostFocus_Handler;

            App.Current.CompositionTargertRenderingEvent  += App_CompositionTargertRenderingHandler;
            App.Current.UpdateRequiredAfterUserInteraction = true;

            if (_D3DImageContainer == null)
            {
                _D3DImageContainer = new D3DImageSharpDX();
            }

            SetupRendering();

            CameraInteraction = new CameraInteraction(this);     // Note: This requires ShowSceneControl to have been loaded
        }
Пример #12
0
 private void LostFocus_Handler(object sender, RoutedEventArgs e)
 {
     CameraInteraction.HandleFocusLost();
 }
Пример #13
0
 private void MouseWheel_Handler(object sender, MouseWheelEventArgs e)
 {
     CameraInteraction.HandleMouseWheel(e.Delta);
     e.Handled = true;
 }