很早之前就知道avalon有3D支持,尤其那个球的Demo,
http://blogs.msdn.com/danlehen/archive/2004/06/01/146259.aspx,前几天刚刚下到CTP,Win FX SDK中的3D例子很少,而且不怎么好用,就目前对xaml的认识还不足以改正其中的错误,无奈,只好再寻例子了,上周末找了半天,终于找到了,在一个录像中照扒下来的。
<
Window
x:Class
="AvalonApp.Window1"
xmlns
="http://schemas.microsoft.com/2003/xaml"
xmlns:x
="Definition"
Text
="AvalonApp"
>
<
Viewport3D
>
<
Viewport3D
.Camera
>
<
PerspectiveCamera
Position
="0,0,5"
Up
="0,1,0"
LookAtPoint
="0,0,0"
FieldOfView
="45"
>
<
PerspectiveCamera
.Position
>
<
Point3DAnimation
From
="0,0,5"
To
="5,5,5"
Duration
="2"
RepeatBehavior
="Forever"
AutoReverse
="true"
></
Point3DAnimation
>
</
PerspectiveCamera.Position
>
</
PerspectiveCamera
>
</
Viewport3D.Camera
>
<
Viewport3D
.Models
>
<
AmbientLight
Color
="White"
></
AmbientLight
>
<
GeometryModel3D
>
<
GeometryModel3D
.Material
>
<
BrushMaterial
Brush
="Blue"
></
BrushMaterial
>
</
GeometryModel3D.Material
>
<
GeometryModel3D
.Geometry
>
<
MeshGeometry3D
Positions
="-1,1,0 1,1,0 1,-1,0 -1,-1,0"
TriangleIndices
="0 1 2 0 2 3"
>
</
MeshGeometry3D
>
</
GeometryModel3D.Geometry
>
</
GeometryModel3D
>
</
Viewport3D.Models
>
</
Viewport3D
>
</
Window
>
运行效果如图,视角是移动的。
这又不禁让我想起了
VRML,2年前,我学VRML的时候,就曾经想过,其实VRML应该用XML来写,结果Xaml真的出现了,更出乎意料的是,是MS搞的,那些致力于WEB 3D的公司为什么没有自己把VRML形成XML系列的标准呢,唉,给MS抢了先了。