Sunday, June 14, 2009

End of the beginning.

Due to various reason, we decided to pull out of this Years Imagine Cup. A major stumbling block with the project was the difficulty of producing a user interface in XNA. Once hit the point progress slowed down completely, as well I had other matter with my studies.

However just looking over the blogs now has rekindled my interest, not only that, I believe I now have the required skills to bring this project through to a finish.

I'm not in a hurry though, I have exams soon, which are important, and multiple other projects. I have a website, http://www.metalmonkeygames.com/ , which has another blog and details about different projects.

I've been working on another game user WPF, and I reckon I could bring over many of the elements i've learnt in that over to this project. Using WPF for the user interface, and XNA for the game engine will make things much easier.

I will keep using this blog for any developments on this project.

Thursday, December 4, 2008

Country Colours

After drawing the country borders, my next task I wanted to do was have each country it's own colour. Because while Cornflour Blue worked for water, it just wasn't working for the land.

Now I had all the vertex points making up the shapes of the countries, but in order to color them in, it wasn't as simple and clicking flood fill in paint.

Each shape had to be converted into triangles, as a triangle is simple for a graphics card to draw. Any shape can be converted into triangles, and there are a few different methods to do this.

Photobucket

I downloaded a triangulation class from http://www.xnawiki.com/index.php?title=Polygon_Triangulation
How it works it is goes through each set of 3 points in the polygon and checks if the triangle is what is called an 'ear'. If it is, it can be removed from the polygon and set aside. And the process is continued on the now smaller polygon.

This process will continue, removing triangles until only 1 triangles is left, then we know have a list of triangles which we can draw.

However there were a few problems with this code I downloaded, at one point my visual studio kept freezing up, turns out it was stuck in an infinite loop. The reason was I was sending an extra vertex point (In the shapefile, the first and last point of the polygon is the same, completing the shape. The triangulation does not accept this extra point).

While I caused it by sending the wrong data, it not very good of the original programmer to have the possibility of an infinite loop in their programming (They used a 'Do' loop while the polygon has more then 3 points, so if the data is incorrect and no points get removed, it would loop forever).
If it were me, I would have done dome kind of checking to make sure the process is working, and break out of the loop if it's not.

Anyway, I got it working, here is the result;
Photobucket
North Africa

Photobucket
Central America

The shapefile came in two resolutions, i'm using the low resolution one here.

Thursday, November 20, 2008

Mentors

I talked to one of our lecturers today, Mike Lopez. He has agreed to be our team's Academic Mentor. Mike started us off on learning about XNA. He has a wealth of programming knowledge and experience and I'm sure will be a great help to us!

Wednesday, November 19, 2008

The World

There are two ways XNA can draw lines. As a LineStrip, where we get one long line going through all the points from start to finish. Or a ListList, which gives individual lines between points.

For drawing the world border data, I needed a bit of both, continuous lines around a country, but each country is separate from each other.

Since all the vertex data is in one array, it needs a list of indices to tell the graphics card which lines to draw.

If I had any graphical talent, I would come up with a fancy diagram explaining what I mean... but I don't.


After creating the vertices and the indices, they can then be copied to the graphics card, and unless they need to be changed, they will only need to be copied once, which gives a huge boost to performance.


As I mentioned in my previous post, I wrote an importer for the Xbase file that comes with the shape file. Here is a screen shot of the countries with their names.



At the moment I can scroll around the world, and zoom in and out. However what will be more difficult is getting the world to wrap around in the East and West direction.

Monday, November 17, 2008

Shapefile Importer

While we are still deciding on a topic as of now. I have started working on a shape file importer for the XNA content pipeline.

A shapefile is a popular Geospatial vector data format, and contains different types of shape data, from 2dD points, polylines, polygons to 3d shapes.

The datafile I'm using is from the 'thematic mapping' blog, and contains the borders of all the countries.

The shapefile comes in a binary format, however there was enough information on the wikipedia to write an importer for it. I haven't done anything like this before, and it was actully easier then I thought it would be.

Here is a sample of the border data drawn in XNA;



The shapefile comes with a database file in an xBase format, which contains information for the shapes, in the case of the world border data, it has information like Country Codes, Names and Populations. I have also written an importer for this.

Michael

Sunday, November 16, 2008

Imagine Cup 2009

I'm starting this blog to document our teams project for the 2009 Imagine Cup.

Presently out group consists of two people, Michael and Graham. We are based in Auckland, New Zealand.