mrfangzheng

Hope and fear are useless. Be confident, and always be prepared for the worst.
  首页  :: 新随笔  :: 联系 :: 管理

WPF : 3D 最简单的WPF 3D

Posted on 2008-05-02 15:48  mrfangzheng  阅读(646)  评论(0编辑  收藏  举报
<Window x:Class="SimplestWpf3D.Window1"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    Title
="Window1" Height="300" Width="300">
    
<Grid>
        
<Viewport3D>
            
<!--Camera-->
            <Viewport3D.Camera>
                
<PerspectiveCamera />
            
</Viewport3D.Camera>
            
            
<!--Lights and Objects in the Children-->
            <Viewport3D.Children>                
                
<!--Light-->
                <ModelVisual3D>
                    
<ModelVisual3D.Content>
                        
<DirectionalLight Color="White" Direction="0,1,-1"/>
                    
</ModelVisual3D.Content>
                
</ModelVisual3D>
                
                
<!--Object-->
                <ModelVisual3D>
                    
<ModelVisual3D.Content>
                        
<GeometryModel3D>
                            
<GeometryModel3D.Geometry>
                                
<MeshGeometry3D Positions="-1 0 -8, 1 0 -8, 0 1 -8"/>
                            
</GeometryModel3D.Geometry>
                            
<GeometryModel3D.Material>
                                
<DiffuseMaterial Brush="Red" />
                            
</GeometryModel3D.Material>
                        
</GeometryModel3D>
                    
</ModelVisual3D.Content>
                
</ModelVisual3D>
            
</Viewport3D.Children> 
        
</Viewport3D>
    
</Grid>
</Window>