|
本帖最后由 oirrm 于 2014-6-2 19:47 编辑
void DrawAreaWithType(int RectangleMode,osg::ref_ptr<osg::Geometry> RectangleGeometry,osg::ref_ptr<osg::StateSet> RectangleStateset,bool IsMove)
{
RectangleStateset->setMode(GL_BLEND,osg::StateAttribute::ON);
RectangleStateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
RectangleStateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF|osg::StateAttribute:ROTECTED);
osg::ref_ptr <osg:ineWidth> LineSize = new osg::LineWidth;
LineSize ->setWidth(2.0) ;
RectangleStateset->setAttributeAndModes(LineSize.get(),osg::StateAttribute::ON);
RectangleGeometry->setVertexArray(m_VertexV3a);
RectangleGeometry->addPrimitiveSet(new osg:rawArrays(RectangleMode,0,m_VertexV3a->size()));
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
osg::Vec4 color(1,0,1,0.5);
colors->push_back(color);
RectangleGeometry->setColorArray(colors);
RectangleGeometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array;
osg::Vec3 normal = osg::Z_AXIS;
normals->push_back(normal);
RectangleGeometry->setNormalArray(normals.get());
RectangleGeometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
RectangleGeometry->setStateSet(RectangleStateset);
if(IsMove)
{
if(m_VertexV3a->size() < 4)
{
return;
}
osg::ref_ptr<osgUtil::Tessellator> tes = new osgUtil::Tessellator();
tes->setBoundaryOnly(false);
tes->setWindingType(osgUtil::Tessellator::TESS_WINDING_POSITIVE );
tes->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
tes->retessellatePolygons(*RectangleGeometry);
}
}
|
|