How can I get the vertices from the TriangleIndexFunctor?  The operator() only receives 3 unsigned ints which are the indices.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield
Sent: Wednesday, August 30, 2006 4:39 AM
To: osg users
Subject: Re: [osg-users] Collecting vertex array... is this correct?

 

Hi Jeff,

You are working along the right lines. Personally I'd use the TriangleIndexFunctor rather than the TriangleFunctor as this way you'll be able to better account for vertices that are used more than once, as you'll be passed a Vec3* point, as well as the index into.

Robert.

On 8/29/06, Jeff Kershner <[EMAIL PROTECTED]> wrote:

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/

Reply via email to