我自己定制了一个3D模型,自己计算出模型后直接写的坐标,但是那个纹理坐标我不知道该怎么去写,所以二维的按钮贴到模型上后不会显示出来。下面是我的代码,希望大家给点帮助。
1 <Viewport3D ClipToBounds="true" Width="400" Height="300" >
2
3 <Viewport3D.Camera>
4 <PerspectiveCamera x:Name="camera" FarPlaneDistance="50" LookDirection="0,0,-1"
5 UpDirection="0,1,0" NearPlaneDistance="0" Position="0,0,5"
6 FieldOfView="30" />
7 </Viewport3D.Camera>
8
9 <ModelVisual3D>
10 <ModelVisual3D.Content>
11 <Model3DGroup x:Name="group">
12 <AmbientLight Color="DarkGray" />
13 <DirectionalLight Color="White" Direction="0,0,5" />
14 </Model3DGroup>
15 </ModelVisual3D.Content>
16 </ModelVisual3D>
17
18 <Viewport2DVisual3D>
19
20 <Viewport2DVisual3D.Material>
21 <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="Orange"/>
22 </Viewport2DVisual3D.Material>
23
24 <Viewport2DVisual3D.Geometry>
25 <MeshGeometry3D
26 TriangleIndices="0,3,7 7,4,0 1,5,6 6,2,1 4,7,6 6,5,4"
27 Positions="-1,0.4,0 1,0.4,0 1,-0.4,0 -1,-0.4,0 -0.5,0.5,0.5 0.5,0.5,0.5 0.5,-0.5,0.5 -0.5,-0.5,0.5"
28 />
29 </Viewport2DVisual3D.Geometry>
30
31 <Viewport2DVisual3D.Visual>
32 <Border Background="Chocolate" BorderThickness="2" BorderBrush="Yellow">
33 <Button Width="60" Height="30" Content="测试按钮" />
34 </Border>
35 </Viewport2DVisual3D.Visual>
36
37 </Viewport2DVisual3D>
38 </Viewport3D>