Geometric Modeling

Geometric modeling is at the heart of 3D graphics and is, quite frankly, among the most tedious and time-consuming parts of the entire enterprise. Although many people are born with a gift for creating models, the rest of us have to learn incrementally and through experimentation. Fortunately, there are programs to facilitate the process of building 3D shapes, and it also possible to purchase or download a large number of prebuilt shapes that can be imported into Java 3D. Finally, with 3D laser scanners becoming less expensive, the importation of 3D models will become more commonplace.

That said, it is strongly advised that you come to grips with the challenges of creating a 3D model. Geometric modeling can have a particularly steep learning curve but becomes considerably easier after the first couple of attempts.

In general, 3D models are best made incrementally. It is recommended that beginners start by specifying a single point or line and viewing that alone before adding new elements. It is also well worth the effort to make a list of parts and to begin thinking about these parts in terms of vertices and surfaces (see more next).

We present the basics here and develop these concepts as we work through several examples in the next chapter.

Wireframe and Solid Surface Models

A three-dimensional object can be described by the position of its points in an Euclidean three-dimensional space. The term Euclidean space is reserved for any n-dimensional space in which all points in the space are referenced to a single origin. The important idea here is that any point in an n-dimensional Euclidean space can be represented by n individual values (all implicitly referenced to the origin). For example, a Cartesian space is a special type of Euclidean space that is commonly used in 2D operations. In fact, we used numerous Cartesian spaces in the examples of Chapter 3, “Graphics Programming with the Java 2D API.” A point in Cartesian space is represented by two values (x, y). For example, the point (10.0, 10.0) is meaningful because we assume the origin is (0.0, 0.0). A 2D shape can thus be described by a list of points, called vertices, in the 2D space. By drawing lines between the vertices and rasterizing them, a rendering of the shape is obtained.

Likewise, a 3D shape is also described by a list of vertices —this time using points with three values (x, y, z) . The simplest form of a 3D shape is the wireframe model in which vertices are connected by a series of straight lines (see Figure 10.7). Generally, wireframe models have been replaced in most applications by solid surface models but are still used in many computer aided design applications. A solid surface model is one in which the surface is approximated by a connected set of polygons (see Figure 10.8) .

Figure 10.7. A wireframe model created in Autodesk 3D Studio.


Figure 10.8. A solid surface version of the model from Figure 10.7.


A solid surface model can be built from a wireframe model and is essentially a wireframe with faces. We begin with the simplest example, building a cube in the center of a space. The first task is to specify eight three-dimensional points that define the corners of the cube. The points of the cube for this example are listed in Table 10.3.

Table 10.3. Points Defining a 10x10x10 Cube
Element X Y Z
1 -10.0 -10.0 10.0
2 10.0 -10.0 10.0
3 -10.0 -10.0 -10.0
4 10.0 -10.0 -10.0
5 -10.0 10.0 10.0
6 10.0 10.0 10.0
7 -10.0 10.0 -10.0
8 10.0 10.0 -10.0

To make a wireframe version of this model, we would simply define a series of lines connecting the elements in series 1-2, 2-3,…7-8.

To make this wireframe model of a cube into a solid surface model, we need to add squares as shown in Table 10.4.

Table 10.4. One Possible Set of Faces for the Points in Table 10.3
Face # Point #1 Point #2 Point #3 Point #4
1 1 3 4 2
2 5 6 8 7
3 1 2 6 5
4 2 4 8 6
5 4 3 7 8
7 3 1 5 7

Note that the particular polygons used in this example are defined with four points and are naturally called quads. The other commonly used polygon is the triangle. In fact, if we wanted to make a more efficient version of this particular surface mode, we would respecify each quad as two triangles. Returning to the problem of drawing quads, for the first face we would begin at point #1 (-10.0, -10.0, 10.0), move to point #3 (-10.0, -10.0, -10.0), to point #4 (10.0, -10.0, -10.0), to point #2 (10.0, -10.0, 10.0), and finally return to point #1. Indeed, this is directly analogous to the PathInterator and GeneralPath methods used in Java 2D (see Chapter 3). We would then proceed to draw the next face and so forth.

The object we just drew is from the general family of shapes known as polyhedrons. In a polyhedron, every edge is shared by exactly two faces. The basic process involved in creating a 3D geometric model is to first find a set of polygonal faces that describe the shape we intend to draw and then break this set of polygons into triangles (or quads), thus creating a triangle (or quad) mesh. Triangles are used because they are the optimal representation for hardware acceleration. At this stage, the effort of creating a sketch and parts list of the model really pays off. If the model is at all complicated—for example, a simple fighter jet or a room—there will be choices to be made.

Specifying geometry vertex by vertex is generally too time-consuming to be of much practical value. Thus, it is usually preferable to find an algorithm for programming these points or even to draw the object in a 3D drawing program first and then import it. Another very common way to get the model is to use a predefined VRML (Virtual Reality Model Language) model. It should be noted, however, that VRML still requires a significant effort and knowledge of scene creation. Regardless of which path or combination of paths a developer takes, there is often a need to operate at a pretty low level. Knowledge of these fundamental ideas is essential to understanding 3D graphics in general. You will have the opportunity to work through several examples in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset