原文:WPF 3D 常用类(1)

几何数据相关类

Geometry3D

抽象类, 用于定义物体的几何数据, 可用于计算HitTest和BoundingBox

MeshGeometry3D

Geometry3D的子类, 定义网格的顶点, 三角形顶点, 法线, Texture(纹理)的座标

常用属性: Positions, TriangleIndices, Noramls, TextureCoordinates

模型相关类 (模型=几何数据+变形(位置,旋转,尺寸)+材质)

Model3D

抽象类, 表示一个3D模型, 子类有: Light, GeometryModel3D, Model3DGroup

GeometryModel3D

Model3D的子类, 不仅包含了物体的几何数据Geometry, 还包含了物体的材质Matrial, 变形Transform

<GeometryModel3D Geometry="{StaticResource myTeapot}">

<GeometryModel3D.Material>
    <DiffuseMaterial>
      <DiffuseMaterial.Brush>
        <SolidColorBrush Color="Blue" Opacity="1.0" /></DiffuseMaterial.Brush>
      </DiffuseMaterial>
  </GeometryModel3D.Material>

<GeometryModel3D.Transform>
    <RotateTransform3D>
      <RotateTransform3D.Rotation>
        <AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,3,0" Angle="1" />
      </RotateTransform3D.Rotation>
    </RotateTransform3D>
  </GeometryModel3D.Transform>

</GeometryModel3D>

----------------------------------------------------------------------

  1. <GeometryModel3D>
  2.  
  3. <GeometryModel3D.Geometry>
  4. <MeshGeometry3D
  5. Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0"
  6. Normals="0 0 1 0 0 1 0 0 1 0 0 1"
  7. TextureCoordinates="0 1 1 1 0 0 1 0 "
  8. TriangleIndices="0 1 2 1 3 2" />
  9. </GeometryModel3D.Geometry>
  10.  
  11. <GeometryModel3D.Material>
  12. <DiffuseMaterial>
  13. <DiffuseMaterial.Brush>
  14. <SolidColorBrush Color="Cyan" Opacity="0.3"/>
  15. </DiffuseMaterial.Brush>
  16. </DiffuseMaterial>
  17. </GeometryModel3D.Material>
  18.  
  19. <GeometryModel3D.Transform>
  20. <TranslateTransform3D
  21. OffsetX="2" OffsetY="0" OffsetZ="-1" >
  22. </TranslateTransform3D>
  23. </GeometryModel3D.Transform>
  24.  
  25. </GeometryModel3D>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

多个GeometryModel3D的实例可以共享一个Geometry3D的实例, 只需设置不通的Material, Transform就可以呈现出不同的物体.

视觉相关类 (包含一个Model3D对象)

Visual3D

Visual的职责是:

  • Output display

  • Transformations
  • Hittesting
  • Clipping
  • Bounding box calculations

没有的功能包括:

  • Event handling

  • Layout
  • Styles
  • Data binding
  • Globalization

抽象类, Viewport3D.Children就是Visual3D对象的集合

Visual3D类有一个属性Visual3DModel, 该属性的类型是Model3D

class Visual3D

{

Model3D Visual3DModel { get;set; }

}

ModelVisual3D

Visual3D的子类, 增加了Content, Children等属性

容易混淆的名字 : Visual3D, ModelVisual3D, Model3D, Visual3DModel(属性名)

Viewport3D

负责渲染3D对象, HitTest, 大致由Camera + 一组ModelVisual3D对象(Lights + 多个GeometryModel3D对象)

  1. <Viewport3D ClipToBounds="True" Width="150" Height="150" Canvas.Left="0" Canvas.Top="10">
  2.  
  3. <!-- Defines the camera used to view the 3D object. -->
  4. <Viewport3D.Camera>
  5. <PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1" FieldOfView="60" />
  6. </Viewport3D.Camera>
  7.  
  8. <!-- The ModelVisual3D children contain the 3D models -->
  9. <Viewport3D.Children>
  10.  
  11. <!-- Light -->
  12. <ModelVisual3D>
  13. <ModelVisual3D.Content>
  14. <DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
  15. </ModelVisual3D.Content>
  16. </ModelVisual3D>
  1.  
  1. <!-- Objects -->
  2. <ModelVisual3D>
  3. <ModelVisual3D.Content>
  4. <GeometryModel3D>
  5.  
  6. <!-- The geometry specifes the shape of the 3D plane. In this sample, a flat sheet is created. -->
  7. <GeometryModel3D.Geometry>
  8. <MeshGeometry3D
  9. TriangleIndices="0,1,2 3,4,5 "
  10. Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
  11. TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
  12. Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
  13. </GeometryModel3D.Geometry>
  14.  
  15. <!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
  16. covers the surface of the 3D object.-->
  17. <GeometryModel3D.Material>
  18. <MaterialGroup>
  19. <DiffuseMaterial>
  20. <DiffuseMaterial.Brush>
  21. <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
  22. <LinearGradientBrush.GradientStops>
  23. <GradientStop Color="Yellow" Offset="0" />
  24. <GradientStop Color="Red" Offset="0.25" />
  25. <GradientStop Color="Blue" Offset="0.75" />
  26. <GradientStop Color="LimeGreen" Offset="1" />
  27. </LinearGradientBrush.GradientStops>
  28. </LinearGradientBrush>
  29. </DiffuseMaterial.Brush>
  30. </DiffuseMaterial>
  31. </MaterialGroup>
  32. </GeometryModel3D.Material>
  33.  
  34. <!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
  35. 3D object rotated. -->
  36. <GeometryModel3D.Transform>
  37. <RotateTransform3D>
  38. <RotateTransform3D.Rotation>
  39. <AxisAngleRotation3D Axis="0,3,0" Angle="40" />
  40. </RotateTransform3D.Rotation>
  41. </RotateTransform3D>
  42. </GeometryModel3D.Transform>
  43. </GeometryModel3D>
  1. </ModelVisual3D.Content>
  2. </ModelVisual3D>
  1. </Viewport3D.Children>
  2. </Viewport3D>

Viewport2DVisual3D

用于把一个2D对象,比如Button, TextBlock放在一个3D物体上

  1. <Viewport2DVisual3D Geometry="{StaticResource plane}">

  2. <Viewport2DVisual3D.Material>
  3. <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="true" />
  4. </Viewport2DVisual3D.Material>
  5.  
  6. <Button>3.5!</Button>
  7.  
  8. </Viewport2DVisual3D>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Viewport3DVisual

把一组3D对象绘制在2D对象上

UIElement3D(支持事件)

UIElement3D

ModelUIElement3D : 和ModelVisual3D类似, 但支持事件

ContainerUIElement3D : 一组ModelUIElement3D的集合, 但不表现自己

WPF 3D 常用类(1)的更多相关文章

  1. WPF 3D 知识点大全以及实例

    引言 现在物联网概念这么火,如果监控的信息能够实时在手机的客服端中以3D形式展示给我们,那种体验大家可以发挥自己的想象. 那生活中我们还有很多地方用到这些,如上图所示的Kinect 在医疗上的应用,当 ...

  2. WPF 3D 模型旋转

    原文:WPF 3D 模型旋转 WPF 是 Microsoft 在 Framework3.0 中支持的一种技术,它能作出很绚丽的界面,同时它也支持3D的操作.在3D操作主要包括平移(Translate) ...

  3. WPF DataGrid常用属性记录

    WPF DataGrid常用属性记录 组件常用方法: BeginEdit:使DataGrid进入编辑状态. CancelEdit:取消DataGrid的编辑状态. CollapseRowGroup:闭 ...

  4. WPF 3D 小小小小引擎 - ·WPF 3D变换应用

    原文:WPF 3D 小小小小引擎 - ·WPF 3D变换应用 WPF可以提供的3D模型使我们可以轻松地创建3D实体,虽然目前来看还很有一些性能上的问题,不过对于一些简单的3D应用应该是可取的,毕竟其开 ...

  5. android 系统层 常用类介绍

    类名 功能介绍 示意图 surfacemanager为应用程序显示2d和3d程序无缝结合 mediaFramework 基于packetvideocore 该库支持常见视频图片格式的回放和录放譬如mp ...

  6. WPF 3D变换应用

    WPF可以提供的3D模型使我们可以轻松地创建3D实体,虽然目前来看还很有一些性能上的问题,不过对于一些简单的3D应用应该是可取的,毕竟其开发效率高,而且也容易上手. 下面给大家演示的是使用在WPF 3 ...

  7. WPF 3D model - Sphere, Cone, and Cylinder

    原文:WPF 3D model - Sphere, Cone, and Cylinder   Extending Visual3D - Sphere, Cone, and Cylinder http: ...

  8. WPF 3D 获取鼠标在场景的3d坐标

    原文:WPF 3D 获取鼠标在场景的3d坐标 上一篇中我们谈到了WPF 3d做图的一些简单原理,这里我们简单介绍一下怎样获得鼠标在场景中的3d坐标,知道了3d坐标就可以进行很多操作了: 首先介绍一下3 ...

  9. WPF 3D动态加载模型文件

    原文:WPF 3D动态加载模型文件 这篇文章需要读者对WPF 3D有一个基本了解,至少看过官方的MSDN例子. 一般来说关于WPF使用3D的例子,都是下面的流程: 1.美工用3DMAX做好模型,生成一 ...

随机推荐

  1. zoj 3870

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5518 题意:n个数,从中选出两个数,问这两个数的异或值大于两个数较大 ...

  2. 字符编码详解 good

    字符编码详解 字符编码详解

  3. JAVA WEB开发环境搭建教程

    一.下载安装JDK,配置好环境变量.(例如我JDK安装的目录为:C:\Program Files (x86)\Java\jdk1.6.0_10     ) 点击我的电脑-属性-系统设置(高级系统设置) ...

  4. C++ 指针—02 指针与引用的对照

    ★同样点: ●都是地址的概念: 指针指向一块内存,它的内容是所指内存的地址:而引用则是某块内存的别名. ★不同点: ●指针是一个实体,而引用仅是个别名: ●引用仅仅能在定义时被初始化一次,之后不可变: ...

  5. GMM的EM算法

    在聚类算法K-Means, K-Medoids, GMM, Spectral clustering,Ncut一文中我们给出了GMM算法的基本模型与似然函数,在EM算法原理中对EM算法的实现与收敛性证明 ...

  6. Iconfinder 如何杜绝盗版,哈希算法检测图像重复

    原地址:http://blog.jobbole.com/65914/ 本文由 伯乐在线 - 小鱼 翻译自 Silviu Tantos.欢迎加入技术翻译小组.转载请参见文章末尾处的要求. [伯乐在线导读 ...

  7. OCP读书笔记(5) - 使用RMAN创建备份

    5.Creating Backups with RMAN 创建备份集 RMAN> backup as backupset format '/u01/app/oracle/backup/rmanb ...

  8. 浅谈OCR之Onenote 2010

    原文:浅谈OCR之Onenote 2010 上一次我们讨论了Tesseract OCR引擎的用法,作为一款老牌的OCR引擎,目前已经开源,最新版本3.0中更是加入了中文OCR功能,再加上Google的 ...

  9. hdu2712(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2712 题意:是求最短的非子串(子串不要求连续)的长度. 分析:把序列划分为尽量多(假设为ans)的含有 ...

  10. 《Android内核剖析》读书笔记 第13章 View工作原理【View重绘过程】

    计算视图大小的过程(Measure) 视图大小,准确的来说应该是指视图的布局大小:我们在layout.xml中为每个UI控件设置的layout_width/layout_height两个属性被用来设置 ...