Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

nvsg::LOD Class Reference

Level Of Detail class. More...

#include <LOD.h>

Inheritance diagram for nvsg::LOD:

Inheritance graph
[legend]
Collaboration diagram for nvsg::LOD:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual NVSG_API const LOD * clone (void) const
 Get a clone of this LOD object. More...

NVSG_API void setRanges (const float *ranges, size_t count)
 Set all range values. More...

NVSG_API const float * getRanges (void) const
 Get all ranges. More...

NVSG_API size_t getNumberOfRanges (void) const
 Get the number of ranges. More...

NVSG_API void setCenter (const nvmath::Vec3f &center)
 Set the center. More...

NVSG_API const nvmath::Vec3fgetCenter (void) const
 Determine the LOD to use. More...

NVSG_API size_t getLODToUse (const nvmath::Mat44f &modelViewMatrix) const

Static Public Methods

NVSG_API const LOD * create (void)
 Create a LOD. More...

NVSG_API const LOD * createFromBase (const Group &rhs)
 Create a LOD by copying from a Group. More...


Protected Methods

NVSG_API LOD (void)
 Default Constructor. More...

NVSG_API LOD (const Group &rhs)
 Partial Constructor. More...

NVSG_API LOD (const LOD &rhs)
 Copy Constructor. More...

virtual NVSG_API ~LOD (void)
 Prohibit explicit creation on stack by making the destructor protected. More...


Detailed Description

Level Of Detail class.

This class is a special kind of a group containing different representations of the same object as well as some range information. The representations include different levels of detail, meaning that the first child is the best and most precise representation of the object, the second child is of lower resolution, and so on. The current implementation determines the distance between the camera and the given center point of the object (dist). The distance is compared against the ranges and the corresponding range defines the LOD representation to use.

It works like this:

 IF (dist < ranges[0])                    THEN activeChild = 0
 ELSE IF (ranges[i-1] < dist < ranges[i]) THEN activeChild = i
 ELSE IF (dist > ranges[LASTRANGE])       THEN activeChild = LASTRANGE+1

Note:
You should provide n ranges and n+1 children. If you specify too few ranges, the extra children will never be used. If you instead provide to few children, the last child will be used for all the extra ranges.
Note:
In some cases you do not want to draw something on the last (infinite) level. In this case simply add an empty Group node at the lowest resolution level. Same for the highest resolution level if you want geometry to disappear if it is too near to the camera.


Constructor & Destructor Documentation

NVSG_API nvsg::LOD::LOD void    [protected]
 

Default Constructor.

NVSG_API nvsg::LOD::LOD const Group   rhs [protected]
 

Partial Constructor.

NVSG_API nvsg::LOD::LOD const LOD &    rhs [protected]
 

Copy Constructor.

virtual NVSG_API nvsg::LOD::~LOD void    [protected, virtual]
 

Prohibit explicit creation on stack by making the destructor protected.


Member Function Documentation

NVSG_API const LOD* nvsg::LOD::create void    [static]
 

Create a LOD.

Returns:
a constant pointer to a LOD.

Reimplemented from nvsg::Group.

NVSG_API const LOD* nvsg::LOD::createFromBase const Group   rhs [static]
 

Create a LOD by copying from a Group.

Returns:
a constant pointer to a LOD.
Parameters:
rhs  Group to copy from

virtual NVSG_API const LOD* nvsg::LOD::clone void    const [virtual]
 

Get a clone of this LOD object.

Returns:
A pointer to the new created clone.

Reimplemented from nvsg::Group.

NVSG_API void nvsg::LOD::setRanges const float *    ranges,
size_t    count
 

Set all range values.

Parameters:
ranges  Pass NULL to clear the ranges.
count  Number of range values.

NVSG_API const float* nvsg::LOD::getRanges void    const
 

Get all ranges.

Returns:
A pointer to a float array.

NVSG_API size_t nvsg::LOD::getNumberOfRanges void    const
 

Get the number of ranges.

Returns:
The number of ranges.

NVSG_API void nvsg::LOD::setCenter const nvmath::Vec3f   center
 

Set the center.

The center is the point used for finding the exact level of detail by calculating its distance to the camera.

Parameters:
center  Center point.

NVSG_API const nvmath::Vec3f& nvsg::LOD::getCenter void    const
 

Determine the LOD to use.

Returns:
The point that is used for the distance calculation.

NVSG_API size_t nvsg::LOD::getLODToUse const nvmath::Mat44f   modelViewMatrix const
 

This method is called by the ModelViewTraverser. It calculates the distance between the center point and the camera.

We calculate the distance by transforming the center into
object space - while the camera is located at the origin in object space the calculation trivial.
Returns:
The index of the LOD level that this node will use. 0xffffffff will be returned when there is no LOD level available.
Parameters:
modelViewMatrix  currentWorldMatrix * currentViewingMatrix


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:20:29 2005 for NVSGSDK by NVIDIA