Hi All,
The question below is being forwarded from "Larry"...
I was wondering if someone could explain how setVertexAttribIndices
works. In my application, I have an array of vertices that I set for my
geometry. I then build my triangle primitives using those vertices (when
I build my triangles, some vertices are used more than once). If I want
to assign an attribute variable to be accessed by my shaders, do I have
to assign it twice for the vertices that are repeated or just once? If
not, is the indexArray that I am passing into setVertexAttribIndices
array just a 1:1 mapping with the indices of my vertex array? Currently,
when I have my attribute array the same size as my vertices, I get a
segmentation fault. Here is the code I am using:
TemplateIndexArray <unsigned int, Array::UIntArrayType, 1,
GL_UNSIGNED_INT> *index;
index = new TemplateIndexArray<unsigned int, Array::UIntArrayType, 1,
GL_UNSIGNED_INT>;
for (int i = 0; i < itsVertices->size(); i++)
{
index->push_back(i); // vertex 0 assigned color array element
}
TemplateArray <GLfloat, Array::FloatArrayType, 1, GL_FLOAT>*
thePatchAttributes = new TemplateArray <GLfloat, Array::FloatArrayType,
1, GL_FLOAT>;
for (int i = 0; i < itsVertices->size(); i++)
{
thePatchAttributes->push_back(info[0] + info[1]);
}
itsGeometry->setVertexAttribArray (6, thePatchAttributes);
itsGeometry->setVertexAttribIndices(6, index);
itsGeometry->setVertexAttribBinding (6, osg::Geometry::BIND_PER_VERTEX);
Thanks.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/