As I proceed farther into wannabe, I find I need more content to test and validate the work I’m doing. That is the purpose for the vignette milestones over in the issue tracker. So, I’ve finally started on one: Rain. In it, the plan is to have a house, a yard, some background terrain, and ultimately some animated rain falling silently. Read through the end for some fun videos!Here’s the house:
Nothing special yet, but it helps nail down the goals here, and the look I’m ultimately going for.
The interesting thing I found is that, as I was adding content, now I was needing tools to create that content. I don’t want to plot each of these pixels one at a time. So in the past I had added a line algorithm, but even this is inadequate when you’re dealing with complex scenes. So, I tweaked the Plotter interface to let me implement flood and edge fills easily. Of course, that still doesn’t replace talent or diligence, but it brings things closer to possible.
The other half (ha, probably more than half) of the work I’ve been doing is trying to improve the frame rate of the whole thing, to make it smoother and perform better. Herein is a fascinating trade-off of making the data structures smarter so I can draw less, but the smarter structures take up more CPU time themselves. I think there’s probably a better data structure to use here, but I steadfastly refuse to look up voxel data structures just yet.
An improvement, performance-wise, is the addition of the dirty flag to grids. This way we don’t have to re-process grid contents unless there’s something that really changed. Fun quirk here: because the code currently uses a central Grid as a buffer to aggregate several other grids’ contents, it turns out it changes way more often than it needs to. There’s probably a better way to do this.
You can find a number of individual commits for this work at in pull #22.
Here’s a little bonus added in that pull: RotateGrid — applies a rotation matrix to a grid. And it is incredibly ugly but simultaneously fascinating. It’s not rotating the rendering, it’s moving the voxels around (giving them new x,y,z coordinates) and shoving them back into a grid. That is, this isn’t like Minecraft where you’re moving a camera around and you’re seeing blocks from different angles, it’s actually moving each one. Check it out:
And the sample swing app supports interactive rotation: