LOFT,给螺旋加管道
曲线生成方形管
osg::ref_ptr<osg::Node> createLoft()
{
// First, we would create a helicoid geometry. To finish the work with Loft class, we should have
// at least a helix path and a cross-section shape. We may just use the Helix class to generate
// the required curve (Need to set number of coils, and radius and pitch parameters).
//螺旋管
//osg::ref_ptr<osgModeling::Helix> helix =
// new osgModeling::Helix( 1.5f, 0.2f, 1.0f, osg::Vec3(-xInterval, 0.0f, 0.0f) );
//多段线管
osg::ref_ptr<osgModeling::Curve> helix = new osgModeling::Curve;
helix->addPathPoint( osg::Vec3(-0.5f, 0.0f, 0.0f) );
helix->addPathPoint( osg::Vec3(-0.5f, 0.0f, 2.0f) );
helix->addPathPoint( osg::Vec3(0.0f, 0.0f, 4.0f) );
// And then, set the section shape and a loft model is created. The simplest section which is only a line segment
// will be applied to the whole model. Loft class suggest use 2D curves (on XOY plane) as section shapes.
osg::ref_ptr<osgModeling::Curve> section = new osgModeling::Curve;
section->addPathPoint( osg::Vec3(0.5f,0.0f,0.0f) );//管道横截面
section->addPathPoint( osg::Vec3(-0.5f,0.0f,0.0f) );
section->addPathPoint( osg::Vec3(-0.5f,0.5f,0.0f) );
section->addPathPoint( osg::Vec3(0.5f,0.5f,0.0f) );
section->addPathPoint( osg::Vec3(0.5f,0.0f,0.0f) );
osg::ref_ptr<osgModeling::Loft> geom1 =
new osgModeling::Loft( helix.get(), section.get() );
发表评论: