flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > I search example fill boxes 3D triangle. |
| Author |
|
|
pabloreda 16 Mar 2026, 16:42
There's a very simple idea that works. I implemented it in the older version of my language.
The idea is to use the midpoint to find the voxels it touches and assign them the texture color at that location. You have to be careful to ensure the midpoint calculation converges because you need to stop when the recursion returns the same point. I generate an octree from the voxels, but when it's generated, it's just an array of voxels. To generate the octree, I order them using Morton's sort order, and this grouping is the octree itself. Here's the code: https://github.com/phreda4/r4/blob/master/r4/3d/voxobj.txt the algo is rectri(tri): if tri == tri_ad → setvox else: M01 = midpoint(V0, V1) M12 = midpoint(V1, V2) M02 = midpoint(V0, V2) rectri( tri(V0, M01, M02) ) rectri( tri(V1, M01, M12) ) rectri( tri(V2, M12, M02) ) rectri( tri(M01, M12, M02) ) |
|||
|
|
Roman 17 Mar 2026, 14:47
I thinking Bresenham's line algorithm for 3D.
https://www.geeksforgeeks.org/python/bresenhams-algorithm-for-3-d-line-drawing/ And filling triangle many lines form boxes. Bresenham's line algorithm for 2D very simple. |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.