Hi Wang Rui,
I've reviewed your changes in depth now, and reproduced the bug at my
end when not using your changes, and see the fix once I merge them.
Reviewing the original .osg style code and your changes I now
understand then problem much clearer, and have tried out a fix of my
own, along the lines of yours, but adopting a more compact syntax
which is a more similar in style to the original .osg implementation.
My changes work fine for me at my end, so I believe they should be
fine for at least the VPB usage, however, I am a little concerned that
I might be deviating a bit too much from the serialization style
you've used in other parts of the OSG so I'd appreciate you have a
look at the changes and giving me your opinion if they are OK/what
issues there might be in this approach.
The code I am using is:
static bool readLayers( osgDB::InputStream& is,
osgTerrain::CompositeLayer& layer )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
std::string type;
is >> type;
if ( type=="Object" )
{
osgTerrain::Layer* child =
dynamic_cast<osgTerrain::Layer*>( is.readObject() );
if ( child ) layer.addLayer( child );
}
else if ( type=="File" )
{
std::string compoundname;
is.readWrappedString( compoundname );
layer.addLayer( compoundname );
}
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeLayers( osgDB::OutputStream& os, const
osgTerrain::CompositeLayer& layer )
{
unsigned int size = layer.getNumLayers();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
const osgTerrain::Layer* child = layer.getLayer(i);
std::string type = child ? std::string("Object") : std::string("File");
os << type;
if ( child )
{
os << child;
}
else
{
os.writeWrappedString( layer.getCompoundName(i) );
os << std::endl;
}
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
And the generated .source file uses a single string that encodes the
type of layer - "File" or "Object", following by either a compund
filename string or the layer object itself. An example of this in
action follows:
ColorLayers 1 {
osgTerrain::CompositeLayer {
UniqueID 5
Layers 16 {
File "../BayArea/47321743.tif"
File "../BayArea/73661607.tif"
File "../BayArea/89077985.tif"
File "../BayArea/96896432.tif"
File "../BayArea/84760776.tif"
File "../BayArea/39837829.tif"
File "../BayArea/26202505.tif"
File "../BayArea/24507168.tif"
File "../BayArea/02104744.tif"
File "../BayArea/67494819.tif"
File "../BayArea/61452075.tif"
File "../BayArea/40124919.tif"
File "../BayArea/55263869.tif"
File "../BayArea/71177555.tif"
Object osgTerrain::ProxyLayer {
UniqueID 6
FileName "../BlueMarble/land_shallow_topo_east.tif"
Locator TRUE {
osgTerrain::Locator {
UniqueID 7
CoordinateSystemType GEOGRAPHIC
Format "WKT"
CoordinateSystem "GEOGCS[\"WGS
84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"
EllipsoidModel TRUE {
osg::EllipsoidModel {
UniqueID 8
RadiusEquator 6.37814e+06
RadiusPolar 6.35675e+06
}
}
Transform Matrixd {
180 0 0 0
0 180 0 0
0 0 1 0
0 -90 0 1
}
}
}
}
Object osgTerrain::ProxyLayer {
UniqueID 9
FileName "../BlueMarble/land_shallow_topo_west.tif"
Locator TRUE {
osgTerrain::Locator {
UniqueID 10
CoordinateSystemType GEOGRAPHIC
Format "WKT"
CoordinateSystem "GEOGCS[\"WGS
84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"
EllipsoidModel TRUE {
osg::EllipsoidModel {
UniqueID 11
RadiusEquator 6.37814e+06
RadiusPolar 6.35675e+06
}
}
Transform Matrixd {
180 0 0 0
0 180 0 0
0 0 1 0
-180 -90 0 1
}
}
}
}
}
Does this look OK?
Thanks,
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org