Click or drag to resize
AB4D logo

MouseCameraControllerRotateCameraConditions Property

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

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

Property Value

MouseCameraControllerMouseAndKeyboardConditions
Remarks

RotateCameraConditions gets or sets conditions from MouseCameraControllerMouseAndKeyboardConditions enum that must be met to rotate the camera.

To specify which mouse button is used for rotation set RotateCameraConditions 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 RotateCameraConditions: MouseAndKeyboardConditions.ShiftKey, MouseAndKeyboardConditions.AltKey or MouseAndKeyboardConditions.ControlKey.

To disable the camera rotation set RotateCameraConditions to MouseAndKeyboardConditions.Disabled.

Default value of RotateCameraConditions is MouseAndKeyboardConditions.RightMouseButtonPressed.

To specify conditions to move the camera use MoveCameraConditions 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 IntelliSense 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