Isometric coordination - Screen to map

08/11/2013 15:24 { Angelius }#1
I am loading a bitmap with a fixed W/H of 467 pixel into a picture box and when that picture box is clicked i am capturing the muse X/Y and then i need to convert those X/Y into a real time map coords.

For example the market place map has a fixed width/height of 384 and the picture box where the mini map is loaded has a fixed W/H of 467.

Assuming that i clicked somewhere on the loaded picture box aka the "mini map".. Somewhere near the love stone. How do i convert the mouse X/Y to point to the exact same location on the real market map?

The point is to be able to travel to any desired location only by clicking on that location on the mini map.. Like COG does.

It seemed like a very simple task to do but mehh i suck at math and i am not getting the idea at all.
08/11/2013 17:18 pro4never#2
would you not take clicked coords and multiply them by the ratio of the map actual size vs the map displayed size to scale the coords correctly?
08/11/2013 17:43 InfamousNoone#3
Quote:
Originally Posted by pro4never View Post
would you not take clicked coords and multiply them by the ratio of the map actual size vs the map displayed size to scale the coords correctly?
The problem is that the mini-map does not display the map in such a way where "north" is north. This is why it's an isometric coordinate system.

I'm probably over complicating this, but you'd basically come up with a scale factor (of how "compressed" the mini map representation is of the actual map), and then I would use polar coordinates to do a 45-degree rotation and then scale accordingly.

I think Ultimation would be able to answer this question the best :)
08/11/2013 18:20 pro4never#4
Quote:
Originally Posted by InfamousNoone View Post
The problem is that the mini-map does not display the map in such a way where "north" is north. This is why it's an isometric coordinate system.

I'm probably over complicating this, but you'd basically come up with a scale factor (of how "compressed" the mini map representation is of the actual map), and then I would use polar coordinates to do a 45-degree rotation and then scale accordingly.

I think Ultimation would be able to answer this question the best :)
That's what I get for posting right when I wake up QQ

I believe he already posted a translation system for maps and it was quiet simple once you knew the formula. I had it working in a test version of my map viewer for a while so yah, shouldn't be overly complicated to add in if you search the forums for map editor or some similar terms.
08/11/2013 19:23 Nishikado#5
i missed infamousenoone on AI .. bot ,
08/12/2013 03:46 U2_Caparzo#6
i'm getting very nice results with this, i would say it's "exact" (the * 2 make this lost a tiny bit of the coordinate, but will not be more than 1 or 2)
Code:
    class Program
    {
        static Size pictureBox_Size;
        static Size image_Size;//the original size obv.
        static double x_Multiplier
        {
            get { return  pictureBox_Size.Width / image_Size.Width; }
        }

        static double y_Multiplier
        {
            get { return pictureBox_Size.Height / image_Size.Height; }
        }
         Point GetPoint(int x, int y)
        {
            int _x = (int)Math.Round(y * 2 / y_Multiplier + x / x_Multiplier);// / x_Multiplier) +(x % (int)Math.Round(x_Multiplier)));
            int _y = (int)Math.Round(y * 2/ y_Multiplier + (pictureBox_Size.Width -x) / x_Multiplier);
            return new Point() { X = _x, Y = _y};
        }
        static void Main(string[] args)
        {
            pictureBox_Size = new Size(){ Width = 100, Height = 100 };//the size of the pictureBox
            image_Size = new Size(){ Width = 50, Height = 50 };//the size of the loaded image
            int x = int.Parse(Console.ReadLine());
            int y = int.Parse(Console.ReadLine());
            Console.WriteLine(GetPoint(x, y));
            Console.ReadLine();
        }
    }
i based it in this simple draw :o

[Only registered and activated users can see links. Click Here To Register...]

#Updated:
edited formula
08/15/2013 02:03 { Angelius }#7
Quote:
Originally Posted by InfamousNoone View Post
I think Ultimation would be able to answer this question the best :)
I'll see if i can get him to help :P
Thanks.

Quote:
Originally Posted by pro4never View Post
I believe he already posted a translation system for maps and it was quiet simple once you knew the formula. I had it working in a test version of my map viewer for a while so yah, shouldn't be overly complicated to add in if you search the forums for map editor or some similar terms.
Spent some time searching for it but unfortunately all i found was a demo video that he posted log time ago.

Quote:
Originally Posted by U2_Caparzo View Post
Code:
    class Program
    {
        static Size pictureBox_Size;
        static Size image_Size;//the original size obv.
        static double x_Multiplier
        {
            get { return  pictureBox_Size.Width / image_Size.Width; }
        }

        static double y_Multiplier
        {
            get { return pictureBox_Size.Height / image_Size.Height; }
        }
         Point GetPoint(int x, int y)
        {
            int _x = (int)Math.Round(y * 2 / y_Multiplier + x / x_Multiplier);// / x_Multiplier) +(x % (int)Math.Round(x_Multiplier)));
            int _y = (int)Math.Round(y * 2/ y_Multiplier + (pictureBox_Size.Width -x) / x_Multiplier);
            return new Point() { X = _x, Y = _y};
        }
        static void Main(string[] args)
        {
            pictureBox_Size = new Size(){ Width = 100, Height = 100 };//the size of the pictureBox
            image_Size = new Size(){ Width = 50, Height = 50 };//the size of the loaded image
            int x = int.Parse(Console.ReadLine());
            int y = int.Parse(Console.ReadLine());
            Console.WriteLine(GetPoint(x, y));
            Console.ReadLine();
        }
    }
I appreciate the effort but the code you posted is not accurate by any means.. Its just way off.

Try to change pictureBox_Size and image_Size to the following and see for yourself.

pictureBox_Size = new Size(){ Width = 467, Height = 467};//pictureBoxSize
image_Size = new Size(){ Width = 384, Height = 384};//RealMapSize -> Market -> 1036
08/15/2013 16:28 U2_Caparzo#8
Quote:
Originally Posted by { Angelius } View Post

I appreciate the effort but the code you posted is not accurate by any means.. Its just way off.
[Only registered and activated users can see links. Click Here To Register...]

tested too in the map 1700, it seems to be that the final coordinate must be multiplied by 256/TileSize(GameMap.dat), market has a tile size of 256 so it will be just 1, but in the map 1700 the tile size is 128, and if you multiply the points given by my formula by 256/128 using the Map1700 minimap, you get a "near point" (it seems to have a linear or exponential error, i'll try to figure out it, because the larger are the maps, the error is greater.
)
08/16/2013 08:04 go for it#9
just multiply the scale factor at any x and y before proceeding, and the returning coords will be a ready to use, you would need to figure out another factor (from what i understand) that tq uses to convert from iso to screen coords

[Only registered and activated users can see links. Click Here To Register...]
08/21/2013 21:40 Ultimation#10
ok, using the minimaps isnt the best idea, there is a generic algo but it only gives u a close location not an exact location. My advise would be, use a image of the width,height of the map coordinates, i.e Windplain is 920 x 920. If you like i can run you off the map images. they will be like minimaps but the correct sizes, Or you could load the minimaps, size them to the coordinate size of the map, (they may be pixelated) and do it like that. Either works, let me know
08/24/2013 04:53 { Angelius }#11
Quote:
Originally Posted by Ultimation View Post
ok, If you like i can run you off the map images. they will be like minimaps but the correct sizes
That would be great.. Thanks :)