ZENITH ("Zen Engine for Navigating wIreframes In Three-dimensional Holographic space") is a wireframe renderer written in OCaml.
ZENITH is built with dune, and depends on the OCaml Graphics
library. To run:
# Will render the Utah teapot .obj file
make run
# Will render each object around a circle
OBJS="path_to_obj path_to_another_obj ..." make run
# Renders the demo shown below
OBJS="objs/uv_sphere.obj objs/torus.obj objs/star_destroyer.obj \
objs/pyramid.obj objs/cube.obj objs/blender_monkey.obj objs/arwing.obj" make run
# Renders the lambda cube below (uses a debug feature set at compile-time)
OBJS="objs/lambdacube.obj" make run
Checkpoint | Summary |
---|---|
Bad Perspective | My meshes are close to rendering correctly, but some issue with my perspective transformation maps some vertices to the origin |
Success 1 | My meshes now render properly |
Success 2 | I can now load meshes from .obj files |
If you want to color your Blender models, the only shader compatible with the Kd
(diffuse color) field of a .MTL file is Principled BSDF.
The logo model and material were designed in Blender and are a suitable example of supported .OBJ and .MTL vernacular. Blend file available here.
# Comments
# Vertices
v 0.0 1.9 -5.8
v 1.1 0.4 -0.7
v 38.4 0.2 7.1
# Lines
l 1 2
l 2 3
# Faces
f 1 2 3
# Faces with vertex normals (ignored)
f 1/1/1 2/2/2 3/3/3
# .MTL File Locations
mtllib mymat.mtl
# Material Usage
usemtl MyMat
If two faces share edges but not materials, the face occurring later in the file will overwrite those edges' colors.
# Material Name Declarations
newmtl MyMat
# Diffuse Color
Kd 0.5 0.75 1.0
Y
|
|
|
--------- X
/
/
/
Z