Пример #1
0
void RefosgBillboard::addChild(osg::Object *child) {
	{NodeCallback *cobj = dynamic_cast<NodeCallback *>(child);
	if (cobj != 0) {
		_object->setUpdateCallback(cobj);
		return;
	}}
	{osg::StateSet *cobj = dynamic_cast<osg::StateSet *>(child);
	if (cobj != 0) {
		_object->setStateSet(cobj);
		return;
	}}
	{NodeCallback *cobj = dynamic_cast<NodeCallback *>(child);
	if (cobj != 0) {
		_object->setEventCallback(cobj);
		return;
	}}
	{Drawable *cobj = dynamic_cast<Drawable *>(child);
	if (cobj != 0) {
		_object->addDrawable(cobj);
		return;
	}}
	{NodeCallback *cobj = dynamic_cast<NodeCallback *>(child);
	if (cobj != 0) {
		_object->setCullCallback(cobj);
		return;
	}}
	throw InvalidTypeException();
}
Пример #2
0
//***********************************************************
//FUNCTION:
void CPickNode::__drawCoordinateLine(const osg::Vec3f& vOrigin, float vLength, osg::ref_ptr<osg::Geode>& vLineNode)
{
	osg::ref_ptr<osg::Geometry> CoordGeometry = new osg::Geometry();
	osg::ref_ptr<osg::Vec3Array> CoordVertex = new osg::Vec3Array();

	CoordVertex->push_back(vOrigin);
	CoordVertex->push_back(osg::Vec3(vOrigin.x()+vLength, vOrigin.y(), vOrigin.z()));
	CoordVertex->push_back(vOrigin);
	CoordVertex->push_back(osg::Vec3(vOrigin.x(), vOrigin.y()+vLength, vOrigin.z()));
	CoordVertex->push_back(vOrigin);
	CoordVertex->push_back(osg::Vec3(vOrigin.x(), vOrigin.y(), vOrigin.z()+vLength));
	CoordGeometry->setVertexArray(CoordVertex.get());
	CoordGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, 6));

	osg::ref_ptr<osg::Vec4Array> VertColor = new osg::Vec4Array();
	VertColor->push_back(osg::Vec4(1.0, 0.0, 0.0, 1.0));
	VertColor->push_back(osg::Vec4(1.0, 0.0, 0.0, 1.0));
	VertColor->push_back(osg::Vec4(0.0, 1.0, 0.0, 1.0));
	VertColor->push_back(osg::Vec4(0.0, 1.0, 0.0, 1.0));
	VertColor->push_back(osg::Vec4(0.0, 0.0, 1.0, 1.0));
	VertColor->push_back(osg::Vec4(0.0, 0.0, 1.0, 1.0));
	CoordGeometry->setColorArray(VertColor.get());
	CoordGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);

	osg::ref_ptr<osg::LineWidth> LineSize = new osg::LineWidth();
	LineSize->setWidth(5);
	vLineNode->getOrCreateStateSet()->setAttributeAndModes(LineSize.get(), osg::StateAttribute::ON);
	vLineNode->addDrawable(CoordGeometry.get());
}
Пример #3
0
//***********************************************************
//FUNCTION:
void CPickNode::__drawCoordinateMask(const osg::Vec3f& vOrigin, float vLength, osg::ref_ptr<osg::Geode>& vMaskNode)
{
	osg::ref_ptr<osg::Geometry> MakGeom = new osg::Geometry();
	osg::ref_ptr<osg::Vec3Array> MaskVert = new osg::Vec3Array();

	for (unsigned int i=1; i<=10; i++)
	{
		float Offfset = vLength / 10.0 * i;
		MaskVert->push_back(osg::Vec3(vOrigin.x()+Offfset, vOrigin.y(), vOrigin.z()));
		MaskVert->push_back(osg::Vec3(vOrigin.x(), vOrigin.y()+Offfset, vOrigin.z()));
		MaskVert->push_back(osg::Vec3(vOrigin.x(), vOrigin.y(), vOrigin.z()+Offfset));
	}
	osg::ref_ptr<osg::Vec4Array> ColorArray = new osg::Vec4Array;
	ColorArray->push_back(osg::Vec4(1.0, 1.0, 1.0, 1.0));

	MakGeom->setVertexArray(MaskVert.get());
	MakGeom->setColorArray(ColorArray);
	MakGeom->setColorBinding(osg::Geometry::BIND_OVERALL);

	MakGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 30));
	vMaskNode->addDrawable(MakGeom.get());

	osg::ref_ptr<osg::Point> PointSize = new osg::Point(5.0);
	osg::ref_ptr<osg::StateSet> PointStateSet = vMaskNode->getOrCreateStateSet();
	PointStateSet->setAttribute(PointSize);
}
Пример #4
0
osg::ref_ptr<osg::Geode> VTKActorToOSG(vtkActor *actor, osg::ref_ptr<osg::Geode> geode, int verbose)
{
	// make actor current
	actor->GetMapper()->Update();

	// this could possibly be any type of DataSet, VTKActorToOSG assumes polyData
	if (strcmp(actor->GetMapper()->GetInput()->GetClassName(), "vtkPolyData"))
	{
		std::cerr << "ERROR! Actor must use a vtkPolyDataMapper." << std::endl;
		std::cerr << "If you are using a vtkDataSetMapper, use vtkGeometryFilter instead." << std::endl;
		return NULL;
	}

	// if geode doesn't exist, then create a new one
	if (!geode.valid())
		geode = new osg::Geode();

	// get poly data
	vtkPolyData *polyData = (vtkPolyData *) actor->GetMapper()->GetInput();

	// get primitive arrays
	osg::ref_ptr<osg::Geometry> points, lines, polys, strips;

	// create new Geometry for the Geode
	points = processPrimitive(actor, polyData->GetVerts(), osg::PrimitiveSet::POINTS, verbose);
	lines = processPrimitive(actor, polyData->GetLines(), osg::PrimitiveSet::LINE_STRIP, verbose);
	polys = processPrimitive(actor, polyData->GetPolys(), osg::PrimitiveSet::POLYGON, verbose);
	strips = processPrimitive(actor, polyData->GetStrips(), osg::PrimitiveSet::TRIANGLE_STRIP, verbose);

	// remove old gsets and delete them
	geode->removeDrawables(0, geode->getNumDrawables());

	if (points.valid())
		geode->addDrawable(points.get());
	if (lines.valid())
		geode->addDrawable(lines.get());
	if (polys.valid())
		geode->addDrawable(polys.get());
	if (strips.valid())
		geode->addDrawable(strips.get());

	return geode;
}
Пример #5
0
  void GridVisualizationBase::loadImageAsRectangle(osg::ref_ptr<osg::Geode> geode,
						   osg::ref_ptr<osg::Image> image,
						   float pos_x1,float pos_y1,float pos_x2,float pos_y2)const
  {
    if(! (image.valid()))
    {
      std::cout << "Error Loading Texture: Image is not valid " << std::endl;
      exit(0);
    }
    // Create a Geometry object.
    osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
    
    //full color display
    osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
    geom->setColorArray( c.get() );
    geom->setColorBinding( osg::Geometry::BIND_OVERALL );
    c->push_back( osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f ) );
    
    //set texture coordinates
    osg::ref_ptr<osg::Vec2dArray>  texture_coordinates = new osg::Vec2dArray;
    texture_coordinates->push_back(osg::Vec2d(0,0));
    texture_coordinates->push_back(osg::Vec2d(1,0));
    texture_coordinates->push_back(osg::Vec2d(1,1));
    texture_coordinates->push_back(osg::Vec2d(0,1));
    geom->setTexCoordArray(0, texture_coordinates.get());
    
    // Specify the vertices:
    osg::ref_ptr<osg::Vec3Array>  vertice_array = new osg::Vec3Array;
    vertice_array->push_back(osg::Vec3(pos_x1,pos_y1,0));
    vertice_array->push_back(osg::Vec3(pos_x2,pos_y1,0));
    vertice_array->push_back(osg::Vec3(pos_x2,pos_y2,0));
    vertice_array->push_back(osg::Vec3(pos_x1,pos_y2,0));
    // Associate this set of vertices with the geometry associated with the geode 
    geom->setVertexArray(vertice_array);
   
     // Create a QUAD primitive by specifying the 
     // vertices from our vertex list that make up this QUAD:

    // Add primitive to the geometry
    geom->addPrimitiveSet(new osg::DrawArrays( osg::PrimitiveSet::POLYGON, 0, vertice_array->size() ) );
    
    // Attach the image in a Texture2D object
    osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
    texture->setImage( image.get() );

    osg::StateSet *state = geom->getOrCreateStateSet();
    
    //apply texture to geom
    state->setTextureAttributeAndModes(0, texture.get());
    
    //remove old drawables
    while(geode->removeDrawables(0));
    //add a mew one
    geode->addDrawable(geom.get());  
  }
Пример #6
0
void Scene::createVertexNode()
{
    _vgeode = new osg::Geode;
    _vgeode->setDataVariance(osg::Object::DYNAMIC);

    osg::Vec3f lightDir(1.0f, 1.0f, 1.0f);
    lightDir.normalize();

    auto offsets = new osg::Uniform(osg::Uniform::FLOAT_VEC3, "offsets", Scene::VertexInstances);
    offsets->setDataVariance(osg::Object::DYNAMIC);

    auto stateSet = _vgeode->getOrCreateStateSet();
    stateSet->setAttributeAndModes(_instancedProgram, osg::StateAttribute::ON);
    stateSet->addUniform(new osg::Uniform("ecLightDirection", lightDir));
    stateSet->addUniform(new osg::Uniform("lightColor", osg::Vec3(1.0f, 1.0f, 1.0f)));
    stateSet->addUniform(offsets);

    osg::Vec3 scale(1.0f, 1.0f, 1.0f);
    osg::Vec4 color(0.25f, 0.25f, 0.25f, 1.0f);

    auto vertexMatrix = osg::Matrixf::scale(scale * 0.125f * 0.25f);
    auto normalMatrix = inverseTranspose(vertexMatrix);

    _vgeometry = new osgKaleido::PolyhedronGeometry("#27");
    _vgeometry->setUseDisplayList(false);
    _vgeometry->setUseVertexBufferObjects(true);

    _vgeometry->update(nullptr); // Force geometry generation

    auto vertices = dynamic_cast<osg::Vec3Array*>(_vgeometry->getVertexArray());
    if (vertices != nullptr) {
        transform(*vertices, vertexMatrix);
    }

    auto normals = dynamic_cast<osg::Vec3Array*>(_vgeometry->getNormalArray());
    if (normals != nullptr) {
        transform(*normals, normalMatrix);
    }

    auto colors = dynamic_cast<osg::Vec4Array*>(_vgeometry->getColorArray());
    if (colors != nullptr) {
        fill(*colors, color);
    }

    makeInstanced(_vgeometry, Scene::VertexInstances);

    auto size = 1.0f;
    osg::BoundingBox bb(-size, -size, -size, +size, +size, +size);
    _vgeometry->setInitialBound(bb);

    _vgeode->addDrawable(_vgeometry);

    addChild(_vgeode);
}
Пример #7
0
void Scene::createPolyhedronNode()
{
    _pgeode = new osg::Geode;
    _pgeode->setDataVariance(osg::Object::DYNAMIC);

    osg::Vec3f lightDir(0.0f, 0.0f, 1.0f);
    lightDir.normalize();

    auto stateSet = _pgeode->getOrCreateStateSet();
    stateSet->setAttributeAndModes(_twoSidedProgram, osg::StateAttribute::ON);
    stateSet->addUniform(new osg::Uniform("ecLightDirection", lightDir));
    stateSet->addUniform(new osg::Uniform("lightColor", osg::Vec3(1.0f, 1.0f, 1.0f)));

    _pgeometry = new osgKaleido::PolyhedronGeometry("#27");
    _pgeometry->setUseDisplayList(false);
    _pgeometry->setUseVertexBufferObjects(true);

    _pgeode->addDrawable(_pgeometry);

    addChild(_pgeode);
}
Пример #8
0
void LSysPlant::drawPlant(osg::ref_ptr<osg::Geode> &node)
{
    generatePlantWord();
    generatePlant();

    osg::ref_ptr<osg::Geometry> line_loop = new osg::Geometry;
    line_loop->setVertexArray( _vertices.get() );
    line_loop->addPrimitiveSet( _indices.get() );
    osgUtil::SmoothingVisitor::smooth( *line_loop );

    vector<NaturalCubicSpline> branch_splines;
    int element_count = 0;

    for(int i = 0; i < _branches.size(); i++)
    {
        element_count = (*_branches[i]).getNumElements();
        
        if(element_count == 1)
        {
            printf("Branch %d had just 1 vertex!\n", i);
            continue;
        }

        //for(int j = 0; j < element_count; j++)
        //{
            //printf("%d %f %f %f\n", i, 
                    //(*_branches[i])[j].x(),
                    //(*_branches[i])[j].y(),
                    //(*_branches[i])[j].z());
        //}

        node->addDrawable(  NaturalCubicSpline(_branches[i],3).drawExtrudedCylinder(3, 0.05f) );
        //node->addDrawable(  NaturalCubicSpline(_branches[i]).drawSpline() );
    }

    /*node->addDrawable( line_loop.get() );*/
}
int initViewer()
{
    //Creating the root node
    //osg::ref_ptr<osg::Group> root (new osg::Group);

    //The geode containing our shpae
    //osg::ref_ptr<osg::Geode> myshapegeode (new osg::Geode);

    //Our shape: a capsule, it could have been any other geometry (a box, plane, cylinder etc.)
    //osg::ref_ptr<osg::Capsule> myCapsule (new osg::Capsule(osg::Vec3f(),1,2));

    //Our shape drawable
    //osg::ref_ptr<osg::ShapeDrawable> capsuledrawable (new osg::ShapeDrawable(myCapsule.get()));

    //myshapegeode->addDrawable(capsuledrawable.get());

    // create Geometry object to store all the vertices and lines primitive.
    osg::Geometry* stopLinesGeom = new osg::Geometry();
    osg::Geometry* brakeLinesGeom = new osg::Geometry();
    osg::Geometry* slowLinesGeom = new osg::Geometry();
    osg::Geometry* outlineGeom = new osg::Geometry();
    osg::Geometry* originGeom = new osg::Geometry();
    stopLinesGeom->setUseDisplayList( false );
    brakeLinesGeom->setUseDisplayList( false );
    slowLinesGeom->setUseDisplayList( false );
    outlineGeom->setUseDisplayList( false );
    originGeom->setUseDisplayList( false );

    // pass the created vertex array to the points geometry object.
    stopLinesGeom->setVertexArray(stopVertices);
    brakeLinesGeom->setVertexArray(brakeVertices);
    slowLinesGeom->setVertexArray(slowVertices);
    outlineGeom->setVertexArray(outlineVertices);
    originGeom->setVertexArray(originVertices);
    
    // set the colors as before, plus using the above
    osg::Vec4Array* stopColors = new osg::Vec4Array;
    osg::Vec4Array* brakeColors = new osg::Vec4Array;
    osg::Vec4Array* slowColors = new osg::Vec4Array;
    osg::Vec4Array* outlineColors = new osg::Vec4Array;
    osg::Vec4Array* originColors = new osg::Vec4Array;
    
    stopLinesGeom->setColorArray(stopColors);
    brakeLinesGeom->setColorArray(brakeColors);
    slowLinesGeom->setColorArray(slowColors);
    outlineGeom->setColorArray(outlineColors);
    originGeom->setColorArray(originColors);

    stopLinesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
    brakeLinesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
    slowLinesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
    outlineGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
    originGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
    
    stopColors->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f)); //red
    brakeColors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); //yellow
    slowColors->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f)); //green
    //outlineColors->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f)); //red
    outlineColors->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f)); //green
    originColors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); //white

    // set the normal in the same way color.
    osg::Vec3Array* normals = new osg::Vec3Array;
    normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));

    stopLinesGeom->setNormalArray(normals);
    stopLinesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
    brakeLinesGeom->setNormalArray(normals);
    brakeLinesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
    slowLinesGeom->setNormalArray(normals);
    slowLinesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
    
    outlineGeom->setNormalArray(normals);
    outlineGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
    
    originGeom->setNormalArray(normals);
    originGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);

    // This time we simply use primitive, and hardwire the number of coords to use
    // since we know up front,
    if (DRAW_OUTLINE) {
        outlineGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,NUM_VERTS));
        myshapegeode->addDrawable(outlineGeom);
    }

    if (DRAW_RAYS) {
        stopLinesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,NUM_VERTS));
        brakeLinesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,NUM_VERTS));
        slowLinesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,NUM_VERTS));
        myshapegeode->addDrawable(stopLinesGeom);
        myshapegeode->addDrawable(brakeLinesGeom);
        myshapegeode->addDrawable(slowLinesGeom);
    }

    if (DRAW_ORIGIN) {
        originGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,NUM_VERTS));
        myshapegeode->addDrawable(originGeom);
    }

    // add the points geometry to the geode.
    myshapegeode->setDataVariance(osg::Object::DYNAMIC);

    root->addChild(myshapegeode.get());

    //The geode containing our shpae
    osg::ref_ptr<osg::Geode> myTextGeode (new osg::Geode);
    
    //osgText::Text* myText = new osgText::Text();

    // Geode - Since osgText::Text is a derived class from drawable, we 
    // must add it to an osg::Geode before we can add it to our ScenGraph.
    myTextGeode->addDrawable(myText);

    //Set the screen alignment - always face the screen
    myText->setAxisAlignment(osgText::Text::SCREEN);

    //Set the text to our default text string
    myText->setText("Default Text");


    //myText->setPosition(osg::Vec3d(25, 75, 0));
    myText->setPosition(osg::Vec3d(0, 0, 0));
    myText->setColor(osg::Vec4d(1.0f, 1.0f, 1.0f, 1.0f));
    myText->setCharacterSize(48);
    //myText->setFont("./fonts/Vera.ttf");
   
    char output[256] = "";
    sprintf(output, "epoch: %d, scanNumber: %s, totalBytesRead: %d, stop: %d, closest_y: %d, speed: %f\n", (int)time(0), scanNumber, totalBytesRead, stop, closest_y_cm, speed);

    myText->setText(output);

    root->addChild(myTextGeode.get());


    root->setUpdateCallback(new redrawCallback);

    viewer.setSceneData( root.get() );
    //viewer.setThreadingModel(osgViewer::Viewer::ThreadingModel::SingleThreaded);

    //Stats Event Handler s key
    //viewer.addEventHandler(new osgViewer::StatsHandler);

    //Windows size handler
    //viewer.addEventHandler(new osgViewer::WindowSizeHandler);

    // add the state manipulator
    //viewer.addEventHandler( new       osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );

    //The viewer.run() method starts the threads and the traversals.
    return (viewer.run());
}
void osgMain::createPipe(osg::Vec3 & pt1, osg::Vec3 & pt2, osg::Vec3 & pt3, osg::Vec3Array* shape,bool startPt,osg::ref_ptr<osg::Geode>  & currentLine)
{
	__android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe");
    //shape must be at xy plane
    if(shape->size()<3)
    {
    	__android_log_print(ANDROID_LOG_ERROR,"jni server","create pipe NOOOO");
    	return ;
    }

    //currentLine->addDrawable(new osg::ShapeDrawable(new osg::Sphere(pt3,1.0f)));
    //return;
    osg::Vec3 v12=(pt1-pt2);
    v12.normalize();
    osg::Vec3 v32=(pt3-pt2);
    v32.normalize();
    osg::ref_ptr<osg::Vec3Array> startShape;
    osg::Vec3 center(0,0,0);
    for(int i=0;i<shape->size();i++)
        center=center+shape->at(i);
    center=center/(float)shape->size();
    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK1");
    if(startPt)
    {
    	 __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK2");
        startShape=new osg::Vec3Array;

        osg::Vec3 posZ(0.0,0.0,1.0);
        osg::Vec3 rotAxis=posZ^(-v12);
        if(rotAxis.length2()<0.01f)
            return ;
        float rotAngle=(float)acos((double)(posZ*(-v12)));
        osg::Matrixd mat;
        mat.makeRotate(rotAngle,rotAxis);
        for(int i=0;i<shape->size();i++)
            startShape->push_back(mat.preMult(shape->at(i)-center)+pt1);
        __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK3");
    }
    else
        startShape=shape;

    osg::Vec3 p2Dir;
    osg::Vec3 half=(v12+v32)/2.0f;
    half.normalize();
    osg::Vec3 p2DirOrtho=v12^half;
    p2DirOrtho.normalize();
    p2Dir=p2DirOrtho^half;
    p2Dir.normalize();

    osg::Vec3 shapeDir=(startShape->at(2)-startShape->at(1))^(startShape->at(0)-startShape->at(1));
    shapeDir.normalize();
    if(shapeDir*(-v12)<0.0)
        shapeDir=-shapeDir;
    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK3");
    osg::ref_ptr<osg::Vec3Array> p2Shape=new osg::Vec3Array;
    osg::Vec3 rotAxis=shapeDir^p2Dir;
    float rotAngle=(float)acos((double)(shapeDir*p2Dir));
    osg::Matrixd mat;
    mat.makeRotate(rotAngle,rotAxis);
    osg::Vec3 trans=pt2-pt1;
    center.set(0,0,0);
    for(int i=0;i<startShape->size();i++)
        center=center+startShape->at(i);
    center=center/(float)startShape->size();
    for(int i=0;i<startShape->size();i++)
        p2Shape->push_back(mat.preMult(startShape->at(i)-center)+center+trans);

    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK4");
    osg::ref_ptr<osg::Geometry> pipe=new osg::Geometry;

    osg::ref_ptr<osg::Vec3Array> allVerts=new osg::Vec3Array;
    int numVerts=p2Shape->size();
    for(unsigned int i=0;i<numVerts;i++)
    {
        allVerts->push_back(startShape->at(i));
        allVerts->push_back(startShape->at((i+1)%numVerts));
        allVerts->push_back(p2Shape->at(i));
        allVerts->push_back(startShape->at((i+1)%numVerts));
        allVerts->push_back(p2Shape->at((i+1)%numVerts));
        allVerts->push_back(p2Shape->at(i));
    }
    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK5");
    pipe->setVertexArray(allVerts.get());

    osg::ref_ptr<osg::DrawArrays> array=new osg::DrawArrays(GL_TRIANGLES,0,allVerts->size());
    pipe->addPrimitiveSet(array);
    osgUtil::SmoothingVisitor::smooth(*pipe);
    for(int i=0;i<numVerts;i++)
        shape->at(i)=p2Shape->at(i);
    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe OK6");
    if(startPt)
    {
        //currentLine=new osg::Geode();
        currentLine->addDrawable(pipe);
    }
    else
    {
         osgUtil::Optimizer::MergeGeometryVisitor::mergeGeometry(*currentLine->getDrawable(0)->asGeometry(),*pipe);
    }
    //return pipe.release();
    __android_log_print(ANDROID_LOG_ERROR,"jni client","create pipe finish");

}