[osg-users] TriangleMesh color
Ben Axelrod
baxelrod at coroware.com
Wed May 14 15:10:47 PDT 2008
Hi,
I am trying to use a triangle mesh. And for some reason, it always shows up black. Here is a snipit of code:
osg::ref_ptr<osg::Geode> _geode;
_geode = new osg::Geode();
osg::ref_ptr<osg::TriangleMesh> _trimesh;
_trimesh = new osg::TriangleMesh();
osg::ref_ptr<osg::ShapeDrawable> _SD;
_SD = new osg::ShapeDrawable(_trimesh.get());
_SD->setColor(osg::Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
_geode->addDrawable(_SD.get());
osg::Vec3Array* vecs = new osg::Vec3Array();
vecs->push_back(osg::Vec3d(0, 0, 0));
vecs->push_back(osg::Vec3d(1, 0, 0));
vecs->push_back(osg::Vec3d(0, 0, 1));
_trimesh->setVertices(vecs);
osg::TemplateIndexArray<unsigned int, osg::Array::UIntArrayType, 1, 1>* ind =
new osg::TemplateIndexArray<unsigned int, osg::Array::UIntArrayType, 1, 1>();
ind->push_back(0);
ind->push_back(1);
ind->push_back(2);
_trimesh->setIndices(ind);
As you can see, the TriangleMesh is a child of a ShapeDrawable node, which should set its color to white. This technique has worked great for the other shape primitives. Is there another way to set the color for a TriangleMesh? Or is there another way I should construct my tree? Or is it a bug?
Thanks,
-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080514/befd5898/attachment.htm>
More information about the osg-users
mailing list