Exemplo n.º 1
0
	virtual void apply(osg::Geode& geode)
	{
		for (unsigned i=0; i<geode.getNumDrawables(); ++i)
		{
			osg::Geometry *geo = dynamic_cast<osg::Geometry *>(geode.getDrawable(i));
			if (!geo) continue;

			osg::StateSet *stateset = geo->getStateSet();
			if (!stateset) continue;

			osg::StateAttribute *state = stateset->getAttribute(osg::StateAttribute::MATERIAL);
			if (!state) continue;

			osg::Material *mat = dynamic_cast<osg::Material *>(state);
			if (!mat) continue;

			const osg::Vec4 v4 = mat->getDiffuse(FAB);
			if (v4.r() == 1.0f && v4.g() == 0.0f && v4.b() == 1.0f)
			{
				//VTLOG("oldmat rc %d, ", mat->referenceCount());

				osg::Material *newmat = (osg::Material *)mat->clone(osg::CopyOp::DEEP_COPY_ALL);
				newmat->setDiffuse(FAB, osg::Vec4(c.r*2/3,c.g*2/3,c.b*2/3,1));
				newmat->setAmbient(FAB, osg::Vec4(c.r*1/3,c.g*1/3,c.b*1/3,1));

				//VTLOG("newmat rc %d\n", newmat->referenceCount());

				stateset->setAttribute(newmat);
				//VTLOG(" -> %d %d\n", mat->referenceCount(), newmat->referenceCount());
			}
		}
		osg::NodeVisitor::apply(geode);
	}
Exemplo n.º 2
0
QColor OSGTextNode::color() const
{
    const osg::Vec4 osgColor = h->text->getColor();
    return QColor::fromRgbF(
                osgColor.r(),
                osgColor.g(),
                osgColor.b(),
                osgColor.a());
}
Exemplo n.º 3
0
//
//set the drop shadow color
//
void TextRegion::SetBackDropColor(const osg::Vec4 &color)
{
	_backdropColor.r() = color.r();
	_backdropColor.g() = color.g();
	_backdropColor.b() = color.b();
	_backdropColor.a() = this->GetAlpha()*0.5f;
    
	_text->setBackdropColor(_backdropColor);
    
    _dirtyRenderState = true;
}
Exemplo n.º 4
0
 bool operator()( const osg::Vec4& in, osg::Vec4& out ) {
     out = in;
     out.a() = 0.3333*(in.r() + in.g() + in.b());
     return true;
 }
Exemplo n.º 5
0
void CSulGeomTriangleList::setColor( const osg::Vec4& color )
{
	setColor( color.r(), color.g(), color.b(), color.a() );
}
Exemplo n.º 6
0
 inline void rgba(float& r,float& g,float& b,float& a) const { a = (r*_colour.r()+g*_colour.g()+b*_colour.b()+a*_colour.a()); }
    // rasterizes a geometry to color
    void rasterize(const Geometry* geometry, const osg::Vec4& color, RenderFrame& frame, 
                   agg::rasterizer& ras, agg::rendering_buffer& buffer)
    {
        unsigned a = (unsigned)(127.0f+(color.a()*255.0f)/2.0f); // scale alpha up
        agg::rgba8 fgColor = agg::rgba8( (unsigned)(color.r()*255.0f), (unsigned)(color.g()*255.0f), (unsigned)(color.b()*255.0f), a );
        
        ConstGeometryIterator gi( geometry );
        while( gi.hasMore() )
        {
            const Geometry* g = gi.next();

            for( Geometry::const_iterator p = g->begin(); p != g->end(); p++ )
            {
                const osg::Vec3d& p0 = *p;
                double x0 = frame.xf*(p0.x()-frame.xmin);
                double y0 = frame.yf*(p0.y()-frame.ymin);

                if ( p == g->begin() )
                    ras.move_to_d( x0, y0 );
                else
                    ras.line_to_d( x0, y0 );
            }
        }
        agg::renderer<agg::span_abgr32, agg::rgba8> ren(buffer);
        ras.render(ren, fgColor);

        ras.reset();
    }