For a 2d top down tiles-based game I am currently creating, I need to parse a .exr file holding heightmap data into my mongodb (or convert it to some other format and then read into the database).
This is basically the representation of my game world, which I crafted through using Terragen.
I figure I need to read out the heightmap data for each pixel and then convert that to a x,y tile in my database.
If I can do this I should be left with a 2d array of tiles with various x,y coordinates and elevations attached to them. From there, I should be able to determine the type of tile for that place in the game world, and continue further.
However, I have no idea how to extract the data from this .exr file and then read it into a 2d geospatially indexed array on my mongoDB database.
I hope someone can help! :)
Ok, I'm going to respond with a partial answer. If anyone has a full answer please do add it and I will update.
In order to solve this problem, I brought the .exr file into Photoshop and then saved as a 32 bit .tif file. From here, I downloaded GDAL (http://www.gdal.org/) and installed the gdal_translate utility.
The utility then is able to take the .tif data and section it off into multiple .png files for me.
Finally, I parse each .png file seperately into my database, adding subsequent data to each "pixel" that I run through as I parse through all the png files.
End up with a 2 dimensional geospatial array with very exact elevation data.