OSGRangeLOD.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *                     Copyright 2000-2002 by OpenSG Forum                   *
00006  *                                                                           *
00007  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00008  *                                                                           *
00009 \*---------------------------------------------------------------------------*/
00010 /*---------------------------------------------------------------------------*\
00011  *                                License                                    *
00012  *                                                                           *
00013  * This library is free software; you can redistribute it and/or modify it   *
00014  * under the terms of the GNU Library General Public License as published    *
00015  * by the Free Software Foundation, version 2.                               *
00016  *                                                                           *
00017  * This library is distributed in the hope that it will be useful, but       *
00018  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00020  * Library General Public License for more details.                          *
00021  *                                                                           *
00022  * You should have received a copy of the GNU Library General Public         *
00023  * License along with this library; if not, write to the Free Software       *
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00025  *                                                                           *
00026 \*---------------------------------------------------------------------------*/
00027 /*---------------------------------------------------------------------------*\
00028  *                                Changes                                    *
00029  *                                                                           *
00030  *                                                                           *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035 \*---------------------------------------------------------------------------*/
00036
00037 OSG_BEGIN_NAMESPACE
00038
00039 template<class RenderActionT> inline
00040 ActionBase::ResultE RangeLOD::render(Action *action)
00041 {
00042     RenderActionT  *ra = dynamic_cast<RenderActionT  *>(action);
00043
00044     Pnt3f eyepos;
00045
00046     ra->getActivePartition()->getCameraToWorld().mult(eyepos, eyepos);
00047
00048     Pnt3f objpos;
00049
00050     ra->topMatrix().mult(getCenter(), objpos);
00051
00052     Real32 dist = eyepos.dist(objpos);
00053
00054     if(dist > getSwitchOut() && dist < getSwitchIn())
00055     {
00056         return Action::Continue;
00057     }
00058     else
00059     {
00060         return Action::Skip;
00061     }
00062
00063 #if 0
00064     action->useNodeList();
00065
00066     UInt32 numLevels = action->getNNodes();
00067
00068     if(numLevels == 0)
00069         return Action::Continue;
00070
00071     Int32           index     = -1;
00072
00073     const MFReal32 *range = getMFRange();
00074
00075     UInt32 numRanges = range->size();
00076
00077     if (numRanges == 0)
00078     {
00079         index = 0;
00080     }
00081     else
00082     {
00083         Pnt3f eyepos;
00084
00085         ra->getActivePartition()->getCameraToWorld().mult(eyepos, eyepos);
00086
00087         Pnt3f objpos;
00088
00089         ra->topMatrix().mult(getCenter(), objpos);
00090
00091         Real32 dist = eyepos.dist(objpos);
00092
00093         if(numRanges >= numLevels)
00094             numRanges = numLevels - 1;
00095
00096         if(dist >= (*range)[numRanges - 1])
00097         {
00098             index = numRanges;
00099         }
00100         else
00101         {
00102             for(index = 0; index < numRanges; ++index)
00103             {
00104                 if(dist < (*range)[index])
00105                     break;
00106             }
00107         }
00108     }
00109
00110     Node *nodePtr = action->getNode(index);
00111
00112     if(ra->isVisible(nodePtr))
00113     {
00114         ra->addNode(nodePtr);
00115     }
00116
00117     return ActionBase::Continue;
00118 #endif
00119 }
00120
00121 OSG_END_NAMESPACE
00122
00123