Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

chip2n/zig-obj

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-obj

https://github.com/chip2n/zig-obj/workflows/CI/badge.svg

Minimal Zig parser for .obj and .mtl files.

Features

The following features are implemented:

OBJ files:

  • Vertices
  • Texture coordinates
  • Normals
  • Objects

MTL files:

  • Bump map
  • Diffuse map
  • Specular map
  • Ambient map
  • Roughness map
  • Metallic map
  • Sheen map
  • Emissive map
  • Normal map
  • Ambient color
  • Diffuse color
  • Specular color
  • Specular highlight
  • Emissive coefficient
  • Optical density
  • Dissolve
  • Illumination
  • Roughness
  • Metallic
  • Sheen
  • Clearcoat thickness
  • Clearcoat roughness
  • Anisotropy
  • Anisotropy rotation

If something is missing or not working properly, feel free to open an issue/pull request and I’ll take a look.

Getting started

Add module to your projects build.zig.zon file:

zig fetch --save git+https://github.com/chip2n/zig-obj.git

Add the dependency to your executable in build.zig:

pub fn build(b: *std.build.Builder) void {
    ...
    const obj_mod = b.dependency("obj", .{ .target = target, .optimize = optimize }).module("obj");
    exe_mod.addImport("obj", obj_mod);
}

Building a static library

Build a static library by running:

zig build

Usage

const obj = @import("obj");

var model = try obj.parseObj(allocator, @embedFile("cube.obj"));
defer model.deinit(allocator);
var material = try obj.parseMtl(allocator, @embedFile("cube.mtl"));
defer material.deinit(allocator);

Running tests

Tests are being ran automatically each day using the nightly Zig build.

Run the test suite manually with:

zig build test

About

Minimal Zig parser for .obj and .mtl files

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.