< Zurück | Inhalt | Weiter >

DistanceLOD Class

java.lang.Object

|

+−−javax.media.j3d.SceneGraphObject

|

+−−javax.media.j3d.Node

|

+−−javax.media.j3d.Leaf

|

+−−javax.media.j3d.Behavior

|

+−−javax.media.j3d.LOD

|

+−−javax.media.j3d.DistanceLOD


LOD itself is an abstract class. The only class derived from it is DistanceLOD which implements a LOD behavior based on the distance of the viewer from a point. Conceivably you could derive your own custom LOD behaviors from the abstract base class to implement application specific LOD functionality, or to switch the state of objects based on UI input.


The SplineInterpolatorTest example application uses a simple DistanceLOD behavior. Two versions of the 3D world are created, a high resolution version to be used when the viewer is less than 180 meters away and a low resolution version to be used when the viewer is more than 180 meters away.


The two versions of the world are created within separate Groups and added to a single Switch Node—the high resolution world is added first.


A DistanceLOD object is then created and initialized with an array of distances—as we only have two versions of the world we just have to pass in a single distance value to select between them. If we had n distance values in the distances array, and hence n + 1 models in the Switch Node, the formula for selecting between them is shown in table 11.5.


Table 11.5


Index selected

Distance (d)

0

if d <= distances[0]

i

if distances[I – 1] < d <= distances[i]

n

if d > distances[n – 1]

The DistanceLOD is then passed a reference to the Switch Node that it is going to control using the

LOD.addSwitch method.


 

From SplineInterpolatorTest.java