The depth file format is a simple text file format to store 3D triangle-based geometry.
It is designed for fast and easy parsing with only very few parsing code required.
Format:
DEPTH VERTEXCOUNT X Y Z X Y Z ... INDEXCOUNT A B C A B C ...
The whole file is build out of several by whitespace-character separated values.
DEPTH - this is the file header.
VERTEXCOUNT - the count of following X,Y,Z vertex points (one XYZ is one count).
X Y Z - one 3D vertex coordinate.
INDEXCOUNT - the count of following A,B,C vertex indices (one ABC triangle is one count).
A B C - the 3 vertex points indices for one triangle.
Here Javascript code to parse the depth file format (without validation):
function parse_depth_file (depth_file_content)
{
// split by whitespaces
var parsed = depth_file_content.split(/[ \r\n\t]+/);
// check the file header
if (parsed[0] != "DEPTH")
return null;
// vertex count * x,y,z
var vcnt = 3 * parsed[1];
// get the data and automatically convert it
var vx = new Float32Array( parsed.slice(2, 2 + vcnt) );
var ix = new Uint16Array( parsed.slice(2 + vcnt + 1) );
// done with parsing
return {vx:vx, ix:ix};
}