Source Code CSS World2Screen

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
Since many People are asking them how to do external WorldToScreen in CSS, here i go:

C++:
typedef float ViewMatrix[ 16 ]; //Can be done different, i'm just using it like this

bool WorldToScreen( Vector from, Vector &to, ViewMatrix m_vMatrix ) 
{ 
	to.x = m_vMatrix[ 0 ] * from.x + m_vMatrix[ 1 ] * from.y + m_vMatrix[ 2 ] * from.z + m_vMatrix[ 3 ]; 
	to.y = m_vMatrix[ 4 ] * from.x + m_vMatrix[ 5 ] * from.y+ m_vMatrix[ 6 ] * from.z + m_vMatrix[ 7 ]; 
	float w = m_vMatrix[ 12 ] * from.x + m_vMatrix[ 13 ] * from.y + m_vMatrix[ 14 ] * from.z + m_vMatrix[ 15 ]; 
	
    if( w < 0.01f ) return false; 

    float invw = 1.0f / w; 
	to.x *= invw; 
	to.y *= invw; 

    float x = Resolution[ 0 ] / 2; // Resolution is my Global Variable which is holding the resolution of the game
    float y = Resolution[ 1 ] / 2; 
	
    x += 0.5 * to.x * Resolution[ 0 ] + 0.5; 
    y -= 0.5 * to.y * Resolution[ 1 ] + 0.5; 

	to.x = x;
	to.y = y;

    return true;
}
But how to get to the WorldToScreenMatrix( m_vMatrix in my example above ) and use it?

C++:
//Before every WorldToScreen Call:
DWORD dwTemp;
ViewMatrix W2SMatrix;
ReadProcessMemory( hlProc, LPCVOID( dwClientDLL + 0x54BE14 ), &dwTemp, 4, 0 );
ReadProcessMemory( hlProc, LPCVOID( dwTemp + 0x22C ), &W2SMatrix, sizeof( ViewMatrix ), 0 );
//Then:
if( WorldToScreen( TargetPlayer->GetAbsOrigin( ), ScreenCoordinates, W2SMatrix ) ) 
{
//Draw Shit 
}
Offsets are up2date, i may post them after updates here, but finding out, how to update them yourself should be better ;)
 

m00k00

Newbie
Silenced
Nov 27, 2012
1
151
0
Hi siM,
thanks for your code.
Do you have a tutorial or some hints how to find the WorldToScreenMatrix (i.e. in other games)?
This would be great.
Greetings
 

NubTIK

Jr.Coder
Full Member
Nobleman
Dec 5, 2012
58
1,573
1
Please, Correct me if im wrong but dont you just have the w2smatrix(3'rd param in the function) as your own position?
 

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
My own Position? Why should I use my own Position for the World2Screen?
Btw in this Code is a little Mistake with the Dll i'm reading the matrix out, it's not the client.dll, but the engine.dll.
 

NubTIK

Jr.Coder
Full Member
Nobleman
Dec 5, 2012
58
1,573
1
My own Position? Why should I use my own Position for the World2Screen?
Btw in this Code is a little Mistake with the Dll i'm reading the matrix out, it's not the client.dll, but the engine.dll.
Lol ye sorry I know I was pretty confused at the time, I know you dont need position for w2s its just that when Isaw 0x22C I knew that was the current position offset in the clocalplayer lol sorry for the inconvenience
 

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
The new Offsets:
Pointer: engine.dl + 0x58371C
Offset: Pointer + 0x2D4

Hf.
 

roarboar

Newbie
Full Member
Feb 3, 2013
27
212
0
I have some questions regarding implementation.
First of all, what is contained in the "To" and "From" parameters? I always thought To is the enemy's x,y,z coords and from is the players x,y,z coords.

Secondly, I have some programming questions, since I program in c# some of the code seems a bit peculiar to me.

From what I understand you make a float array with the length of 16.
Then you pass 16 as the buffer length to the readprocessmemory method. But usually readprocessmemory returns bytes and not floats. So do you actually get 16 real floats here or just bytes? And convert them to floats?
Needless to say if I want to retrieve 16 floats in c# i need to do 16 x 4 because each float consists of 4 bytes. Thats why this is so confusing to me.

also some values like the third index seem a bit arbitrary, when you retrieve these results do they look something like this? https://i.imgur.com/vyZNmXv.jpg

Looking forward to your replies I cant wait to finally get my esp done !
 

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
Vector from = enemys x,y,z
To = x,y Coordinates on Screen

ReadProcessMemory is taking the return value as a parameter, so depending on that, it will return the value. Because i use a Matrix of 16 Floats i have to change the size as well.
 

roarboar

Newbie
Full Member
Feb 3, 2013
27
212
0
Vector from = enemys x,y,z
To = x,y Coordinates on Screen

ReadProcessMemory is taking the return value as a parameter, so depending on that, it will return the value. Because i use a Matrix of 16 Floats i have to change the size as well.
I hope you dont mind me asking these questions but what do you mean with coordinates on screen? Coordinates of what exactly on screen? Or do you mean the X and Y of the player without taking Z into calculation?

Im sorry im just really confused because the coordinates of the screen is exactly what worldtoscreen calculates for you, so I am having a hard time understanding what exactly to pass onto this parameter.
 

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
Nope that what WorldToScreen is for, the Coordinates on the desktop where you draw at.
 

roarboar

Newbie
Full Member
Feb 3, 2013
27
212
0
Oh i see, the & sign in front of "to" is similar to the "out" keyword in c#, so you just set the to variable. Took me a while to understand since I code in c#.
Thanks im going to try when I get home.
 

roarboar

Newbie
Full Member
Feb 3, 2013
27
212
0
Alright I have implemented the code and for some reason I am getting wrong values. I am thinking it may have something to do with what I put into my matrix. Here is a screenshot:
https://i.imgur.com/eiNFyAo.jpg

On the lefthand side I selected everything that I put into the matrix in cheatengine (16 floats), and on the righthand side you can see the 16 floats in my code.
Is the vMatrix actually supposed to look like this or am I getting the wrong values or something? I am not really sure what it otherwise could be, ive used the pointer that you provided.

"engine.dll" + 58371C = e12ad00
p -> + 2d4.

EDIT:

I decided to add the code too:

C++:
        public bool WorldToScreen( Vector3 from, out Point to, float[] m_vMatrix ) 
        { 
            float toX;
            float toY;
            to = new Point();

            toX = m_vMatrix[ 0 ] * from.X + m_vMatrix[ 1 ] * from.Y + m_vMatrix[ 2 ] * from.Z + m_vMatrix[ 3 ]; 
            toY = m_vMatrix[ 4 ] * from.X + m_vMatrix[ 5 ] * from.Y+ m_vMatrix[ 6 ] * from.Z + m_vMatrix[ 7 ]; 
            float w = m_vMatrix[ 12 ] * from.X + m_vMatrix[ 13 ] * from.Y + m_vMatrix[ 14 ] * from.Z + m_vMatrix[ 15 ]; 
    
            if( w < 0.01f ) return false; 

            float invw = 1.0f / w; 
            toX *= invw; 
            toY *= invw; 

            float x = 1280 / 2; // Resolution is my Global Variable which is holding the resolution of the game
            float y = 1024 / 2;

            x += 0.5f * toX * 1280.0f + 0.5f;
            y -= 0.5f * toY * 1024.0f + 0.5f; 

            to.X = (int)x;
            to.Y = (int)y;

            return true;
        }

C++:
        public float[] ReadFloatArray(int offset, int length)
        {
            float[] buffer = new float[length];
            ReadProcessMemory(this.processHandle,offset, buffer, length * 4, 0);
            return buffer;
        }
 
Last edited:

roarboar

Newbie
Full Member
Feb 3, 2013
27
212
0
Well I got it to work, but what values does the vMatrix actually contain that we are using for the worldtoscreen function, does anyone actually know? In other words, what do the 16 floats that we use actually represent?
 

brinkz

Coder
Meme Tier VIP
Sep 3, 2012
209
1,688
12
For the new update, World 2 Screen Matrix:
engine.dll + 0x58479C ; Offset 0x2D4
 
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.

Similar threads

Community Mods