From Luc Frauciel, Added support for osgTerrain::ValidDataOperator.
From Robert Osfield, added versioning to the above.
This commit is contained in:
parent
9cd56609db
commit
0a6b4d5709
@ -35,8 +35,9 @@
|
|||||||
#define VERSION_0024 24
|
#define VERSION_0024 24
|
||||||
#define VERSION_0025 25
|
#define VERSION_0025 25
|
||||||
#define VERSION_0026 26
|
#define VERSION_0026 26
|
||||||
|
#define VERSION_0027 27
|
||||||
|
|
||||||
#define VERSION VERSION_0026
|
#define VERSION VERSION_0027
|
||||||
|
|
||||||
/* The BYTE_SEX tag is used to check the endian
|
/* The BYTE_SEX tag is used to check the endian
|
||||||
of the IVE file being read in. The IVE format
|
of the IVE file being read in. The IVE format
|
||||||
|
@ -50,6 +50,11 @@ void Layer::write(DataOutputStream* out)
|
|||||||
|
|
||||||
out->writeUInt(getMinLevel());
|
out->writeUInt(getMinLevel());
|
||||||
out->writeUInt(getMaxLevel());
|
out->writeUInt(getMaxLevel());
|
||||||
|
|
||||||
|
if (out->getVersion() >= VERSION_0027)
|
||||||
|
{
|
||||||
|
writeValidDataOperator(out,getValidDataOperator());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::read(DataInputStream* in)
|
void Layer::read(DataInputStream* in)
|
||||||
@ -83,6 +88,10 @@ void Layer::read(DataInputStream* in)
|
|||||||
setMinLevel(in->readUInt());
|
setMinLevel(in->readUInt());
|
||||||
setMaxLevel(in->readUInt());
|
setMaxLevel(in->readUInt());
|
||||||
|
|
||||||
|
if (in->getVersion() >= VERSION_0027)
|
||||||
|
{
|
||||||
|
setValidDataOperator(readValidDataOperator(in));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerHelper::writeLayer(DataOutputStream* out, osgTerrain::Layer* layer)
|
void LayerHelper::writeLayer(DataOutputStream* out, osgTerrain::Layer* layer)
|
||||||
@ -196,3 +205,56 @@ osgTerrain::Locator* LayerHelper::readLocator(DataInputStream* in)
|
|||||||
|
|
||||||
return locator;
|
return locator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer::writeValidDataOperator(DataOutputStream* out, osgTerrain::ValidDataOperator* validDataOperator)
|
||||||
|
{
|
||||||
|
if (validDataOperator)
|
||||||
|
{
|
||||||
|
out->writeBool(true);
|
||||||
|
osgTerrain::ValidRange* validRange = dynamic_cast<osgTerrain::ValidRange*>(validDataOperator);
|
||||||
|
if (validRange)
|
||||||
|
{
|
||||||
|
out->writeInt(IVEVALIDRANGE);
|
||||||
|
out->writeFloat(validRange->getMinValue());
|
||||||
|
out->writeFloat(validRange->getMaxValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
osgTerrain::NoDataValue* noDataValue = dynamic_cast<osgTerrain::NoDataValue*>(validDataOperator);
|
||||||
|
if (noDataValue)
|
||||||
|
{
|
||||||
|
out->writeInt(IVENODATAVALUE);
|
||||||
|
out->writeFloat(noDataValue->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out->writeBool(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
osgTerrain::ValidDataOperator* Layer::readValidDataOperator(DataInputStream* in)
|
||||||
|
{
|
||||||
|
bool hasOperator = in->readBool();
|
||||||
|
if (!hasOperator) return 0;
|
||||||
|
|
||||||
|
int id = in->peekInt();
|
||||||
|
if (id==IVEVALIDRANGE)
|
||||||
|
{
|
||||||
|
id = in->readInt();
|
||||||
|
float minValue = in->readFloat();
|
||||||
|
float maxValue = in->readFloat();
|
||||||
|
return new osgTerrain::ValidRange(minValue,maxValue);
|
||||||
|
}
|
||||||
|
else if (id==IVENODATAVALUE)
|
||||||
|
{
|
||||||
|
id = in->readInt();
|
||||||
|
float value = in->readFloat();
|
||||||
|
return new osgTerrain::NoDataValue(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -36,10 +36,14 @@ class LayerHelper
|
|||||||
class Layer : public osgTerrain::Layer, public ReadWrite
|
class Layer : public osgTerrain::Layer, public ReadWrite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void write(DataOutputStream* out);
|
void write(DataOutputStream* out);
|
||||||
void read(DataInputStream* in);
|
void read(DataInputStream* in);
|
||||||
|
|
||||||
|
void writeValidDataOperator(DataOutputStream* out, osgTerrain::ValidDataOperator* validDataOperator);
|
||||||
|
osgTerrain::ValidDataOperator* readValidDataOperator(DataInputStream* in);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -130,6 +130,9 @@ namespace ive {
|
|||||||
#define IVEPROXYLAYER 0x00200007
|
#define IVEPROXYLAYER 0x00200007
|
||||||
#define IVETERRAINTECHNIQUE 0x00200008
|
#define IVETERRAINTECHNIQUE 0x00200008
|
||||||
#define IVEGEOMETRYTECHNIQUE 0x00200009
|
#define IVEGEOMETRYTECHNIQUE 0x00200009
|
||||||
|
#define IVEVALIDDATAOPERATOR 0x0020000A
|
||||||
|
#define IVEVALIDRANGE 0x0020000B
|
||||||
|
#define IVENODATAVALUE 0x0020000C
|
||||||
//#define IVETERRAIN 0x0020000A
|
//#define IVETERRAIN 0x0020000A
|
||||||
|
|
||||||
// osgFX classes
|
// osgFX classes
|
||||||
|
Loading…
Reference in New Issue
Block a user