AB4D Forum

Full Version: Move Camera with Touch screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I have a touchscreen only display (no mouse available), there is a way to easily pan camera using MouseCameraController?

I tried MoveCameraConditions="RightMouseButtonPressed" but right click with touch screen is very difficult.

There is a way to handle multipoint touchscreen? I hope to pan when user press two points (like when zooming) and then drag the screen.

Thank you
You can enable touch moving with 3 fingers with setting the IsTouchMoveEnabled to true (two fingers are used for pinch zoom).

What is more, you can also fully customize when and which touch events start rotation, movement or zooming.

All you need to do is derive your own class from MouseCameraController and override the GetManipulationActions method - there you will be able to set isMoving to true when two fingers are touching the screen.

To make the change easier you can check the original source code of the method:

       /// <summary>
       /// GetManipulationActions method gets the ManipulationDeltaEventArgs and based on that sets which actions should be performed by MouseCameraController.
       /// This method can be overridden to specify custom behavior with touch events.
       /// </summary>
       /// <param name="manipulationDeltaEventArgs">ManipulationDeltaEventArgs</param>
       /// <param name="isRotating">isRotating</param>
       /// <param name="isMoving">isMoving</param>
       /// <param name="isZooming">isZooming</param>
       protected virtual void GetManipulationActions(ManipulationDeltaEventArgs manipulationDeltaEventArgs, out bool isRotating, out bool isMoving, out bool isZooming)
           int touchedFingersCount = manipulationDeltaEventArgs.Manipulators.Count();
           ManipulationDelta delta = manipulationDeltaEventArgs.DeltaManipulation;

           // Zooming with two fingers
           isZooming = IsTouchZoomEnabled && touchedFingersCount == 2 && (delta.Scale.X != 1 || delta.Scale.Y != 1);

           if (delta.Translation.X == 0 && delta.Translation.Y == 0)
               isMoving = false;
               isRotating = false;
               // Moving with one finger if TouchRotate is disabled or if touched with more or equal than 3 fingers
               isMoving = IsTouchMoveEnabled && ((!IsTouchRotateEnabled && touchedFingersCount == 1) ||
                                                 touchedFingersCount >= 3);

               // Rotating with:
               // - one finger
               // - two fingers when IsConcurrentTouchZoomEnabled is true
               // - three fingers or more and is not moving
               isRotating = IsTouchRotateEnabled && (touchedFingersCount == 1 ||
                                                    (isZooming && IsConcurrentTouchZoomEnabled) ||
                                                    (!isMoving && touchedFingersCount >= 3));
Thank you very much, I had not noticed that pan is with three fingers. It works.

Thank you