// 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(); }
void DebugShadowMap::ViewData::setDebugPolytope ( const char * name, const ConvexPolyhedron & polytope, osg::Vec4 colorOutline, osg::Vec4 colorInside ) { if( !getDebugDraw() ) return; if( &polytope == NULL ) { // delete PolytopeGeometry & pg = _polytopeGeometryMap[ std::string( name ) ]; for( unsigned int i = 0; i < VECTOR_LENGTH( pg._geometry ) ; i++ ) { if( pg._geometry[i].valid() ) { if( _geode[i].valid() && _geode[i]->containsDrawable( pg._geometry[i].get() ) ) _geode[i]->removeDrawable( pg._geometry[i].get() ); pg._geometry[i] = NULL; } } _polytopeGeometryMap.erase( std::string( name ) ); } else { // update PolytopeGeometry & pg = _polytopeGeometryMap[ std::string( name ) ]; pg._polytope = polytope; if( colorOutline.a() > 0 ) pg._colorOutline = colorOutline; if( colorInside.a() > 0 ) pg._colorInside = colorInside; for( unsigned int i = 0; i < VECTOR_LENGTH( pg._geometry ) ; i++ ) { if( !pg._geometry[i].valid() ) { pg._geometry[i] = new osg::Geometry; pg._geometry[i]->setDataVariance( osg::Object::DYNAMIC ); pg._geometry[i]->setUseDisplayList( false ); pg._geometry[i]->setSupportsDisplayList( false ); } if( _geode[i].valid() && !_geode[i]->containsDrawable( pg._geometry[i].get() ) ) { osg::Geode::DrawableList & dl = const_cast< osg::Geode::DrawableList &> ( _geode[i]->getDrawableList() ); dl.insert( dl.begin(), pg._geometry[i].get() ); } } } }
QColor OSGTextNode::color() const { const osg::Vec4 osgColor = h->text->getColor(); return QColor::fromRgbF( osgColor.r(), osgColor.g(), osgColor.b(), osgColor.a()); }
bool operator()( const osg::Vec4& in, osg::Vec4& out ) { out = in; out.a() = 0.3333*(in.r() + in.g() + in.b()); return true; }
void CSulGeomTriangleList::setColor( const osg::Vec4& color ) { setColor( color.r(), color.g(), color.b(), color.a() ); }
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()); }