Advertisement

Isometric Calculations

Started by December 13, 1999 07:52 AM
11 comments, last by Takki 25 years ago
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.

Get off my lawn!

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.
Advertisement
That doesn't make much sense. so... tell us about your *team*.
William Reiach - Human Extrodinaire

Marlene and Me


My "team" is not the topic of this thread, is it?
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.

Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Currently working on Rise of Praxis MUD: http://www.riseofpraxis.net/

First, Iso is not 45° degrees...

And then, why should anything look wrong? The graphics aren't re-calculated, only coordinates.

Advertisement
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.

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

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

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

This topic is closed to new replies.

Advertisement