OSGRangeLOD.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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