C# World To Screen
Hey I am trying to make c# Overlay Esp. But cant get my W2S working....


Doesnt look nice does it ?
Well World To screen just dont work.
W2S function:
How I call it..
Any help is appreciated.


Doesnt look nice does it ?

Well World To screen just dont work.
W2S function:
Code:
bool WorldToScreen(Vector3 from, ref Vector3 to, float[] flMatrix)
{
float w = 0.0f;
to[0] = flMatrix[0] * from[0] + flMatrix[1] * from[1] + flMatrix[2] * from[2] + flMatrix[3];
to[1] = flMatrix[4] * from[0] + flMatrix[5] * from[1] + flMatrix[6] * from[2] + flMatrix[7];
w = flMatrix[12] * from[0] + flMatrix[13] * from[1] + flMatrix[14] * from[2] + flMatrix[15];
if (w < 0.01f)
return false;
float invw = 1.0f / w;
to[0] *= invw;
to[1] *= invw;
int width = (int)(this.Right - this.Left);
int height = (int)(this.Bottom - this.Top);
float x = width / 2;
float y = height / 2;
x += (float)(0.5 * to[0] * width + 0.5);
y -= (float)(0.5 * to[1] * height + 0.5);
to[0] = x + this.Left;
to[1] = y + this.Top;
return true;
}
Code:
for (int i = 1; i <= 64; i++)
{
Vector3 w2s = new Vector3();
var pMatrix = new float[16];
Buffer.BlockCopy(Mem.ReadMem(ClientDLL + of.ViewMatrix, 64), 0, pMatrix, 0, Mem.ReadMem(ClientDLL + of.ViewMatrix, 64).Length);
Player pCurrent = new Player(Mem.ReadInt(ClientDLL + of.EntityList + ((i - 1) * 16)), Mem);
if (WorldToScreen(pCurrent.Position, ref w2s, pMatrix))
font.DrawString(null, "Nice", (int)w2s.X, (int)w2s.Y, new SlimDX.Color4(Color.Green));
}