Solved Requesting help with Matrix math

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

AvMM-

Full Member
May 11, 2019
8
24
2
Game Name
Runescape
Anticheat
not sure
How long you been coding/hacking?
15 years
Coding Language
C# preferred
So, i've got a matrix that i want to use for transforming 3D points into screen space.
5923


I've got Plater/Entity coordinates that are using the same grid system, so the numeric values of X,Y,Z are relative to the X,Y,Z i've marked on the matrix.

However when i apply the world to screen function with the Column-Major variation with those values and an Entity X,Y,Z i get this :
5924


And with Row Major, get the wrong values, which tend to be zero's most of the time. So i'm assuming this game is using column major?

I've tried using several different world to screen functions, but to no avail.

Here are some of the functions i've tried :


C#:
Vector2 WorldToScreen(Vector3 pointInWorld, Matrix view, Matrix projection, int screenWidth, int screenHeight)
        {
            Vector4 pointInNdc = Vector3.Transform(pointInWorld, view * projection);
            float screenX = (pointInNdc.X + 1) / 2f * screenWidth;
            float screenY = (1 - pointInNdc.Y) / 2f * screenHeight;
            return new Vector2(screenX, screenY);
        }
C#:
private Vector2 get2dPoint(Vector3 point3D, Matrix viewMatrix,
                 Matrix projectionMatrix, int width, int height)
        {

            Matrix viewProjectionMatrix = projectionMatrix * viewMatrix;
            //transform world to clipping coordinates
            Vector4 newPoint = Vector3.Transform(point3D, viewProjectionMatrix);
            int winX = (int)Math.Round(((newPoint.X + 1) / 2.0) *
                                         width);
            //we calculate -point3D.getY() because the screen Y axis is
            //oriented top->down
            int winY = (int)Math.Round(((1 - newPoint.Y) / 2.0) *
                                         height);
            return new Vector2(winX, winY);
        }
C#:
 private Vector2 WorldToScreen(Matrix viewMatrix, Vector2 screenSize, Vector3 point3D)
        {
            Vector2 returnVector = Vector2.Zero;
            float w = viewMatrix[3, 0] * point3D.X + viewMatrix[3, 1] * point3D.Y + viewMatrix[3, 2] * point3D.Z + viewMatrix[3, 3];
            if (w >= 0.01f)
            {
                float inverseX = 1f / w;
                returnVector.X =
                    (screenSize.X / 2f) +
                    (0.5f * (
                    (viewMatrix[0, 0] * point3D.X + viewMatrix[0, 1] * point3D.Y + viewMatrix[0, 2] * point3D.Z + viewMatrix[0, 3])
                    * inverseX)
                    * screenSize.X + 0.5f);
                returnVector.Y =
                    (screenSize.Y / 2f) -
                    (0.5f * (
                    (viewMatrix[1, 0] * point3D.X + viewMatrix[1, 1] * point3D.Y + viewMatrix[1, 2] * point3D.Z + viewMatrix[1, 3])
                    * inverseX)
                    * screenSize.Y + 0.5f);
            }
            return returnVector;
        }
Now, I Understand that some of these functions take a projection matrix, which i've tried my best to implement from the values following the View Matrix in the memory,
but that hasn't worked for me either.

There are also several view matrices, 29 recurring ones in scans at least... and i've tried plugging them all in to each function as both Row Major, and Column Major. Some seems close but still not reliable.

I would assume that the math in the functions is not the problem considering i'm using 3 different functions and getting relatively the same result.

So basically what i'm asking is... Am i using the wrong functions for this process? or am i plugging the values in wrong?

I've been at this for almost 5 days now just stuck on this one thing. Any help or guidance would be greatly appreciated.

And before any of you guys direct me to google, i've been searching for hours each day. I imagine i have the right values and I'm just implementing it wrong.

PLEASE someone explain what i'm doing wrong.
 

Attachments

AvMM-

Full Member
May 11, 2019
8
24
2
Alright, so.. I never got the Matrix to work, but Above the Float location in memory is the already converted location into mouse coords... wish i noticed that before i spent a week on this... Anyway, thanks for the help!
 
  • Like
Reactions: Rablidad

Icew0lf

Software Ninjaneer
Dank Tier VIP
Fleep Tier Donator
Aug 20, 2013
614
17,558
43
The w2s might be right but the viewmatrix is a wrong one. Normaly u have only 3 or 4 big numbers in a VM which are x y z(+Projektion row), and this should be in the right in directx games or bottom row in ogl games.
Here an example how it should look in DX:
https://www.3dgep.com/understanding-the-view-matrix/
 
  • Like
Reactions: AvMM-

AvMM-

Full Member
May 11, 2019
8
24
2
The w2s might be right but the viewmatrix is a wrong one. Normaly u have only 3 or 4 big numbers in a VM which are x y z(+Projektion row), and this should be in the right in directx games or bottom row in ogl games.
Here an example how it should look in DX:
https://www.3dgep.com/understanding-the-view-matrix/
Thanks so much for the quick reply! I'm looking into it now, but the matrix im working with is OpenGL. How will the matrix look in this case?
 

AvMM-

Full Member
May 11, 2019
8
24
2
Yes. This looks much better. Better try several matrixes together by running multiple w2s at once...it will save a lot of time
yea, i've been trying since i posted that, i still can't seem to get it right.
should the bottom row look similar to my characters X,Y,Z or is it normal to have those giant numbers?
 
Feb 10, 2019
152
2,468
18
yea, i've been trying since i posted that, i still can't seem to get it right.
should the bottom row look similar to my characters X,Y,Z or is it normal to have those giant numbers?
Start by looking at your name that the game displays on screen or your healthbar/nameplates above your player(if they exist) and see what the game calls for w2s more than likely you can just call the games w2s function instead or just simply go to the games ws2s function and copy it in c#
 

AvMM-

Full Member
May 11, 2019
8
24
2
Start by looking at your name that the game displays on screen or your healthbar/nameplates above your player(if they exist) and see what the game calls for w2s more than likely you can just call the games w2s function instead or just simply go to the games ws2s function and copy it in c#
Hey, sorry for the late reply. I'm still at it. I think i found the view transforms you were talking about above the Player base. But i'm not sure what to make of it. here is what i found.
5934
 
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