Click or drag to resize
AB4D logo

MouseCameraControllerMoveCameraConditions Property

Gets or sets conditions from MouseAndKeyboardConditions enum that must be met to move the camera. Default value is MouseAndKeyboardConditions.RightMouseButtonPressed and MouseAndKeyboardConditions.AltKey.

Namespace: Ab3d.Controls
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax
C#
public MouseCameraControllerMouseAndKeyboardConditions MoveCameraConditions { get; set; }

Property Value

MouseCameraControllerMouseAndKeyboardConditions
Remarks

MoveCameraConditions gets or sets conditions from MouseCameraControllerMouseAndKeyboardConditions enum that must be met to move the camera.

To specify which mouse button is used to move the camera set MoveCameraConditions to MouseAndKeyboardConditions.LeftMouseButtonPressed, MouseAndKeyboardConditions.RightMouseButtonPressed or MouseAndKeyboardConditions.MiddleMouseButtonPressed.

To specify that a special modifier key must be also pressed, one of the following conditions can be added (with or operator) to the MoveCameraConditions: MouseAndKeyboardConditions.ShiftKey, MouseAndKeyboardConditions.AltKey or MouseAndKeyboardConditions.ControlKey.

To disable the camera movement set MoveCameraConditions to MouseAndKeyboardConditions.Disabled.

Default value of MoveCameraConditions is MouseAndKeyboardConditions.RightMouseButtonPressed and MouseAndKeyboardConditions.AltKey (in csharp: MouseAndKeyboardConditions.LeftMouseButtonPressed | MouseAndKeyboardConditions.AltKey).

To specify conditions to rotate the camera use RotateCameraConditions property.

Example

The following code sets the mouse camera controller to rotate the mouse with pressed left mouse button and to move the camera with pressed left mouse button and alt key. Note that the setting enums that are marked with Flags attribute in XAML can be done with adding comma between values (there are some problems with Visual Studio IntelliSence but it works).

XAML
<Page x:Class="PowerToysSamples"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys"
    xmlns:ab3dControls="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"  
    xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys">
    <Grid>
        <Viewport3D>
            <visuals:PyramidVisual3D BottomCenterPosition="0 0 30" Size="20 20 20"
                                           Material="Green"/>
        </Viewport3D>

        <cameras:SceneCamera Heading="30" Attitude="-20" 
                                   Distance="2" IsDistancePercent="True"/>

        <ab3dControls:MouseCameraController x:Name="MouseCameraController1" 
                              RotateCameraConditions="LeftMouseButtonPressed"
                              MoveCameraConditions="LeftMouseButtonPressed, AltKey"/>
    </Grid>
</Page>

The same conditions can be also set in code:

C#
MouseCameraController1.RotateCameraConditions = LeftMouseButtonPressed;
MouseCameraController1.MoveCameraConditions = LeftMouseButtonPressed | AltKey;
See Also