Register for your free account! | Forgot your password?

Go Back   elitepvpers > Conquer Online 2 > CO2 Main - Discussions / Questions > CO2 Programming
You last visited: Today at 06:53

  • Please register to post and access all features, it's quick, easy and FREE!


Isometric coordination - Screen to map

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 985
Received Thanks: 1,064
Isometric coordination - Screen to map

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.



{ Angelius } is offline  
Old 08/11/2013, 17:18   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,311
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?


pro4never is offline  
Old 08/11/2013, 17:43   #3
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,877
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
InfamousNoone is offline  
Thanks
1 User
Old 08/11/2013, 18:20   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,311
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.


pro4never is offline  
Thanks
1 User
Old 08/11/2013, 19:23   #5
 
elite*gold: 0
Join Date: Jan 2007
Posts: 73
Received Thanks: 6
i missed infamousenoone on AI .. bot ,
Nishikado is offline  
Old 08/12/2013, 03:46   #6
 
elite*gold: 0
Join Date: Aug 2011
Posts: 314
Received Thanks: 88
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



#Updated:
edited formula
U2_Caparzo is offline  
Thanks
1 User
Old 08/15/2013, 02:03   #7
 
elite*gold: 0
Join Date: Aug 2010
Posts: 985
Received Thanks: 1,064
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
{ Angelius } is offline  
Old 08/15/2013, 16:28   #8
 
elite*gold: 0
Join Date: Aug 2011
Posts: 314
Received Thanks: 88
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.


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.
)
U2_Caparzo is offline  
Old 08/16/2013, 08:04   #9
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 323
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

go for it is offline  
Old 08/21/2013, 21:40   #10
 
elite*gold: 0
Join Date: Mar 2005
Posts: 1,307
Received Thanks: 1,363
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
Ultimation is offline  
Thanks
3 Users
Old 08/24/2013, 04:53   #11
 
elite*gold: 0
Join Date: Aug 2010
Posts: 985
Received Thanks: 1,064
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


{ Angelius } is offline  
Reply



« Encryption method | question about programming »

Similar Threads
x,y coordination _ kind of mess
04/28/2010 - SRO Ask the Experts - 2 Replies
hii all i have problem in finding the right address of (x.y.z) i tried to find the address using the old way with cheat-engine ((float -unknown initial value < increase-decrease>)) but it's hopeless so i used google to find a way and there's idea about adding the x offset to basic character address Basic_character + X offset = x coordination Basic_character + y offset = y coordination Basic_character + z offset = z coordination



All times are GMT +1. The time now is 06:53.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.