Raised This Month: $31 Target: $400
 7% 

Solved How to reconcile the coordinates and scale of the radar map with ingame coordinates


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
randunel
Member
Join Date: Mar 2007
Old 04-04-2020 , 11:12   How to reconcile the coordinates and scale of the radar map with ingame coordinates
Reply With Quote #1

I'm building a platform (sm plugin + backend server + web page) in which I'm showing CS:GO players in realtime on the web, with optional delays.

A demo of work in progress (web page + csgo client) is available here: https://gfycat.com/equatorialcomplexcockerspaniel
1. left hand side:
- web browser
- map background (radar) with broken coordinates and scale
- players in yellow with undeterminate team (in demo, me)
- T players are red circles
- CT players are blue circles
- black dots are bullets
- yellow dots are various entities on the map
2. right hand side:
- csgo game
3. observe csgo player (right) moving in the browser (left, yellow circle)

The problem: I can't align the SVG map in the web page, because I can only get the map's upper-left coordinates from resource/overviews/de_dust2.txt (pos_x, pos_y) and scale as a float, with no means to correlate this information to the X/Y/Z+orientation coordinates being retrieved from the game server (each player's and each entity's coordinates).

Can anyone help in reconciling the position and scale of the radar map (.dds file in resource/overviews/*.dds) with the coordinates retrieved from srcds's logging of players and entities?

Last edited by randunel; 04-05-2020 at 08:50. Reason: Solved
randunel is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-04-2020 , 11:45   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #2

One guy made this earlier
[CSGO] Live game data (Open source)

https://github.com/jonaslagoni/csgoLiveServer
__________________
Do not Private Message @me
Bacardi is offline
randunel
Member
Join Date: Mar 2007
Old 04-04-2020 , 11:56   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #3

Thank you for sharing that, I had no idea someone else had attempted this. It would appear that he manually set up the web page to match the de_dust.bsp coordinates:

Code:
function getPosX(pos_x){
  return ((Math.abs(pos_x+2850))/6.0)-10;
}
function getPosY(pos_y){
  return ((Math.abs(pos_y-4073))/6.0)-10;
}


I was hoping there's a more automated way of doing things, instead of manually figuring out the coordinates one map at a time using an unknown amount of attempts.

A recap of the data that's available:
- dds (image) 0,0 coordinates in game, part of .txt file (mapping of img(0,0) -> ingame(X,Y))
- dds (image) scale as a float, might be able to retrieve using a plugin. This is normally calculated ingame, Valve have a tutorial on how to do this
- ingame coordinates of every entity and player

Would it be possible for a SM plugin to retrieve the radar'x X,Y (corner) coordinates and its scale, programmatically? If so, then some maps have the X,Y coordinates of the bombsite in the radar .txt file, and 2 points would suffice to automate scaling things.

Last edited by randunel; 04-04-2020 at 12:00.
randunel is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-04-2020 , 12:29   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #4

I haven't in long time doing maps and radars.

It should be possible, SourceMod plugin to read map's overviews file.
example

csgo\resource\overviews\de_dust2.txt
Code:
// HLTV overview description file for de_dust2_v2.bsp

"de_dust2"
{
	"material"	"overviews/de_dust2_v2"	// texture file
	"pos_x"		"-2476"	// upper left world coordinate
	"pos_y"		"3239"
	"scale"		"4.4" 
	"rotate"	"1"
	"zoom"		"1.1"	

	// loading screen icons and positions
	"CTSpawn_x"	"0.62"
	"CTSpawn_y"	"0.21"
	"TSpawn_x"	"0.39"
	"TSpawn_y"	"0.91"

	"bombA_x"	"0.80"
	"bombA_y"	"0.16"
	"bombB_x"	"0.21"
	"bombB_y"	"0.12"
}
...rest is maths and programming, what you like to do with this information.

I have not tested. I just shared info.
__________________
Do not Private Message @me
Bacardi is offline
randunel
Member
Join Date: Mar 2007
Old 04-04-2020 , 12:41   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #5

Exactly right, but "pos_x" and "pos_y" are the only ones guaranteed to be present, offering one of 2 mappings, mapping of img(0,0) -> ingame(X,Y).

Unfortunately, *Spawn_* and bomb* are neither guaranteed, nor accurate. They appear to have been added by a human, and do not match srcds's entity coordinates, leading to a skewed output (e.g. bullets landing in walls are not on walls, but either in the air, or inside of walls).

However, slightly skewed and partial map support is better than nothing at all Thanks for looking into this, so far.
randunel is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-04-2020 , 22:28   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #6

I have played little bit, I maybe found a trick.

I uploaded test plugin, it's kindy messy.
- It read map overview file ...resource/overviews/%s.txt
- And print on server console every 3 seconds, human players coordinates and so on...

--

Ok, what you could do is MakeVectorFromPoints
https://sm.alliedmods.net/new-api/ve...ctorFromPoints

Because, we have a map offset ("pos_x", "pos_y") from KeyValue file
and player location GetClientAbsOrigin
https://sm.alliedmods.net/new-api/cl...lientAbsOrigin
PHP Code:
// Final result in map_pos[3]
// And right order, from map corner to -> player location.
MakeVectorFromPoints(map_offsetplayer_posmap_pos); 

Then, I decide to invert Y scale.
PHP Code:
map_pos[1] = -map_pos[1
This way I can start from radar map upper-left corner 0,0 (right side picture)


Finally, you divide coordinates with map "scale"
PHP Code:
// You should get coordinates which fit in picture 1024 x 1024 dimension.
map_pos[0] /= scale;
map_pos[1] /= scale

- I'm not 80% sure, is this right way to do it. But works some how.
- All those radar *.dds pictures what I can found are 1024 x1024. Maybe that is basic dimension.
Attached Files
File Type: sp Get Plugin or Get Source (radartest.sp - 42 views - 4.2 KB)
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-04-2020 , 22:40   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #7

Sry double post.
I post just results, from de_dust2
results
__________________
Do not Private Message @me
Bacardi is offline
randunel
Member
Join Date: Mar 2007
Old 04-05-2020 , 08:43   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #8

Bacardi, you're right! Thanks for helping me realise that each dds image pixel translates to "scale * pixels" coordinates ingame. This means that I don't need any other known points to calculate, given that each image pixel (e.g. point 1024x1024) translates to 1024*scale as ingame coordinates.

In case anyone finds this thread in a future search: just multiply the size of the image with the "scale" parametre to calculate the ingame coordinates shown by the radar map.

Demo with the result: https://gfycat.com/unimportantringedirrawaddydolphin

This problem is solved, thank you!

Last edited by randunel; 04-05-2020 at 08:57. Reason: added demo
randunel is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 04-04-2021 , 12:09   Re: How to reconcile the coordinates and scale of the radar map with ingame coordinat
Reply With Quote #9

Quote:
Originally Posted by randunel View Post
Bacardi, you're right! Thanks for helping me realise that each dds image pixel translates to "scale * pixels" coordinates ingame. This means that I don't need any other known points to calculate, given that each image pixel (e.g. point 1024x1024) translates to 1024*scale as ingame coordinates.

In case anyone finds this thread in a future search: just multiply the size of the image with the "scale" parametre to calculate the ingame coordinates shown by the radar map.

Demo with the result: https://gfycat.com/unimportantringedirrawaddydolphin

This problem is solved, thank you!
https://forums.alliedmods.net/showth...83#post2742983

For example, de_aztec_radar.vdc " This is on all standard maps, resolution (1024*1024)/10 = map coordinates.
How do I draw players on the map texture? This needs to be rendered in real time, and somehow drawn on the map texture.

Last edited by tonline_kms65; 04-04-2021 at 12:16.
tonline_kms65 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:00.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode