From Luc Frauciel, "You'll find attached a modification of DXWriter to support Material color:
If a material is present, the diffuse color is affected to current layer."
This commit is contained in:
@@ -481,6 +481,12 @@ void DXFWriterNodeVisitor::processStateSet(osg::StateSet* ss)
|
||||
{
|
||||
if (pm->getMode(osg::PolygonMode::FRONT)==osg::PolygonMode::LINE) _writeTriangleAs3DFace = false;
|
||||
}
|
||||
osg::Material * mat = dynamic_cast<osg::Material *>(ss->getAttribute(osg::StateAttribute::MATERIAL));
|
||||
if (mat)
|
||||
{
|
||||
const osg::Vec4& color = mat->getDiffuse(osg::Material::FRONT);
|
||||
_layer._color = _acadColor.findColor(color.asABGR()>>8);
|
||||
}
|
||||
}
|
||||
|
||||
void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m)
|
||||
@@ -490,8 +496,6 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m)
|
||||
// We only want to create a new layer for geometry with something to draw
|
||||
if (geo->getVertexArray() && geo->getVertexArray()->getNumElements() ) {
|
||||
|
||||
processStateSet(_currentStateSet.get());
|
||||
|
||||
if ( _firstPass ) {
|
||||
// Must have unique layer names
|
||||
_layer._name = getLayerName( geo->getName().empty() ? geo->getParent(0)->getName() : geo->getName() );
|
||||
@@ -510,6 +514,9 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m)
|
||||
} else {
|
||||
_layer = _layers[_count++];
|
||||
OSG_DEBUG << "writing Layer " << _layer._name << std::endl;
|
||||
|
||||
processStateSet(_currentStateSet.get());
|
||||
|
||||
if ( geo->getNumPrimitiveSets() ) {
|
||||
for(unsigned int i = 0; i < geo->getNumPrimitiveSets(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user