Level of Detail Reduced for Performance
161
csLOD allows you to reach a compromise between performance and the level of detail
rendered. For high quality images, a shape close to the camera should be rendered in
high detail. When a shape recedes from the camera, the same level of detail is not
necessary. Reducing the level of image detail reduces the number of vertices required to
render a shape, which results in improved performance.
OpenGL Optimizer can create the csLOD child nodes.
Choosing a Child Node Based on Range
The distance, called the range, that determines which child of the csLOD is displayed is
defined as the distance between a camera and a shape’s center. Each child node of a
csLOD node is associated with a range of distance values. The range is computed during
the traversal of the scene graph. You set the range value using csLOD methods:
void setCenter(const csVec3f& c);
void getCenter(csVec3f &c) const;
void setRange(int index, float nearDistance,float farDistance);
void setRangeNear(int child,float distance);
void setRangeFar(int child,float distance);
int getNumRanges() const {return numRanges; }
float getRangeNear(int child) const;
float getRangeFar(int child) const;
The setCenter() method specifies the center of the LOD. The center point aids in
calculating the range between the camera and the shape.
The setRange() method specifies the ranges over which a child node of the csLOD node
is selected for display. The number of ranges must correspond to the number of csLOD
child nodes. If that is not the case:
• If too few ranges are specified, the highest-order child nodes are ignored.
• If too many ranges are specified, the extra ranges are ignored.
Instead of using setRange(), you can use setRangeNear() together with setRangeFar() to
specify the range over which a child node of a csLOD node is selected for display.