示例#1
0
bool View_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
    const osgViewer::View &view = dynamic_cast<const osgViewer::View&>(obj);

    osg::notify(osg::NOTICE) << "View_writeLocalData" << std::endl;

    if (view.getCamera())
    {
        fw.writeObject(*view.getCamera());
    }

    if (view.getNumSlaves() != 0)
    {
        fw.indent() << "Slaves {" << std::endl;
        fw.moveIn();

        for (unsigned int i = 0; i < view.getNumSlaves(); ++i)
        {
            const osg::Camera *camera = view.getSlave(i)._camera.get();
            if (camera)
            {
                fw.writeObject(*camera);
            }
        }

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

    return true;
}
示例#2
0
static bool writeMatrix(const osg::Matrix &matrix, osgDB::Output &fw, const char *keyword)
{
    fw.indent() << keyword << " {" << std::endl;
    fw.moveIn();
    fw.indent() << matrix(0, 0) << " " << matrix(0, 1) << " " << matrix(0, 2) << " " << matrix(0, 3) << std::endl;
    fw.indent() << matrix(1, 0) << " " << matrix(1, 1) << " " << matrix(1, 2) << " " << matrix(1, 3) << std::endl;
    fw.indent() << matrix(2, 0) << " " << matrix(2, 1) << " " << matrix(2, 2) << " " << matrix(2, 3) << std::endl;
    fw.indent() << matrix(3, 0) << " " << matrix(3, 1) << " " << matrix(3, 2) << " " << matrix(3, 3) << std::endl;
    fw.moveOut();
    fw.indent() << "}" << std::endl;
    return true;
}
示例#3
0
bool Locator_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
{
    const osgVolume::Locator& locator = static_cast<const osgVolume::Locator&>(obj);

    const osg::Matrixd& matrix = locator.getTransform();
    fw.indent() << "Transform {" << std::endl;
    fw.moveIn();
    fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << std::endl;
    fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << std::endl;
    fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << std::endl;
    fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << std::endl;
    fw.moveOut();
    fw.indent() << "}"<< std::endl;

    return true;
}
示例#4
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;
}