Light Direction in Word

Draw Data Matrix in Word Light Direction

Light Direction
Data Matrix ECC200 Drawer In None
Using Barcode encoder for Office Word Control to generate, create Data Matrix image in Office Word applications.
www.OnBarcode.com
GS1-128 Maker In None
Using Barcode drawer for Word Control to generate, create USS-128 image in Office Word applications.
www.OnBarcode.com
Figure 6-1. Triangles lit according to incoming light Simply defining the position of the light source and the position of your objects is not enough for your graphics card to add correct lighting to an object, though. For each triangle of your 3D object, you will need to add some information, allowing your graphics card to calculate the amount of light hitting the surface. You can do this by specifying the normal vector in each vertex of your object, which are the spikes in the corners of the triangles shown in Figure 6-1. Once you ve specified the correct normal in each vertex, the BasicEffect can render your object with correct lighting.
Create Denso QR Bar Code In None
Using Barcode creator for Word Control to generate, create QR Code image in Word applications.
www.OnBarcode.com
UPCA Printer In None
Using Barcode generation for Office Word Control to generate, create GS1 - 12 image in Office Word applications.
www.OnBarcode.com
CH A PT ER 6 A DD I NG LI GHT T O YOUR SC ENE I N XN A 2.0
Barcode Encoder In None
Using Barcode encoder for Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
Create Barcode In None
Using Barcode drawer for Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
How It Works
Code 128A Generation In None
Using Barcode maker for Microsoft Word Control to generate, create ANSI/AIM Code 128 image in Microsoft Word applications.
www.OnBarcode.com
Painting Code11 In None
Using Barcode creation for Word Control to generate, create USD - 8 image in Word applications.
www.OnBarcode.com
In Figure 6-1, several squares (each consisting of two triangles) are drawn, and their colors represent the amount of incoming light. The more the square is perpendicular to the direction of the light, the more light it receives. The last square is completely perpendicular to the direction of the light so should be fully lit. The first square, however, is positioned along the direction of the light and should therefore receive no light at all.
Data Matrix 2d Barcode Generation In None
Using Barcode creator for Software Control to generate, create Data Matrix ECC200 image in Software applications.
www.OnBarcode.com
Data Matrix Maker In None
Using Barcode printer for Word Control to generate, create Data Matrix 2d barcode image in Office Word applications.
www.OnBarcode.com
Definition of the Normal
Code 3/9 Drawer In None
Using Barcode encoder for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Barcode Maker In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
How is the graphics card supposed to know this In each corner of each triangle (called a vertex; see recipe 5-1), you ll define the direction perpendicular to the triangle. This direction is called the normal. This normal direction has been indicated in each vertex of Figure 6-1 as a spike. Because there is only one direction perpendicular to a surface, all vertices of the same quad have the same normal direction. This normal direction allows your graphics card to calculate how much light hits the triangle. As explained in detail in recipe 6-5, you do this by projecting the normal on the direction of the light, as shown in Figure 6-2. The direction of the light is shown as the long black arrow at the bottom of the image going from left to right. The rotated black bars in Figure 6-2 represent the quads of Figure 6-1. The projections of the normal of each quad on the light direction are shown as the thick black blocks on the light direction. The bigger the black block, the more your triangle should be lit.
Code 128 Code Set A Generator In C#.NET
Using Barcode encoder for VS .NET Control to generate, create Code 128B image in .NET framework applications.
www.OnBarcode.com
Reading PDF 417 In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Light Direction
Making UCC - 12 In None
Using Barcode drawer for Online Control to generate, create UPC Symbol image in Online applications.
www.OnBarcode.com
Draw QR Code ISO/IEC18004 In VS .NET
Using Barcode maker for VS .NET Control to generate, create Quick Response Code image in VS .NET applications.
www.OnBarcode.com
Figure 6-2. Projecting the normal on the light direction The normal of the triangle on the left is perpendicular to the direction of the light, so the projection is 0, and the triangle will not be lit. The triangle on the right side has a normal parallel to the light direction, so its projection will be maximal, and the plane will be lit at full intensity. Given the direction of the light and the normal in a vertex, your graphics card can easily calculate the length of the projection (the thick black block). This is how the graphics card calculates the correct lighting.
Generate Barcode In Visual Studio .NET
Using Barcode maker for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Quick Response Code Creation In Java
Using Barcode creator for BIRT reports Control to generate, create QR Code image in Eclipse BIRT applications.
www.OnBarcode.com
Applying Shading to Your Scene
Printing UCC - 12 In None
Using Barcode generator for Online Control to generate, create EAN 128 image in Online applications.
www.OnBarcode.com
Barcode Drawer In VS .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
For each pixel, the graphics card will calculate the amount of lighting that should be applied to that pixel, as described earlier. Next, the graphics card multiplies this amount of lighting with the original color of that pixel.
CHAPTER 6 ADDIN G LIGHT TO Y OUR SCE NE IN XNA 2.0
Adding Normal Data to Your Vertices
The previous paragraph explains that, next to the 3D position and color, each vertex should also store its normal direction. XNA comes with one predefined vertex format that allows you to save a normal in each vertex: the VertexPositionNormalTexture struct. This format allows you to save the 3D position, normal direction, and texture coordinate for each vertex. See recipe 5-2 on textured triangles and recipe 5-14 to learn how you can define your own vertex format. The following method creates an array to hold six such vertices, which define two triangles that create a quad. This quad is lying on the floor, because all Y coordinates of the vertices are 0. Therefore, the normal stored in each vertex is the (0,1,0) Up direction, because this is the direction perpendicular to the quad. The vertex format also expects you to add texture coordinates, so the graphics card knows where to sample the colors from an image (see recipe 5-2). private void InitVertices() { vertices = new VertexPositionNormalTexture[6]; int i = 0; vertices[i++] = new VertexPositionNormalTexture(new Vector3(-1, 0, 1), new Vector3(0, 1, 0), new Vector2(1,1)); vertices[i++] = new VertexPositionNormalTexture(new Vector3(-1, 0, -1), new Vector3(0, 1, 0), new Vector2(0,1)); vertices[i++] = new VertexPositionNormalTexture(new Vector3(1, 0, -1), new Vector3(0, 1, 0), new Vector2(0,0)); vertices[i++] = new VertexPositionNormalTexture(new Vector3(1, 0, -1), new Vector3(0, 1, 0), new Vector2(0,0)); vertices[i++] = new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, 1, 0), new Vector2(1,0)); vertices[i++] = new VertexPositionNormalTexture(new Vector3(-1, 0, 1), new Vector3(0, 1, 0), new Vector2(1,1)); myVertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements); } The last line makes sure the VertexDeclaration (see recipe 5-1) is created only once, because this will not need to be changed.
Tip In this case of a triangle lying flat on the ground, it s easy to calculate its normal. Read recipe 5-7 to
Copyright © OnBarcode.com . All rights reserved.