Exemplo n.º 1
0
bool VolumeTile_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
{
    const osgVolume::VolumeTile& volumeTile = static_cast<const osgVolume::VolumeTile&>(obj);

    int prec = fw.precision();
    fw.precision(15);

    if (volumeTile.getLocator())
    {
        fw.writeObject(*volumeTile.getLocator());
    }

    if (volumeTile.getLayer())
    {
        fw.writeObject(*volumeTile.getLayer());
    }

    if (volumeTile.getVolumeTechnique())
    {
        fw.writeObject(*volumeTile.getVolumeTechnique());
    }    

    fw.precision(prec);
    
    return true;
}
bool ClusterCullingCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
    const ClusterCullingCallback* ccc = dynamic_cast<const ClusterCullingCallback*>(&obj);
    if (!ccc) return false; 

    int prec = fw.precision();
    fw.precision(15);

    fw.indent() << "controlPoint " << ccc->getControlPoint() << std::endl;
    fw.indent() << "normal " << ccc->getNormal() << std::endl;
    fw.indent() << "radius " << ccc->getRadius() << std::endl;
    fw.indent() << "deviation " << ccc->getDeviation() << std::endl;
 
    fw.precision(prec);

    return true;
}
Exemplo n.º 3
0
bool AnimationPath_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
    const osg::AnimationPath* ap = dynamic_cast<const osg::AnimationPath*>(&obj);
    if (!ap) return false;

    fw.indent() << "LoopMode ";
    switch(ap->getLoopMode())
    {
        case AnimationPath::SWING:
            fw << "SWING" <<std::endl;
            break;
        case AnimationPath::LOOP:
            fw << "LOOP"<<std::endl;
            break;
        case AnimationPath::NO_LOOPING:
            fw << "NO_LOOPING"<<std::endl;
            break;
    }

    const AnimationPath::TimeControlPointMap& tcpm = ap->getTimeControlPointMap();

    fw.indent() << "ControlPoints {"<< std::endl;
    fw.moveIn();

    int prec = fw.precision();
    fw.precision(15);

    for (AnimationPath::TimeControlPointMap::const_iterator itr=tcpm.begin();
         itr!=tcpm.end(); 
         ++itr)
    {
        fw.indent() << itr->first << " " << itr->second.getPosition() << " " << itr->second.getRotation() << " " <<itr->second.getScale() << std::endl;

    }

    fw.precision(prec);

    fw.moveOut();
    fw.indent() << "}"<< std::endl;

    return true;
}
Exemplo n.º 4
0
 void setPrecision(osgDB::Output& fout, const osgDB::ReaderWriter::Options* options) const
 {
     if (options)
     {
         std::istringstream iss(options->getOptionString());
         std::string opt;
         while (iss >> opt)
         {
             if(opt=="PRECISION" || opt=="precision") 
             {
                 int prec;
                 iss >> prec;
                 fout.precision(prec);
             }
             if (opt=="OutputTextureFiles")
             {
                 fout.setOutputTextureFiles(false);
             }
         }
     }
bool Array_writeLocalData( const osg::Array& array, osgDB::Output& fw )
{
    switch(array.getType())
    {
    case( osg::Array::ByteArrayType):
    {
        const osg::ByteArray& carray = static_cast<const osg::ByteArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArrayAsInts(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::ShortArrayType):
    {
        const osg::ShortArray& carray = static_cast<const osg::ShortArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::IntArrayType):
    {
        const osg::IntArray& carray = static_cast<const osg::IntArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::UByteArrayType):
    {
        const osg::UByteArray& carray = static_cast<const osg::UByteArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArrayAsInts(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::UShortArrayType):
    {
        const osg::UShortArray& carray = static_cast<const osg::UShortArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::UIntArrayType):
    {
        const osg::UIntArray& carray = static_cast<const osg::UIntArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<" ";
        osgDB::writeArray(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::Vec4ubArrayType):
    {
        const osg::Vec4ubArray& carray = static_cast<const osg::Vec4ubArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<" ";
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case( osg::Array::FloatArrayType):
    {
        const osg::FloatArray& carray = static_cast<const osg::FloatArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end());
        return true;
    }
    break;
    case( osg::Array::Vec2ArrayType):
    {
        const osg::Vec2Array& carray = static_cast<const osg::Vec2Array&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case( osg::Array::Vec3ArrayType):
    {
        const osg::Vec3Array& carray = static_cast<const osg::Vec3Array&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case( osg::Array::Vec4ArrayType):
    {
        const osg::Vec4Array& carray = static_cast<const osg::Vec4Array&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case( osg::Array::DoubleArrayType):
    {
        int prec = fw.precision(15);
        const osg::DoubleArray& carray = static_cast<const osg::DoubleArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end());
        fw.precision(prec);
        return true;
    }
    break;
    case( osg::Array::Vec2dArrayType):
    {
        int prec = fw.precision(15);
        const osg::Vec2dArray& carray = static_cast<const osg::Vec2dArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        fw.precision(prec);
        return true;
    }
    break;
    case( osg::Array::Vec3dArrayType):
    {
        int prec = fw.precision(15);
        const osg::Vec3dArray& carray = static_cast<const osg::Vec3dArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        fw.precision(prec);
        return true;
    }
    break;
    case( osg::Array::Vec4dArrayType):
    {
        int prec = fw.precision(15);
        const osg::Vec4dArray& carray = static_cast<const osg::Vec4dArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        fw.precision(prec);
        return true;
    }
    break;
    case( osg::Array::Vec2sArrayType):
    {
        const osg::Vec2sArray& carray = static_cast<const osg::Vec2sArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(), 3);
        return true;
    }
    break;
    case( osg::Array::Vec3sArrayType):
    {
        const osg::Vec3sArray& carray = static_cast<const osg::Vec3sArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(), 2);
        return true;
    }
    break;
    case( osg::Array::Vec4sArrayType):
    {
        const osg::Vec4sArray& carray = static_cast<const osg::Vec4sArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<std::endl;
        osgDB::writeArray(fw,carray.begin(),carray.end(), 1);
        return true;
    }
    break;
    case( osg::Array::Vec2bArrayType):
    {
        const osg::Vec2bArray& carray = static_cast<const osg::Vec2bArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<" ";
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case( osg::Array::Vec3bArrayType):
    {
        const osg::Vec3bArray& carray = static_cast<const osg::Vec3bArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<" ";
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case(osg::Array::Vec4bArrayType):
    {
        const osg::Vec4bArray& carray = static_cast<const osg::Vec4bArray&>(array);
        fw<<array.className()<<" "<<carray.size()<<" ";
        osgDB::writeArray(fw,carray.begin(),carray.end(),1);
        return true;
    }
    break;
    case(osg::Array::ArrayType):
    default:
        return false;
    }
}