How to get x,y,z position from .map ix?

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

User avatar
frcol
Posts: 99
Joined: 22 Aug 2010, 09:26
Location: Brazil
Contact:

How to get x,y,z position from .map ix?

Postby frcol » 27 Nov 2014, 13:39

Hi bax and Paolo,
I´m creating a GPS inside my application and to show where things are we´ve decided to get the .map to get the x,y position of the tiles that we need.

What´s exactly the logic used to tranform ix in coordinates (ex: 21486 in a 100x80 map)? It´s coordinate is 86,54,2.

We need the 86,54,0 tile, but we don´t know it, we just have the 21486.

we are subtracting 8000 (each layer Z), so this tile is in z = 2.
then we divide the result (5486) by 100 (the width), result = 54,86 (the y position = 54)
Then we get the 0,86 and multiply by 100 (width), and get the x = 86

Is that correct? It will work for all tiles?

thanks
Fabio Colombini
Brazil
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: How to get x,y,z position from .map ix?

Postby Bax » 02 Dec 2014, 07:57

ix counter starts from the lower level (z=0) and from the tile in the upper, left corner (x=0, y=0), moving right and down.
So your math is right.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 9 guests