print barcode zebra vb.net WORKING WITH 2D IMAGES /TEXTURES IN XNA 2.0 in Word

Drawer ECC200 in Word WORKING WITH 2D IMAGES /TEXTURES IN XNA 2.0

CHAPTER 3 WORKING WITH 2D IMAGES /TEXTURES IN XNA 2.0
ECC200 Encoder In None
Using Barcode generation for Office Word Control to generate, create DataMatrix image in Microsoft Word applications.
www.OnBarcode.com
Generate Code 128 In None
Using Barcode encoder for Office Word Control to generate, create Code128 image in Microsoft Word applications.
www.OnBarcode.com
Figure 3-17. Spherical billboarding (left), cyclindrical billboarding (right)
Drawing Barcode In None
Using Barcode drawer for Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
Painting Code 39 In None
Using Barcode encoder for Word Control to generate, create Code 3 of 9 image in Office Word applications.
www.OnBarcode.com
Note This kind of billboarding is labeled cylindrical, because when you position the camera inside a lot of such billboarded images, they will create a cylindrical tunnel. This is caused by the fact that they are allowed to be rotated along only one direction. Figure 3-18 shows such a tunnel.
Creating GS1 - 12 In None
Using Barcode maker for Word Control to generate, create UPC Code image in Microsoft Word applications.
www.OnBarcode.com
Paint PDF417 In None
Using Barcode printer for Microsoft Word Control to generate, create PDF-417 2d barcode image in Word applications.
www.OnBarcode.com
The code to calculate the corner points of each billboard is almost the same as in the first part of this recipe. You only need to use another billboarding matrix, which can be created using the Matrix.CreateConstrainedBillboard method: Matrix bbMatrix = Matrix.CreateConstrainedBillboard(center, quatCam.Position, new Vector3(0, 1, 0), quatCam.Forward, null); As an extra constraint to the rotation, you can now specify the single direction around which the billboard is allowed to rotate. For a tree, this will be the (0,1,0) Up vector. To make the rotation more accurate when the camera is very close to the object, you can also specify the Up vector of the camera.
Generate Barcode In None
Using Barcode generator for Microsoft Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
Encode Planet In None
Using Barcode maker for Word Control to generate, create USPS PLANET Barcode image in Word applications.
www.OnBarcode.com
C HA PTER 3 WORKING WITH 2D IMA GES/TEXTU RES IN XN A 2.0
Data Matrix Generator In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
www.OnBarcode.com
Data Matrix ECC200 Decoder In VB.NET
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Figure 3-18. Even more cylindrical billboarding
ANSI/AIM Code 128 Generator In None
Using Barcode creator for Software Control to generate, create ANSI/AIM Code 128 image in Software applications.
www.OnBarcode.com
QR Code 2d Barcode Encoder In Java
Using Barcode encoder for Eclipse BIRT Control to generate, create QR Code ISO/IEC18004 image in BIRT applications.
www.OnBarcode.com
Performance Considerations: Part 2
Data Matrix 2d Barcode Generation In None
Using Barcode creation for Software Control to generate, create Data Matrix ECC200 image in Software applications.
www.OnBarcode.com
Barcode Creator In None
Using Barcode generator for Online Control to generate, create Barcode image in Online applications.
www.OnBarcode.com
The first part of this recipe showed how you can create a billboarding engine in XNA code. However, this approach puts a lot of stress on your CPU and is highly inefficient for your graphics card, as you can read here. Say you want to render 1,000 billboarded 2D images in your 3D scene. Whenever the camera changes position, you need to recalculate the positions of the four corner points of each of your images so they are again facing the camera. Targeting an update rate of 60 updates/second, this comes down to calculating 4,000 3D positions 60 times each second, which has to be done on the CPU. Furthermore, for each frame a complete array of 6,000 vertices needs to be created to hold the two triangles needed to display each billboard. The CPU is a general-purpose processor, not really optimized for this kind of calculation. A task like this will cripple the CPU, severely limiting whatever else you need the CPU for, such as general game logic. Moreover, each frame this updated vertex buffer needs has to be sent to the graphics card! This requires the graphics card to put this data in nonoptimal memory and puts a lot of traffic on your PCI-express (or AGP) bus. Wouldn t it be incredible if you just had to store the 3D center position and size of each billboard only one time in the fast static memory on your graphics card and have your GPU (the calculation unit on your graphics card) perform all the billboarding calculations instead of the CPU Keep in mind that your GPU is optimized for vector operations, making it an order of magnitude faster at doing these calculations than your CPU. This combines the following important benefits: One-time-only traffic on your PCI-express (or AGP) bus Calculation time much shorter (because the GPU is optimized for these kind of calculations) Absolutely no billboarding calculations done on the CPU, leaving the CPU free to do more important work And it introduces no drawbacks. This is almost starting to sound like a cheap infomercial!
QR Code 2d Barcode Drawer In Java
Using Barcode printer for Java Control to generate, create Quick Response Code image in Java applications.
www.OnBarcode.com
Universal Product Code Version A Drawer In Java
Using Barcode creation for BIRT reports Control to generate, create GTIN - 12 image in BIRT applications.
www.OnBarcode.com
CHAPTER 3 WORKING WITH 2D IMAGES /TEXTURES IN XNA 2.0
ECC200 Maker In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
www.OnBarcode.com
Code 128 Code Set A Decoder In VS .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Preparing Your Code for HLSL Billboarding
Code 128 Code Set B Recognizer In C#
Using Barcode reader for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
USS-128 Printer In None
Using Barcode creator for Font Control to generate, create UCC-128 image in Font applications.
www.OnBarcode.com
You can still use a list to keep track of your billboards, so you can use the AddBillboards method without any modification. The CreateBBVertices method, however, will be simplified, because all billboarding calculations will be done in the vertex shader on the GPU. A billboard will still be drawn using two quads, so for each billboard you will still need to pass six vertices to the GPU. So, what exactly do you want the vertex shader to do You want the vertex shader to compute the 3D rotated coordinates of each of the six vertices surrounding a billboard so the billboard is facing the camera. To do this, the vertex shader needs to know the following information about each vertex: The 3D position of the center of the billboard to which the vertex belongs Some kind of information identifying which corner point the current vertex is of the billboard so the vertex shader can calculate the corresponding offset from the center The usual texture coordinates, so they can be passed to the pixel shader that will use them to sample at the right location from the texture
Note Obviously, your vertex shader also needs to know the location of the camera in 3D space before it can rotate the billboards so they are facing the camera. This camera position is the same for all vertices, however, and should therefore be set as an XNA-to-HLSL variable, instead of storing this position inside each vertex.
This means that one part of the information carried by all six vertices belonging to a billboard will be the same: the 3D position of the center of the billboard. As information that identifies the vertex as one of the four corner points, you could, for example, pass a number between 0 and 3, where 0 means, for example, the top-left corner points and 3 the bottom-right corner points. However, you are already passing this kind of information to the vertex shader by means of the texture coordinate! Indeed, a (0,0) texture coordinate indicates the current vertex is the top-left corner point, and a (1,0) texture coordinate indicates a top-right corner point. As a summary: for each billboard you want to draw, you need to render two triangles, so you need to pass six vertices to the vertex shader. These six vertices will carry the same positional data: the center of the billboard. Each of the six vertices will also carry its specific texture coordinate, required for correctly texturing the two triangles, but in this case the texture coordinate will also be used by the vertex shader to determine which corner point the current vertex is, so the vertex shader can calculate the offset of the current vertex to the center of the billboard. So in your XNA code, adjust the CreateBBVertices method so it generates these vertices and stores them in an array:
Copyright © OnBarcode.com . All rights reserved.