博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF动态加载3D 放大-旋转-平移
阅读量:7097 次
发布时间:2019-06-28

本文共 1953 字,大约阅读时间需要 6 分钟。

原文:

WavefrontObjLoader.cs

 

第二步:ModelVisual3DWithName.cs

public class ModelVisual3DWithName:ModelVisual3D

    {
        public string Name { get; set; }

        public object Tag { get; set; }

    }

第三步:MainWindow.xmal

<Grid x:Name="lay">

     <Viewport3D x:Name="vp" Margin="0">
      <Viewport3D.Camera>
       <PerspectiveCamera FieldOfView="45" FarPlaneDistance="100" LookDirection="0,0,-3.4142135623731" NearPlaneDistance="0.1" Position="0,0,3.4142135623731" UpDirection="0,3,0"/>
      </Viewport3D.Camera>
        </Viewport3D>
        <Slider Height="23" HorizontalAlignment="Left" Margin="220,288,0,0" Name="slider1" VerticalAlignment="Top" Width="100" Maximum="2000" />
        <Slider Height="23" HorizontalAlignment="Left" Margin="49,288,0,0" Name="slider2" VerticalAlignment="Top" Width="100" Maximum="1000" />
        <Slider Height="23" HorizontalAlignment="Left" Margin="367,288,0,0" Name="slider3" VerticalAlignment="Top" Width="100" Minimum="200" Maximum="2000" />
        <Slider Height="23" HorizontalAlignment="Left" Margin="567,288,0,0" Name="slider4" VerticalAlignment="Top" Width="100" Minimum="200" Maximum="2000" />
    </Grid>

第四步:MainWindow.xmal

PerspectiveCamera myPCamera;

        DirectionalLight myDirectionalLight;
        Model3DGroup myModel3DGroup;
        WavefrontObjLoader wfl;
        ModelVisual3DWithName mv3dw;
        public MainWindow()
        {
            InitializeComponent();
            wfl = new WavefrontObjLoader();            slider1.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider1_ValueChanged);
            slider2.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider2_ValueChanged);
            slider3.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider3_ValueChanged);
            slider4.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider4_ValueChanged);            
            createCamera();
            createLight();
            createModel3D();
            create360();
            //createAnimation();
        }
        #region //光源
        private void createLight()
        {
            myDirectionalLight = new DirectionalLight();
            myDirectionalLight.Color = Colors.White;
            myDirectionalLight.Direction = new Vector3D(-0.61, -0.5, -0.61);
      

转载地址:http://pzaql.baihongyu.com/

你可能感兴趣的文章
美团“反黑”:是矫情还是刷存在感?
查看>>
通过 http post 方式上传多张图片
查看>>
【新书推荐】“上海高校精品课程”立体化教材《数据库原理及应用》第3版出版发行...
查看>>
我的友情链接
查看>>
linux配置双网卡双路由
查看>>
TextField输入时被Keyboard挡住的解决办法
查看>>
iOS 键盘遮挡输入框的解决方案
查看>>
POJ -- 3087 Shuffle'm Up
查看>>
cocospods使用
查看>>
简单模拟STL库中string的实现
查看>>
redis集群详细配置
查看>>
Python smtplib使用实例:网易邮箱向QQ邮箱发送邮件
查看>>
Google Protobuf在Netty中的使用
查看>>
今年以来的美国重大信息泄漏事件回顾
查看>>
TCP/IP 3.1动态路由选择协议
查看>>
js实现时间的显示,且动态刷新
查看>>
Python基础
查看>>
DVB开发之节目搜索
查看>>
我的友情链接
查看>>
Please enter a valid URL. Protocol is required (http://, https:// or ftp://) in Magento 1.9.2
查看>>