Solved World to Screen

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

sachamo2010

Newbie
Full Member
Mar 9, 2017
14
448
0
I've been trying to figure out W2S for about a week now and I've made some progress in understanding what it's doing but still can't figure out how to make it work...I get the feeling that I'm really close and probably missing something super simple but all the tutorials and videos go over the same stuff and it's just not clicking in my head

Looking at Rake 's guide (https://guidedhacking.com/showthread.php?8313-ESP-Overview) I followed both links at the bottom. The one about finding the ViewMatrix (https://guidedhacking.com/showthread.php?7903-How-To-Find-the-View-Matrix-With-Cheat-Engine) makes sense and I was able to learn how to find the matrix in other games as well as in AC. The other link in the main guide (https://guidedhacking.com/showthread.php?8044-World2Screen-function) goes over two different W2S functions, the first of which should apply to AC.

This is Rake's function + my comments (lines starting with // **)
C++:
bool WorldToScreen(vec3_t pos, vec3_t &screen, float matrix[16], int windowWidth, int windowHeight) {
	// **pos = x, y, z of the target (i have this)
	// **&screen = player's screen? (no idea what this is/how to find it)
	// **matrix[16] (i have this)
	// **windowWidth (i have this)
	// **windowHeight (i have this)
	
    //Matrix-vector Product, multiplying world(eye) coordinates by projection matrix = clipCoords
    vec4 clipCoords;
    clipCoords.x = pos.x*matrix[0] + pos.y*matrix[4] + pos.z*matrix[8] + matrix[12];
    clipCoords.y = pos.x*matrix[1] + pos.y*matrix[5] + pos.z*matrix[9] + matrix[13];
    clipCoords.z = pos.x*matrix[2] + pos.y*matrix[6] + pos.z*matrix[10] + matrix[14];
    clipCoords.w = pos.x*matrix[3] + pos.y*matrix[7] + pos.z*matrix[11] + matrix[15];
	// **this is fancy matrix-math to convert the pos variable & show it's relevance to our camera (i think?)
 
    if (clipCoords.w < 0.1f)
        return false;
	// **if location is behind us, return false since we can't draw that
 
    //perspective division, dividing by clip.W = Normalized Device Coordinates
    vec3_t NDC;
    NDC.x = clipCoords.x / clipCoords.w;
    NDC.y = clipCoords.y / clipCoords.w;
    NDC.z = clipCoords.z / clipCoords.w;
	// **not entirely sure what this does...assuming more fancy math tricks
 
    screen.x = (windowWidth / 2 * NDC.x) + (NDC.x + windowWidth / 2);
    screen.y = -(windowHeight / 2 * NDC.y) + (NDC.y + windowHeight / 2);
	// **convert the 3d position to our 2d screen
    return true;
}
If anybody could point me in the right direction on how to get this going, I'd greatly appreciate it. Just trying to start simple right now and draw a circle on enemy player's heads then I'll worry about drawing lines and such once I'm more comfortable with w2s.

Thanks in advance!
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,153
78,998
2,396
The argument &screen is a vector you pass by reference that the 2d screen coordinates of the enemy will be stored in when the function is completed, it's passed by reference because the function already has a return value and you need to get the screencoordinates out of local scope so it persists after the function returns
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,746
40,528
316
vec3_t &screen is the vector which will contain the screen coordinates which you can tell if you actually read what the function is doing. Just pass a {0,0,0} vector. screen.x/screen.y will be the coordinates you need after calling this function.
 

sachamo2010

Newbie
Full Member
Mar 9, 2017
14
448
0
Rake;48473 said:
The argument &screen is a vector you pass by reference that the 2d screen coordinates of the enemy will be stored in when the function is completed, it's passed by reference because the function already has a return value and you need to get the screencoordinates out of local scope so it persists after the function returns
I knew it was something simple lol. I was trying to figure out how to get a screen object or camera object or something and pass that in XD I saw that it was out'ing the X, Y but wasn't quite putting it all together. Thanks again Rake!
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods