Graphics Reference
In-Depth Information
1
2
3
4
5
6
7
8
9
10
11
<Page
xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml"
>
<Page.Resources>
Materials and meshes will be specified here.
</Page.Resources>
<Viewport3D Width= "640" Height= "480" >
The entire 3D scene, including camera, lights, model, will be specified here.
</Viewport3D>
</Page>
Note: Here again, as in Chapter 2, some of XAML's “syntactic vinegar” will be
obvious and may inspire questions. However, this chapter is not intended to be an
XAML reference or to replace .NET's documentation; our focus is on semantics,
not syntax.
The camera, the lights, and the scene's objects are specified inside the
Viewport3D tag. The basic template of a viewport and its content looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<Viewport3D ... >
<Viewport3D.Camera>
<PerspectiveCamera described below />
</Viewport3D.Camera>
Figure 6.3: WPF's 3D right-
handed coordinate system situ-
ated in a desert scene.
<!- The ModelVisual3D wraps around the scene's content ->
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
Lights and objects will be specified here.
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
We want the camera to be initially placed so that it lies well outside the pyra-
mid, but is close enough to ensure that the pyramid dominates the rendered image.
So we will position the camera at ( 57, 247, 41 ) and “aim” it toward the pyramid's
center point. 1
1
2
3
4
5
6
7
<PerspectiveCamera
Position= "57, 247, 41"
LookDirection= "-0.2, 0, -0.9"
UpDirection= "0, 1, 0"
NearPlaneDistance= "0.02" FarPlaneDistance= "1000"
FieldOfView= "45"
/>
The camera is a geometric object, placed in the scene's world coordinate sys-
tem (via the Position attribute) and oriented via two vectors.
1. Determining the numeric values that make a scene “look right” is often the result of
trial and error; thus, scene design is greatly facilitated by interactive 3D development
environments that offer instant feedback while a designer experiments with the place-
ment and orientation of objects, cameras, and lights.
 
 
Search WWH ::




Custom Search