Converted osg::LOD from used n+1 successive ranges to n min/max ranges,
one min/max pair per child. Converted the rest of the OSG to use the new osg::LOD node.
This commit is contained in:
@@ -646,9 +646,12 @@ osg::Group* ConvertFromFLT::visitLOD(osg::Group& osgParent, LodRecord* rec)
|
||||
|
||||
float64x3* pCenter = &pSLOD->Center;
|
||||
lod->setCenter(osg::Vec3(pCenter->x(), pCenter->y(), pCenter->z())*_unitScale);
|
||||
lod->setRange(0, pSLOD->dfSwitchOutDist*_unitScale);
|
||||
lod->setRange(1, pSLOD->dfSwitchInDist*_unitScale);
|
||||
|
||||
lod->setRange(0, pSLOD->dfSwitchOutDist*_unitScale,
|
||||
pSLOD->dfSwitchInDist*_unitScale);
|
||||
|
||||
lod->setName(pSLOD->szIdent);
|
||||
|
||||
visitAncillary(osgParent, *lod, rec)->addChild( lod );
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
@@ -668,9 +671,12 @@ osg::Group* ConvertFromFLT::visitOldLOD(osg::Group& osgParent, OldLodRecord* rec
|
||||
(float)pSLOD->Center[0],
|
||||
(float)pSLOD->Center[1],
|
||||
(float)pSLOD->Center[2])*_unitScale);
|
||||
lod->setRange(0, ((float)pSLOD->dwSwitchOutDist)*_unitScale);
|
||||
lod->setRange(1, ((float)pSLOD->dwSwitchInDist)*_unitScale);
|
||||
|
||||
lod->setRange(0, ((float)pSLOD->dwSwitchOutDist)*_unitScale,
|
||||
((float)pSLOD->dwSwitchInDist)*_unitScale);
|
||||
|
||||
lod->setName(pSLOD->szIdent);
|
||||
|
||||
visitAncillary(osgParent, *lod, rec)->addChild( lod );
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
|
||||
@@ -39,32 +39,36 @@ bool LOD_readLocalData(Object& obj, Input& fr)
|
||||
fr+=4;
|
||||
}
|
||||
|
||||
// For backwards compatibility with old style LOD's (pre October 2002).
|
||||
bool matchFirst = false;
|
||||
if ((matchFirst=fr.matchSequence("Ranges {")) || fr.matchSequence("Ranges %i {"))
|
||||
{
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
int capacity;
|
||||
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else
|
||||
else if (fr[1].getInt(capacity))
|
||||
{
|
||||
//_rangeList.(capacity);
|
||||
lod.getRangeList().reserve(capacity);
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
float range;
|
||||
int i=0;
|
||||
float minRange=0.0;
|
||||
float maxRange=0.0;
|
||||
unsigned int i=0;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (fr[0].getFloat(range))
|
||||
if (fr[0].getFloat(maxRange))
|
||||
{
|
||||
lod.setRange(i,range);
|
||||
if (i>0) lod.setRange(i-1,minRange,maxRange);
|
||||
++fr;
|
||||
++i;
|
||||
minRange = maxRange;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,6 +81,44 @@ bool LOD_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
}
|
||||
|
||||
if ((matchFirst=fr.matchSequence("RangeList {")) || fr.matchSequence("RangeList %i {"))
|
||||
{
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
int capacity;
|
||||
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else if (fr[1].getInt(capacity))
|
||||
{
|
||||
lod.getRangeList().reserve(capacity);
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
float minRange=0.0;
|
||||
float maxRange=0.0;
|
||||
unsigned int i=0;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (fr[0].getFloat(minRange) && fr[1].getFloat(maxRange) )
|
||||
{
|
||||
lod.setRange(i,minRange,maxRange);
|
||||
fr+=2;
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -85,14 +127,14 @@ bool LOD_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const LOD& lod = static_cast<const LOD&>(obj);
|
||||
|
||||
fw.indent() << "Center "<< lod.getCenter() << std::endl;
|
||||
if (lod.getCenterMode()==osg::LOD::USER_DEFINED_CENTER) fw.indent() << "Center "<< lod.getCenter() << std::endl;
|
||||
|
||||
fw.indent() << "Ranges {"<< std::endl;
|
||||
fw.indent() << "RangeList "<<lod.getNumRanges()<<" {"<< std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
for(unsigned int i=0; i<lod.getNumRanges();++i)
|
||||
{
|
||||
fw.indent() << lod.getRange(i) << std::endl;
|
||||
fw.indent() << lod.getMinRange(i) << " "<<lod.getMaxRange(i)<<std::endl;
|
||||
}
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<< std::endl;
|
||||
|
||||
@@ -16,7 +16,7 @@ RegisterDotOsgWrapperProxy g_SwitchProxy
|
||||
(
|
||||
osgNew osg::Switch,
|
||||
"Switch",
|
||||
"Object Node Group Switch",
|
||||
"Object Node Switch Group",
|
||||
&Switch_readLocalData,
|
||||
&Switch_writeLocalData
|
||||
);
|
||||
@@ -51,7 +51,7 @@ bool Switch_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr.matchSequence("values {"))
|
||||
if (fr.matchSequence("ValueList {"))
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
@@ -89,7 +89,7 @@ bool Switch_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
case(Switch::MULTIPLE_CHILDREN_ON):
|
||||
{
|
||||
fw.indent()<<"values {"<< std::endl;
|
||||
fw.indent()<<"ValueList {"<< std::endl;
|
||||
fw.moveIn();
|
||||
const Switch::ValueList& values = sw.getValueList();
|
||||
for(Switch::ValueList::const_iterator itr=values.begin();
|
||||
|
||||
@@ -202,9 +202,9 @@ osg::Node* ConvertFromPerformer::visitLOD(osg::Group* osgParent,pfLOD* lod)
|
||||
osgLOD->setCenter(osgCenter);
|
||||
|
||||
int i;
|
||||
for(i=0;i<lod->getNumRanges();++i)
|
||||
for(i=0;i<lod->getNumRanges()-1;++i)
|
||||
{
|
||||
osgLOD->setRange(i,lod->getRange(i));
|
||||
osgLOD->setRange(i,lod->getRange(i),lod->getRange(i+1));
|
||||
}
|
||||
|
||||
for(i=0;i<lod->getNumChildren();++i)
|
||||
|
||||
@@ -489,8 +489,7 @@ void* lodRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
Vec3 osg_Center;
|
||||
osg_Center[0] = center.x; osg_Center[1] = center.y; osg_Center[2] = center.z;
|
||||
osg_Lod->setCenter(osg_Center);
|
||||
osg_Lod->setRange(0,minRange);
|
||||
osg_Lod->setRange(1,maxRange);
|
||||
osg_Lod->setRange(0,minRange,maxRange);
|
||||
|
||||
// Our LODs are binary so we need to add a group under this LOD and attach stuff
|
||||
// to that instead of the LOD
|
||||
|
||||
Reference in New Issue
Block a user