 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.
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 ColumnMajor variation with those values and an Entity X,Y,Z i get this :
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 :
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.
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 ColumnMajor variation with those values and an Entity X,Y,Z i get this :
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;
}
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

87.9 KB Views: 4