PerspectiveCamera 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表透視投影相機。
public ref class PerspectiveCamera sealed : System::Windows::Media::Media3D::ProjectionCamera
public sealed class PerspectiveCamera : System.Windows.Media.Media3D.ProjectionCamera
type PerspectiveCamera = class
inherit ProjectionCamera
Public NotInheritable Class PerspectiveCamera
Inherits ProjectionCamera
- 繼承
-
PerspectiveCamera
範例
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<DockPanel>
<Viewbox>
<Canvas Width="321" Height="201">
<!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
<Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
<!-- Defines the camera used to view the 3D object. -->
<Viewport3D.Camera>
<PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
</Viewport3D.Camera>
<!-- The ModelVisual3D children contain the 3D models -->
<Viewport3D.Children>
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
you can create multiple lights with different colors that shine from different directions. -->
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<!-- The geometry specifies the shape of the 3D plane. In this sample, a flat sheet is created. -->
<GeometryModel3D.Geometry>
<MeshGeometry3D
TriangleIndices="0,1,2 3,4,5 "
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
</GeometryModel3D.Geometry>
<!-- The material specifies the material applied to the 3D object. In this sample a tiled drawing
covers the surface of the 3D object.-->
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<DrawingBrush Viewport="0,0,0.1,0.1" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z"
Brush="Gray" />
<GeometryDrawing Geometry="M0.9,0 L1,0.1 0.1,1 0,0.9z"
Brush="Gray" />
<GeometryDrawing Geometry="M0.25,0.25 L0.5,0.125 0.75,0.25 0.5,0.5z"
Brush="#FFFF00" />
<GeometryDrawing Geometry="M0.25,0.75 L0.5,0.875 0.75,0.75 0.5,0.5z"
Brush="Black" />
<GeometryDrawing Geometry="M0.25,0.75 L0.125,0.5 0.25,0.25 0.5,0.5z"
Brush="#FF0000" />
<GeometryDrawing Geometry="M0.75,0.25 L0.875,0.5 0.75,0.75 0.5,0.5z"
Brush="MediumBlue" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
3D object rotated. -->
<GeometryModel3D.Transform>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="0,3,0" Angle="40" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
</Canvas>
</Viewbox>
</DockPanel>
</Page>
備註
PerspectiveCamera 指定將 3D 模型投影到 2D 視覺表面。 此投影包含透視縮短。 換句話說,描述 PerspectiveCamera 一個邊會收斂於地平線上某一點的阻斷體。 靠近相機的物體看起來較大,遠離鏡頭的物體看起來較小。
下圖顯示正交投影與透視縮短相機投影的差異。
建構函式
| 名稱 | Description |
|---|---|
| PerspectiveCamera() |
初始化 PerspectiveCamera 類別的新執行個體。 |
| PerspectiveCamera(Point3D, Vector3D, Vector3D, Double) |
使用指定的位置、方向與視野初始化該類別的新實例 PerspectiveCamera 。 |
欄位
| 名稱 | Description |
|---|---|
| FieldOfViewProperty |
識別 FieldOfView 依賴性質。 |
屬性
| 名稱 | Description |
|---|---|
| CanFreeze |
會得到一個值,表示該物件是否能被設定為不可修改。 (繼承來源 Freezable) |
| DependencyObjectType |
會取得 DependencyObjectType 包裹此實例 CLR 類型的 。 (繼承來源 DependencyObject) |
| Dispatcher |
了解 Dispatcher 這與此 DispatcherObject 有關。 (繼承來源 DispatcherObject) |
| FarPlaneDistance |
取得或設定一個值,指定相機遠剪接平面與相機的距離。 (繼承來源 ProjectionCamera) |
| FieldOfView |
取得或設定一個代表相機水平視野的值。 |
| HasAnimatedProperties |
會得到一個值,表示是否有一個或多個 AnimationClock 物件與該物件的相依屬性相關聯。 (繼承來源 Animatable) |
| IsFrozen |
會得到一個值,表示該物件目前是否可修改。 (繼承來源 Freezable) |
| IsSealed |
會獲得一個值,表示該實例目前是否封存(唯讀)。 (繼承來源 DependencyObject) |
| LookDirection |
取得或設定 a Vector3D ,定義相機在世界座標中所觀察的方向。 (繼承來源 ProjectionCamera) |
| NearPlaneDistance |
取得或設定一個值,指定相機近剪裁平面與相機的距離。 (繼承來源 ProjectionCamera) |
| Position |
取得或設定相機在世界座標中的位置。 (繼承來源 ProjectionCamera) |
| Transform |
取得或設定套用到 Transform3D 到相機上。 (繼承來源 Camera) |
| UpDirection |
取得或設定 a Vector3D ,定義相機向上的方向。 (繼承來源 ProjectionCamera) |
方法
事件
| 名稱 | Description |
|---|---|
| Changed |
當 Freezable 它所包含的物件被修改時,會發生這種情況。 (繼承來源 Freezable) |
明確介面實作
| 名稱 | Description |
|---|---|
| IFormattable.ToString(String, IFormatProvider) |
使用指定的格式,格式化目前實例的值。 (繼承來源 Camera) |