15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3-D ❘ 1031<br />

to define the light to show the model. SpecularMaterial adds illuminated highlight reflections when<br />

specular highlight reflections occur. The example code makes use of DiffuseMaterial <strong>and</strong> references a<br />

brush from the resource named mainCover:<br />

<br />

<br />

<br />

<br />

The brush for the main cover is a VisualBrush. The VisualBrush has a Border with a Grid that<br />

consists of two Label elements. One Label element defines the text Professional <strong>C#</strong> 4 <strong>and</strong> is written<br />

to the cover:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Professional <strong>C#</strong> 4<br />

<br />

<br />

<br />

<br />

<br />

Because a brush is defined by a 2-D coordinate system <strong>and</strong> the model has a 3-D coordinate system, a<br />

translation between them needs to be done. This translation is done by the TextureCoordinates property<br />

of the MeshGeometry3D. The TextureCoordinates specify every point of the triangle <strong>and</strong> shows how it<br />

maps to 2-D. The first point 0 0 0 maps to 0 1, the second point 10 0 0 maps to 1 1, <strong>and</strong> so on. Be aware<br />

that y has a different direction in the 3-D <strong>and</strong> 2-D coordinate systems. Figure 35-36 shows the coordinate<br />

system for 2-D:<br />

<br />

0/0<br />

1<br />

x<br />

1<br />

y<br />

figure 35-36<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!