Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How can I find coordinates to screen in a map?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 172

PostPosted: Tue Nov 16, 2021 1:45 pm    Post subject: How can I find coordinates to screen in a map? Reply with quote

Im working with medieval total war 2. And im trying to understand what tells the cities to be rendered in the specific pixel coordinate in my screen.

I have the city coordinates. But what i really want is the coordinates in my screen of the city.

How should i do this?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Tue Nov 16, 2021 1:53 pm    Post subject: Reply with quote

Search for "view matrix"

You should know basic linear algebra and 3d computer graphics.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 172

PostPosted: Wed Nov 17, 2021 1:14 am    Post subject: Reply with quote

That seems to be my view coordinates, x, y, and z. What im trying to catch is the coordinates of a city in my screen.

So for example. The coordinates of the city in my map are x109, y147.
That stays the same always.

But i need to find out the pixel in my screen where the city is being rendered, when the city is being render. Because sometimes, if i move my map to the corner for example, the city will not show up.

So when the city is in the center of my screen it should be on the pixel x960, that is 1920 (my screen x size) / 2.

Is there a way to detect this?
Or thats not so easy?

I can also calculate manually.
For example i get the map size, 200x, 200y.
And i get my screen coordinates 1920, 1080.
Then i get my current map coordinates constantly.
Then i get the coordinates of the city 109, 147.

Then i check if the city is showing in my view matrix.
If it is, then calculate where it is.

Is this the way to go? Looks like reinventing the wheel?
Back to top
View user's profile Send private message
blueberrypie
How do I cheat?
Reputation: 0

Joined: 11 Nov 2021
Posts: 5

PostPosted: Wed Nov 17, 2021 5:19 am    Post subject: Reply with quote

Not sure if I understand what you are trying to do, but it sounds like you want to calculate world to screen coordinates. Like ParkourPenguin said, it involves finding your view matrix. Then you need to multiply the indexes with each other (in either row or column major order).

It's too much for me to explain in a single comment, but there are lots of guides on that, so google ahead. It's not super easy tho if you are new to that stuff.

ESPs use this technique (to render ESP boxes of e.g. NPCs in the world to the screen), so you can use those hacks for reference when you Google this.
Back to top
View user's profile Send private message
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 172

PostPosted: Wed Nov 17, 2021 7:30 am    Post subject: Reply with quote

I see now. Thank you. That will take time. Will get there someday. But now i know its not as simple as i thought.

EDIT:

Actually it seems this is even harder. There are no examples around that apply to a game like Medieval Total War 2.

The camera in this case is not like the FPS. So i dont think it just turns around like that.

I could only find the zoom variable and the x and the y variable.

I dont think i can turn around like in an FPS, but it would be so cool if it was possible.
Back to top
View user's profile Send private message
blueberrypie
How do I cheat?
Reputation: 0

Joined: 11 Nov 2021
Posts: 5

PostPosted: Fri Nov 19, 2021 5:55 am    Post subject: Reply with quote

I don't think it matters in this case. I haven't played Medieval Total War 2, but looking at screenshots it looks like it's basically 3d, just with a top down camera view depending on what screen you are in.

All games need to render to the screen, and as far as I know they do this by using different matrices and combining them. When you do world to screen calculations, you don't need to worry about any of them except for the final MVP matrix (model-view projection) matrix. That has all the calculations done by the game for you already, and that's the one you are looking for. Then you just do your world to screen calculations on that to get your final results.

The flow basically looks something like this:
1. Find the view matrix (aka MVP matrix). This is the hard part since it's hard to know/test if you got the right one. It's essentially a trial and error process.
2. Calculate clip coordinates by multiplying the position of your target (i.e. the city) with your matrix.
3. Do perspective division on the clip coordinates to turn them into NDC coordinates (normalized device coordinates).
4. Finally, transform your calculated NDC coordinates to window coordinates that you can render on the screen.

This process should be just about the same for all games, although I'm not expert and I have only done this for FPS games.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites