From Liang Aibin, removed redundent spaces
This commit is contained in:
@@ -115,9 +115,9 @@
|
||||
using namespace ive;
|
||||
using namespace std;
|
||||
|
||||
void DataInputStream::setOptions(const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
_options = options;
|
||||
void DataInputStream::setOptions(const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
_options = options;
|
||||
|
||||
if (_options.get())
|
||||
{
|
||||
@@ -131,7 +131,7 @@ DataInputStream::DataInputStream(std::istream* istream)
|
||||
unsigned int endianType ;
|
||||
|
||||
_loadExternalReferenceFiles = false;
|
||||
|
||||
|
||||
_verboseOutput = false;
|
||||
|
||||
_istream = istream;
|
||||
@@ -140,11 +140,11 @@ DataInputStream::DataInputStream(std::istream* istream)
|
||||
_byteswap = 0;
|
||||
|
||||
if(!istream){
|
||||
throw Exception("DataInputStream::DataInputStream(): null pointer exception in argument.");
|
||||
throw Exception("DataInputStream::DataInputStream(): null pointer exception in argument.");
|
||||
}
|
||||
|
||||
endianType = readUInt() ;
|
||||
|
||||
|
||||
if ( endianType != ENDIAN_TYPE) {
|
||||
// Make sure the file is simply swapped
|
||||
if ( endianType != OPPOSITE_ENDIAN_TYPE ) {
|
||||
@@ -153,14 +153,14 @@ DataInputStream::DataInputStream(std::istream* istream)
|
||||
osg::notify(osg::INFO)<<"DataInputStream::DataInputStream: Reading a byteswapped file" << std::endl ;
|
||||
_byteswap = 1 ;
|
||||
}
|
||||
|
||||
|
||||
_version = readUInt();
|
||||
|
||||
|
||||
// Are we trying to open a binary .ive file which version are newer than this library.
|
||||
if(_version>VERSION){
|
||||
throw Exception("DataInputStream::DataInputStream(): The version found in the file is newer than this library can handle.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DataInputStream::~DataInputStream(){}
|
||||
@@ -168,12 +168,12 @@ DataInputStream::~DataInputStream(){}
|
||||
bool DataInputStream::readBool(){
|
||||
char c;
|
||||
_istream->read(&c, CHARSIZE);
|
||||
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readBool(): Failed to read boolean value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBool() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
|
||||
return c!=0;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ char DataInputStream::readChar(){
|
||||
throw Exception("DataInputStream::readChar(): Failed to read char value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeChar() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ unsigned char DataInputStream::readUChar(){
|
||||
throw Exception("DataInputStream::readUChar(): Failed to read unsigned char value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUChar() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -208,9 +208,9 @@ unsigned short DataInputStream::readUShort(){
|
||||
throw Exception("DataInputStream::readUShort(): Failed to read unsigned short value.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap) osg::swapBytes((char *)&s,SHORTSIZE);
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -222,9 +222,9 @@ unsigned int DataInputStream::readUInt(){
|
||||
throw Exception("DataInputStream::readUInt(): Failed to read unsigned int value.");
|
||||
|
||||
if (_byteswap) osg::swapBytes((char *)&s,INTSIZE) ;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUInt() ["<<s<<"]"<<std::endl;
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -242,9 +242,9 @@ int DataInputStream::readInt(){
|
||||
// if (_istream->rdstate() & _istream->failbit)
|
||||
// throw Exception("DataInputStream::readInt(): Failed to read int value.");
|
||||
|
||||
|
||||
|
||||
if (_byteswap) osg::swapBytes((char *)&i,INTSIZE) ;
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeInt() ["<<i<<"]"<<std::endl;
|
||||
|
||||
return i;
|
||||
@@ -297,7 +297,7 @@ unsigned long DataInputStream::readULong(){
|
||||
if (_byteswap) osg::swapBytes((char *)&l,LONGSIZE) ;
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeULong() ["<<l<<"]"<<std::endl;
|
||||
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ std::string DataInputStream::readString()
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeString() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ osg::Vec2 DataInputStream::readVec2()
|
||||
v.y()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ osg::Vec4 DataInputStream::readVec4(){
|
||||
v.w()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
osg::Vec2d DataInputStream::readVec2d()
|
||||
@@ -379,7 +379,7 @@ osg::Vec2d DataInputStream::readVec2d()
|
||||
v.y()=readDouble();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2d() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ osg::Vec4d DataInputStream::readVec4d(){
|
||||
v.w()=readDouble();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -425,9 +425,9 @@ osg::Plane DataInputStream::readPlane(){
|
||||
v[2]=readDouble();
|
||||
v[3]=readDouble();
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ osg::Vec4ub DataInputStream::readVec4ub(){
|
||||
v.a()=readChar();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4ub() ["<<v<<"]"<<std::endl;
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ osg::Quat DataInputStream::readQuat(){
|
||||
q.w()=readFloat();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
|
||||
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ osg::Geometry::AttributeBinding DataInputStream::readBinding(){
|
||||
char c = readChar();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBinding() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
|
||||
switch((int)c){
|
||||
case 0: return osg::Geometry::BIND_OFF;
|
||||
case 1: return osg::Geometry::BIND_OVERALL;
|
||||
@@ -488,12 +488,12 @@ osg::Array* DataInputStream::readArray(){
|
||||
case 9: return readVec2sArray();
|
||||
case 10: return readVec3sArray();
|
||||
case 11: return readVec4sArray();
|
||||
case 12: return readVec2bArray();
|
||||
case 13: return readVec3bArray();
|
||||
case 12: return readVec2bArray();
|
||||
case 13: return readVec3bArray();
|
||||
case 14: return readVec4bArray();
|
||||
case 15: return readVec2dArray();
|
||||
case 16: return readVec3dArray();
|
||||
case 17: return readVec4dArray();
|
||||
case 17: return readVec4dArray();
|
||||
default: throw Exception("Unknown array type in DataInputStream::readArray()");
|
||||
}
|
||||
}
|
||||
@@ -504,18 +504,18 @@ osg::IntArray* DataInputStream::readIntArray()
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
osg::IntArray* a = new osg::IntArray(size);
|
||||
|
||||
|
||||
_istream->read((char*)&((*a)[0]), INTSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readIntArray(): Failed to read Int array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl;
|
||||
if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
if (_byteswap) {
|
||||
for (int i = 0 ; i < size ; i++ ) osg::swapBytes((char *)&((*a)[i]),INTSIZE) ;
|
||||
}
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ osg::UByteArray* DataInputStream::readUByteArray()
|
||||
throw Exception("DataInputStream::readUByteArray(): Failed to read UByte array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByteArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -549,10 +549,10 @@ osg::UShortArray* DataInputStream::readUShortArray()
|
||||
throw Exception("DataInputStream::readUShortArray(): Failed to read UShort array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShortArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
osg::swapBytes((char *)&((*a)[i]),SHORTSIZE) ;
|
||||
}
|
||||
return a;
|
||||
@@ -571,7 +571,7 @@ osg::UIntArray* DataInputStream::readUIntArray()
|
||||
throw Exception("DataInputStream::readUIntArray(): Failed to read UInt array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
@@ -593,7 +593,7 @@ osg::Vec4ubArray* DataInputStream::readVec4ubArray()
|
||||
throw Exception("DataInputStream::readVec4ubArray(): Failed to read Vec4ub array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4ubArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -602,16 +602,16 @@ osg::FloatArray* DataInputStream::readFloatArray()
|
||||
int size = readInt();
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
osg::FloatArray* a = new osg::FloatArray(size);
|
||||
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readFloatArray(): Failed to read float array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
@@ -627,14 +627,14 @@ osg::Vec2Array* DataInputStream::readVec2Array()
|
||||
return NULL;
|
||||
|
||||
osg::Vec2Array* a = new osg::Vec2Array(size);
|
||||
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*2*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec2Array(): Failed to read Vec2 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
float *ptr = (float*)&((*a)[0]) ;
|
||||
@@ -654,12 +654,12 @@ osg::Vec3Array* DataInputStream::readVec3Array()
|
||||
osg::Vec3Array* a = new osg::Vec3Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), FLOATSIZE*3*size);
|
||||
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec3Array(): Failed to read Vec3 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
@@ -684,7 +684,7 @@ osg::Vec4Array* DataInputStream::readVec4Array(){
|
||||
throw Exception("DataInputStream::readVec4Array(): Failed to read Vec4 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap) {
|
||||
float *ptr = (float*)&((*a)[0]) ;
|
||||
for (int i = 0 ; i < size*4 ; i++ ) {
|
||||
@@ -831,14 +831,14 @@ osg::Vec2dArray* DataInputStream::readVec2dArray()
|
||||
return NULL;
|
||||
|
||||
osg::Vec2dArray* a = new osg::Vec2dArray(size);
|
||||
|
||||
|
||||
_istream->read((char*)&((*a)[0]), DOUBLESIZE*2*size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec2dArray(): Failed to read Vec2d array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2dArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
double *ptr = (double*)&((*a)[0]) ;
|
||||
@@ -858,12 +858,12 @@ osg::Vec3dArray* DataInputStream::readVec3dArray()
|
||||
osg::Vec3dArray* a = new osg::Vec3dArray(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), DOUBLESIZE*3*size);
|
||||
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readVec3dArray(): Failed to read Vec3d array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3dArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
|
||||
if (_byteswap)
|
||||
{
|
||||
@@ -888,7 +888,7 @@ osg::Vec4dArray* DataInputStream::readVec4dArray(){
|
||||
throw Exception("DataInputStream::readVec4dArray(): Failed to read Vec4d array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4dArray() ["<<size<<"]"<<std::endl;
|
||||
|
||||
|
||||
if (_byteswap) {
|
||||
double *ptr = (double*)&((*a)[0]) ;
|
||||
for (int i = 0 ; i < size*4 ; i++ ) {
|
||||
@@ -913,7 +913,7 @@ osg::Matrixf DataInputStream::readMatrixf()
|
||||
throw Exception("DataInputStream::readMatrix(): Failed to read Matrix array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
|
||||
|
||||
|
||||
return mat;
|
||||
}
|
||||
@@ -933,28 +933,28 @@ osg::Matrixd DataInputStream::readMatrixd()
|
||||
throw Exception("DataInputStream::readMatrix(): Failed to read Matrix array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
|
||||
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
osg::Image* DataInputStream::readImage(std::string filename)
|
||||
{
|
||||
// If image is already read and in list
|
||||
// If image is already read and in list
|
||||
// then just return pointer to this.
|
||||
ImageMap::iterator mitr=_imageMap.find(filename);
|
||||
ImageMap::iterator mitr=_imageMap.find(filename);
|
||||
if (mitr!=_imageMap.end()) return mitr->second.get();
|
||||
|
||||
// Image is not in list.
|
||||
// Read it from disk,
|
||||
|
||||
// Image is not in list.
|
||||
// Read it from disk,
|
||||
osg::Image* image = osgDB::readImageFile(filename.c_str(),_options.get());
|
||||
|
||||
|
||||
// add it to the imageList,
|
||||
_imageMap[filename] = image;
|
||||
// and return image pointer.
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeImage() ["<<image<<"]"<<std::endl;
|
||||
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -1061,13 +1061,13 @@ osg::StateSet* DataInputStream::readStateSet()
|
||||
|
||||
// read its properties from stream
|
||||
((ive::StateSet*)(stateset))->read(this);
|
||||
|
||||
|
||||
// and add it to the stateset map,
|
||||
_statesetMap[id] = stateset;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return stateset;
|
||||
}
|
||||
|
||||
@@ -1229,17 +1229,17 @@ osg::StateAttribute* DataInputStream::readStateAttribute()
|
||||
else if(attributeID == IVELIGHT){
|
||||
attribute = new osg::Light();
|
||||
((ive::Light*)(attribute))->read(this);
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("Unknown StateAttribute in StateSet::read()");
|
||||
}
|
||||
|
||||
|
||||
// and add it to the stateattribute map,
|
||||
_stateAttributeMap[id] = attribute;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@@ -1257,13 +1257,13 @@ osg::Uniform* DataInputStream::readUniform()
|
||||
|
||||
// read its properties from stream
|
||||
((ive::Uniform*)(uniform))->read(this);
|
||||
|
||||
|
||||
// and add it to the uniform map,
|
||||
_uniformMap[id] = uniform;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUniform() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return uniform;
|
||||
}
|
||||
|
||||
@@ -1282,13 +1282,13 @@ osg::Shader* DataInputStream::readShader()
|
||||
|
||||
// read its properties from stream
|
||||
((ive::Shader*)(shader))->read(this);
|
||||
|
||||
|
||||
// and add it to the shader map,
|
||||
_shaderMap[id] = shader;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShader() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
@@ -1307,18 +1307,18 @@ osg::Drawable* DataInputStream::readDrawable()
|
||||
osg::Drawable* drawable;
|
||||
if(drawableTypeID == IVEGEOMETRY)
|
||||
{
|
||||
drawable = new osg::Geometry();
|
||||
drawable = new osg::Geometry();
|
||||
((Geometry*)(drawable))->read(this);
|
||||
}
|
||||
else if(drawableTypeID == IVESHAPEDRAWABLE)
|
||||
{
|
||||
drawable = new osg::ShapeDrawable();
|
||||
drawable = new osg::ShapeDrawable();
|
||||
((ShapeDrawable*)(drawable))->read(this);
|
||||
}
|
||||
else if(drawableTypeID == IVETEXT){
|
||||
drawable = new osgText::Text();
|
||||
((Text*)(drawable))->read(this);
|
||||
}
|
||||
}
|
||||
else if(drawableTypeID == IVEFADETEXT){
|
||||
drawable = new osgText::FadeText();
|
||||
((FadeText*)(drawable))->read(this);
|
||||
@@ -1330,13 +1330,13 @@ osg::Drawable* DataInputStream::readDrawable()
|
||||
else
|
||||
throw Exception("Unknown drawable drawableTypeIDentification in Geode::read()");
|
||||
|
||||
|
||||
|
||||
// and add it to the stateattribute map,
|
||||
_drawableMap[id] = drawable;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@@ -1355,7 +1355,7 @@ osg::Shape* DataInputStream::readShape()
|
||||
osg::Shape* shape;
|
||||
if(shapeTypeID == IVESPHERE)
|
||||
{
|
||||
shape = new osg::Sphere();
|
||||
shape = new osg::Sphere();
|
||||
((Sphere*)(shape))->read(this);
|
||||
}
|
||||
else if(shapeTypeID == IVEBOX)
|
||||
@@ -1380,19 +1380,19 @@ osg::Shape* DataInputStream::readShape()
|
||||
}
|
||||
else if(shapeTypeID == IVEHEIGHTFIELD)
|
||||
{
|
||||
shape = new osg::HeightField();
|
||||
shape = new osg::HeightField();
|
||||
((HeightField*)(shape))->read(this);
|
||||
}
|
||||
else
|
||||
throw Exception("Unknown shape shapeTypeIDentification in Shape::read()");
|
||||
|
||||
|
||||
|
||||
// and add it to the stateattribute map,
|
||||
_shapeMap[id] = shape;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShape() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
@@ -1409,7 +1409,7 @@ osg::Node* DataInputStream::readNode()
|
||||
|
||||
osg::Node* node;
|
||||
int nodeTypeID= peekInt();
|
||||
|
||||
|
||||
if(nodeTypeID== IVEMATRIXTRANSFORM){
|
||||
node = new osg::MatrixTransform();
|
||||
((ive::MatrixTransform*)(node))->read(this);
|
||||
@@ -1524,10 +1524,10 @@ osg::Node* DataInputStream::readNode()
|
||||
|
||||
// and add it to the node map,
|
||||
_nodeMap[id] = node;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeNode() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1536,7 +1536,7 @@ osgTerrain::Layer* DataInputStream::readLayer()
|
||||
// Read node unique ID.
|
||||
int id = readInt();
|
||||
if (id<0) return 0;
|
||||
|
||||
|
||||
// See if layer is already in the list.
|
||||
LayerMap::iterator itr= _layerMap.find(id);
|
||||
if (itr!=_layerMap.end()) return itr->second.get();
|
||||
@@ -1546,7 +1546,7 @@ osgTerrain::Layer* DataInputStream::readLayer()
|
||||
|
||||
osgTerrain::Layer* layer = 0;
|
||||
int layerid = peekInt();
|
||||
|
||||
|
||||
if (layerid==IVEHEIGHTFIELDLAYER)
|
||||
{
|
||||
layer = new osgTerrain::HeightFieldLayer;
|
||||
@@ -1567,19 +1567,19 @@ osgTerrain::Layer* DataInputStream::readLayer()
|
||||
std::string filename = readString();
|
||||
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename+".gdal");
|
||||
osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(object.get());
|
||||
|
||||
|
||||
osg::ref_ptr<osgTerrain::Locator> locator = readLocator();
|
||||
unsigned int minLevel = readUInt();
|
||||
unsigned int maxLevel = readUInt();
|
||||
|
||||
|
||||
if (proxyLayer)
|
||||
{
|
||||
if (locator.valid()) proxyLayer->setLocator(locator.get());
|
||||
|
||||
|
||||
proxyLayer->setMinLevel(minLevel);
|
||||
proxyLayer->setMaxLevel(maxLevel);
|
||||
}
|
||||
|
||||
|
||||
layer = proxyLayer;
|
||||
}
|
||||
else{
|
||||
@@ -1588,10 +1588,10 @@ osgTerrain::Layer* DataInputStream::readLayer()
|
||||
|
||||
// and add it to the node map,
|
||||
_layerMap[id] = layer;
|
||||
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeLayer() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
@@ -1601,7 +1601,7 @@ osgTerrain::Locator* DataInputStream::readLocator()
|
||||
// Read statesets unique ID.
|
||||
int id = readInt();
|
||||
if (id<0) return 0;
|
||||
|
||||
|
||||
// See if stateset is already in the list.
|
||||
LocatorMap::iterator itr= _locatorMap.find(id);
|
||||
if (itr!=_locatorMap.end()) return itr->second.get();
|
||||
@@ -1612,12 +1612,12 @@ osgTerrain::Locator* DataInputStream::readLocator()
|
||||
|
||||
// read its properties from stream
|
||||
((ive::Locator*)(locator))->read(this);
|
||||
|
||||
|
||||
// and add it to the locator map,
|
||||
_locatorMap[id] = locator;
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeLocator() ["<<id<<"]"<<std::endl;
|
||||
|
||||
|
||||
return locator;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,9 +111,9 @@
|
||||
using namespace ive;
|
||||
|
||||
|
||||
void DataOutputStream::setOptions(const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
_options = options;
|
||||
void DataOutputStream::setOptions(const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
_options = options;
|
||||
|
||||
if (_options.get())
|
||||
{
|
||||
@@ -146,8 +146,8 @@ DataOutputStream::DataOutputStream(std::ostream * ostream)
|
||||
_includeExternalReferences = false;
|
||||
_writeExternalReferenceFiles = false;
|
||||
_useOriginalExternalReferences = true;
|
||||
|
||||
|
||||
|
||||
|
||||
_ostream = ostream;
|
||||
if(!_ostream)
|
||||
throw Exception("DataOutputStream::DataOutputStream(): null pointer exception in argument.");
|
||||
@@ -161,25 +161,25 @@ void DataOutputStream::writeBool(bool b)
|
||||
{
|
||||
char c = b?1:0;
|
||||
_ostream->write(&c, CHARSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBool() ["<<(int)c<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeChar(char c){
|
||||
_ostream->write(&c, CHARSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeChar() ["<<(int)c<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUChar(unsigned char c){
|
||||
_ostream->write((char*)&c, CHARSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUChar() ["<<(int)c<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShort(unsigned short s){
|
||||
_ostream->write((char*)&s, SHORTSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -191,57 +191,57 @@ void DataOutputStream::writeShort(short s){
|
||||
|
||||
void DataOutputStream::writeUInt(unsigned int s){
|
||||
_ostream->write((char*)&s, INTSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUInt() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeInt(int i){
|
||||
_ostream->write((char*)&i, INTSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeInt() ["<<i<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloat(float f){
|
||||
_ostream->write((char*)&f, FLOATSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloat() ["<<f<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeLong(long l){
|
||||
_ostream->write((char*)&l, LONGSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeLong() ["<<l<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeULong(unsigned long l){
|
||||
_ostream->write((char*)&l, LONGSIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeULong() ["<<l<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeDouble(double d){
|
||||
_ostream->write((char*)&d, DOUBLESIZE);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeDouble() ["<<d<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeString(const std::string& s){
|
||||
writeInt(s.size());
|
||||
_ostream->write(s.c_str(), s.size());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeString() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeCharArray(const char* data, int size){
|
||||
_ostream->write(data, size);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeCharArray() ["<<data<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2(const osg::Vec2& v){
|
||||
writeFloat(v.x());
|
||||
writeFloat(v.y());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ void DataOutputStream::writeVec3(const osg::Vec3& v){
|
||||
writeFloat(v.x());
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.z());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -258,14 +258,14 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){
|
||||
writeFloat(v.y());
|
||||
writeFloat(v.z());
|
||||
writeFloat(v.w());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2d(const osg::Vec2d& v){
|
||||
writeDouble(v.x());
|
||||
writeDouble(v.y());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ void DataOutputStream::writeVec3d(const osg::Vec3d& v){
|
||||
writeDouble(v.x());
|
||||
writeDouble(v.y());
|
||||
writeDouble(v.z());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3d() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ void DataOutputStream::writeVec4d(const osg::Vec4d& v){
|
||||
writeDouble(v.y());
|
||||
writeDouble(v.z());
|
||||
writeDouble(v.w());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ void DataOutputStream::writePlane(const osg::Plane& v)
|
||||
writeDouble(v[1]);
|
||||
writeDouble(v[2]);
|
||||
writeDouble(v[3]);
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -301,13 +301,13 @@ void DataOutputStream::writeVec4ub(const osg::Vec4ub& v){
|
||||
writeChar(v.g());
|
||||
writeChar(v.b());
|
||||
writeChar(v.a());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4ub() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2b(const osg::Vec2b& v){
|
||||
writeChar(v.r());
|
||||
writeChar(v.g());
|
||||
writeChar(v.g());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2b() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void DataOutputStream::writeQuat(const osg::Quat& q){
|
||||
writeFloat(q.y());
|
||||
writeFloat(q.z());
|
||||
writeFloat(q.w());
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -347,13 +347,13 @@ void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
|
||||
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
|
||||
default: throw Exception("Unknown binding in DataOutputStream::writeBinding()");
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBinding() ["<<b<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeArray(const osg::Array* a){
|
||||
switch(a->getType()){
|
||||
case osg::Array::IntArrayType:
|
||||
case osg::Array::IntArrayType:
|
||||
writeChar((char)0);
|
||||
writeIntArray(static_cast<const osg::IntArray*>(a));
|
||||
break;
|
||||
@@ -377,15 +377,15 @@ void DataOutputStream::writeArray(const osg::Array* a){
|
||||
writeChar((char)5);
|
||||
writeFloatArray(static_cast<const osg::FloatArray*>(a));
|
||||
break;
|
||||
case osg::Array::Vec2ArrayType:
|
||||
case osg::Array::Vec2ArrayType:
|
||||
writeChar((char)6);
|
||||
writeVec2Array(static_cast<const osg::Vec2Array*>(a));
|
||||
break;
|
||||
case osg::Array::Vec3ArrayType:
|
||||
case osg::Array::Vec3ArrayType:
|
||||
writeChar((char)7);
|
||||
writeVec3Array(static_cast<const osg::Vec3Array*>(a));
|
||||
break;
|
||||
case osg::Array::Vec4ArrayType:
|
||||
case osg::Array::Vec4ArrayType:
|
||||
writeChar((char)8);
|
||||
writeVec4Array(static_cast<const osg::Vec4Array*>(a));
|
||||
break;
|
||||
@@ -413,15 +413,15 @@ void DataOutputStream::writeArray(const osg::Array* a){
|
||||
writeChar((char)14);
|
||||
writeVec4bArray(static_cast<const osg::Vec4bArray*>(a));
|
||||
break;
|
||||
case osg::Array::Vec2dArrayType:
|
||||
case osg::Array::Vec2dArrayType:
|
||||
writeChar((char)15);
|
||||
writeVec2dArray(static_cast<const osg::Vec2dArray*>(a));
|
||||
break;
|
||||
case osg::Array::Vec3dArrayType:
|
||||
case osg::Array::Vec3dArrayType:
|
||||
writeChar((char)16);
|
||||
writeVec3dArray(static_cast<const osg::Vec3dArray*>(a));
|
||||
break;
|
||||
case osg::Array::Vec4dArrayType:
|
||||
case osg::Array::Vec4dArrayType:
|
||||
writeChar((char)17);
|
||||
writeVec4dArray(static_cast<const osg::Vec4dArray*>(a));
|
||||
break;
|
||||
@@ -437,62 +437,62 @@ void DataOutputStream::writeIntArray(const osg::IntArray* a)
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt(a->index(i));
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUByteArray(const osg::UByteArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeChar((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUByteArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUShortArray(const osg::UShortArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeUShort((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUShortArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUIntArray(const osg::UIntArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeInt((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec4ubArray(const osg::Vec4ubArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeVec4ub((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4ubArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeFloatArray(const osg::FloatArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeFloat((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ void DataOutputStream::writeVec2Array(const osg::Vec2Array* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec2((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ void DataOutputStream::writeVec3Array(const osg::Vec3Array* a)
|
||||
for(int i = 0; i < size; i++){
|
||||
writeVec3((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -526,13 +526,13 @@ void DataOutputStream::writeVec4Array(const osg::Vec4Array* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec4((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeVec2sArray(const osg::Vec2sArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x());
|
||||
@@ -544,7 +544,7 @@ void DataOutputStream::writeVec2sArray(const osg::Vec2sArray* a)
|
||||
|
||||
void DataOutputStream::writeVec3sArray(const osg::Vec3sArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x());
|
||||
@@ -557,7 +557,7 @@ void DataOutputStream::writeVec3sArray(const osg::Vec3sArray* a)
|
||||
|
||||
void DataOutputStream::writeVec4sArray(const osg::Vec4sArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x());
|
||||
@@ -571,7 +571,7 @@ void DataOutputStream::writeVec4sArray(const osg::Vec4sArray* a)
|
||||
|
||||
void DataOutputStream::writeVec2bArray(const osg::Vec2bArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeVec2b((*a)[i]);
|
||||
@@ -582,7 +582,7 @@ void DataOutputStream::writeVec2bArray(const osg::Vec2bArray* a)
|
||||
|
||||
void DataOutputStream::writeVec3bArray(const osg::Vec3bArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeVec3b((*a)[i]);
|
||||
@@ -593,7 +593,7 @@ void DataOutputStream::writeVec3bArray(const osg::Vec3bArray* a)
|
||||
|
||||
void DataOutputStream::writeVec4bArray(const osg::Vec4bArray* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeVec4b((*a)[i]);
|
||||
@@ -609,7 +609,7 @@ void DataOutputStream::writeVec2dArray(const osg::Vec2dArray* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec2d((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec2dArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ void DataOutputStream::writeVec3dArray(const osg::Vec3dArray* a)
|
||||
for(int i = 0; i < size; i++){
|
||||
writeVec3d((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec3dArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ void DataOutputStream::writeVec4dArray(const osg::Vec4dArray* a)
|
||||
for(int i=0;i<size;i++){
|
||||
writeVec4d((*a)[i]);
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4dArray() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ void DataOutputStream::writeMatrixf(const osg::Matrixf& mat)
|
||||
writeFloat(mat(r,c));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ void DataOutputStream::writeMatrixd(const osg::Matrixd& mat)
|
||||
writeDouble(mat(r,c));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ void DataOutputStream::writeDrawable(const osg::Drawable* drawable)
|
||||
|
||||
// write the id.
|
||||
writeInt(id);
|
||||
|
||||
|
||||
if(dynamic_cast<const osg::Geometry*>(drawable))
|
||||
((ive::Geometry*)(drawable))->write(this);
|
||||
else if(dynamic_cast<const osg::ShapeDrawable*>(drawable))
|
||||
@@ -967,7 +967,7 @@ void DataOutputStream::writeShape(const osg::Shape* shape)
|
||||
|
||||
// write the id.
|
||||
writeInt(id);
|
||||
|
||||
|
||||
if(dynamic_cast<const osg::Sphere*>(shape))
|
||||
((ive::Sphere*)(shape))->write(this);
|
||||
else if(dynamic_cast<const osg::Box*>(shape))
|
||||
@@ -1136,9 +1136,9 @@ void DataOutputStream::writeImage(IncludeImageMode mode, osg::Image *image)
|
||||
if (image && !(image->getFileName().empty())){
|
||||
writeString(image->getFileName());
|
||||
}
|
||||
else{
|
||||
else{
|
||||
writeString("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IMAGE_INCLUDE_FILE:
|
||||
// Include image file in stream
|
||||
@@ -1170,25 +1170,25 @@ void DataOutputStream::writeImage(IncludeImageMode mode, osg::Image *image)
|
||||
|
||||
//Close file
|
||||
infile.close();
|
||||
|
||||
|
||||
} else {
|
||||
writeString("");
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else{
|
||||
writeString("");
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IMAGE_COMPRESS_DATA:
|
||||
if(image)
|
||||
{
|
||||
//Get ReaderWriter for jpeg images
|
||||
|
||||
|
||||
std::string extension = "png";
|
||||
if (image->getPixelFormat()==GL_RGB) extension = "jpg";
|
||||
|
||||
|
||||
osgDB::ReaderWriter* writer = osgDB::Registry::instance()->getReaderWriterForExtension(extension);
|
||||
|
||||
if(writer)
|
||||
@@ -1207,11 +1207,11 @@ void DataOutputStream::writeImage(IncludeImageMode mode, osg::Image *image)
|
||||
// 1 - Same code can be used to read in as with IMAGE_INCLUDE_FILE mode
|
||||
// 2 - Maybe in future version user can specify which format to use
|
||||
writeString(std::string(".")+extension); //Need to add dot so osgDB::getFileExtension will work
|
||||
|
||||
|
||||
//Write size of stream
|
||||
int size = outputStream.tellp();
|
||||
writeInt(size);
|
||||
|
||||
|
||||
//Write stream
|
||||
writeCharArray(outputStream.str().c_str(),size);
|
||||
|
||||
@@ -1256,7 +1256,7 @@ void DataOutputStream::writeLayer(const osgTerrain::Layer* layer)
|
||||
|
||||
// write the id.
|
||||
writeInt(id);
|
||||
|
||||
|
||||
if (dynamic_cast<const osgTerrain::HeightFieldLayer*>(layer))
|
||||
{
|
||||
((ive::HeightFieldLayer*)(layer))->write(this);
|
||||
|
||||
Reference in New Issue
Block a user