Hi,

you're setting up a texture on your geode without actually setting texture
coordinates. OpenGL will helpfully ;-) pick up coordinates from the last
textured object for you.

Quoting Shawn Cook <[EMAIL PROTECTED]>:
> // create Geometry object to store all the vetices and lines primtive.
> nodeGeode = new osg::Geode();
> modelXForm->addChild(nodeGeode.get());
> osg::Geometry* polyGeom = new osg::Geometry();
> osg::Vec3Array* vertices = new osg::Vec3Array();
> polyGeom->setVertexArray(vertices);
>
> // color
> osg::Vec4Array* colors = new osg::Vec4Array;
> colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
> polyGeom->setColorArray(colors);
> polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
> //texture
> osg::ref_ptr<osg::StateSet> stateset;
> osg::ref_ptr<osg::Texture2D> texture;
> if (nodeImage.get())
> {
> stateset = new osg::StateSet;
> texture = new osg::Texture2D;
> texture->setImage(nodeImage.get());
>
stateset->setTextureAttributeAndModes(0,texture.get(),osg::StateAttribute::ON);
>
> osg::BlendFunc *blendFunc = new osg::BlendFunc;
> blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE);
> stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
> stateset->setAttributeAndModes(new osg::BlendFunc, osg::StateAttribute::ON );
> stateset->setAttributeAndModes( blendFunc, osg::StateAttribute::ON );
> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> }
> nodeTcoords = new osg::Vec2Array();
> polyGeom->setStateSet(stateset.get());
> //normals
> osg::Vec3Array* normals = new osg::Vec3Array;
> normals->push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
> polyGeom->setNormalArray(normals);
> polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
> //add to nodeGeode
> nodeGeode->addDrawable(polyGeom);
> }//Create nodes
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to