GETTING THE MOST OUT OF VERTICES in Microsoft Word

Encode Data Matrix ECC200 in Microsoft Word GETTING THE MOST OUT OF VERTICES

CHAPTER 5 GETTING THE MOST OUT OF VERTICES
Draw DataMatrix In None
Using Barcode encoder for Office Word Control to generate, create ECC200 image in Microsoft Word applications.
www.OnBarcode.com
Paint EAN13 In None
Using Barcode creator for Word Control to generate, create EAN13 image in Microsoft Word applications.
www.OnBarcode.com
Rendering Multiple Triangles Using the TriangleList
Make Data Matrix 2d Barcode In None
Using Barcode generator for Office Word Control to generate, create ECC200 image in Word applications.
www.OnBarcode.com
PDF417 Creation In None
Using Barcode generator for Word Control to generate, create PDF417 image in Microsoft Word applications.
www.OnBarcode.com
Now that you ve managed to render one triangle, there s no challenge in rendering a few of them. First define their vertices: private void InitVertices() { myVertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements); vertices = new VertexPositionColor[12]; vertices[0] = new VertexPositionColor(new Vector3(-5, 1, 1), Color.Red); vertices[1] = new VertexPositionColor(new Vector3(-5, 5, 1), Color.Green); vertices[2] = new VertexPositionColor(new Vector3(-3, 1, 1), Color.Blue); vertices[3] = new VertexPositionColor(new Vector3(-3, 5, 1), Color.Gray); vertices[4] = new VertexPositionColor(new Vector3(-1, 1, 1), Color.Purple); vertices[5] = new VertexPositionColor(new Vector3(-1, 5, 1), Color.Orange); vertices[6] = new VertexPositionColor(new Vector3(1, 1, 1), Color.BurlyWood); vertices[7] = new VertexPositionColor(new Vector3(1, 5, 1), Color.Gray); vertices[8] = new VertexPositionColor(new Vector3(3, 1, 1), Color.Green); vertices[9] = new VertexPositionColor(new Vector3(3, 5, 1), Color.Yellow); vertices[10] = new VertexPositionColor(new Vector3(5, 1, 1), Color.Blue); vertices[11] = new VertexPositionColor(new Vector3(5, 5, 1), Color.Red); }
Creating Barcode In None
Using Barcode generator for Microsoft Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
Quick Response Code Printer In None
Using Barcode creation for Word Control to generate, create QR-Code image in Word applications.
www.OnBarcode.com
Tip Instead of doing all indicing manually, you can save yourself some time and use an integer that is
Make Code 39 In None
Using Barcode printer for Word Control to generate, create ANSI/AIM Code 39 image in Microsoft Word applications.
www.OnBarcode.com
Create Bookland EAN In None
Using Barcode creation for Microsoft Word Control to generate, create ISBN image in Microsoft Word applications.
www.OnBarcode.com
incremented after each line.
ECC200 Printer In None
Using Barcode generator for Microsoft Word Control to generate, create Data Matrix ECC200 image in Microsoft Word applications.
www.OnBarcode.com
Data Matrix ECC200 Recognizer In VB.NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
With twelve vertices defined, all you have to do is indicate you want to render four triangles from them: device.DrawUserPrimitives<VertexPositionColor> (PrimitiveType.TriangleList, vertices, 0, 4); If you want to render only the last two triangles, you should mention you want to start rendering from the seventh vertex. Since arrays are 0-based, this vertex has index 6: device.DrawUserPrimitives<VertexPositionColor> (PrimitiveType.TriangleList, vertices, 6, 2); This can save you some bandwidth because less data is being pushed from your system RAM to your graphics card.
Barcode Creator In None
Using Barcode generation for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
Universal Product Code Version A Maker In None
Using Barcode encoder for Software Control to generate, create UPCA image in Software applications.
www.OnBarcode.com
CHAPTER 5 GETTING THE MOST OUT OF VE RTICES
Linear Creation In Visual Basic .NET
Using Barcode printer for Visual Studio .NET Control to generate, create Linear Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
EAN13 Drawer In None
Using Barcode printer for Microsoft Excel Control to generate, create EAN-13 Supplement 5 image in Office Excel applications.
www.OnBarcode.com
Rendering Multiple Triangles Using the TriangleStrip
PDF-417 2d Barcode Recognizer In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Encoding Barcode In Java
Using Barcode creator for BIRT reports Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
Whenever the triangles you want to render are connected to each other with a side, you can save a lot of memory, and thus bandwidth, by using a TriangleStrip instead of a TriangleList. Take a look at the six triangles shown in Figure 5-1. Using a TriangleList, this would take 6*3 = 18 vertices. However, only eight of them are unique, so the ten duplicates you re storing and sending to your graphics card are a total waste of memory, bandwidth, and processing power of your GPU!
GS1 RSS Encoder In Visual Studio .NET
Using Barcode creator for VS .NET Control to generate, create GS1 DataBar Limited image in Visual Studio .NET applications.
www.OnBarcode.com
UCC - 12 Creator In None
Using Barcode printer for Font Control to generate, create UCC-128 image in Font applications.
www.OnBarcode.com
1 5 0 7 3 2
Code 128C Printer In .NET Framework
Using Barcode encoder for Reporting Service Control to generate, create Code 128 Code Set C image in Reporting Service applications.
www.OnBarcode.com
Generate Code 128C In None
Using Barcode creation for Font Control to generate, create Code 128 Code Set C image in Font applications.
www.OnBarcode.com
Figure 5-1. Rendering a TriangleStrip By specifying you have stored your triangles as a TriangleStrip, XNA will draw the first triangle based on the first three vertices stored in the array. From then on, XNA will create a new triangle for each next vertex, using the new vertex and the previous two. So, the first triangle is defined by vertices 0, 1, and 2; the second triangle is defined by vertices 1, 2, and 3; the third is defined by vertices 2, 3, and 4; and so on. To render x triangles, you need to define x+2 vertices. So if you have stored twelve vertices in an array (as done in the InitVertices method earlier), you can render ten triangles as a TriangleStrip using this line: device.DrawUserPrimitives<VertexPositionColor> (PrimitiveType.TriangleStrip, vertices, 0, 10);
Note When defining a TriangleStrip, it s impossible to fulfill the culling rule, where you want to define each triangle in a counterclockwise winding order (see recipe 5-6). To solve this, culling is a bit special for TriangleStrips. The first triangle needs to be defined in clockwise winding order, and then the winding order needs to be flipped for each triangle (this will automatically be the case!).
CHAPTER 5 GETTING THE MOST OUT OF VERTICES
Rendering Multiple Points Using a PointList
Next to triangles, you can also render lines and points. This involves using the same code; you specify only a different type of primitive. Simply store a vertex for each point you want to render in an array. If you have stored 12 vertices in an array as shown earlier, this is how you render the 12 3D points to the screen: device.DrawUserPrimitives<VertexPositionColor> (PrimitiveType.PointList, vertices, 0, 12); Note that each point will occupy exactly one pixel on your screen, no matter how close/far the camera is from the point. Anyway, you ll need a couple of good eyes to see the pixels.
Copyright © OnBarcode.com . All rights reserved.