osg绘制闭合曲线
osg绘制闭合曲线
osg::TessellationHints* outline_hits1 = new osg::TessellationHints(); outline_hits1->setDetailRatio(0.9f); osg::Geode* outline_geode = new osg::Geode(); osg::Geode* outline_node_geode = new osg::Geode(); osg::Geometry* outline_geometry = new osg::Geometry(); osg::ref_ptr<osg::Group> outline_group = new osg::Group; //设置顶点数据 outline_geometry->setVertexArray(outline_vec3array); //设置法线 osg::Vec3Array* outline_normal = new osg::Vec3Array(); outline_normal->push_back(osg::Vec3(0.0f, 1.0f, 1.0f)); outline_geometry->setNormalArray(outline_normal); outline_geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); outline_geode->addDrawable(outline_geometry); //设置材质 osg::ref_ptr<osg::Material> outline_material = new osg::Material; { //设置环境光 outline_material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 0.7, 0.0, 1.0)); //设置散射光 outline_material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0)); //设置镜面光 outline_material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0)); //设置幅射光 outline_material->setShininess(osg::Material::FRONT_AND_BACK, 60.0); } osg::ref_ptr<osg::StateSet> outline_stateset = outline_geode->getOrCreateStateSet(); osg::ref_ptr<osg::LineWidth> outline_lineWidth = new osg::LineWidth(100.0f); outline_stateset->setAttribute(outline_lineWidth); outline_geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0, outline_final_vecs.size())); //设置材质 outline_geometry->getOrCreateStateSet()->setAttributeAndModes(outline_material, osg::StateAttribute::ON); if (m_root !=nullptr) { outline_group->addChild(outline_geode); outline_group->addChild(outline_node_geode); m_root->addChild(outline_group.get()); }
#########################
QQ 3087438119