Show
Ignore:
Timestamp:
12/29/06 10:28:00 (2 years ago)
Author:
cneumann
Message:

- regenerated all base files to include the full set

of access functions for non-ptr mfields.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/NodeCores/Groups/Misc/OSGDistanceLODBase.cpp

    r435 r459  
    7373 
    7474/*! \class OSG::DistanceLOD 
    75     This Node manages the different levels of detail available for a 
    76     Geometry and decides which one should be rendered, according to the 
    77     distance from the current camera. The details of the selection process 
    78     are taken from VRML97 standard. 
    79  
    80     The node chooses which child to render based on the range values in the 
    81     Range multi-field and the current distance of the camera from the 
    82     object.   The children should be ordered from the highest level of 
    83     detail to the  lowest level of detail. The range values specify the 
    84     distances at which to  switch between the different children. 
    85  
    86     The center field is a translation offset in the local coordinate system 
    87     that specifies the center of the object for distance calculations.  In 
    88     order to calculate which level to display, first the distance from the 
    89     viewpoint to the center point of the LOD node (with corresponding 
    90     transformations) is computed.  If the distance is less than the first 
    91     range value, then the first LOD is drawn. If it is between the first 
    92     and the second values, then the second LOD is drawn, and so on. 
     75    This Node manages the different levels of detail available for a Geometry 
     76    and decides which one should be rendered, according to the distance from the 
     77    current camera. The details of the selection process are taken from VRML97 
     78    standard.  
     79 
     80    The node chooses which child to render based on the range values in the Range 
     81    multi-field and the current distance of the camera from the object.   
     82    The children should be ordered from the highest level of detail to the  
     83    lowest level of detail. The range values specify the distances at which to  
     84    switch between the different children. 
     85 
     86    The center field is a translation offset in the local coordinate system that 
     87    specifies the center of the object for distance calculations.  In order to 
     88    calculate which level to display, first the distance from the  
     89    viewpoint to the center point of the LOD node (with corresponding  
     90    transformations) is computed.  If the distance is less than the first range 
     91    value, then the first LOD is drawn. If it is between the first and the second 
     92    values, then the second LOD is drawn, and so on. 
    9393 
    9494    \example Setting up a OSG::DistanceLOD 
     
    9797    You would also need to add children for the 4 LODs. 
    9898 
    99     \code DistanceLOD lod = DistanceLOD::create(); 
    100  
    101     // this is supposed to be the center of the LOD model, // that is, this 
    102     is the point the distance is measured from lod->setCenter(12,1,5); // 
    103     now we add the distances when models will change 
     99    \code 
     100    DistanceLOD lod = DistanceLOD::create(); 
     101 
     102    // this is supposed to be the center of the LOD model, 
     103    // that is, this is the point the distance is measured from 
     104    lod->setCenter(12,1,5); 
     105    // now we add the distances when models will change 
    104106    lod->editMFRange()->push_back(6.0); 
    105107    lod->editMFRange()->push_back(12.0); 
    106     lod->editMFRange()->push_back(24.0); \endcode \endexample 
     108    lod->editMFRange()->push_back(24.0); 
     109    \endcode 
     110    \endexample 
    107111 */ 
    108112 
     
    114118    The center for distance calculation. 
    115119*/ 
     120 
    116121/*! \var Real32          DistanceLODBase::_mfRange 
    117122    The range intervals. 
    118123*/ 
     124 
    119125 
    120126void DistanceLODBase::classDescInserter(TypeObject &oType) 
     
    249255    "current camera. The details of the selection process are taken from VRML97\n" 
    250256    "standard. \n" 
     257    "\n" 
    251258    "The node chooses which child to render based on the range values in the Range\n" 
    252259    "multi-field and the current distance of the camera from the object.  \n" 
     
    254261    "lowest level of detail. The range values specify the distances at which to \n" 
    255262    "switch between the different children.\n" 
     263    "\n" 
    256264    "The center field is a translation offset in the local coordinate system that\n" 
    257265    "specifies the center of the object for distance calculations.  In order to\n" 
     
    261269    "value, then the first LOD is drawn. If it is between the first and the second\n" 
    262270    "values, then the second LOD is drawn, and so on.\n" 
     271    "\n" 
    263272    "\\example Setting up a OSG::DistanceLOD\n" 
     273    "\n" 
    264274    "Here is an example of setting up an lod core with a center and a range.\n" 
    265275    "You would also need to add children for the 4 LODs.\n" 
     276    "\n" 
    266277    "\\code\n" 
    267278    "DistanceLOD lod = DistanceLOD::create();\n" 
     279    "\n" 
    268280    "// this is supposed to be the center of the LOD model,\n" 
    269281    "// that is, this is the point the distance is measured from\n" 
     
    337349 
    338350 
     351/*********************************** Non-ptr code ********************************/ 
     352void DistanceLODBase::pushToRange(const Real32& value) 
     353{ 
     354    editMField(RangeFieldMask, _mfRange); 
     355    _mfRange.push_back(value); 
     356} 
     357 
     358void DistanceLODBase::insertIntoRange(UInt32                uiIndex, 
     359                                                   const Real32& value   ) 
     360{ 
     361    editMField(RangeFieldMask, _mfRange); 
     362 
     363    MFReal32::iterator fieldIt = _mfRange.begin(); 
     364 
     365    fieldIt += uiIndex; 
     366 
     367    _mfRange.insert(fieldIt, value); 
     368} 
     369 
     370void DistanceLODBase::replaceInRange(UInt32                uiIndex, 
     371                                                       const Real32& value   ) 
     372{ 
     373    if(uiIndex >= _mfRange.size()) 
     374        return; 
     375 
     376    editMField(RangeFieldMask, _mfRange); 
     377 
     378    _mfRange[uiIndex] = value; 
     379} 
     380 
     381void DistanceLODBase::replaceInRange(const Real32& pOldElem, 
     382                                                        const Real32& pNewElem) 
     383{ 
     384    Int32  elemIdx = _mfRange.findIndex(pOldElem); 
     385 
     386    if(elemIdx != -1) 
     387    { 
     388        editMField(RangeFieldMask, _mfRange); 
     389 
     390        MFReal32::iterator fieldIt = _mfRange.begin(); 
     391 
     392        fieldIt += elemIdx; 
     393 
     394        (*fieldIt) = pNewElem; 
     395    } 
     396} 
     397 
     398void DistanceLODBase::removeFromRange(UInt32 uiIndex) 
     399{ 
     400    if(uiIndex < _mfRange.size()) 
     401    { 
     402        editMField(RangeFieldMask, _mfRange); 
     403 
     404        MFReal32::iterator fieldIt = _mfRange.begin(); 
     405 
     406        fieldIt += uiIndex; 
     407        _mfRange.erase(fieldIt); 
     408    } 
     409} 
     410 
     411void DistanceLODBase::removeFromRange(const Real32& value) 
     412{ 
     413    Int32 iElemIdx = _mfRange.findIndex(value); 
     414 
     415    if(iElemIdx != -1) 
     416    { 
     417        editMField(RangeFieldMask, _mfRange); 
     418 
     419        MFReal32::iterator fieldIt = _mfRange.begin(); 
     420 
     421        fieldIt += iElemIdx; 
     422 
     423        _mfRange.erase(fieldIt); 
     424    } 
     425} 
     426 
     427void DistanceLODBase::clearRange(void) 
     428{ 
     429    editMField(RangeFieldMask, _mfRange); 
     430 
     431    _mfRange.clear(); 
     432} 
     433 
     434 
    339435/*------------------------------ access -----------------------------------*/ 
    340436