示例#1
0
文件: Box.cpp 项目: joevandyk/osg
bool osgWidget_Box_writeData(const osg::Object& obj, osgDB::Output& fw) {
	const osgWidget::Box& model = static_cast<const osgWidget::Box&>(obj);
	
	fw.indent() << fw.wrapString("Box stuff...") << std::endl;

	return true;
}
bool ParticleEffect_writeLocalData(const osg::Object& object, osgDB::Output& fw)
{
    const osgParticle::ParticleEffect& effect = static_cast<const osgParticle::ParticleEffect&>(object);
    fw.indent()<<"textFileName "<<fw.wrapString(effect.getTextureFileName())<<std::endl;
    fw.indent()<<"position "<<effect.getPosition()<<std::endl;
    fw.indent()<<"scale "<<effect.getScale()<<std::endl;
    fw.indent()<<"intensity "<<effect.getIntensity()<<std::endl;
    fw.indent()<<"startTime "<<effect.getStartTime()<<std::endl;
    fw.indent()<<"emitterDuration "<<effect.getEmitterDuration()<<std::endl;
    fw.indent()<<"particleDuration "<<effect.getParticleDuration()<<std::endl;

    osgParticle::rangef rf = effect.getDefaultParticleTemplate().getSizeRange();
    fw.indent() << "particleSizeRange " << rf.minimum << " " << rf.maximum << std::endl;

    rf = effect.getDefaultParticleTemplate().getAlphaRange();
    fw.indent() << "particleAlphaRange " << rf.minimum << " " << rf.maximum << std::endl;

    osgParticle::rangev4 rv4 = effect.getDefaultParticleTemplate().getColorRange();
    fw.indent() << "particleColorRange ";
    fw << rv4.minimum.x() << " " << rv4.minimum.y() << " " << rv4.minimum.z() << " " << rv4.minimum.w() << " ";
    fw << rv4.maximum.x() << " " << rv4.maximum.y() << " " << rv4.maximum.z() << " " << rv4.maximum.w() << std::endl;

    fw.indent()<<"wind "<<effect.getWind()<<std::endl;

    fw.indent()<<"useLocalParticleSystem ";
    if (effect.getUseLocalParticleSystem()) fw<<"TRUE"<<std::endl;
    else
    {
        fw<<"FALSE"<<std::endl;
        fw.writeObject(*effect.getParticleSystem());
    }

    return true;
}
示例#3
0
bool osgWidget_NullWidget_writeData(const osg::Object& /*obj*/, osgDB::Output &fw)
{
    // const osgWidget::NullWidget& model = static_cast<const osgWidget::NullWidget&>(obj);

    fw.indent() << fw.wrapString("NullWidget stuff...") << std::endl;

    return true;
}
示例#4
0
bool osgWidget_WindowManager_writeData(const osg::Object& /*obj*/, osgDB::Output& fw)
{
	// const osgWidget::WindowManager& model = static_cast<const osgWidget::WindowManager&>(obj);
	
	fw.indent() << fw.wrapString("WindowManager stuff...") << std::endl;

	return true;
}
bool osgWidget_EmbeddedWindow_writeData(const osg::Object& /*obj*/, osgDB::Output& fw)
{
	// const osgWidget::Window::EmbeddedWindow& model = static_cast<const osgWidget::Window::EmbeddedWindow&>(obj);

	fw.indent() << fw.wrapString("EmbeddedWindow stuff...") << std::endl;

	return true;
}
示例#6
0
bool ImageLayer_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
{
    const osgTerrain::ImageLayer& layer = static_cast<const osgTerrain::ImageLayer&>(obj);

    std::string fileName = layer.getFileName();

    if (fw.getOutputTextureFiles())
    {
        if (fileName.empty())
        {
            fileName = fw.getTextureFileNameForOutput();
        }
        osgDB::writeImageFile(*layer.getImage(), fileName);
    }
    if (!fileName.empty())
    {
        fw.indent()<<"file "<< fw.wrapString(fileName) << std::endl;
    }

    return true;
}
示例#7
0
bool TextBase_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
    const osgText::Text &text = static_cast<const osgText::Text &>(obj);

    // color
    osg::Vec4 c = text.getColor();
    fw.indent() << "color " << c.x() << " " << c.y() << " " << c.z() << " " << c.w() << std::endl;

    if (text.getFont())
    {
        fw.indent() << "font " << text.getFont()->getFileName() << std::endl;
    }

    // font resolution
    fw.indent() << "fontResolution " << text.getFontWidth() << " " << text.getFontHeight() << std::endl;

    // charater size.
    fw.indent() << "characterSize " << text.getCharacterHeight() << " " << text.getCharacterAspectRatio() << std::endl;

    fw.indent() << "characterSizeMode ";
    switch(text.getCharacterSizeMode())
    {
      case osgText::Text::OBJECT_COORDS : fw<<"OBJECT_COORDS"<<std::endl; break;
      case osgText::Text::SCREEN_COORDS : fw<<"SCREEN_COORDS"<<std::endl; break;
      case osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT: fw<<"OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT"<<std::endl; break;
    }

    // maximum dimension of text box.
    if (text.getMaximumWidth()>0.0f)
    {
        fw.indent() << "maximumWidth " << text.getMaximumWidth() << std::endl;
    }

    if (text.getMaximumHeight()>0.0f)
    {
        fw.indent() << "maximumHeight " << text.getMaximumHeight() << std::endl;
    }

    if (text.getLineSpacing()>0.0f)
    {
        fw.indent() << "lineSpacing " << text.getLineSpacing() << std::endl;
    }

    // alignment
    fw.indent() << "alignment ";
    switch(text.getAlignment())
    {
      case osgText::Text::LEFT_TOP:        fw << "LEFT_TOP" << std::endl; break;
      case osgText::Text::LEFT_CENTER :    fw << "LEFT_CENTER" << std::endl; break;
      case osgText::Text::LEFT_BOTTOM :    fw << "LEFT_BOTTOM" << std::endl; break;

      case osgText::Text::CENTER_TOP:      fw << "CENTER_TOP" << std::endl; break;
      case osgText::Text::CENTER_CENTER:   fw << "CENTER_CENTER" << std::endl; break;
      case osgText::Text::CENTER_BOTTOM:   fw << "CENTER_BOTTOM" << std::endl; break;

      case osgText::Text::RIGHT_TOP:       fw << "RIGHT_TOP" << std::endl; break;
      case osgText::Text::RIGHT_CENTER:    fw << "RIGHT_CENTER" << std::endl; break;
      case osgText::Text::RIGHT_BOTTOM:    fw << "RIGHT_BOTTOM" << std::endl; break;

      case osgText::Text::LEFT_BASE_LINE:  fw << "LEFT_BASE_LINE" << std::endl; break;
      case osgText::Text::CENTER_BASE_LINE:fw << "CENTER_BASE_LINE" << std::endl; break;
      case osgText::Text::RIGHT_BASE_LINE: fw << "RIGHT_BASE_LINE" << std::endl; break;

      case osgText::Text::LEFT_BOTTOM_BASE_LINE:  fw << "LEFT_BOTTOM_BASE_LINE" << std::endl; break;
      case osgText::Text::CENTER_BOTTOM_BASE_LINE:fw << "CENTER_BOTTOM_BASE_LINE" << std::endl; break;
      case osgText::Text::RIGHT_BOTTOM_BASE_LINE: fw << "RIGHT_BOTTOM_BASE_LINE" << std::endl; break;
    };


    if (!text.getRotation().zeroRotation())
    {
        fw.indent() << "rotation " << text.getRotation() << std::endl;
    }

    if (text.getAutoRotateToScreen())
    {
        fw.indent() << "autoRotateToScreen TRUE"<< std::endl;
    }


    // layout
    fw.indent() << "layout ";
    switch(text.getLayout())
    {
      case osgText::Text::LEFT_TO_RIGHT: fw << "LEFT_TO_RIGHT" << std::endl; break;
      case osgText::Text::RIGHT_TO_LEFT: fw << "RIGHT_TO_LEFT" << std::endl; break;
      case osgText::Text::VERTICAL: fw << "VERTICAL" << std::endl; break;
    };


    // position
    osg::Vec3 p = text.getPosition();
    fw.indent() << "position " << p.x() << " " << p.y() << " " << p.z() << std::endl;

    // color
//    osg::Vec4 c = text.getColor();
//    fw.indent() << "color " << c.x() << " " << c.y() << " " << c.z() << " " << c.w() << std::endl;

    // draw mode
    fw.indent() << "drawMode " << text.getDrawMode() << std::endl;

    // bounding box margin
    fw.indent() << "BoundingBoxMargin " << text.getBoundingBoxMargin() << std::endl;

    // bounding box color
    osg::Vec4 bbc = text.getBoundingBoxColor();
    fw.indent() << "BoundingBoxColor " << bbc.x() << " " << bbc.y() << " " << bbc.z() << " " << bbc.w() << std::endl;

    // text
    const osgText::String& textstring = text.getText();
    bool isACString = true;
    osgText::String::const_iterator itr;
    for(itr=textstring.begin();
        itr!=textstring.end() && isACString;
        ++itr)
    {
        if (*itr==0 || *itr>256) isACString=false;
    }
    if (isACString)
    {
        std::string str;

        for(itr=textstring.begin();
            itr!=textstring.end();
            ++itr)
        {
            str += (char)(*itr);
        }

        //std::copy(textstring.begin(),textstring.end(),std::back_inserter(str));

        fw.indent() << "text " << fw.wrapString(str) << std::endl;
    }
    else
    {
        // do it the hardway...output each character as an int
        fw.indent() << "text "<<textstring.size()<<std::endl;;
        osgDB::writeArray(fw,textstring.begin(),textstring.end());
    }

    return true;
}