I recently used 3D files in STL format to learn how to add them to my favorites.
From: http://www.cnblogs.com/ourshell/archive/2010/05/03/1726821.html
STL can only be used to indicate closed faces or bodies. STL files can be in either the plaintext format or binary format. Its file format is very simple
Plaintext:
Solid name
Facet normal Ni NJ NK
Outer Loop
Vertex v1x v1y v1z
Vertex v2x v2y v2z
Vertex v3x v3y v3z'
Endloop
Endfacet
Endsolid name
Binary:
Uint8 [80]-Header
Uint32-Number of triangles
Foreach triangle
Real32 [3]-Normal Vector
Real32 [3]-vertex 1
Real32 [3]-vertex 2
Real32 [3]-vertex 3
Uint16-attribute Byte Count
End
The file format is simple. It can only describe the geometric information of 3D objects. It does not support color materials and other information. It is a 3D printer. (It sounds dizzy if you do not know what to add a 3D file, the most common supported file formats are 3D printers, which are generally not as good as quick prototyping machines.
Conversion from: (Yan Yuming) STL File Reading display based on VC ++ and OpenGL
Binary format of STL
The binary STL file uses a fixed number of bytes to provide the geometric information of the triangle. The 80-byte starting from the file is the file header used to store the part name. Then, a four-byte integer is used to describe the number of triangles in the model. The geometric information of each triangle is given one by one. Each triangle takes up 50 fixed bytes, which are three 4-byte floating point numbers (the method vector of the corner) and three 4-byte floating point numbers (the coordinates of one vertex) the last two bytes of three 4-byte floating point numbers (the coordinates of two vertices) and three 4-byte floating point numbers (the coordinates of three vertices) are used to describe the attributes of a triangle. The size of a complete binary STL file is the number of triangles multiplied by 50 plus 84 bytes, totaling 134 bytes.
Stl ascii file format
The ASCII format STL file provides the geometric information of the triangle surface line by line. Each line starts with one or two keywords. In STL files, the information unit facet of the triangle surface is a triangular surface with vector direction. The STL three-dimensional model is composed of a series of such triangular surfaces. The path and file name of the entire STL file are provided in the first line. In an STL file, each facet is composed of seven rows of data. facet normal is the coordinate of the forward vector pointing to the External Object of the triangle, outer Loop indicates that the subsequent three rows of data are the three vertex coordinates of the triangle surface, and the three vertices are arranged counterclockwise along the direction of the normal vector pointing to the external object.
The structure of STL Files in ASCII format is as follows:
Solid filename STL // file path and file name
Facet normal x y z // three component values of the Triangle Surface Method Vector
Outer Loop
Vertex x y z // coordinate of the first vertex of the Triangle Surface
Vertex x y z // second vertex coordinate of the Triangle Surface
Vertex x y z // coordinate of the third vertex on the Triangle Surface
Endloop
Endfacet // complete the definition of a triangle surface
---
Endsolid filename STL // The entire STL file definition ends