Target |
public class TargetPositionCamera : BaseTargetPositionCamera, IMovableCamera
The TargetPositionCamera type exposes the following members.
Name | Description | |
---|---|---|
TargetPositionCamera | Constructor |
Name | Description | |
---|---|---|
RotationCenterPosition | Gets or sets a nullable Point3D that can specify a custom 3D position around which this TargetPositionCamera is rotated. Rotation around custom center position changes the camera angles (Heading and Attitude) and also TargetPosition. When RotationCenterPosition is null, the rotation is done with changing only Heading and Attitude properties. | |
TargetPosition | Gets or sets a Point3D that defines the position on which the camera is looking. |
Name | Description | |
---|---|---|
AnimateTo | Animates the TargetPosition, Distance and CameraWidth to the specified values. The animation takes animationDurationInMilliseconds and uses the specified easingFunction. | |
BaseCreateFrom |
This method is called from CreateFrom method and actually sets the properties on this camera.
(Overrides SphericalCameraBaseCreateFrom(Camera)) | |
MoveBackward | Moves the camera backward (in the opposite as look direction) | |
MoveCamera | Moves the camera for the moveVector (regardless of the current camera's LookDirection and UpDirection) | |
MoveDown | Moves the camera down (in the opposite up direction) | |
MoveForward | Moves the camera forward (in the look direction) | |
MoveLeft | Moves the camera left (strafe) | |
MoveRight | Moves the camera right (strafe) | |
MoveTargetPositionTo | Animates the TargetPosition to the finalTargetPosition. The animation takes animationDurationInMilliseconds and uses the specified easingFunction. | |
MoveUp | Moves the camera up (in the up direction) | |
RotateCamera |
Rotates this camera for the specified heading and attitude.
When RotationCenterPosition is set, the camera rotates around RotationCenterPosition which can change Heading, Attitude, TargetPosition and Distance.
(Overrides SphericalCameraRotateCamera(Double, Double)) | |
StrafeCamera | Calculates the moveVector based on the current camera's LookDirection and UpDirection |
Name | Description | |
---|---|---|
RotationCenterPositionProperty | RotationCenterPositionProperty |
TargetPositionCamera is a camera that is looking at the TargetPosition from the specified angle and distance.
The angle is specified by Heading, Attitude and Bank properties.
The distance from the camera to the TargetPosition is defined by the Distance property.
TargetPositionCamera also has some other properties that are common to all cameras that derive from SphericalCamera class.
The ShowCameraLight defines when the camera light is shown. The possible values are:
The CameraLight property is by default a DirectionalLight with White color. The value can be set to a new DirectionalLight with some other color. Other types of Lights are not supported - will not change according to the camera's changed.
Because SphericalCamera is derived from BaseCamera, the TargetPositionCamera also contains properties that are defined in BaseCamera and therefore common to all the cameras:
The Viewport3D that is controlled by this camera is defined by IsAutoViewport3DFindingEnabled, TargetViewport3D and TargetViewport3DName properties.
If the Window, Page or UserControl has only one Viewport3D, there is no need to set and of the above properties on the camera. By default the IsAutoViewport3DFindingEnabled is set to true and that means, that the Viewport3D is automatically find from the current UserControl, Page or Window and it is set to a TargetViewport3D property.
But if there are more Viewport3D objects defined, than by default the first Viewport3D will be used by the camera. With setting the TargetViewport3D or TargetViewport3DName it is possible to specify which Viewport3D will be controlled by the camera.
The following xaml creates a Viewport3D with a 3D Box and a TargetPositionCamera that is looking at the bottom of the Box from above. The Distance from the camera to the TargetPosition is 100. Because there is no light defined in the Viewport3D and the default value of the camera's ShowCameraLight property is true, the cameras adds a light that is illuminating the scene.
The sample also defines a MouseCameraController to control the camera with the mouse and a CameraControlPanel that shows some nice buttons that can be also used to control the camera.
<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:BoxVisual3D CenterPosition="50 100 0" Size="50 200 20" Material="Blue"/> </Viewport3D> <cameras:TargetPositionCamera Heading="0" Attitude="-50" Distance="100" TargetPosition="75 0 20"/> <ab3dControls:MouseCameraController/> <ab3dControls:CameraControlPanel VerticalAlignment="Bottom" HorizontalAlignment="Left"/> </Grid> </Page>