osg绘制ifc工字钢的端面
osg::Geode* createIfcPolygon2() { osg::Geode* geode = new osg::Geode(); //face 8 { osg::Geometry* geom_face1 = new osg::Geometry(); osg::Vec3Array* coords_face1 = new osg::Vec3Array(); geom_face1->setVertexArray(coords_face1); std::vector<osg::Vec3> point_vecs_bottom; { osg::Vec3 indexVecB_1; indexVecB_1[0] = 7700.0f; indexVecB_1[1] = 70.0f; indexVecB_1[2] = -130.0f; osg::Vec3 indexVecB_2; indexVecB_2[0] = 7700.0f; indexVecB_2[1] = 70.0f; indexVecB_2[2] = 130.0f; osg::Vec3 indexVecB_3; indexVecB_3[0] = 7700.0f; indexVecB_3[1] = 150.0f; indexVecB_3[2] = 130.0f; osg::Vec3 indexVecB_4; indexVecB_4[0] = 7700.0f; indexVecB_4[1] = 150.0f; indexVecB_4[2] = 150.0f; osg::Vec3 indexVecB_5; indexVecB_5[0] = 7700.0f; indexVecB_5[1] = -150.0f; indexVecB_5[2] = 150.0f; osg::Vec3 indexVecB_6; indexVecB_6[0] = 7700.0f; indexVecB_6[1] = -150.0f; indexVecB_6[2] = 130.0f; osg::Vec3 indexVecB_7; indexVecB_7[0] = 7700.0f; indexVecB_7[1] = -70.0f; indexVecB_7[2] = 130.0f; osg::Vec3 indexVecB_8; indexVecB_8[0] = 7700.0f; indexVecB_8[1] = -70.0f; indexVecB_8[2] = -130.0f; osg::Vec3 indexVecB_10; indexVecB_10[0] = 7700.0f; indexVecB_10[1] = -150.0f; indexVecB_10[2] = -130.0f; osg::Vec3 indexVecB_11; indexVecB_11[0] = 7700.0f; indexVecB_11[1] = -150.0f; indexVecB_11[2] = -150.0f; osg::Vec3 indexVecB_12; indexVecB_12[0] = 7700.0f; indexVecB_12[1] = 150.0f; indexVecB_12[2] = -150.0f; osg::Vec3 indexVecB_13; indexVecB_13[0] = 7700.0f; indexVecB_13[1] = 150.0f; indexVecB_13[2] = -130.0f; point_vecs_bottom.push_back(indexVecB_1); point_vecs_bottom.push_back(indexVecB_2); point_vecs_bottom.push_back(indexVecB_3); point_vecs_bottom.push_back(indexVecB_4); point_vecs_bottom.push_back(indexVecB_5); point_vecs_bottom.push_back(indexVecB_6); point_vecs_bottom.push_back(indexVecB_7); point_vecs_bottom.push_back(indexVecB_8); point_vecs_bottom.push_back(indexVecB_10); point_vecs_bottom.push_back(indexVecB_11); point_vecs_bottom.push_back(indexVecB_12); point_vecs_bottom.push_back(indexVecB_13); } //添加数据 std::vector<osg::Vec3>::iterator iter1; for (iter1 = point_vecs_bottom.begin(); iter1 != point_vecs_bottom.end(); ++iter1) { osg::Vec3 index_point = *iter1; coords_face1->push_back(index_point); } //geom_face1->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, 0, point_vecs_bottom.size())); geom_face1->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON, 0, point_vecs_bottom.size())); osg::ref_ptr<osgUtil::Tessellator> tscx = new osgUtil::Tessellator; //设置分格类型为几何体 tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY); //设置只显示轮廓线为false。设置环绕规则,这里不太懂 tscx->setWindingType(osgUtil::Tessellator::TESS_WINDING_ODD); //使用分格化 tscx->retessellatePolygons(*(geom_face1)); geode->addDrawable(geom_face1); } return geode; }
#############################
QQ 3087438119