writeObj
This function saves a triangular 3D Mesh in a Wavefront OBJ file format according to its elements provided as input arguments.
The function will only take 3, 5 or 7 input arguments. The last argument should be a char string referring to the filename of the OBJ file, whereas the first 2, 4, or 6 input arguments should be 2-dimensional matrices containing the elements of the triangular mesh in the following order:
v can be either an matrix with x,y,z vertex coordinates or an matrix containing the vertex coordinates and the r,g,b color information for each vertex in the range .
f must be an matrix with the indices of each corresponding vertex, where is the number of faces.
vt must be an matrix, where is the number of texture coordinates.
ft must be an matrix with the indices of each corresponding texture coordinates.
vn must be an matrix with x,y,z normal coordinates, where is the number of normals.
fn must be an matrix with the indices of each corresponding face normal.
If 5 input arguments are provided, the function will determine whether there is a texture coordinates matrix or a vertex normals matrix by the size of the second dimension of the matrix provided as the third input argument.
Source Code: writeObj