Watch this tutorial by Max:
One Formula That Demystifies 3D Graphics https://www.youtube.com/watch?v=qjWkNZ0SXfo
Based on: https://github.com/tsoding/formula
Penger Model: https://github.com/Max-Kawula/penger-obj
https://aminet.net/package/dev/asm/ASMPro1.22
From amiga shell:
assign asmpro: Work:MyAsmProFolder
asmpro:
AsmPRO
From Menu: Open ami3d.s source
RightAmiga+Shift+A (assembly)
type: j (to jump at start)
enjoy.
penger_rotate.mp4
For js example from formula you can do basic conversion in python:
#!/usr/bin/env python3
import struct
cube_verts = [
{"x": 0.25, "y": 0.25, "z": 0.25},
{"x": -0.25, "y": 0.25, "z": 0.25},
{"x": -0.25, "y": -0.25, "z": 0.25},
{"x": 0.25, "y": -0.25, "z": 0.25},
{"x": 0.25, "y": 0.25, "z": -0.25},
{"x": -0.25, "y": 0.25, "z": -0.25},
{"x": -0.25, "y": -0.25, "z": -0.25},
{"x": 0.25, "y": -0.25, "z": -0.25},
]
cube_faces = [
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4],
[1, 5],
[2, 6],
[3, 7],
]
def faces_to_edges(faces):
edges = set()
for face in faces:
for i in range(len(face)):
a, b = face[i], face[(i+1) % len(face)]
edge = (min(a,b), max(a,b))
edges.add(edge)
return sorted(edges)
def to_fixed88(val):
fixed = int(val * 256)
return max(-32768, min(32767, fixed))
def write_binary(verts, faces, outfile):
edges = faces_to_edges(faces)
with open(outfile, 'wb') as f:
f.write(struct.pack('>HH', len(verts), len(edges)))
for v in verts:
f.write(struct.pack('>hhh',
to_fixed88(v["x"]),
to_fixed88(v["y"]),
to_fixed88(v["z"])))
for a, b in edges:
f.write(struct.pack('>HH', a, b))
print(f"wrote {outfile}: {len(verts)} verts, {len(edges)} edges")
write_binary(cube_verts, cube_faces, r'cube.dat')
penger_src = open(r'penger.js').read()
penger_src = '\n'.join(l for l in penger_src.split('\n') if not l.strip().startswith('//'))
penger_src = penger_src.replace('const ', '')
penger_src = penger_src.replace('x:', '"x":').replace('y:', '"y":').replace('z:', '"z":')
exec(penger_src)
write_binary(vs, fs, r'penger.dat')