4

I'm jumping into the world of .ply files. I've read a little bit about them but the documentation regarding their formatting doesn't quite seem to line up with what I have in my file. I've been trying to make sense of this article here but I'm not having much luck.

This is what my .ply file looks like, format wise:

element vertex 940
property float x
property float y
property float z
property float nx
property float ny
property float nz
property float s
property float t
element face 1559
property list uchar uint vertex_indices
end_header
0.106050 -0.077401 2.338200 -0.234779 0.430097 -0.871700 0.766400 1.131300
0.093450 -0.093151 2.345250 -0.618366 0.706809 -0.343486 0.742100 1.116300
0.106050 -0.075601 2.355600 -0.792810 0.606189 -0.062685 0.774600 1.120500
0.096000 -0.103051 2.327850 0.044801 0.552751 -0.832118 0.731200 1.123200
0.057600 -0.110401 2.323950 -0.333872 0.740287 -0.583483 0.726800 1.104800

and then after a few hundred lines of that, this:

3 0 1 2
3 1 0 3
3 1 3 4
3 4 5 1
3 4 6 5
3 4 7 6
3 4 8 7
3 8 4 3
3 3 9 8
3 3 10 9
3 10 3 0
3 0 11 10
3 11 0 12
3 12 13 11
3 12 14 13
3 14 12 15
3 15 16 14
3 16 15 17
3 17 18 16
3 17 19 18
3 19 17 20
3 20 21 19
3 20 22 21
3 22 20 23
3 22 23 24

Like I said, I'm trying to make sense of it so I can write my own program to take the vertices and connect them to reform the object. Can anyone help?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sp1nt3rC311
  • 41
  • 1
  • 3

3 Answers3

3

Wikipedia has an answer for you.

The ply-file starts with a header, which offers you all relevant information about how to read the data section. Important keywords of the header are element and property.

The element keyword introduces a new section, which describes data. There are two of them in your example. The first to store the vertex data and the other one to store the face data.

The property keyword introduces a new property of this data section. It is followed by the type and the kind of the data. x, y and z refer to vertex position information, nx, ny and nz to normal information which belong to the vertex and s and t are the texture coordinates for the vertex. The information in the data block is stored in the order of appearence.

The other data block is charaterized by the line

property list uchar uint vertex_indices

The first unknown keyword is list, which indicates that the data of the property vertex_indices are stored in a list. uchar refers to the data type, which stores the number of list entries for this property and uint is the type of ech list entry. Let's have look at your example:

3 0 1 2
  • 3 is from type uchar and indicates that there are three list entries (so this face is a triangle)
  • 0 1 2 are the indices of the vertices (from the data block above) and from type unsigned integer
DanceIgel
  • 714
  • 8
  • 25
1

I found a demo application in java, which renders exactly this format: it is called jply and can be found on GITHUB: https://github.com/smurn/jPLY There are also these examples: http://quabr.com/19609248/rendering-ply-files-in-opengl http://1987.io/questions/2365561/android-and-opengl-how-display-faces

Hope it might help.

user2924714
  • 1,918
  • 1
  • 19
  • 26
0

Is is possible to store normal of each face (face:- formed by typically 3 vertices ). Inside the .ply file .

sha111
  • 113
  • 1
  • 12