Esempio n. 1
0
osg::Object *RefosgLOD::getChildObject(unsigned i) {
	if (i < 1) {
		return _object->getStateSet();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getCullCallback();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getUpdateCallback();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getEventCallback();
	} else {
		i -= 1;
	}
	if (i < _object->getNumChildren()) {
		return _object->getChild(i);
	} else {
		i -= _object->getNumChildren();
	}
	throw std::out_of_range("child");
}
osg::Object *RefosgParticlePrecipitationEffect::getChildObject(unsigned i) {
	if (i < 1) {
		return _object->getFog();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getUpdateCallback();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getStateSet();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getEventCallback();
	} else {
		i -= 1;
	}
	if (i < 1) {
		return _object->getCullCallback();
	} else {
		i -= 1;
	}
	throw std::out_of_range("child");
}
Esempio n. 3
0
void overrideTexture(const std::string &texture, Resource::ResourceSystem *resourceSystem, osg::ref_ptr<osg::Node> node)
{
    if (texture.empty())
        return;
    std::string correctedTexture = Misc::ResourceHelpers::correctTexturePath(texture, resourceSystem->getVFS());
    // Not sure if wrap settings should be pulled from the overridden texture?
    osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D(resourceSystem->getImageManager()->getImage(correctedTexture));
    tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
    tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
    tex->setName("diffuseMap");

    osg::ref_ptr<osg::StateSet> stateset;
    if (node->getStateSet())
        stateset = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
    else
        stateset = new osg::StateSet;

    stateset->setTextureAttribute(0, tex, osg::StateAttribute::OVERRIDE);

    node->setStateSet(stateset);
}
Esempio n. 4
0
void TextBase::setFont(osg::ref_ptr<Font> font)
{
    if (_font==font) return;

    osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : Font::getDefaultFont()->getStateSet();
    osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : Font::getDefaultFont()->getStateSet();

    if (getStateSet() == previousFontStateSet)
    {
        setStateSet( newFontStateSet );
    }

    _font = font;

    computeGlyphRepresentation();
}
Esempio n. 5
0
void
Text::setFont(osg::ref_ptr<osgText::Font> font)
{
    if (_font.get() == font.get())
        return;

#if OSG_VERSION_GREATER_OR_EQUAL(3,5,8)
    osgText::Text::setFont(font);
#else
    static Threading::Mutex mutex;
    Threading::ScopedMutexLock lock(mutex);

    osg::StateSet* previousFontStateSet = _font.valid() ? _font->getStateSet() : osgText::Font::getDefaultFont()->getStateSet();
    osg::StateSet* newFontStateSet = font.valid() ? font->getStateSet() : osgText::Font::getDefaultFont()->getStateSet();
    //if (getStateSet() == previousFontStateSet)
    {
        if (newFontStateSet && VirtualProgram::get(newFontStateSet) == 0L)
        {
            VirtualProgram* vp = VirtualProgram::getOrCreate(newFontStateSet);
            vp->setName("osgEarth::Text");
            osgEarth::Shaders coreShaders;
            coreShaders.load(vp, coreShaders.TextLegacy);
#if defined(OSG_GL3_AVAILABLE) && !defined(OSG_GL2_AVAILABLE) && !defined(OSG_GL1_AVAILABLE)
            newFontStateSet->setDefine("OSGTEXT_GLYPH_ALPHA_FORMAT_IS_RED");
#endif
            Lighting::set(newFontStateSet, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);

            OE_INFO << LC << "Installed VPs on a font" << std::endl;
        }

        setStateSet( newFontStateSet );
    }

    osgText::TextBase::setFont(font);
#endif
}
Esempio n. 6
0
 osg::StateSet *getLightingStateSet() { return mLightPass->getStateSet(); }