An improvement would be to use a osg::Vec3Array instead of a std::vector<float> m_VertexList. An osg::Vec3Array is, in essence, an std::vector<osg::Vec3> ... . This keeps your triples together.
-don
I am using the TriangleFunctor like Robert suggested to get triangle information. What I need is a vertex buffer that I can give to the physics objects. Something is not working between OSG and ODE and I am not sure if I am not getting the triangles correctly.
This is what I do:
struct Triangle
{
void operator() (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool)
{
m_VertexList.push_back(v1[0]);
m_VertexList.push_back(v1[1]);
m_VertexList.push_back(v1[2]);
m_VertexList.push_back(v2[0]);
m_VertexList.push_back(v2[1]);
m_VertexList.push_back(v2[2]);
m_VertexList.push_back(v3[0]);
m_VertexList.push_back(v3[1]);
m_VertexList.push_back(v3[2]);
}
std::vector<float> m_VertexList;
};
…
osg::TriangleFunctor<Triangle> tf;
pGeometry->accept(tf);
So after this m_VertexList should be a list of all the vertices… correct?
Then to create a vertex array I am doing the following:
float* pVertexArray = new float[tf.m_VertexList.size()];
int c = 0;
for (vector<float>::iterator it = tf.m_VertexList.begin(); it != tf.VertexList.end(); it++)
pVertexBuffer[c++] = *it;
Is this a correct to create a Vertex Array?
/jk
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
