Page 1 of 1

Map Coordinate Question...

Posted: Sat Nov 04, 2006 4:32 pm
by akmad
Does only here know, or can any from Firaxis tell me, the formula for the conversion from the City StartX and StartY to the map (.tga) pixel coordinates?

For these questions I'm considering the first 601x601 image in a map .tga file to be the "map". Likewise the map coordinates that I'm referencing here are the pixel coordinates on that map.

From what I can gather, a city at StartX=0, StartY=0 will be positioned around point 180, 180 on the map. It may not be exactly this but it's pretty close. However, if I consider that point to be the origin of the city layout coordinates the resulting positions for all the other cities are not correct.

If you look at the map image you'll notice that spots where cities are placed tend to be "smudged"... giving a uniform color and thus a flat terrain. Using these smudges as markers for cities I've been able to calculate that a cities location on the map can be (approximately) calculated via the following formula:

Code: Select all

Map.X = (180 + City.StartX) * .9
Map.Y = (180 + City.StartY) * .9
I don't think that this formula is correct; however I cannot tell if the formula is wrong or the starting location is wrong.

Any help on this would be greatly appreciated.

Thanks,
Wes

Posted: Sun Nov 05, 2006 5:19 am
by Lama
I did some reverse engineering on this. Here are my findings, based on the Germany map.

If you take a thumbnail of your map and resize it to 620x620 pixels, city coordinates (cc) and pixels (px) are congruent, in aspect ratio.
However, the point cc_x,cc_y(0,0) is at px_x,px_y(160,160).
To put a city at the point px_x,px_y(300,400), the city coordinates would read cc_x,cc_y(140,240), where cc=px-160.
This is true only where the px-value is above 160 on either axis.
Any cc below px_x or px_y 160 would be prefaced by a – [minus], where the value would be cc=160-px.

See if that works for other maps, as well.

Posted: Sun Nov 05, 2006 2:30 pm
by zzbusch
Lama wrote:I did some reverse engineering on this. Here are my findings, based on the Germany map.

If you take a thumbnail of your map and resize it to 620x620 pixels, city coordinates (cc) and pixels (px) are congruent, in aspect ratio.
However, the point cc_x,cc_y(0,0) is at px_x,px_y(160,160).
To put a city at the point px_x,px_y(300,400), the city coordinates would read cc_x,cc_y(140,240), where cc=px-160.
This is true only where the px-value is above 160 on either axis.
Any cc below px_x or px_y 160 would be prefaced by a – [minus], where the value would be cc=160-px.

See if that works for other maps, as well.
Huh? :wink: :?:

Posted: Mon Nov 06, 2006 12:48 am
by Lama
zz,

to translate my previous post, city coordinates do not seem to align with the pixels of the thumbnail. If a point on the thumbnail is at x,y(120,240) pixels ('px'), the city coordinates ('cc') you will want to enter in the sceanrio manager to have a city appear at that point are NOT x,y(120,240).
So how do you figure out what coordinates to enter to have a city appear at a particular point on your map?
Do as I suggested: Take a thumbnail, resize it to 620x620, use this resized map to decide where you want your city to be, then do the calculations to translate pixel-coordinates to in-game city-coordinates.

Example:
On a 620x620 image of the map, I want to place a city at a point of px_x,px_y(120,240).
The zero-point of our grid is at the point of x,y(160,160) PIXELS.

Therefore (and this is actually a simpler formula I just came up with), you always want to subtract 160 from the pixel value of each coordinate point in order to get your city location.

For x: 120-160=-40
For y: 240-160=80

Therefore, city coordinates are x,y(-40,80).