今天我開始在WPF學習一些3D,並將一些簡單的例子(平面)複製到我的XAML中,並且它們都工作正常。但是,當我調整相機和飛機的座標以滿足我的需求時,我總是什麼都看不到。3D WPF的問題
我不知道自己做錯了什麼,我也已經勾畫了(非常簡單)3D場景來驗證我的數據,這一切對我來說似乎都是正確的。
任何人都可以請檢查以下XAML並告訴我我做錯了什麼?我只想在x-z平面上創建一架飛機,也就是某種「地板」,照相機從頂部俯視它。
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera Position="0 1 0"
LookDirection="0 -1 0"
FieldOfView="60"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ModelVisual3D>
<ModelVisual3D.Content>
<AmbientLight Color="White"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D>
<MeshGeometry3D.Positions>
<Point3D X="-1" Y="0" Z="1"/>
<Point3D X="1" Y="0" Z="1"/>
<Point3D X="1" Y="0" Z="-1"/>
<Point3D X="-1" Y="0" Z="-1"/>
</MeshGeometry3D.Positions>
<MeshGeometry3D.TriangleIndices>
0 1 2 0 2 3
</MeshGeometry3D.TriangleIndices>
<MeshGeometry3D.Normals>
<Vector3D X="0" Y="1" Z="0"/>
<Vector3D X="0" Y="1" Z="0"/>
<Vector3D X="0" Y="1" Z="0"/>
<Vector3D X="0" Y="1" Z="0"/>
<Vector3D X="0" Y="1" Z="0"/>
<Vector3D X="0" Y="1" Z="0"/>
</MeshGeometry3D.Normals>
</MeshGeometry3D>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Red" Opacity="0.75"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
編輯:我只是嘗試用攝像機的位置和LookDirection,終於看到了一些東西,當我改變了LookDirection是不垂直於平面,例如:
<PerspectiveCamera Position="0 2 0"
LookDirection="0 -2 1"
FieldOfView="60"/>
這是正常的行爲嗎?
非常感謝!
gehho。
這個伎倆!沒有考慮調整向上的方向。非常感謝! – gehho 2010-03-11 07:21:32