Changeset 819

Show
Ignore:
Timestamp:
01/03/08 22:41:37
Author:
robert
Message:

Added setting of a colour array to shape extruded geometries, commented out Material setting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vpb/ShapeFilePlacer.cpp

    r816 r819  
    2222#include <osg/NodeVisitor> 
    2323#include <osg/Array> 
     24 
    2425#include <osgUtil/ConvertVec> 
    2526#include <osgUtil/DrawElementTypeSimplifier> 
     27#include <osgUtil/SmoothingVisitor> 
    2628 
    2729#include <osgSim/ShapeAttribute> 
     
    524526                            dets.simplify(*(clonedGeom.get())); 
    525527                             
     528                             
     529                            osg::Vec4Array* colours = dynamic_cast<osg::Vec4Array*>(clonedGeom->getColorArray()); 
     530                            if (!colours) 
     531                            {                             
     532                                colours = new osg::Vec4Array(1); 
     533                                (*colours)[0].set(1.0f,1.0f,1.0f,1.0f); 
     534                                clonedGeom->setColorArray(colours); 
     535                                clonedGeom->setColorBinding(osg::Geometry::BIND_OVERALL); 
     536                            } 
     537                             
    526538                            // ** insert the geometry in scnene graph 
    527539                            clonedGeode->addDrawable(clonedGeom.get()); 
     540 
     541                            osgUtil::SmoothingVisitor sv; 
     542                            sv.smooth(*clonedGeom);  // this will replace the normal vector with a new one 
     543 
    528544                        } 
    529545                    } 
     
    588604    model->accept(shapePlacer); 
    589605 
     606#if 0 
    590607    osg::Material * mat = new osg::Material; 
    591     mat->setDiffuse(osg::Material::FRONT, osg::Vec4f(1.0f,0.0f,0.0f,1.0f)); 
     608    mat->setDiffuse(osg::Material::FRONT, osg::Vec4f(1.0f,1.0f,1.0f,1.0f)); 
    592609    model->getOrCreateStateSet()->setAttributeAndModes(mat, osg::StateAttribute::ON); 
     610#endif 
    593611     
    594612    if (shapePlacer.getCreatedModel())