This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nitrogenfingers's profile picture

3D Heightmaps in Computercraft

Started by nitrogenfingers, 01 May 2015 - 07:26 AM
nitrogenfingers #1
Posted 01 May 2015 - 09:26 AM
I was playing around with some old code I posted some months ago and was thinking about what I could do with it. A few ideas came together and I'm going to have a go this weekend at making a navigable 3D heightmap in computercraft. It's going to require a lot of changes to my old 3D code but I'm optimistic it's doable.

I made a mockup of what a heightmap in CC might look like:



So the idea is that each corner of these triangles is a 3D point you put in a big list, which then adds faces to the front of them and colours them according to their properties; if the face is very steep it probably a cliff so it has a grey face, if it's low altitude it's grass green, if it's high it's rocky or snowy so grey or white and so on. In this mockup I set 0 to be sea level, so points below that are translated and are blue if all vertices are sea level, or yellow if at least one is. But I also tossed around the idea of having a separate model or vertex storage system available so from above the water is at 0 but if you go underwater you can see what's beneath.

I was sort of inspired by other games that did height maps with a very limited colour palette and processing power, which although mostly cosmetic, shows it can sort of be done:


I think in my head I had the ultimate idea of turning this into a flight simulator. I'd program turtles to move around my world, as they can collect and produce height maps from real minecraft worlds far easier than writing them manually, and then convert the height points of my blocks into the vertices used to make the map. Then I'd program some basics physics, and have the camera move like a plane so you can fly around your now smoother-yet-blockier world on a monitor.

Does anyone have any comments, ideas on how this might work or how foolish the endeavor is, things they might do with it?
DannySMc #2
Posted 01 May 2015 - 10:03 AM
This is a great idea and actually could be easily done! I think it would be cool to use monitors on the floor that face up to have like height maps and have a turtle update it every now and then sending back the coords and the data, then the computer can create a virtual map in memory and display it? Hmm I have so many cool ideas for this!

Edit: Might make a projector for CC if this gets made, an awesome mod idea :D/>

Edit2:

If you wanted to make it a game then you can use a game to interact with the computer to receive the map etc, and like how minecraft works, it can save the world in chunks and probably would be good to get a turtle with a chunk loader attached!
Edited on 01 May 2015 - 08:06 AM
Bomb Bloke #3
Posted 01 May 2015 - 10:12 AM
I was sort of inspired by other games that did height maps with a very limited colour palette and processing power, which although mostly cosmetic, shows it can sort of be done:

Your main problem isn't really colour depth, and it's certainly not processing power; it's display resolution. Those screenshots you've got there, from the golden days of yore, have well over 100x the amount of pixels the standard ComputerCraft display has. Granted, they're limiting their rendering area to about a quarter of the screen, but that's still well over about 20x…

Other than that, and the slow speed at which turtles traverse the world, I think it's quite viable.

You might consider a different method of gathering your terrain data. Command Computers are one obvious alternative (by playing a variant of the classic "higher/lower" guessing game, you should be able to pinpoint the highest block at each x/z co-ord with something less than ten commands.getBlockInfo() calls, on average), though those systems have an obvious limitation in that one doesn't always have the required privileges to use them.

It might also be possible to get hold of the sort of code used by the likes of AMIDST. Subject to change depending on the version of MineCraft installed (and that's before you even think about what mods might be affecting things…), but I doubt there's a faster method than generating the data directly from the world seed.
CrazedProgrammer #4
Posted 01 May 2015 - 10:23 AM
That would be really cool!
Maybe you can make it monitor compatible so you can have a 0.5 scale 8x6 monitor with 162 by 80 pixels resolution. (wiki link)
I'm looking forward to this :D/>
Edited on 01 May 2015 - 09:49 AM
DannySMc #5
Posted 01 May 2015 - 11:34 AM
That would be really cool!
Maybe you can make it monitor compatible so you can have a 0.5 scale 8x6 monitor with 140 by 80 pixels resolution.
I'm looking forward to this :D/>

Yeah this could work!!