Пример #1
0
Geode* createTextureQuad(Texture2D *texture)
{
    Vec3Array *vertices = new Vec3Array;
    vertices->push_back(Vec3(-1.0, -1.0, 0.0));
    vertices->push_back(Vec3(1.0, -1.0, 0.0));
    vertices->push_back(Vec3(1.0, 1.0, 0.0));
    vertices->push_back(Vec3(-1.0, 1.0, 0.0));

    Vec2Array *texcoord = new Vec2Array;
    texcoord->push_back(Vec2(0.0, 0.0));
    texcoord->push_back(Vec2(1.0, 0.0));
    texcoord->push_back(Vec2(1.0, 1.0));
    texcoord->push_back(Vec2(0.0, 1.0));

    Geometry *geom = new Geometry;
    geom->setVertexArray(vertices);
    geom->setTexCoordArray(0, texcoord);
    geom->addPrimitiveSet(new DrawArrays(GL_QUADS, 0, 4));

    Geode *geode = new Geode;
    geode->addDrawable(geom);
    geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, StateAttribute::ON);

    return geode;
}
Пример #2
0
void Marker::init(GeometryType gt, Interaction *interaction, float size, Vec4 &color)
{
    Geode *geode;

    _gt = gt;
    if (_gt == CONE)
        geode = createCone(color);
    else if (_gt == BOX)
        geode = createBox(color);
    else
        geode = createSphere(color);

    setSize(size);
    setColor(color);

    // Make sure lighting is correct when marker is scaled:
    StateSet *stateSet = geode->getOrCreateStateSet();
    stateSet->setMode(GL_RESCALE_NORMAL, StateAttribute::ON);
    //stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); // Philip added this else the color is not visible in opencover

    _interaction = interaction;
    _node->addChild(geode);

    if (_interaction)
        _interaction->addListener(this, this);
    _interactionA = new vrui::coTrackerButtonInteraction(vrui::coInteraction::ButtonA, "MarkerMove", vrui::coInteraction::Medium);
    _interactionB = NULL;
    assert(_interactionA);
}
/***************************************************************
* Function: createText()
***************************************************************/
Geode *CAVEGroupReferenceAxis::createText3D(osgText::Text3D **text)
{
    Geode *textGeode = new Geode;
    *text = new osgText::Text3D;
    textGeode->addDrawable(*text);

    (*text)->setFont(CAVEGeode::getDataDir() + "Fonts/TN.ttf");
    (*text)->setCharacterSize(gCharSize, 0.7);
    (*text)->setCharacterDepth(gCharDepth);
    (*text)->setPosition(Vec3(0, 0, 0));
    (*text)->setAlignment(osgText::Text3D::CENTER_BOTTOM);
    (*text)->setDrawMode(osgText::Text3D::TEXT);
    (*text)->setAxisAlignment(osgText::Text3D::XZ_PLANE);
    (*text)->setRenderMode(osgText::Text3D::PER_GLYPH);
    (*text)->setText("");

    Material *material = new Material;
    material->setDiffuse(Material::FRONT_AND_BACK, Vec4(0, 1, 0, 1));
    material->setAmbient(Material::FRONT_AND_BACK, Vec4(0, 1, 0, 1));
    material->setAlpha(Material::FRONT_AND_BACK, 1.0f);

    StateSet *stateset = textGeode->getOrCreateStateSet();
    stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
    stateset->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
    stateset->setRenderingHint(StateSet::TRANSPARENT_BIN);

    return textGeode;
}
Пример #4
0
Geode* ChessUtils::createRectangleWithTexture(Vec3 centerPosition, Image* image, int width, int height, Vec4 color) {
	int halfWidth = width / 2;
	int halfHeight = height / 2;

	Vec3Array* vertices = new Vec3Array();	
	vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));
	vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));

	Vec3Array* normals = new Vec3Array();
	normals->push_back(Vec3(0.0f, 0.0f, 1.0f));

	Vec2Array* texcoords = new Vec2Array();
	texcoords->push_back(Vec2(0.0f, 0.0f));
	texcoords->push_back(Vec2(1.0f, 0.0f));
	texcoords->push_back(Vec2(1.0f, 1.0f));
	texcoords->push_back(Vec2(0.0f, 1.0f));

	Vec4Array* colors = new Vec4Array();
	colors->push_back(color);

	Geometry* quad = new Geometry();
	quad->setVertexArray(vertices);
	quad->setNormalArray(normals);
	quad->setNormalBinding(osg::Geometry::BIND_OVERALL);	
	quad->setColorArray(colors);
	quad->setColorBinding(osg::Geometry::BIND_OVERALL);
	quad->setTexCoordArray(0, texcoords);
	quad->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4));

	Texture2D* texture = new Texture2D();
	if (image != NULL) {
		texture->setImage(image);
	}			

	Geode* geode = new Geode();
	geode->addDrawable(quad);

	osg::BlendFunc* blendFunc = new osg::BlendFunc();
	blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	osg::TexEnv* blendTexEnv = new osg::TexEnv();
	blendTexEnv->setMode(osg::TexEnv::BLEND);

	osg::StateSet* geodeStateset = geode->getOrCreateStateSet();
	geodeStateset->setAttributeAndModes(blendFunc);
	geodeStateset->setTextureAttribute(0, blendTexEnv);
	geodeStateset->setTextureAttributeAndModes(0, texture);
	geodeStateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
	
	return geode;
}
Пример #5
0
PositionAttitudeTransform *VideoGeode::createVideoSphere(float size, bool texRepeat)
{
	Geode *sphere = new Geode();
	sphere->addDrawable(new ShapeDrawable(new Sphere(Vec3(0, 0, 4), size)));
	
	// assign the material to the sphere
	StateSet *sphereStateSet = sphere->getOrCreateStateSet();
	sphereStateSet->ref();
	sphereStateSet->setAttribute(_material);
	
   try {
      sphereStateSet->setTextureAttributeAndModes(0, createVideoTexture(texRepeat), StateAttribute::ON);
   } catch (char *e) {
      throw e;
   }
	
	PositionAttitudeTransform *sphereTransform = new PositionAttitudeTransform();
	sphereTransform->addChild(sphere);
	return sphereTransform;
}
/***************************************************************
* Function: switchFloorplan()
***************************************************************/
void VirtualScenicHandler::switchFloorplan(const int &idx, const VisibilityOption &option)
{
    if (idx >= mFloorplanSwitch->getNumChildren()) 
    {
        return;
    }

    if (option == INVISIBLE)
    {
        if (mFloorplanIdx >= 0) 
        {
            mFloorplanSwitch->setSingleChildOn(mFloorplanIdx);
        }
        else 
        {
            mFloorplanSwitch->setAllChildrenOff();
        }
    }
    else 
    {
        Geode *floorplanGeode = dynamic_cast <Geode*> (mFloorplanSwitch->getChild(idx));
        StateSet *stateset = floorplanGeode->getOrCreateStateSet();
        Material *material = dynamic_cast<Material*> (stateset->getAttribute(StateAttribute::MATERIAL)); 

        if (!material) 
        {
            material = new Material;
        }

        if (option == TRANSPARENT)
        {
            material->setAlpha(Material::FRONT_AND_BACK, 0.5f);
        }
        else if (option == SOLID)
        {
            material->setAlpha(Material::FRONT_AND_BACK, 1.0f);
            mFloorplanIdx = idx;
        }
        mFloorplanSwitch->setSingleChildOn(idx);
    }
}
Пример #7
0
PositionAttitudeTransform *VideoGeode::createVideoPlane(float sizeX, float sizeY, bool texRepeat)
{
	// vertex array
	Vec3Array *vertexArray = new Vec3Array();
   
   sizeX /= 2.0;
   sizeY /= 2.0;
	
   vertexArray->push_back(Vec3(-sizeX, 0, -sizeY));
	vertexArray->push_back(Vec3(sizeX, 0, -sizeY));
	vertexArray->push_back(Vec3(sizeX, 0, sizeY));
	vertexArray->push_back(Vec3(-sizeX, 0, sizeY));

	
   /*vertexArray->push_back(Vec3(-sizeX, -sizeY, 0));
	vertexArray->push_back(Vec3(sizeX, -sizeY, 0));
	vertexArray->push_back(Vec3(sizeX, sizeY, 0));
	vertexArray->push_back(Vec3(-sizeX, sizeY, 0));*/
   
	// face array
	DrawElementsUInt *faceArray = new DrawElementsUInt(PrimitiveSet::TRIANGLES, 0);
	
	faceArray->push_back(0); // face 1
	faceArray->push_back(1);
	faceArray->push_back(2);
	faceArray->push_back(2); // face 2
	faceArray->push_back(3);
	faceArray->push_back(0);
	
	// normal array
	Vec3Array *normalArray = new Vec3Array();
	normalArray->push_back(Vec3(0, 0, 1));
	
	// normal index
	TemplateIndexArray<unsigned int, Array::UIntArrayType, 24, 4> *normalIndexArray;
	normalIndexArray = new TemplateIndexArray<unsigned int, Array::UIntArrayType, 24, 4>();
	
	normalIndexArray->push_back(0);
	normalIndexArray->push_back(0);
	normalIndexArray->push_back(0);
	normalIndexArray->push_back(0);
	
	// texture coordinates
	Vec2Array *texCoords = new Vec2Array();
	texCoords->push_back(Vec2(0.0f, 0.0f));
	texCoords->push_back(Vec2(1.0f, 0.0f));
	texCoords->push_back(Vec2(1.0f, 1.0f));
	texCoords->push_back(Vec2(0.0f, 1.0f));
	
	Geometry *geometry = new Geometry();
	geometry->setVertexArray(vertexArray);
	geometry->setNormalArray(normalArray);
	geometry->setNormalIndices(normalIndexArray);
	geometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
	geometry->setTexCoordArray(0, texCoords);
	geometry->addPrimitiveSet(faceArray);
	
	Geode *plane = new Geode();
	plane->addDrawable(geometry);
	
	// assign the material to the sphere
	StateSet *planeStateSet = plane->getOrCreateStateSet();
	planeStateSet->ref();
	planeStateSet->setAttribute(_material);
	
   try {
		planeStateSet->setTextureAttributeAndModes(0, createVideoTexture(texRepeat), StateAttribute::ON);
   } catch (char *e) {
      throw e;
   }
	
	PositionAttitudeTransform *planeTransform = new PositionAttitudeTransform();
	planeTransform->addChild(plane);
	return planeTransform;
}
Пример #8
0
osg::Node *JTOpenPlugin::createShape(JtkShape *partShape, const char *objName)
{
    //cout << "JtkSHAPE\n";

    Geode *geode = new Geode();
    ref_ptr<Geometry> geom = new Geometry();
    StateSet *geoState = geode->getOrCreateStateSet();
    Vec3Array *vert = new Vec3Array;
    Vec3Array *normalArray = new Vec3Array();
    Vec3Array *colorArray = new Vec3Array();
    Vec2Array *tcArray = new Vec2Array();

    DrawArrayLengths *primitives = NULL;
    if (partShape->typeID() == JtkEntity::JtkPOLYGONSET)
    {
        primitives = new DrawArrayLengths(PrimitiveSet::POLYGON);
    }
    else if (partShape->typeID() == JtkEntity::JtkLINESTRIPSET)
    {
        primitives = new DrawArrayLengths(PrimitiveSet::LINE_STRIP);
    }
    else if (partShape->typeID() == JtkEntity::JtkTRISTRIPSET)
    {
        primitives = new DrawArrayLengths(PrimitiveSet::TRIANGLE_STRIP);
    }
    else
    {
        cerr << "unknown partShape->typeID " << partShape->typeID() << endl;
    }
    geode->setName(objName);
    if (primitives)
    {
        for (int set = 0; set < partShape->numOfSets(); set++)
        {
            float *vertex = NULL,
                  *normal = NULL,
                  *color = NULL,
                  *texture = NULL;
            int vertexCount = -1,
                normCount = -1,
                colorCount = -1,
                textCount = -1;

            partShape->getInternal(vertex, vertexCount, normal, normCount,
                                   color, colorCount, texture, textCount, set);

            primitives->push_back(vertexCount);

            // backFaceCulling nur dann, wenn es im CoviseConfig enabled ist
            /*if(backFaceCulling && (mask & Viewer::MASK_SOLID))
         {
         CullFace *cullFace = new CullFace();        // da viele Modelle backface Culling nicht vertragen (nicht richtig modelliert sind)
         cullFace->setMode(CullFace::BACK);
         geoState->setAttributeAndModes(cullFace, StateAttribute::ON);
         }

         // already done in updateMaterial()
         #if 0
         if(Blended)
         {
         BlendFunc *blendFunc = new BlendFunc();
         blendFunc->setFunction(BlendFunc::SRC_ALPHA, BlendFunc::ONE_MINUS_SRC_ALPHA);
         geoState->setAttributeAndModes(blendFunc, StateAttribute::ON);
         #if 1
         AlphaFunc *alphaFunc = new AlphaFunc();
         alphaFunc->setFunction(AlphaFunc::ALWAYS,1.0);
         geoState->setAttributeAndModes(alphaFunc, StateAttribute::OFF);
         #endif
         }
         #endif
         #ifdef HAVE_OSGNV
         if((strncmp(d_currentObject->node->name(),"combineTextures",15)==0)||(strncmp(objName,"combineTextures",15)==0))
         {
         geoState->setAttributeAndModes(combineTextures.get(), StateAttribute::ON);
         }
         if((strncmp(d_currentObject->node->name(),"combineEnvTextures",15)==0)||(strncmp(objName,"combineEnvTextures",15)==0))
         {
         geoState->setAttributeAndModes(combineEnvTextures.get(), StateAttribute::ON);
         }
         #endif*/

            if (vertex && (vertexCount > 0))
            {
                for (int elems = 0; elems < vertexCount; elems++)
                {
                    vert->push_back(Vec3(vertex[elems * 3 + 0], vertex[elems * 3 + 1], vertex[elems * 3 + 2]));
                }
                JtkEntityFactory::deleteMemory(vertex);
            }

            if (normal && (normCount > 0))
            {
                for (int elems = 0; elems < normCount; elems++)
                {
                    normalArray->push_back(Vec3(normal[elems * 3 + 0], normal[elems * 3 + 1], normal[elems * 3 + 2]));
                }
                if (normCount == vertexCount)
                {
                }
                else
                {
                    //geom->setNormalBinding(Geometry::BIND_PER_PRIMITIVE);
                    std::cerr << "JTOpen: normals per primitive not supported" << std::endl;
                }
                JtkEntityFactory::deleteMemory(normal);
            }
            else // generate normals
            {
            }

            if (color && (colorCount > 0))
            {

                for (int elems = 0; elems < colorCount; elems++)
                {
                    colorArray->push_back(Vec3(color[elems * 3 + 0], color[elems * 3 + 1], color[elems * 3 + 2]));
                }

                if (colorCount == vertexCount)
                {
                }
                else
                {
                    //geom->setColorBinding(Geometry::BIND_PER_PRIMITIVE);
                    std::cerr << "JTOpen: colors per primitive not supported" << std::endl;
                }
                JtkEntityFactory::deleteMemory(color);
            }

            if (texture && (textCount > 0))
            {

                for (int elems = 0; elems < textCount; elems++)
                {
                    tcArray->push_back(Vec2(texture[elems * 2 + 0], texture[elems * 2 + 1]));
                }
                JtkEntityFactory::deleteMemory(texture);
            }

            /*   if(!(mask & Viewer::MASK_CONVEX))
         {
         osgUtil::Tesselator *tess = new osgUtil::Tesselator;
         tess->retesselatePolygons(*geom);
         //delete[] tess;
         }*/

            // if enabled, generate tri strips, but not for animated objects
            // if(genStrips && strncmp(objName, "Animated", 8))
            {
                //      d_stripper->stripify(*geom);
            }
        }
        geom->setVertexArray(vert);
        geom->addPrimitiveSet(primitives);
        if (normalArray->size() > 0)
        {
            geom->setNormalArray(normalArray);
            geom->setNormalBinding(Geometry::BIND_PER_VERTEX);
        }
        if (colorArray->size() > 0)
        {
            geom->setColorArray(colorArray);
            geom->setColorBinding(Geometry::BIND_PER_VERTEX);
        }
        if (tcArray->size() > 0)
            geom->setTexCoordArray(0, tcArray);
        if (normalArray->size() == 0)
        {
            osgUtil::SmoothingVisitor::smooth(*(geom.get()), 40.0 / 180.0 * M_PI);
        }
        geode->addDrawable(geom.get());
        geode->setStateSet(geoState);
        return geode;
    }
    return NULL;
}
Пример #9
0
Geode *ClipPlanePlugin::loadPlane()
{

    // *5---*6---*7
    // |    |    |
    // *3--------*4
    // |    |    |
    // *0---*1---*2

    float w = cover->getSceneSize() * 0.1; // width of plane

    Vec3Array *lineCoords = new Vec3Array(12);
    (*lineCoords)[0].set(-w, -0.01, -w);
    (*lineCoords)[1].set(w, -0.01, -w);
    (*lineCoords)[2].set(-w, -0.01, 0.0f);
    (*lineCoords)[3].set(w, -0.01, 0.0f);
    (*lineCoords)[4].set(-w, -0.01, w);
    (*lineCoords)[5].set(w, -0.01, w);
    (*lineCoords)[6].set(-w, -0.01, -w);
    (*lineCoords)[7].set(-w, -0.01, w);
    (*lineCoords)[8].set(0.0f, -0.01, -w);
    (*lineCoords)[9].set(0.0f, -0.01, w);
    (*lineCoords)[10].set(w, -0.01, -w);
    (*lineCoords)[11].set(w, -0.01, w);

    DrawArrayLengths *primitives = new DrawArrayLengths(PrimitiveSet::LINE_STRIP);
    for (int i = 0; i < 6; i++)
    {
        primitives->push_back(2);
    }

    Vec3Array *lineColors = new Vec3Array(12);
    for (int i = 0; i < 12; i++)
    {
        (*lineColors)[i].set(Vec3(1.0f, 1.0f, 1.0f));
    }

    Geometry *geoset = new Geometry();
    geoset->setVertexArray(lineCoords);
    geoset->addPrimitiveSet(primitives);
    geoset->setColorArray(lineColors);

    Material *mtl = new Material;
    mtl->setColorMode(Material::AMBIENT_AND_DIFFUSE);
    mtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.0f));
    mtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
    mtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
    mtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.0f));
    mtl->setShininess(Material::FRONT_AND_BACK, 16.0f);

    Geode *geode = new Geode;
    geode->setName("ClipPlane");
    geode->addDrawable(geoset);

    StateSet *geostate = geode->getOrCreateStateSet();
    geostate->setAttributeAndModes(mtl, StateAttribute::ON);
    geostate->setMode(GL_LIGHTING, StateAttribute::OFF);
    LineWidth *lineWidth = new LineWidth(3.0);
    geostate->setAttributeAndModes(lineWidth, StateAttribute::ON);
    geode->setStateSet(geostate);

    return geode;
}
/***************************************************************
* Function: createFloorplanGeometry()
***************************************************************/
void VirtualScenicHandler::createFloorplanGeometry(const int numPages, 
    CAVEAnimationModeler::ANIMPageEntry **pageEntryArray)
{
    if (numPages <= 0)
    {
        return;
    }

    for (int i = 0; i < numPages; i++)
    {
        // create floorplan geometry
        float length = pageEntryArray[i]->mLength;
        float width = pageEntryArray[i]->mWidth;
        float altitude = pageEntryArray[i]->mAlti;

        Geode *floorplanGeode = new Geode;
        Geometry *floorplanGeometry = new Geometry;

        Vec3Array* vertices = new Vec3Array;
        Vec3Array* normals = new Vec3Array;
        Vec2Array* texcoords = new Vec2Array(4);

        vertices->push_back(Vec3(-length / 2,  width / 2, altitude));	(*texcoords)[0].set(0, 1);
        vertices->push_back(Vec3(-length / 2, -width / 2, altitude));	(*texcoords)[1].set(0, 0);
        vertices->push_back(Vec3( length / 2, -width / 2, altitude));	(*texcoords)[2].set(1, 0);
        vertices->push_back(Vec3( length / 2,  width / 2, altitude));	(*texcoords)[3].set(1, 1);

        for (int k = 0; k < 4; k++) 
        { 
            normals->push_back(Vec3(0, 0, 1));
        }

        DrawElementsUInt* rectangle = new DrawElementsUInt(PrimitiveSet::POLYGON, 0);
        rectangle->push_back(0);	rectangle->push_back(1);
        rectangle->push_back(2);	rectangle->push_back(3);

        floorplanGeometry->addPrimitiveSet(rectangle);
        floorplanGeometry->setVertexArray(vertices);
        floorplanGeometry->setNormalArray(normals);
        floorplanGeometry->setTexCoordArray(0, texcoords);
        floorplanGeometry->setNormalBinding(Geometry::BIND_PER_VERTEX);

        floorplanGeode->addDrawable(floorplanGeometry);
        mFloorplanSwitch->addChild(floorplanGeode);

        /* load floorplan images */
        Material *transmaterial = new Material;
        transmaterial->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
        transmaterial->setAlpha(Material::FRONT_AND_BACK, 1.0f);

        Image* imgFloorplan = osgDB::readImageFile(pageEntryArray[i]->mTexFilename);

        Texture2D* texFloorplan = new Texture2D(imgFloorplan); 

        StateSet *floorplanStateSet = floorplanGeode->getOrCreateStateSet();
        floorplanStateSet->setTextureAttributeAndModes(0, texFloorplan, StateAttribute::ON);
        floorplanStateSet->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
        floorplanStateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
        floorplanStateSet->setAttributeAndModes(transmaterial, StateAttribute::OVERRIDE | StateAttribute::ON);
    }
}
Пример #11
0
void OsgChromosome::renderChromosome(char * file){
    Sphere * mysphere;
	ShapeDrawable * mydrawable;
	Geode* mygeode = new Geode();
    osg::ref_ptr<osg::Material> pMaterial;
	ifstream myReadFile;
    SceneObject * so = new SceneObject(file, true, true, true, true, false);
    PluginHelper::registerSceneObject(so);
    so->attachToScene();
    so->setNavigationOn(true);
    so->addMoveMenuItem();
    so->addNavigationMenuItem();
    
    // open file to read
    myReadFile.open(file);
 	string chr, start, end, comp, x, y, z, output;
    Vec3 prev, curr;
    Vec4 color;
    bool isFirst = true;
 	if (myReadFile.is_open()) {
        printf("is open\n");
            // get rid of top line  
	    getline(myReadFile, output);
            // read each table entry 
        while (!myReadFile.eof()) {
            myReadFile >> chr;
            myReadFile >> start;
            myReadFile >> end;
            myReadFile >> comp;
            myReadFile >> x;
            myReadFile >> y;
            myReadFile >> z;
            curr = Vec3(atof(x.c_str()), atof(y.c_str()), atof(z.c_str()));
            mysphere = new Sphere(curr, .02);

            mydrawable = new ShapeDrawable(mysphere);
            mygeode = new Geode();
            mygeode->addDrawable(mydrawable);
            so->addChild(mygeode);
        	//root->addChild(mygeode);

            // determine the color of the segment
            pMaterial = new osg::Material;
            if (comp.compare("A") == 0)
                color = Vec4(1,0,0,1);
            else if (comp.compare("B") == 0)
                color = Vec4(0,0,1,1);
            else
                color = Vec4(0,1,0,1);

            // set the color of the sphere
	        pMaterial->setDiffuse( osg::Material::FRONT, color);
            mygeode->getOrCreateStateSet()->setAttribute( pMaterial, osg::StateAttribute::OVERRIDE );

            // draw the cylinder bewtween spheres
            if (!isFirst) {
                //mygeode = new Geode();
                AddCylinderBetweenPoints(prev, curr, (float) .02, color, so/*(Group *) root*/);
                //root->addChild(mygeode);   
            }
            prev = curr;
            isFirst = false;
        }
        printf("get attached is %d, number of children is %d\n", so->getAttached(), so->getNumChildObjects());
    }