Function Reference: writeObj

csg-toolkit: writeObj (v, f, filename)
csg-toolkit: writeObj (v, f, vt, ft, filename)
csg-toolkit: writeObj (v, f, vn, fn, filename)
csg-toolkit: writeObj (v, f, vt, ft, vn, fn, filename)

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 N×3 matrix with x,y,z vertex coordinates or an N×6 matrix containing the vertex coordinates and the r,g,b color information for each vertex in the range [0,1].

f must be an M×3 matrix with the indices of each corresponding vertex, where M is the number of faces.

vt must be an N×2 matrix, where N is the number of texture coordinates.

ft must be an M×3 matrix with the indices of each corresponding texture coordinates.

vn must be an N×3 matrix with x,y,z normal coordinates, where N is the number of normals.

fn must be an N×3 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.

See also: readObj, renameObj

Source Code: writeObj