Functions
-
bool offler_read_file(offler_mesh *mesh, const char *filename)
Read the specified OFF file and store the data in
mesh. This function allocates any necessary memory, which must be freed withfree_mesh. Returnsfalseif the file cannot be opened or memory cannot be allocated.
-
void offler_free_mesh(offler_mesh *mesh)
Free the memory associated with
mesh, and, to keep the other members consistent, reset them as though newly defined byOFF_t mesh = {};.
-
void offler_write_file(offler_mesh *mesh, FILE *outfile, bool write_normals, bool write_colour, bool write_textures)
Write
meshto a.offfile. Ifmeshcontains normals and colours, then writing eacg of these can be suppressed. If it contains no normals andhas_normals=true, then degenerate normals will be written for each vertex. If it contains no colours andhas_colour=true, a (N)OFF file is created, with no colour data for the vertices.
-
dotty_aa_bounding_box offler_compute_aabb(const offler_mesh *mesh)
Compute the axis-aligned bounding box of
mesh.
-
void offler_scale(offler_mesh *mesh, double scale_factor)
Scale the position of each vertex in the
meshby the providedscale_factor. A scale factor=1.0causes no change,>1causes growth, and<1causes shrinkage.
-
void offler_swap_axes(offler_mesh *mesh, dotty_axis_pair to_swap)
Swap the specified axes of each vertex in
mesh.
-
void offler_translate(offler_mesh *mesh, dotty_vector translation)
Update the position of each point in the mesh by adding
translation.
-
void offler_export_normals(const offler_mesh *mesh, FILE *normal_file, char delimiter)
Export vertex normals to a delimiter-separated-variables file.
-
void offler_import_normals(offler_mesh *mesh, FILE *normal_file)
Import vertex normals from a delimiter-separated-variables file. The delimiter is assumed to be a single character.
-
void offler_export_colours(const offler_mesh *mesh, FILE *colour_file, char delimiter)
Export vertex colours (r, g, b, a) to a delimiter-separated-variables file.
-
bool offler_import_colours(offler_mesh *mesh, FILE *colour_file)
Import vertex colours (r, g, b, a) from a delimiter-separated-variables file. The delimiter is assumed to be a single character.
-
bool offler_add_fixed_colour(offler_mesh *mesh, offler_colour new_colour)
Set the colour of all vertices in
meshtonew_colour.
-
void offler_calculate_face_normals(offler_mesh *mesh)
Calculate a face’s normal by taking the cross product of two of its sides. The consistency of the orientations is not considered.
-
bool offler_calculate_vertex_normals(offler_mesh *mesh)
Calculate vertex normals by taking a weighted sum of the surrounding face normals. The weights are inversely proportional to the distance between the vertex and the face’s barycentre.