Skip to content

io7m-com/jobj

Repository files navigation

jobj

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jobj

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

jobj

A parser for the useful subset of the Wavefront OBJ file format.

Features

  • Hand-written event-based recovering parser: Efficiently parse, accumulating errors along the way, without being tied to any particular AST types.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • ISC license.

Usage

Provide an implementation of the JOParserEventListenerType interface to a JOParserType:

Path file;
JOParserEventListenerType listener;
InputStream stream;

final JOParserType p =
  JOParser.newParserFromStream(
    Optional.of(file),
    stream,
    listener
  );

p.run();

The listener will receive parse events encountered during parsing of the file.

Coverage

The only specification for the OBJ file format is an unofficial specification that appears to have been handed around for decades.

Most of the OBJ file format has no relevance to anything used in modern computer graphics in 2024, but the format itself is often used as a bare-minimum portable text format for distributing mesh data. This parser attempts to capture the useful subset of data and makes no attempt to parse the entirety of the OBJ format. It's practically guaranteed that the parser will be missing the once piece of data you actually wanted to extract from the .obj file you're parsing. Patches to increase format coverage are welcome.