Friday, 28 February 2014

2D or not to 2D

Session 3

By session 3 I had a single OS terrain 50 data tile loaded using the ASCII file format.  However, it didn't look that great.  The reason for this is that using the Perlin noise algorithm for generating the terrain in the original application, meant that I didn't need a technique to display terrain at a particularly high fidelity.  At this point I came to a minor cross roads.  I had previously used an algorithm written in C++ that created an OpenGL triangle mesh from DTED.  I was going port it to C# and use it to display the terrain in 3D but decided that it would probably take too much time and wasn't really a core objective of the sessions.  This was recorded as another ideas for phase 2.

After ditching the idea for the triangle mesh and keeping to my simple UI approach I started to look around for some easy to implement alternatives.  I considered a few options, including some cool HTML 5 pages, but again chose to keep it simple and use a heat map and the cyclical nature of hue.  I have seen this technique used a couple of times on other projects and remembered that it was fairly simple to implement.  

The algorithm (which is described in detail here) can be used to set a range of acceptable values and then interpolates the hue value between 0 and 360 degrees.  This is then converted to RGB using the algorithm and it gives a  range of values in the same way a colour picker is displayed in a paint application.  So using this technique and applying it to the terrain model you can now see the detail of the OS terrain 50 data.  The range goes from red at its lowest point and purple to its highest. 

The same OS terrain 50 data as displayed previously but now using the colour picker technique for display.
After implementing the new display algorithm, I decided to delay the multiple tile implementation until tomorrow but prepare a new user control to enable multiple tiles instead.  To display multiple tiles I know that I will need to create the user controls in code (current plan is to display 100 tiles or all of the SU tile set) and not in the designer.  The new user control is an ASCII tile panel and inherits from the double buffered panel.  It contains a tile ID, X and Y coordinate of the tile and the file that contains the tile content.  I am not 100% happy with the design of this but for now it will be a good way to test the loading of multiple tiles.  I may revisit this in time so that the user control is valid across any tile content type.

In summary, session 3 has thrown up issues that I hadn't thought were that important initially (display of the tile data) to the main goal but I have managed to implement a timely solution and kept on track with attempting to get a decent test bed for the A* algorithm up and running in a weeks time.  Tomorrow will be using multiple tiles and ensuring that the application doesn't suffer too much from storing all the data in memory.

No comments:

Post a Comment