⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataoutputstream.cpp

📁 最新osg包
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        writeVec3b((*a)[i]);    }    if (_verboseOutput) std::cout<<"read/writeVec3bArray() ["<<size<<"]"<<std::endl;}void DataOutputStream::writeVec4bArray(const osg::Vec4bArray* a){    int size = a->getNumElements();    writeInt(size);    for(int i =0; i<size ;i++){        writeVec4b((*a)[i]);    }    if (_verboseOutput) std::cout<<"read/writeVec4bArray() ["<<size<<"]"<<std::endl;}void DataOutputStream::writeVec2dArray(const osg::Vec2dArray* a){    int size = a->size();    writeInt(size);    for(int i=0;i<size;i++){        writeVec2d((*a)[i]);    }    if (_verboseOutput) std::cout<<"read/writeVec2dArray() ["<<size<<"]"<<std::endl;}void DataOutputStream::writeVec3dArray(const osg::Vec3dArray* a){    int size = a->size();    writeInt(size);    for(int i = 0; i < size; i++){        writeVec3d((*a)[i]);    }    if (_verboseOutput) std::cout<<"read/writeVec3dArray() ["<<size<<"]"<<std::endl;}void DataOutputStream::writeVec4dArray(const osg::Vec4dArray* a){    int size = a->size();    writeInt(size);    for(int i=0;i<size;i++){        writeVec4d((*a)[i]);    }    if (_verboseOutput) std::cout<<"read/writeVec4dArray() ["<<size<<"]"<<std::endl;}void DataOutputStream::writeMatrixf(const osg::Matrixf& mat){    for(int r=0;r<4;r++)    {        for(int c=0;c<4;c++)        {            writeFloat(mat(r,c));        }    }    if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;}void DataOutputStream::writeMatrixd(const osg::Matrixd& mat){    for(int r=0;r<4;r++)    {        for(int c=0;c<4;c++)        {            writeDouble(mat(r,c));        }    }    if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;}void DataOutputStream::writeStateSet(const osg::StateSet* stateset){    StateSetMap::iterator itr = _stateSetMap.find(stateset);    if (itr!=_stateSetMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the stateset.        int id = _stateSetMap.size();        _stateSetMap[stateset] = id;        // write the id.        writeInt(id);        // write the stateset.        ((ive::StateSet*)(stateset))->write(this);        if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute){    StateAttributeMap::iterator itr = _stateAttributeMap.find(attribute);    if (itr!=_stateAttributeMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the stateset.        int id = _stateAttributeMap.size();        _stateAttributeMap[attribute] = id;        // write the id.        writeInt(id);        // write the stateset.        if(dynamic_cast<const osg::AlphaFunc*>(attribute)){            ((ive::AlphaFunc*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::BlendColor*>(attribute)){            ((ive::BlendColor*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::Stencil*>(attribute)){            ((ive::Stencil*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::BlendFunc*>(attribute)){            ((ive::BlendFunc*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::BlendEquation*>(attribute)){            ((ive::BlendEquation*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::Depth*>(attribute)){            ((ive::Depth*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::Viewport*>(attribute)){            ((ive::Viewport*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::Scissor*>(attribute)){            ((ive::Scissor*)(attribute))->write(this);        }        // This is a Material        else if(dynamic_cast<const osg::Material*>(attribute)){            ((ive::Material*)(attribute))->write(this);        }        // This is a CullFace        else if(dynamic_cast<const osg::CullFace*>(attribute)){            ((ive::CullFace*)(attribute))->write(this);        }        // This is a ColorMask        else if(dynamic_cast<const osg::ColorMask*>(attribute)){            ((ive::ColorMask*)(attribute))->write(this);        }        // this is a Cliplane        else if(dynamic_cast<const osg::ClipPlane*>(attribute)){            ((ive::ClipPlane*)(attribute))->write(this);        }        // This is a PolygonOffset        else if(dynamic_cast<const osg::PolygonOffset*>(attribute)){            ((ive::PolygonOffset*)(attribute))->write(this);        }        // This is a PolygonMode        else if(dynamic_cast<const osg::PolygonMode*>(attribute)){            ((ive::PolygonMode*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::ShadeModel*>(attribute)){            ((ive::ShadeModel*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::Point*>(attribute)){            ((ive::Point*)(attribute))->write(this);        }        else if(dynamic_cast<const osg::LineWidth*>(attribute)){            ((ive::LineWidth*)(attribute))->write(this);        }        // This is a LineStipple        else if(dynamic_cast<const osg::LineStipple*>(attribute)){            ((ive::LineStipple*)(attribute))->write(this);        }        // This is a Texture1D        else if(dynamic_cast<const osg::Texture1D*>(attribute)){            ((ive::Texture1D*)(attribute))->write(this);        }        // This is a Texture2D        else if(dynamic_cast<const osg::Texture2D*>(attribute)){            ((ive::Texture2D*)(attribute))->write(this);        }        // This is a Texture2D        else if(dynamic_cast<const osg::Texture3D*>(attribute)){            ((ive::Texture3D*)(attribute))->write(this);        }        // This is a TextureCubeMap        else if(dynamic_cast<const osg::TextureCubeMap*>(attribute)){            ((ive::TextureCubeMap*)(attribute))->write(this);        }        // This is a TextureRectangle        else if(dynamic_cast<const osg::TextureRectangle*>(attribute)){            ((ive::TextureRectangle*)(attribute))->write(this);        }        // This is a TexEnv        else if(dynamic_cast<const osg::TexEnv*>(attribute)){            ((ive::TexEnv*)(attribute))->write(this);        }        // This is a TexEnvCombine        else if(dynamic_cast<const osg::TexEnvCombine*>(attribute)){            ((ive::TexEnvCombine*)(attribute))->write(this);        }        // This is a TexGen        else if(dynamic_cast<const osg::TexGen*>(attribute)){            ((ive::TexGen*)(attribute))->write(this);        }        // This is a TexMat        else if(dynamic_cast<const osg::TexMat*>(attribute)){            ((ive::TexMat*)(attribute))->write(this);        }        // This is a FragmentProgram        else if(dynamic_cast<const osg::FragmentProgram*>(attribute)){            ((ive::FragmentProgram*)(attribute))->write(this);        }        // This is a VertexProgram        else if(dynamic_cast<const osg::VertexProgram*>(attribute)){            ((ive::VertexProgram*)(attribute))->write(this);        }        // This is a LightModel        else if(dynamic_cast<const osg::LightModel*>(attribute)){            ((ive::LightModel*)(attribute))->write(this);        }        // This is a FrontFace        else if(dynamic_cast<const osg::FrontFace*>(attribute)){            ((ive::FrontFace*)(attribute))->write(this);        }        // This is a Program        else if(dynamic_cast<const osg::Program*>(attribute)){            ((ive::Program*)(attribute))->write(this);        }        // This is a PointSprite        else if(dynamic_cast<const osg::PointSprite*>(attribute)){            ((ive::PointSprite*)(attribute))->write(this);        }        // This is a Multisample        else if(dynamic_cast<const osg::Multisample*>(attribute)){            ((ive::Multisample*)(attribute))->write(this);        }        // This is a Fog        else if(dynamic_cast<const osg::Fog*>(attribute)){            ((ive::Fog*)(attribute))->write(this);        }        // This is a Light        else if(dynamic_cast<const osg::Light*>(attribute)){            ((ive::Light*)(attribute))->write(this);        }        else{            std::string className = attribute->className();            throw Exception(std::string("StateSet::write(): Unknown StateAttribute: ").append(className));        }        if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeUniform(const osg::Uniform* uniform){    UniformMap::iterator itr = _uniformMap.find(uniform);    if (itr!=_uniformMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeUniform() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the uniform.        int id = _uniformMap.size();        _uniformMap[uniform] = id;        // write the id.        writeInt(id);        // write the stateset.        ((ive::Uniform*)(uniform))->write(this);        if (_verboseOutput) std::cout<<"read/writeUniform() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeShader(const osg::Shader* shader){    ShaderMap::iterator itr = _shaderMap.find(shader);    if (itr!=_shaderMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeShader() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the shader.        int id = _shaderMap.size();        _shaderMap[shader] = id;        // write the id.        writeInt(id);        // write the stateset.        ((ive::Shader*)(shader))->write(this);        if (_verboseOutput) std::cout<<"read/writeShader() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeDrawable(const osg::Drawable* drawable){    DrawableMap::iterator itr = _drawableMap.find(drawable);    if (itr!=_drawableMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the stateset.        int id = _drawableMap.size();        _drawableMap[drawable] = id;        // 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))            ((ive::ShapeDrawable*)(drawable))->write(this);        else if(dynamic_cast<const osgText::Text*>(drawable))            ((ive::Text*)(drawable))->write(this);        else        {            throw Exception("Unknown drawable in DataOutputStream::writeDrawable()");        }        if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeShape(const osg::Shape* shape){    ShapeMap::iterator itr = _shapeMap.find(shape);    if (itr!=_shapeMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeShape() ["<<itr->second<<"]"<<std::endl;    }    else    {        // id doesn't exist so create a new ID and        // register the stateset.        int id = _shapeMap.size();        _shapeMap[shape] = id;        // 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))            ((ive::Box*)(shape))->write(this);        else if(dynamic_cast<const osg::Cone*>(shape))            ((ive::Cone*)(shape))->write(this);        else if(dynamic_cast<const osg::Cylinder*>(shape))            ((ive::Cylinder*)(shape))->write(this);        else if(dynamic_cast<const osg::Capsule*>(shape))            ((ive::Capsule*)(shape))->write(this);        else if(dynamic_cast<const osg::HeightField*>(shape))            ((ive::HeightField*)(shape))->write(this);        else        {            throw Exception("Unknown shape in DataOutputStream::writeShape()");        }        if (_verboseOutput) std::cout<<"read/writeShape() ["<<id<<"]"<<std::endl;    }}void DataOutputStream::writeNode(const osg::Node* node){    NodeMap::iterator itr = _nodeMap.find(node);    if (itr!=_nodeMap.end())    {        // Id already exists so just write ID.        writeInt(itr->second);        if (_verboseOutput) std::cout<<"read/writeNode() ["<<itr->second<<"]"<<std::endl;    }    else    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -