3D Construction Basics in WPF - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

3D Construction Basics in WPF

Description:

Why points, triangles, and cross products are important to YOU. ... Transformers. More than meets the eye. Transforms. Cooler than Optimus Prime. Transforms ... – PowerPoint PPT presentation

Number of Views:765
Avg rating:3.0/5.0
Slides: 40
Provided by: mikeho5
Category:

less

Transcript and Presenter's Notes

Title: 3D Construction Basics in WPF


1
3D Construction Basics in WPF
  • MN WPF/Silverlight User Group June 16th,
    2009Mike Hodnick

2
Agenda
  • 3D construction theory
  • 3D .NET classes
  • Transforms
  • Animation
  • Texture coordinates
  • Hit testing
  • Real tools and data
  • Resources

3
About Mike Hodnick
  • Lead Consultant at Inetium
  • www.kindohm.com
  • mike.hodnick_at_gmail.com
  • _at_kindohm

4
3D Construction Theory
  • Why points, triangles, and cross products are
    important to YOU.

5
Mesh Basics
  • Positions the vertices of a mesh
  • Triangles the polygons formed by positions
  • Normals determine if a triangles surface is
    lit by light

6
Right-Hand Rule
  • Counter-Clockwise top visible
  • Clockwise bottom visible
  • Not the same thing as Normals

7
Cube Mesh Walkthrough
8
Define Positions
9
Define Triangles and Normals
Triangle 1 p0, p1, p2 Triangle 2 p0, p2,
p3 Triangle 3 p4, p7, p5 Triangle 4 p5, p7,
p6 Triangle 5 p4, p5, p0 Triangle 6 p5, p1,
p0 Triangle 7 p7, p4, p3 Triangle 8 p4, p0,
p3 Triangle 9 p6, p7, p2 Triangle 10 p7,
p3, p2 Triangle 11 p5, p6, p1 Triangle 12
p6, p2, p1Normals for Triangle3 p4
0,1,0p7 0,1,0 p5 0,1,0 Normals for
Triangle11 p5 1,0,0p6 1,0,0p1 1,0,0
10
3D .NET Classes
  • Because coding is more fun than math.

11
3D .Net Classes




Viewport3D
ModelVisual3D
Camera
PerspectiveCamera
OrthographicCamera
ModelVisual3D
ModelVisual3D
ModelVisual3D
ModelVisual3D
12
ModelVisual3D Content
  • Content Model3D
  • ModelVisual3D
  • Light
  • DirectionalLight
  • AmbientLight
  • SpotLight

ModelVisual3D -Model3DGroup -GeometryModel3D
ModelVisual3D Children -ModelVisual3D
13
GeometryModel3D
GeometryModel3D
MeshGeometry3D Points Triangle Indeces Normals
MaterialDiffuseMaterial EmissiveMaterialSpecul
arMaterial
14
MeshGeometry3D Class
  • Positions property gets or sets the collection
    of points that define the objects shape.
  • TriangleIndeces gets or sets the ordering of
    positions by position index. Used to define
    right-hand rule directions.
  • Normals property gets or sets the normals on
    the objects points.

15
PerspectiveCamera Class
  • Position location of the camera
  • LookDirection vector of where the camera is
    looking
  • NearPlaneDistance minimum viewing distance
  • FarPlaneDistance maximum viewing distance
  • FieldOfView horizontal viewing distance
  • UpDirection defines the up vector

16
Create a basic scene
  • demo

17
Transformers
  • More than meets the eye.

18
Transforms
  • Cooler than Optimus Prime.

19
Transforms
  • Move, scale, and rotate 3D geometries
  • Transform3D
  • TranslateTransform3D
  • ScaleTransform3D
  • RotateTransform3D
  • Transform3DGroup
  • Ordering is important

20
Scale Transform
21
Translate Transform
y
y
x
x
22
Rotate Transform
y
y
Rotate 45 about the Z axis
x
x
23
Rotate Translate
y
y
Rotate 45 about the Z axis, then move
x
x
24
Translate Rotate
y
y
Move, then rotate 45 about the Z axis
x
x
25
Transformation demo
  • demo

26
Animation
  • Eye candy.

27
Animation Overview
  • System.Windows.Media.Animation.Animatable
  • Any deriving class can be animated
  • Example animation types
  • Numeric Animation animates numeric properties
    (e.g. int, double, etc).
  • Vector3D Animation Animates vector properties
    that define a direction or axis.
  • Color Animation Animates color changes.
  • Ordering matters when animating transforms

28
Common Animation Properties
  • From
  • To
  • RepeatBehavior
  • AutoReverse

29
Animation demo
  • demo

30
Hit Testing
  • Interact with your model.

31
Hit Testing
  • Handle mouse events
  • Use VisualTreeHelper.HitTest() method
  • Inspect the HitTestResult object

32
Hit Testing
  • demo

33
Real tools and real data.
  • Enough triangles and cubes. Lets see something
    real.

34
3DTools
  • http//www.codeplex.com/3DTools
  • 2D content on 3D (not just visual brushes)
  • Trackball class
  • Texture coordinate generation

35
Petzold Media3D Library
  • Visuals
  • Geometries
  • 3D Text
  • http//www.charlespetzold.com/3D/

36
Create a scene from real data
  • demo

37
WPF 3D Examples/Case Studies
  • The North Face case study http//www.microsoft.com
    /casestudies/casestudy.aspx?casestudyid201147
  • The North Face demo http//channel9.msdn.com/ShowP
    ost.aspx?PostID116426
  • http//www.interknowlogy.com

38
Resources
  • WPF 3D Tutorial http//www.kindohm.com/technical/W
    PF3DTutorial.htm
  • 3D Code Lab http//wpf.netfx3.com/files/folders/la
    bs/entry9680.aspx
  • 3DTools http//www.codeplex.com/3DTools
  • Petzold Media3D http//www.charlespetzold.com/3D/
  • Karsten J http//blogs.msdn.com/karstenj
  • Tim Sneath http//blogs.msdn.com/tims
  • WPF3D team blog http//blogs.msdn.com/wpf3d/

39
The End
Write a Comment
User Comments (0)
About PowerShow.com