Posting to remind myself of how successful I am, because I am successful but I’m not really happy yet. Anyway here goes.
So last time I wrote, which was ages ago, I mentioned that I was having some real trouble with that code project I was working on. Well after months and months of really intensely hard work I’m not having any trouble anymore.
I’d spent about a year on and off trying to successfully write a Delaunay Trianglulation algorithm, to no avail. I tried with a sweep hull method and that turned out to be a buster. I started again literally from scratch with my own data structure classes and got pretty far but was stuck when I posted last. It was really terrible because I could sense that I was close to solving it but I wasn’t at all getting the results I was looking for. It either wouldn’t form a correct triangulation or it’d crash from one nullpointerexception or another. The results looked like this:
Basically this fails the basic principle of Delaunay because the theoretical circle that has each of the vertices of that blue triangle in the middle on its circumference would also be large enough to fit the farther vertex of the adjacent red triangle. In Delaunay triangulations, every triangle has an empty circumcircle, so until the whole set achieves that property, the triangulation fails the “Delaunay” test.
I spent a long time playing with parameters and getting the roll of the terrain right, as well as trying to feel out how this would appropriately scale for structures with a higher triangle-density or a more deeply-sampled noise space. It was good. Really good. I’d done it! ME! Adam, the guy who failed high-school intermediate maths and had to drop down to the lowest possible level actually wrote a functional Delaunay Algorithm! Life is amazing!
I was really keen to port it into Unity to take it to the next level. I backed up my code which was, up until that point, written in Java using Processing and started porting it to C#. I got really far really quickly but no real results. Something kept crashing, I figured it had something to do with the difference between how 2D arrays are handled in Java vs C# (staggered lists vs true 2D implementations) but after a couple of days i still wasn’t getting it. So I checked my Java version and, i shit you not, that wasn’t working either. I’d broken my code somehow and had no way to pinpoint the problem. “Here we go again”.
So another week went by and I finally sorted it out (I’d neglected to really finish writing some random IF statement that was supposed to save me like 3 lines of code per frame, basically useless). Immediately I corrected the errors in Unity and, man, it was looking so good!
I was so chuffed. Seriously, amazed with myself. Over the next week I made the solution more parameterised so that I could customise the kind of results I would get before runtime. Things like number of vertices, radius of triangulation, acclivity of the hills, Simplex noise density (I moved away from Perlin noise). Physics were really trivial to get in as well, thanks to Unity having baked in physics that handles meshes. It took some playing around to get the proportions right. Then I added in some water and voila:
So at this point I’m basically a god, because I can create islands from scratch by clicking my fingers. I successfully created this solution and it works better than anything I’ve ever made.
But I’m not happy with it, somehow. What the hell is wrong with me? I’ve had really very little motivation to do anything since. If you recall I did say I was going to make it dynamic to the player position. i haven’t done that yet. But I’m all out of puff right now. Shouldn’t this be when I have the most energy? Shouldn’t I be feeling amazing and eager? I was. What happened?
I don’t know. I thought writing about it would make me happier 😦
Thanks for reading, anyway. I’ll probably get back into it at some point but I’m not really feeling it right now. It probably has something to do with work, which has been a real drain recently
Oh well, I succeeded so that’s good.