Skip to content

Dguto9/meshing-around

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monkey appearing from and rotating out of Uiua logo

meshing-around

meshing-around is a configurable rendering library for the Uiua language, with a goal of providing Uiuic methods for common rendering operations.

The library provides the following functionality:

  • Mesh importing/exporting from/to Wavefront OBJ and STL files
  • A Suzanne constant!
  • Output of rendered normal, color, and lighting maps (and more)
  • Generation of texture coordinates
  • Material system supporting textures

Want to jump right in? Read the guide!

It is recommended that you familiarize yourself with data definitions and quaternion rotations.

Getting started

To use the library, include the following at the top of your file:

# Experimental!
M ~ "gh: Dguto9/meshing-around"

Create a RenderConfig with a resolution, and create a Mesh instance by importing from a 3D file format:

M~RenderConfig 500_500
°M~OBJ &fras "assets/suzanne.obj"

With only these as arguments, calling M~RenderMeshPreview will yield an image result.

A slightly less brief example

# Experimental!
M ~ "gh: Dguto9/meshing-around"
~ "gh: Omnikar/uiua-math" ~ RQuat

RC ← M~RenderConfig
RO ← M~RenderOutput

RC 500_500

°M~OBJ &fras "assets/suzanne.obj"

°⊸M!Mesh~Transform≈Scale ↯3 0.7
°⊸M!Mesh~Transform≈Rotation RQuat ¯η 1_0_0

⧋⊂⧋÷⟜⇡⊸△◿₂⧋/+⇡100_100       # Rainbow tiles texture
⍉˙⊟₃°(-⊸¬)◿₂⧋/+⇡50_50        # Checker pattern
⊟∩M~Material                 # Make some materials
°⊸M~Mesh~Materials
⍜M~Mesh~MaterialIndex(◿₂⇡⧻)  # Assign materials to triangles

⤚M~RenderMesh        # This one does the rendering!
⊸RO~GenUVs           # Generate texture coordinates
RO~GenMaterials      # Apply the textures
×⊃RO~Albedo RO~Light # Multiply color and lighting to get shading
&ims

Some things to notice

  • uiua-math quaternions are used for all rotations; you will be importing it often
  • Defining aliases like RO and RC is useful, but to remain explicit, these aliases will not be provided by the library

Output

3D monkey model patterned with colored tiles and checkers

What now?

About

A 3D rendering library for Uiua

Resources

Stars

Watchers

Forks

Contributors