# Ply Files

This topic is 3669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, Can anyone tell me how ply files work? I dont understand what the faces tell us exactly in order to place the vertices in their correct place

##### Share on other sites
Here's an example ply for reference:

ply
format ascii 1.0
element vertex 11
property float x
property float y
property float z
element face 11
property list uchar int vertex_indices
0 1 0
0 3 0
2 0 0
2 2 0
2 4 0
3 2 10
4 1.8 0
4 2.2 0
6 0 0
6 2 0
6 4 0
3 0 2 3
3 0 3 1
3 1 3 4
3 2 6 3
3 3 6 5
3 3 5 7
3 3 7 4
3 5 6 7
3 6 8 9
3 6 9 7
3 7 9 10

##### Share on other sites
Looks like the header says you first how many vertices you have,
and which components they have.

In your case 11 vertices with x,y and z coordinates.

And it tells you that you have 11 faces (quads in your case).

0 1 0
0 3 0
2 0 0
2 2 0
2 4 0
3 2 10
4 1.8 0
4 2.2 0
6 0 0
6 2 0
6 4 0

And your vertex indices for the faces are:

3 0 2 3
3 0 3 1
3 1 3 4
3 2 6 3
3 3 6 5
3 3 5 7
3 3 7 4
3 5 6 7
3 6 8 9
3 6 9 7
3 7 9 10

Hth,
Marc

##### Share on other sites
I m ok with that but how will I use the faces in order to create the actual shape?

I suppose the faces tell you where to place the vertices? I ve writen some code for it but it doesnt seem to work properly...

##### Share on other sites
If I'm correct with my assumption that the indices are for polygons, then
you should build your polygon according to the indices. That means
that you use the first four indices to get the vertices to draw.

In your supplied file you would draw a quad with the vertices 3,0,2,3 (First Face)
And then with the next four indices
(vertices 3, 0, 3, 1) - if you are using OpenGL you can use glBegin(GL_QUADS).

But it is not even close to being performant - for performance you have to
build an index buffer and a vertex buffer and draw with VertexBuffer Objects or
the equivalents in DirectX.

Marc

##### Share on other sites
Its triangles as the first one shows how many corners there are, or so I guess.

I found out what was my problem, in the end I had understood what ply files have in them but I had put the wrong number in the tables so they looked up the previous face.

Thanks though :)

##### Share on other sites
Indeed, I haven't looked at the following numbers :)
So building a vertex buffer should be no problem..

Marc

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013394
×