Cycling through triangles in a mesh

Sorry for being unclear; what I ment was how I could cycle through the

vertices of a mesh (either through a vertex buffer or an index buffer)

so that i could apply a collision algorithm using the 3 vertices of a

triangle. I fixed my vertex buffer so that i can get an array of all

the vertices in a mesh but I don't know how to get a triangle at a

time. I tried:

Dim Tri(2) as VERTEX

For i = 0 to nVertices -1 Step 3

Tri(0) = Vertices(i)

Tri(1) = Vertices(i + 1)

Tri(2) = Vertices(i + 2)

CheckCollision(Tri)

Next i

OR:

For i = 0 to nIndices -1 Step 3

Tri(0) = Vertices(Indices(i))

Tri(1) = Vertices(Indices(i + 1))

Tri(2) = Vertices(Indices(i + 2))

CheckCollision(Tri)

Next i

I've tried both methods but both generated triangles that didn't exist

in the mesh (i.e. the vertices weren't in order).

I apprieciate your help :)

-Flav

Quote:

> do you mean read the data or draw?

> to read, you need to lock and step thru the pointer.

> to draw, use a triangle list, and then each set of 3 vertices defines a

> triangle. this can either be implicit ordering, or explicit ordering using

> an index buffer.

> iirc, SDK samples do use index buffers so there are examples.

> --

> Phil Taylor

> PM : DirectX SDK, Managed DirectX, Windows XP Inbox 3D screensavers, and a

> few more bits and bobs.

> http://msdn.microsoft.com/directx

> This posting is provided "AS IS" with no warranties, and confers no rights.

> > How can I cycle through all the triangles of a mesh (3 verticies at a

> > time)? I've tried using an index buffer with a vertex buffer with no

> > success. Any help would be greatly appriciated. Thx,

> > -Flav