Level of detail models

Level of detail is a technique that is used to display simpler models with a lower polygon count when they are off in the background, while displaying higher quality models with larger polygon counts when they are closer to the camera. Sacrificing the quality of those 3D objects in the background can produce a significant performance boost, and because distant 3D objects are smaller when drawn on the screen quite often there is no noticeable drop in visual quality.

The LODObject class, from the away3d.containers package, is a container that will display its child 3D objects only when they fall within a certain perspective value range. This perspective value is calculated with the formula:

perspective value = camera zoom / (1 + distance from camera / camera focus)

A number of LODObject objects can be used as a group to implement the level of detail technique. As an example, let's take three sphere primitives, each constructed with a different number of polygons:

var sphere0:Sphere = new Sphere(
  {
    radius:50, 
    segmentsW: 4, 
    segmentsH:3 
  }
);
var sphere1:Sphere = new Sphere(
  {
    radius:50, 
    segmentsW: 10, 
    segmentsH:8 
  }
);
var sphere2:Sphere = new Sphere(
  {
    radius:50, 
    segmentsW: 16, 
    segmentsH:12 
  }
);

Each of these spheres is then added as a child of a new LODObject object. The minp init object parameter defines the minimum end of the perspective value range that the children of the LODObject object will be visible at. The maximum end of the range is defined up to (but not including) the value supplied via the maxp parameter.

var lodObject0:LODObject = new LODObject(
  {
    minp:0, 
    maxp:0.25
  }, 
  sphere0
);
var lodObject1:LODObject = new LODObject(
  {
    minp:0.25, 
    maxp:0.5
  }, 
  sphere1
);
var lodObject2:LODObject = new LODObject(
  {
    minp:0.5, 
    maxp:1
  }, 
  sphere2
);

To use these three LODObject objects as a group, they can be added as children of a standard ObjectContainer3D object:

var container:ObjectContainer3D = 
  new ObjectContainer3D(lodObject0, lodObject1, lodObject2);

When the container is added to the scene, one of these three spheres will then be visible as the distance between the ObjectContainer3D object (and its children LODObject objects) and the camera changes. To work out at what distance the spheres are visible, the preceding formula can be rewritten as:

distance from camera = (1 / perspective value * camera zoom – 1) * camera focus

Using the default values for the cameras zoom (10) and focus (100) properties, we can work out that the sphere0 3D object will be visible when it is greater than 3,900 units from the camera. The sphere1 3D object will be visible when it is between 3,900 and 1,900 units from the camera. And the sphere2 3D object will be visible when it is up to 1,900 units from the camera.

When the application is run, the following images will appear depending on the distance from the camera to the container that holds the LODObject objects:

Level of detail models
..................Content has been hidden....................

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