The mesh processing of the FBX to HMD conversion : tangents, optimization and LODs, convex hulls. With the natives of HashLink in HL, the meshTools executable elsewhere (tools/meshTools, in the PATH). A platform that has these natives otherwise (a Node addon in Electron) replaces these functions.

Static methods

staticdynamicconvexHulls(vertices:Bytes, vertexCount:Int, indexes:Bytes, triangleCount:Int, maxConvexHulls:Int, resolution:Int):Array<ConvexHullData>

The convex hulls (V-HACD) of a mesh : vertices holds vertexCount positions of 3 Float32, indexes holds triangleCount triangles of 3 Int32.

@:value({ threshold : 180. })staticdynamicmikktspace(vertices:Bytes, count:Int, stride:Int, xPos:Int, normalPos:Int, uvPos:Int, threshold:Float = 180.):Bytes

The MikkTSpace tangents of count vertices of stride floats (position at xPos, normal at normalPos, uv at uvPos), one per index : the triangles are 0,1,2 then 3,4,5... Returns 4 floats per vertex : the tangent and its sign.

@:value({ targetError : 0., targetIndexCount : -1 })staticdynamicoptimize(vertices:Bytes, vertexCount:Int, vertexSize:Int, indexes:Bytes, indexCount:Int, targetIndexCount:Int = -1, targetError:Float = 0.):{vertexCount:Int, indexCount:Int}

Optimizes a mesh in place : merges its identical vertices, simplifies it to targetIndexCount indexes when it is not negative (the LODs, with targetError relative to its size), then orders it for the vertex cache, the overdraw and the vertex fetch. vertices holds vertexCount vertices of vertexSize bytes, position first, indexes holds indexCount Int32. Returns the new counts, the data at the start of the buffers, or null when the platform cannot optimize.