A while ago now, Digimap gave data.gg a SHP file containing elevation data for Guernsey, Sark, Alderney and Herm. Using this data, I’m going to place a WebGL widget on data.gg allowing users to fly around the islands. There’s two ways to approach this:
Create a height-map using the SHP data and generate game engine terrain using it. This would be done using geographic software to rasterize the data into a normal image (like a PNG) with white pixels representing high points and black pixels low (e.g. sea level).
Triangulate the XYZ points in the SHP file to create 3D meshes. This is done using an algorithm to join all the points together to form edges and faces.
This post is going to be about the latter method which is to create a mesh, I’ll do a separate post about the other method in the future. Both approaches have different pros and cons, the mesh approach may be more detailed while game engines (which is ultimately what the WebGL widget will be) will handle terrain better performance wise.
To create the mesh I’m going to be using Blender, an awesome open source 3D graphics editor. You’ll also want to grab an add-on called BlenderGIS which is a “bridge between Blender and geographic data”.
Import
Using the menu, import your SHP file. Note that the ability to import SHP files comes from the BlenderGIS add-on.
These options will appear. The field holding the elevation in my case is caused ZVALUE.
Point Cloud
Depending on your data size, this could take a while but eventually the add-on will do its job and create vertices for all the XYZ coordinates.
What you have here is known as a point cloud. There are loads of tools and algorithms to triangulate point clouds into meshes but BlenderGIS comes with one called ‘Delaunay’ which worked perfectly for me. It’s in the tools area (press T) under the ‘GIS’ tab.
Mesh
Again – this could take a while depending on your data size but eventually you’ll be presented with a mesh containing edges and faces. Due to my data set containing rock formations around the islands, it has created some planes joining the rocks to the island and other rocks. Select one of the planes and press Ctrl-Shift-Alt-F to select all linked flat faces as in the screenshot below. Use X to delete these faces.
There we have it. One mesh.
I have a large data set, so my mesh has 433,775 faces which is too many to be usable. There’s a couple of ways to simplify a mesh but I found using ‘Decimate’ modifier with a collapse ratio of 0.03 produced good results. Below I’ve reduced the mesh to 5,987 faces.
On Wednesday I did a presentation in which I made a game using Unity in ten minutes for a new local software development meet-up called lunch && code. The presentation went surprisingly well, I had concerns about the game working (live programming is a nightmare) and keeping the presentation in the ten minute time window. The games objective is to avoid being knocked off of a platform by walls that spawn every three seconds and move towards the player. The walls are made up of six cubes, one of which is destroyed at random when the wall is created leaving a gap for the player to pass through. The source code for the game is on GitHub here.
lunch && code
The event was organised by Steve Streeting who has uploaded the README.TXT intro slides here. If you’re a software developer in Guernsey you can keep abreast of future events by visiting discuss.gg or by signing up to notifications here. Events will be at lunchtime every last Wednesday of the month.
Over on sacrificialinferno.com I’ve created an in-depth post about building GameMaker games for Linux using Hyper-V. It took me considerably longer than I expected due to the amount of screenshots involved in creating a Hyper-V guest and installing Ubuntu. I used Hyper-V because my Dell XPS 13 laptop is Windows Pro which comes with Hyper-V and I thought I’d give it a shot as I’d usually use VirtualBox. Sadly, I can’t say I was very impressed as the guest was able to cause a BSOD on the host by using dynamic memory.
Anyway, the post covers the following…
Downloading and setting up a base Linux Virtual Machine (VM)
There isn’t really a good reason not to support Linux when using GameMaker which has build support out the box. I’d like to see GameMaker streamlining the build process to make it easier for people unfamiliar with setting up a Linux system, though.
Over on sacrificialinferno.com I’ve posted an update on our progress to Sacrificial Inferno since the Games Jam at the end of January. Bit late posting it on my site – sorry!
What I’m up to
I’ve been working on a mega post explaining how to build an Ubuntu version of games using GameMaker which will be posted in the coming weeks. You have to setup a Ubuntu Server, tell GameMaker how to ssh in to it and hope it builds successfully. I made the build server using Hyper-V which is my first experience with the platform. Can’t say I was very impressed – using dynamic memory allowed the guest virtual machine to use up all the hosts memory causing a Blue Screen of Death.