3Dグラフィックスでピラミッド(三角柱)を作成します。XAMLだけで作成します。
WPF3D でピラミッドを作ってみます。
[実行結果]

[プログラムソース "MainWindow.xaml"]
<Window x:Class="Pyramid.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Pyramid"
mc:Ignorable="d"
Title="MainWindow" Height="480" Width="640">
<Grid>
<Viewport3D Margin="10">
<!-- カメラの設定です -->
<Viewport3D.Camera>
<PerspectiveCamera Position="-4,1,10" LookDirection="4,-1,-10" UpDirection="0,1,0"/>
</Viewport3D.Camera>
<!-- 3Dモデルの記述です -->
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<DirectionalLight Direction="0,0,-1"/>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D>
<MeshGeometry3D.Positions>
0,1,0
1,-1,1
-1,-1,1
1,-1,-1
-1,-1,-1
</MeshGeometry3D.Positions>
<MeshGeometry3D.TriangleIndices>
0,2,1
0,1,3
0,3,4
0,4,2
</MeshGeometry3D.TriangleIndices>
</MeshGeometry3D>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.BackMaterial>
</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</Grid>
</Window>
本ページの情報は、特記無い限り下記 MIT ライセンスで提供されます。
| 2023-04-05 | - | ページデザイン刷新 |
| 2015-08-02 | - | 新規作成 |