Irregular, methods, any and all.

Started by
1 comment, last by NIm 18 years, 4 months ago
I have a question, looking at this map for reference: http://www.ibbp.com/figures/Maps/United-Kingdom.jpg (just for examples sake) #1 : I'd like to have a map, and I'd like it to be ... irregular, this is, not simply tile or hex-based .. think province-based, with odd shapes etc.. I'd imagine it'd be fictional, as it's easier to just randomly make stuff. The problem with this idea, is for the life of me, I cannot think of a way I could nicely implement such a system. There are a couple of ideas I have, one being: I could use OpenGL or DirectX. I could implement provinces in a way such as: I could simply use a collection of polygons to create a "province", with the "province" holding a record of the polygons used, I could use a picking method to detect when a region is being selected and work from that. However, I'm wondering, is that absolutely stupid? I'd imagine there must be a better way. One of the other less feasible options, is simply displaying an image, bitmap maybe and using unique colours for each province. However, this has some drawbacks, it doesn't solve anything in the way of highlighting a province when selected, for example. I'd still need the math to do that. Another drawback being, for a sufficently large map, I'd imagine this would look very horrible. Also, I don't real like the idea of having unique colours for each problems, as I'd like colours to represent terrain for example. I'd like to stick to a non-3dlib if possible, but I don't mind trying new things, especially if it's a superior solution. Anyone who has played any Paradox games should understand what I'm going for. http://www.the-nextlevel.com/reviews/pc/europa_universalis_2/europa_universalis_ii_3.jpg for those that haven't. For those that reply, please post in sufficent detail as you can tell, I'm pretty new to this. Thanks to those that have read.
Advertisement
That just looks like a graph of arbitrary concave polygons to me.

Just keeping the regions as the verticies of the polyhedra should be fine. If you need faster lookups, also keep a bounding rectangle for each region. Then you can do a rough test on the bounding rectangles to figure out which handful of regions need the difficult test.

If you restrict yourself to convex polyhedra, then is_point_inside_polygon test is not that hard. Of course, you could always make any convex polyhedron out of multipule concave ones. Any collision detection resource should be able to help with is_point_inside_polygon, in any case.
i would seem to me htat you dpn't need to have polygons at all. I would have chosen to use bitmaps to store the provinces, but that doesn't neccessarily mean that you have to keep the provinces the same color as they are on the bitmap. Draw black lines for the borders to a province, and at loading time, flood-fill each province to get it's shape and location, then draw it on the map. At Loading time detect which provinces are adjacent and give each province a list of pointers to all adjacent provinces. The way you draw the provinces really depends on what you want.
If you just want an outline, use edge-detection at loading time to find the borders of a province, than store the result in memory, and trace them with whatever type of line you want your if they are selected, draw them a brighter color than the surrounding provinces.

Hope I was helpful!

This topic is closed to new replies.

Advertisement