meshing-around

meshing-around

Validation

Validation module


Validation~Num function

|1.0?Input
Source code
Num°0type

Validation~Char function

|1.0?Input
Source code
Char°1type

Validation~Box function

|1.0?Input
Source code
Box°2type

Validation~Vec₂ function

|1.0?Input
Source code
Vec₂(Num|°[2])

Validation~Vec₃ function

|1.0?Input
Source code
Vec₃(Num|°[3])

Validation~Quat function

|1.0?Input
Source code
Quat(Num|°[4])

Validation~ColorImg function

|1.0?Input
Source code
ColorImg(Num|(°3|°3))

Validation~AlphaImg function

|1.0?Input
Source code
AlphaImg(Num|(°2|°3))

Validation~GreyscaleImg function

|1.0?Input
Source code
GreyscaleImg(Num|°2)

Transform

Transform module

Transform is used to represent the translation, rotation, and scale of an object.


Transform~ data boxed

ID
PositionV~Vec₃
ScaleV~Vec₃
RotationV~Quat

Transform~Forward function

|1Output?Input

Get the 3D vector pointing in the object’s local forward direction.

Source code
Forward˜QRot 0_1_0 Rotation

Transform~Right function

|1Output?Input

Get the 3D vector pointing in the object’s local right direction.

Source code
Right˜QRot 1_0_0 Rotation

Transform~Up function

|1Output?Input

Get the 3D vector pointing in the object’s local up direction.

Source code
Up˜QRot 0_0_1 Rotation

Transform~Rotate function

|2Output?Input1Input2
Source code
Rotate°Rotation QqpRotation

Transform~V function

|1.0?Input
Source code
V°1"Transform"ID

Material

Material module

Materials are used to represent a particular set of shading values. Each field of a material contains a texture, which will be mapped to the surface of any triangle using it. To use a single value rather than a texture, ¤¤ the value.


Material~ data boxed

ID
AlbedoV~ColorImg
RoughnessV~GreyscaleImg
ReflectivityV~GreyscaleImg

Material~V function

|1.0?Input
Source code
V°1"Material"ID

Mesh

Mesh module

A mesh represents a single object to render. It holds a set of triangles, their normal vectors, their UV coordinates, the materials to shade with, which triangles use which materials, a transform, and a set of textures to be moved around with the mesh.


Mesh~ data boxed

ID
TrianglesV~Num°¤°(˜⊂3_3)△
NormalsV~Num°¤°(˜⊂3)△
UVsV~Num°¤°(˜⊂3_2)△
MaterialIndex⊃(V~Num|°1⧻△)
TransformTransform~V
Materials≡Material~V
TextureSet≡V~Box

Mesh~InitNormals function

|1Output?Input
Source code
InitNormals(°NormalsTriNormTriangles)¤˙ Normals

Mesh~CalculateNormals function

|1Output?Input
Source code
CalculateNormals°NormalsTriNormTriangles

Mesh~InitUVs function

|1Output?Input
Source code
InitUVs(°UVs ˜0 ˜3_2 Triangles)1_3_2 UVs

Mesh~InitMaterialIndex function

|1Output?Input
Source code
InitMaterialIndex(°MaterialIndex˜0 ¤Triangles)¤ MaterialIndex

Mesh~ApplyScale function

|1Output?Input
Source code
ApplyScale°TransformScale3 1°Triangles×TransformScale Triangles

Mesh~ApplyRot function

|1Output?Input
Source code
ApplyRot°TransformRotation RQuat0˙0°(Normals|Triangles) QRot(TransformRotation|Normals|Triangles)

Mesh~ApplyPos function

|1Output?Input
Source code
ApplyPos°TransformPosition3°Triangles+TransformPosition Triangles

Mesh~ApplyTransform function

|1Output?Input
Source code
ApplyTransformApplyPos ApplyRot ApplyScale

Mesh~Rotate function

|2Output?Input1Input2
Source code
Rotate°Mesh~TransformRotation QqpMesh~TransformRotation

Mesh~Call function

|1Output?Input
Source code
CallInitUVs InitMaterialIndex InitNormals New

Mesh~V function

|1.0?Input
Source code
V°1"Mesh"ID

RenderConfig

RenderConfig module

A RenderConfig defines some parameters for rendering a mesh, which aren’t specific to the mesh. Using the same RenderConfig with multiple meshes should result in a set of renders which can be composed into a single scene, as though they were rendered from the same camera.


RenderConfig~ data boxed

ID
SizeV~Vec₂
ZoomV~Num
CameraTransform~V
FOVV~Num
LightV~Vec₃
AmbientColorV~Color

RenderConfig~AspectRatio function

|1Output?Input
Source code
AspectRatio/÷Size

RenderConfig~HalfwayVec function

|1Output?Input
Source code
HalfwayVec÷+(¯Light|CameraForward)

RenderConfig~V function

|1.0?Input
Source code
V°1"RenderConfig"ID

RenderOutput

RenderOutput module


RenderOutput~ data boxed

ID
IndexV~GreyscaleImg
DepthV~GreyscaleImg
MaterialIndexV~GreyscaleImg
NormalV~ColorImg
LightV~GreyscaleImg
TriCoordsV~AlphaImg
AmbientV~ColorImg
UVsV~AlphaImg
PosV~ColorImg
MaterialMaterial~V

RenderOutput~ApplyTexture‼ index macro

Source code
ApplyTexture‼°^0^1˜0(×)(UVs|^0)

RenderOutput~ApplyTexture! index macro

Source code
ApplyTexture!ApplyTexture‼^

RenderOutput~GenUVs function

|2Output?Input1Input2
Source code
GenUVs(
NaN GenMeshProp‼Mesh~UVs UVs
)

RenderOutput~GenPos function

|2Output?Input1Input2
Source code
GenPos(
GenMeshProp‼Mesh~Triangles PosMesh~ApplyTransform
)

RenderOutput~GenMaterials function

|2Output?Input1Input2
Source code
GenMaterials(
(MaterialIndex UVs|(Material~Albedo|Material~Roughness|Material~Reflectivity) Mesh~Materials)
=
NaN_NaN¤
₃⌞(/+(0×))
°(MaterialAlbedo|MaterialRoughness|MaterialReflectivity)
)

RenderOutput~ApplyTexFromSet‼ index macro

Source code
ApplyTexFromSet‼(
(°)Mesh~TextureSet
˜ApplyTexture‼^0^1
)

RenderOutput~ApplyTexFromSet! index macro

Source code
ApplyTexFromSet!(
(°)Mesh~TextureSet
˜ApplyTexture‼^
)

RenderOutput~ConvertTanNormals function

|2Output?Input1Input2
Source code
ConvertTanNormals(
(((-°)Mesh~Triangles|(Inv₂-°)Mesh~UVs|Mesh~Normals)Mesh~ApplyTransform
÷(/+˙×)(˜Mmp))
˜Mvp Normal(0Index)
°Normal
)

RenderOutput~Call function

|7Output?Input1Input2Input3Input4Input5Input6Input7
Source code
Call°UVs˜0 TriCoords New

RenderOutput~V function

|1.0?Input
Source code
V°1"RenderOutput"ID

ImageAndDepth

ImageAndDepth module


ImageAndDepth~ data boxed

ImageV~ColorImg
DepthV~GreyscaleImg

ImageAndDepth~Combine function

|2Output?Input1Input2
Source code
CombineImageAndDepth CombineByDepth °ImageAndDepth

Constants

Suzanne constant

Suzanne is a constant containing the “Suzanne” mesh used by Blender as a Mesh instance. The Suzanne constant does not have a UV map.

Monadic functions

TriNorm function

|1Vector?Triangle

Find the normal vector for a triangle

Source code
TriNorm÷Cross°-¤°

DrawTri function

|1Output?Input

Rasterize a triangle PixelLocs ? 2DTriangle

Source code
DrawTri(
//
+-
(˜InTri°)
+°¤
)

STL function

|1Output?Input

Import an STL file as a Mesh. STL files do not contain UV coordinates. There are two types of STL, ASCII and binary. The inverse of this function can decode either, just make sure to &fras or &frab appropriately. The STL function always generates binary STL.

Source code
STL(GenSTL|DecodeSTL)

OBJ function

|1Output?Input

Import an OBJ file as a Mesh. OBJ files should be read with &fras. For use with this library, the OBJ file must only contain triangles, and must contain UV coordinates.

Source code
OBJ(GenOBJ|DecodeOBJ)

Dyadic functions

WorldToView function

|2.2MeshRenderConfig?MeshRenderConfig

Convert from World-space coordinates to View-space coordinates

Source code
WorldToView(
Mesh~Triangles ((Camera~Position|Camera~Rotation|Camera~Scale)RC~Camera)
˜-
˜(QRot (1°)¯)
˜÷
(0_2_1)
°Mesh~Triangles
)

CullBackfaces function

|2Mesh?MeshRenderConfig

Filter out faces by direction facing relative to camera

Source code
CullBackfaces(
˜(¯RC~CameraUp|(Mesh~Normals|Mesh~Triangles|Mesh~UVs|Mesh~MaterialIndex))
₄⌞(>0Dot)
°(Mesh~Normals|Mesh~Triangles|Mesh~UVs|Mesh~MaterialIndex)
)

InTri function

|2Output?Input1Input2

Check if a point is within a triangle Boolean ? 2DTriangle Point

Source code
InTri(
°-°
÷Det₂(¯˜-⌟₂Det₂)
×(×|+)
)

RenderPreview function

|2Render?MeshRenderConfig

Fast render that does not output a depth map for compositing. Use for real-time rendering or scene previewing.

Source code
RenderPreview(
Mesh!(
ApplyTransform
InitNormals
)
((Mesh~Triangles|Mesh~Normals)|RC~CameraForward)
˜(<Dot)
°Mesh~Triangles Mesh~Normals
WorldToView
(
/˜0 RC~Size
| °(-¬)¯Dot(Mesh~Normals|RC~Light)
| ÷/+Mesh~Triangles)
÷+
×
(˜0¤ DrawTri)
°
)

Tetradic functions

CombineByDepth function

|4.2ValueDepth?ValueDepthValueDepth

Pick the closer of two depth-value pairs

Source code
CombineByDepth˜(-×<)

Hexadic functions

RenderMesh function

|6RenderOutput?MeshRenderConfigInput3Input4Input5Input6

Full-featured renderer. Performs the core steps of the full rendering process.

Source code
RenderMesh(
Mesh!(
ApplyTransform
InitNormals
InitMaterialIndex
)
WorldToView
(Mesh~Triangles Mesh~Normals|(RC~CameraForward|˜ RC~Size))
(÷(/+)|)
₃⌟˜(°<Dot)
((+×(/(¤¤)÷)))
(°(0¤ DrawTri))
(
| (˜3RC~Size|RC~AmbientColor)
| (°)(Inv₂-)+×(/(¤¤)÷)(Mesh~Triangles|RC~Size)
| ¯Dot(Mesh~Normals|RC~Light)
| Mesh~Normals
| Mesh~MaterialIndex
)
(
| NaN | 0 | 0
| ˜Mvp(0_1_3_2)˜-°NaN
)
RO
)