PDA

Click to See Complete Forum and Search --> : Isometric - sub-position


git
Jul 23rd, 2001, 07:32 AM
Hiyas,

I'm trying to figure out how to convert a X/Y position within an isometric tile to a blit position.

For example.....a bullet is currently at the point 10.2,13.7 on a map. If you take away the main integer portions, you get the position 0.2/0.7 (approx. bottom left on a grid) in a 1x1 square...

Now, if I have a 40x19 pixel isometric tile, where 0,0 is represented at the middle top, 1,0 is represented at the middle right, 0,1 is represented at the middle left, and 1,1 is represented at the middle bottom, how do I find where on this 40x19 pixel grid the bullet would be?

If you don't have a clue what I'm on about, imagine a position within a grid tile (eg. 0.3, 0.9), and how you would retrieve that as an x/y position of an isometric tile. (here's hoping that explained it in a nutshell ;))

I tried to write some code to do this, but I totally lost track of how I was trying to solve the problem....heh.

Thanks for any help!

-Git

Brykovian
Jul 23rd, 2001, 08:59 AM
Hey Git ...

There's a GameDev.Net article that has helped me get my brain wrapped around isometric theory ... it's found here: www.gamedev.net/reference/articles/article1269.asp

Here's a quote from it about doing the math:

Converting from space coordinates (x,y,z) to a pixel coordinate (x',y') in the projection requires only trivial goniometry. The table below presents the formulae for completeness (also refer to the coordinate system in the figure near the top of this paper for my definition of the x-, y- and z-axes).

Isometric: x' = x - z and y' = y + ½ (x + z)
Dimetric side view: x' = x + ½ z and y' = y + ¼ z
Dimetric top view: x' = x + ¼ z and y' = y + ½ z


Basically, you need to figure out at what height (z) you want the bullet to appear, then do the math to calc the x & y ... I suppose this means you could put a shadow at z=0 and your bullet at z=.5 (or whatever) for a nice bullet-above-the-ground effect.

Anyhow ... how that helps.

-Bryk

Nirces
Jul 23rd, 2001, 10:51 AM
Depends on defination of Isometric i suppose.

My Isometric Engine, uses a 45 Degree Angle, with a Specified Tile Height/Width

So hieght is Specided as TileCo-ord.y + z, x remains the same.

kedaman
Jul 23rd, 2001, 03:31 PM
a generic n-dimensioned isometric projection would be the sum of the unit vector's projections (which is a user defined vector) multiplied with the component, for each dimension. For three dimensions we have a displacement (px,py,pz) projected in D:
D = X*px + Y*py + Z*pz

big letters indication vectors and small letters indicating scalars.