Level of Detail

As mentioned in Chapter 10, level of detail (LOD) is an important optimization technique because it reduces the number of vertices that need to be rendered. It is often stated that the most efficient vertex to render is one that isn't rendered at all.

Remember from that discussion that a texture map pasted on a box will represent the Statue of Liberty just fine when shown from Battery Park but as you get closer, the flat nature of the 2D texture becomes more obvious. What we would really like is multiple levels of detail that switch into the scene systematically as we approach and move away from the model.

LODs fall naturally under the Behavior class abstraction. When looking at the Java 3D documentation for the LOD class, you will note that LOD itself is abstract and that the only subclass is DistanceLOD. There are three constructors for DistanceLOD.

DistanceLOD()
DistanceLOD(float[] distances)
DistanceLOD(float[] distances, Point3f() position)

Note that the first constructor used the default value of 1 and is therefore not necessarily useful unless the values are subsequently set. In the second constructor, an array of floats is used to specify the discrete distances over which the LOD will operate. Note that in the second constructor, the origin of the object is not specified and is assumed to be (0.f, 0.f, 0.f) by default. This can cause some confusion when using this class because the programmer most often wants the origin of the LOD to be the same location as the object and not at the center of the universe typically. The third constructor allows the position of the LOD object (or some other position) to be specified explicitly.

One critical aspect to using the DistanceLOD class is to understand the SwitchNode class presented in Chapter 11. The relationship between the distance and SwitchNode value is determined by breaking up the distance into n discrete bins and then assigning the Switch values to each bin.

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

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