An open API service indexing awesome lists of open source software.

https://github.com/jtsiomb/meshfile

Simple C library for reading/writing 3D mesh file formats.
https://github.com/jtsiomb/meshfile

3ds-loader gltf gltf-loader mesh-loading obj-loader stl-loader wavefront-obj

Last synced: 5 months ago
JSON representation

Simple C library for reading/writing 3D mesh file formats.

Awesome Lists containing this project

README

          

meshfile library
================

![GNU/Linux build status](https://github.com/jtsiomb/meshfile/actions/workflows/build_gnulinux.yml/badge.svg)
![Windows (MinGW) build status](https://github.com/jtsiomb/meshfile/actions/workflows/build_win_mingw.yml/badge.svg)

About
-----
Meshfile is a simple C library for reading and writing 3D mesh file formats. It
reads/writes:

- Indexed triangle meshes, multiple objects per file, with a number of optional
pre-defined vertex attributes. No quads, n-gons, strips, or fans.
- Materials with a number of common pre-defined material attributes, each
optionally combined with a texture map (filename/path).
- Optional transformation node hierarchy.

Animations are explicitly outside of the scope of this library.

Meshfile is very simple to use, and comes with two example programs:
- meshview: an OpenGL 3D model viewer
- meshconv: a converter between any of the supported 3D file formats

File formats
------------
Here's a list of currently supported file formats, and any caveats for each one.

- Wavefront OBJ
- JTF (Just Triangle Faces): http://runtimeterror.com/tech/jtf
- GLTF (OpenGL Transmission Format): currently read-only
- 3DS (3D Studio)
- STL (Stereolithography): binary only

Download
--------
Project website: http://nuclear.mutantstargoat.com/sw/meshfile
Github source code repo: https://github.com/jtsiomb/meshfile

You can find all the meshfile releases at the project website, and the github
releases page:
- http://nuclear.mutantstargoat.com/sw/meshfile/releases
- https://github.com/jtsiomb/meshfile/releases

You can also obtain the latest source code directly from the git repo:
`git clone https://github.com/jtsiomb/meshfile.git`

Using meshfile
--------------
There are two ways to use meshfile:
1. build and install it system-wide (`make && make install`). Then just include
`meshfile.h` in your program and link with `-lmeshfile`.
2. drop the contents of `src` and `include` directories into a subdir of your
program and build it as part of your own build. It has no dependencies, so
it should be as easy as just adding the list of `.c` files to your build.

Meshfile being released under the terms of the GNU LGPL, the second method is
only possible if your program is free software.

Please note that before v1.0 is released, there is no guarantee for API/ABI
stability.

License
-------
Copyright (C) 2025 John Tsiombikas

This program is free software. Feel free to run, modify and/or redistribute
under the terms of the GNU Lesser General Public License v3, or at your option
any later version published by the Free Software Foundation.
See COPYING and COPYING.LESSER for details.

Build
-----
To build meshfile on UNIX, simply run `make`. The meshfile library has zero
dependencies other than libc. Run `make install` as root to install it under the
`/usr/local` prefix. You can change the prefix by editing the first line of the
`Makefile`.

There's also an example mesh viewer program as part of the meshfile
distribution. To build and install that change into `meshview` and run `make`
and `make install` again. For the meshview dependencies and build instructions,
refer to the `meshview/README.md` file.