Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 3 ■ advanCed 3d Content rendering: 3d asset ConCepts and prinCiples


Connect the 3D Vertices: Edges Bridge 3D Vertices


Most 3D geometry uses something called an edge to connect two vertices. An edge is a vector, or straight
line, so it looks like the edge of a razor in 3D space. Three or more edges are needed to form a polygon,
which we are going to cover next. When you are modeling 3D geometry, you can select vertices, edges,
polygons, or entire objects.
If you’ve created your 3D geometry using a more advanced spline-based modeling paradigm, such as
NURBS using MoI 3D, Quads using SILO 2 (which is only $160), or Hash Patches using Animation:Master
(which is only $80), you will need to decimate these formats into polygons or triangles, which we are going
to cover next. The process of decimation turns the infinitely smooth curves used in these paradigms into a
collection of straight edges. This is done using a decimation (smoothness) numeric factor (slider or setting),
which is usually supplied in the File Export function that outputs the spline modeling format from your
curve-based modeler into a polygonal geometric model format.


Creating the Surface: Three Edges Form Polygons, Four Edges Form Quads


Once you have put three edges together in the format of a triangle, you have a polygon, which can be used
as a surface to host a skin, or texture, to make the 3D data look more realistic. Polygons are sometimes
referred to as Triangles, Tris, or Faces, and some modelers use square polygons that are referred to as
“Quads.” If your rendering engine requires triangles as JavaFX and its TriangleMesh class do, you can
decimate Quads into Tris. The decimation algorithm is fairly simple, in this case, as it simply inserts an
edge between two opposite corners of the quad surface, creating two triangles of equal (mirrored) angle
characteristics. The optimal triangle comes from a square polygon and has a 45-45-90 degree corner angle
configuration. The rule of thumb is that the more uniform (square) a triangle is, the better it renders,
whereas “slivered,” or long, thin triangles, could cause rendering artifacts but usually do not.
Once you have a surface (which is usually a triangle, as shown in Figure 3-2), the faces on the basic cube
are quads, and you have defined its normal (which we will learn about next), then you can apply a texture
map. We will cover texture mapping in the next major section of this chapter. There is also another principle
that is related to adjacent polygons or faces that is called a smoothing group, which we will take a look at after
we cover surface normals. So, at the very least, a surface (polygon, triangle, quad, face) will host one normal,
one or more texture maps, and a smoothing group.

Free download pdf