Friday, June 25, 2021

Took last night off, back to messing around with triangles

I played hookie last night… I need to finish the zombie story and submit it by Tuesday night. I owe myself words from yesterday and I need to get it done now that I have some idea where it’s going, but do I have an ending after all? What does Amanda decide?

In other news, I was looking at what I hate about marching cubes and squares. I have been coming sideways at the problem for a long while with the sea levels and sea shores for my world building; when subdividing triangles between above and below sea level and finding the sea level or a boring midpoint between two high points or two low points. I color triangles which have vertices at sea level and above green or tan for land and triangles with vertices which are at or below sea level blue for ocean. If I subdivide all the quads of a 2D grid of world surface into a triangle pair and then subdivide them along sea level or midpoints, depending on the endpoints of a given side or edge, now we’re getting landmass vs. sea, and we can make a list of edges which have two sea level endpoints. We can even chain them up into coastline and find individual islands and continents.


This is apparently something called dual contouring, if I understand this, and I can potentially and procedurally do this for tetrahedrons, which I can get from cubes, either five or six of them. The six way subdivision of a cube is between upper and a lower opposite corners. Each tetra shares these two, p0 and p7, if you will, first and last. The remaining six vertices pair up, each belonging to two adjacent tetrahedrons, (if the upper cube face is (p0,p1,p3,p2) and the lower cube face is (p4,p5,p7,p6), then the six are (p0,p7,p1,p3), (p0,p7,p1,p5), (p0,p7,p4,p5), (p0,p7,p2,p3), (p0,p7,p2,p6), (p0,p7,p4,p6). Or we can slice off four of the eight corners to expose a hidden inner tetrahedron, (p0,p1,p2,p4), (p3,p2,p2,p7), (p5,p7,p4,p1), (p6,p4,p7,p2) and (p0,p3,p4,p6). If the surface crosses within a tetrahedron we can make and display either a single triangle or triangle pair.


You may notice that even in 2D we are making surfaces; we can think of each quad of a 2D grid as a surface suspended in a cube or rectangle. Each quad is really a very tall upside down pyramid or prism. The bottom vertices are all the way down at the center of a nice round world. We are concerned with the rock and water on top of a presumably molten core and the bottom corners we are considering aren’t noticeably closer together than the top corners, which are some height above the highest mountains or the atmosphere. So getting a surface (or surfaces, decidedly plural!) from a 3D grid of points is just thinking about the problem a little harder, I suppose… 8-P


No comments:

Post a Comment