SaveModel

Saves the meshes of the specified cameras into a file using STL or PLY format.

PLY Formaet Header

The PLY format allows to specify arbitrary data streams. NxLib outputs an array of vertices first, containing the coordinates ‘x’, ‘y’ and ‘z’ as floats. If the Texture parameter was set to true each vertex additionally contains an unsigned char value for its red, green and blue color component; these values are named ‘red’, ‘green’, and ‘blue’ respectively in the header definition. If Texture was set to false, the ‘red’, ‘green’ and ‘blue’ fields will not be present. After the vertices a list of triangles is output. Each triangle is defined via a list of vertex indices forming the triangle. The list size is written into the file as unsigned char (which is always 3 for triangles!). Then the three vertex indices follow as unsigned integers.

The full PLY header with texture will then look like this:

ply
format binary_little_endian 1.0
element vertex <NumVertices>
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
element face <NumTriangles>
property list uchar uint vertex_indices
end_header

After the header the following values will be found in binary form in the file (texture is included in this example):

Values

Data Type

Description

x0, y0, z0,

float, float, float

Coordinates of the first vertex

r0, g0, b0,

uchar, uchar, uchar

Color at first vertex

x1, y1, z1,

float, float, float

Coordinates of second vertex

r1, g1, b1,

uchar, uchar, uchar

Color at second vertex

cnt0

uchar

Size of index list for first triangle (always equal to 3)

i00, i01, i02

uint, uint, uint

Indices of vertices forming the first triangle

cnt1

uchar

Size of index list for second triangle (always equal to 3)

i10, i11, i12

uint, uint, uint

Indices of vertices forming the second triangle

Note

The number of vertices and triangles must always be read from the header and is not contained in binary form.