Archived

This topic is now archived and is closed to further replies.

Takki

Isometric Calculations

Recommended Posts

do you mean converting from screen coordinates to iso map coordinates, or taking a rectangular graphic and making it into an iso graphic?

the answer to either one is "yes", but i dont want to go into an explanation of both in a single post.

Share this post


Link to post
Share on other sites
The first one - we (me and my team) made a "normal" 2d map and now we want to bring this to iso... so it is only a translation from these 2d world coordinates to the corresponding iso coordinates.

Share this post


Link to post
Share on other sites
I don't know of any transitional functions off the top of my head, but I'm sure there is one. The thing is, though, I don't believe that the transition from 2D to Isometric will be a pretty one. Things may not look right. Generally, just get your 2D map and rotate it 45 degrees. That should generally do it, but I'm may be wrong.

------------------
Dino M. Gambone
http://www.xyphus.com/users/dino

Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites
Well, a general transformation from a standard rectangular coordinate system to a iso coordinate system is to take a column vector of your x-y coordinates, premultiply by a 2x2 n degree rotation matrix, premultiply by a 2x2 x-y scaling matrix and then add an x-y translation factor. For my work n is 45 degrees, so this worked fine. Your milage may vary.
So it looks like: (though I might have some of the matrices off a little)

| x-scale 0 | * |cos n -sin n | * | x | + | x-trans |
| 0 y-scale | |sin n cos n | * | y | | y-trans |

If this doesn't look right copy and paste into a fixed width text editor.

Share this post


Link to post
Share on other sites
you might want to try this(havent checked, but it's probably correct)
with x,y coordinates from the left bottom corner in the 2d map (By the way i'm not sure if ISO was 30º... just change it for the actual degrees)

y' = x*sin30 + y*sin30
x' = x*cos30 - y*cos30

Share this post


Link to post
Share on other sites
You really don't have to use sin or cos or anything that difficult. If your tiles are at a set ratio 2:1, 3:1, etc, then a simply calculation like the following should work:

// the 2 means 2:1 - use 3 for 3:1
isox = mapx - mapy;
isoy = (mapx / 2) + (mapy / 2);

So, if we want to map something at map coordinate 128, 128, then the iso coordinates would come out to:
isox = 128 - 128; // 0
isoy = (128/2) + (128/2); // 64+64 = 128

Or map coordinates 128, 0:
isox = 128 - 0; // 128
isoy = (128/2) + (0/2); // 64+0 = 64

Note that the iso coordinates are in screen plotting coordinates. So when rendering from map coordinates to the iso coordinates on screen, the origin is the top-most point of the top-most tile, with positive x running down and right and positive y running down and left.


Jim Adams

Share this post


Link to post
Share on other sites
The above uses 2:1 as an example - that means the tiles are twice as wide as they are high (64x32 for example).

Also, 45 degrees around y is correct, but it's also 30 degrees along x. This'll give you a 2:1 ratio.

Jim Adams

Share this post


Link to post
Share on other sites
Many thanks to you Jim! I tested your simple formula - and it works (ok, I only tested it with a few values, but each was correct).

I only had to add the width of the original map to the new isox...

Share this post


Link to post
Share on other sites