GET VIEWMATRIX:
float[] tmp = new float[16];
for (int i = 0; i < 16; i++)
{
var fixedAddress = ADDRESS_VIEWMATRIX + (i*0x4);
var viewMatrixAddress = BASE_CLIENT + "+0x" + fixedAddress.ToString("X8");
tmp[i] = m.readFloat(viewMatrixAddress);
}
viewMatrix = new Matrix4x4(
tmp[0], tmp[1], tmp[2], tmp[3],
tmp[4], tmp[5], tmp[6], tmp[7],
tmp[8], tmp[9], tmp[10], tmp[11],
tmp[12], tmp[13], tmp[14], tmp[15]);
WORLD2SCREEN (copy&paste):
Vector3 temp = new Vector3();
temp.Z = 0f;
temp.X = viewMatrix.M11 * world.X + viewMatrix.M12 * world.Y + viewMatrix.M13 * world.Z + viewMatrix.M14;
temp.Y = viewMatrix.M21 * world.X + viewMatrix.M22 * world.Y + viewMatrix.M23 * world.Z + viewMatrix.M24;
temp.Z = viewMatrix.M31 * world.X + viewMatrix.M32 * world.Y + viewMatrix.M33 * world.Z + viewMatrix.M34;
if (temp.Z < 0.01f)
{
return new Vector2() { X = -1f, Y = -1f };
}
var invw = 1.0f / temp.Z;
temp.X *= invw;
temp.Y *= invw;
var width = (float)SystemParameters.PrimaryScreenWidth;
var height = (float)SystemParameters.PrimaryScreenHeight;
var x = width / 2f;
var y = height / 2f;
x += 0.5f * temp.X * width + 0.5f;
y -= 0.5f * temp.Y * height + 0.5f;
temp.X = x;
temp.Y = y;
return new Vector2() { X = temp.X, Y = temp.Y };