|
The QuadArray© Justin Couch 2001 - 2004QuadArrays provide the basic four-sided rendered primitive. You define the quad by providing four vertices that make up the extremities. The renderer then joins them in the order that you provide them. ConstructionWhen providing the points, the basic pattern follows the other simple primitive types - there is a flat array of vertices that has the components of each coordinate placed sequentially in the array. In the same way that a pair of vertices provided a line for theLineArray primitive, every four
sets of coordinates (or vertices) represents one quad.
Constructing a set of quads starts by constructing an instance of the
int format = GeometryArray.COORDINATE |
GeometryArray.COLOR_3;
QuadArray quads = new QuadArray(8, format);
After the first four sets of vertices (12 items in the coordinate array), then
the next quad is drawn, such as in Figure 6 that shows two quads being drawn.
![]() Figure 6: A quad array showing the vertex numbering for two quads
![]() Figure 7: The types of quads that can be constructed What is the front?Because you can provide any four set of coordinates, this can lead to some apparently interesting issues. For example, your quad cannot be seen! One of the most common traps that programmers new to 3D graphics run into is this issue. This has a lot to do with understanding how 3D rendering systems work. So, let's take a couple of steps backwards and look at what happens during the process of putting your polygon onto the monitor.In highly complex scenes, there will be many polygons. An often quoted cliche is that it reality is rendered in about 60 million polygons. Put that at about 120 frames a second, and you can see that is one hell of a fill-rate for your Geforce 20 to have to push out. When you look out the window to the big blue room, you will notice that of those 60 odd million polygons, you probably see less than a quarter of them. There's a lot behind you, a heap hidden behind other objects, and also a many that sit on the opposite side of the objects to where you are viewing them from. So, put this all down and you've trimmed that to maybe 10 million polygons. Video cards have a hard time pushing through that many polygons at the best of times. Throw in a bit of interaction or animation and you're soon pushing the boundaries of your hardware. To make life easier, your rendering software does a series of checks on the polygons to remove as many as possible before they even get to your video card. Anything that could not possibly be seen is removed - this is termed culling. Apart from the spatial culling (such as the stuff behind you) then we start looking at the individual polygons. Anything that is not facing you doesn't need to be rendered, so can be culled. How does the rendering system decide which polygons face you and which don't? Determining which way a polygon is facing is an important issue - that's why your polygon sometimes shows and sometimes doesn't depending on which way you've declared the vertices. Why does vertex ordering matter? Well, this is really a semi-arbitrary decision. Somehow, the rendering software must determine what constitutes the "front" of the polygon. To do this, the system must determine a direction and that direction is given by the normal to the polygon. In order to determine the normal, the system uses the points of two adjacent edges and does some maths (called a Cross-Product) to create a normal. The nature of this maths is such that depending on which way those two edges are put together, will determine the "direction" that your polygon is facing, and hence what is the front and back. Change the order that the points of your polygon is declared in and the "front" side of the polygon changes, as illustrated in Figure 8.
Figure 8: How the declaration order effects the front side of the polygon |
|
[ j3d.org ]
[ Aviatrix3D ]
[ Code Repository ]
[ Java3D ]
[ OpenGL ]
[ Books ]
[ Contact Us ]
Hosted by Yumetech Last Updated: $Date: 2006/04/18 18:20:11 $ |