Hey guys. Im making esp for BF3 and I just can't get this fixed. Its world to screen. Im using mikroC W2S:
Problem is if i aim exactly on enemy box is okay, even if i move mouse up or down ( so Y is okay):

But if i move my camera left or right this is what happens:

I think problem is in W2S. I made hack for bf3 in C#, translated this W2S funtcion (above) and it worked, idk what is problem here (guess its something with X).
Thank you for your answers! Janck.
Code:
bool WorldToScreen(Vec3 vWorldLocationVec3, Vec3* vOut)
{
int height = getScreenHeight();
int width = GetScreenWidth();
DWORD GameRenderer;
float fovY; //angle :).
Mat4 firstPersonTransform;
float aspect = width / height;
ReadProcessMemory(Target.Handle, (void*)(OffsetGameRenderer), &GameRenderer, 4, NULL);
ReadProcessMemory(Target.Handle, (void*)(GameRenderer + 0x98), &fovY, sizeof(FLOAT), NULL);
ReadProcessMemory(Target.Handle, (void*)(GameRenderer + 0x50), &firstPersonTransform, sizeof(firstPersonTransform), NULL);
D3DXVECTOR3 vOrigin = D3DXVECTOR3(firstPersonTransform[3][0], firstPersonTransform[3][1], firstPersonTransform[3][2]);
D3DXVECTOR3 vLeft = D3DXVECTOR3(firstPersonTransform[0][0], firstPersonTransform[0][1], firstPersonTransform[0][2]);
D3DXVECTOR3 vUp = D3DXVECTOR3(firstPersonTransform[1][0], firstPersonTransform[1][1], firstPersonTransform[1][2]);
D3DXVECTOR3 vForward = D3DXVECTOR3(firstPersonTransform[2][0], firstPersonTransform[2][1], firstPersonTransform[2][2]);
D3DXMATRIX viewMatrix;
D3DXMatrixIdentity(&viewMatrix);
viewMatrix._11 = vLeft.x; viewMatrix._12 = vUp.x; viewMatrix._13 = vForward.x;
viewMatrix._21 = vLeft.y; viewMatrix._22 = vUp.y; viewMatrix._23 = vForward.y;
viewMatrix._31 = vLeft.z; viewMatrix._32 = vUp.z; viewMatrix._33 = vForward.z;
viewMatrix._41 = -D3DXVec3Dot(&vOrigin, &vLeft);
viewMatrix._42 = -D3DXVec3Dot(&vOrigin, &vUp);
viewMatrix._43 = -D3DXVec3Dot(&vOrigin, &vForward);
D3DXMATRIXA16 Proj;
D3DXMatrixPerspectiveFovRH(&Proj, fovY, aspect, 0.1f, 10000.0f);
D3DXMATRIXA16 viewProjectionMatrix = viewMatrix * Proj;
float mX = width * 0.5f;
float mY = height * 0.5f;
float w =
viewProjectionMatrix(0, 3) * vWorldLocationVec3.x +
viewProjectionMatrix(1, 3) * vWorldLocationVec3.y +
viewProjectionMatrix(2, 3) * vWorldLocationVec3.z +
viewProjectionMatrix(3, 3);
if (w < 0.0001f)
{
vOut->z = w;
return false;
}
float x =
viewProjectionMatrix(0, 0) * vWorldLocationVec3.x +
viewProjectionMatrix(1, 0) * vWorldLocationVec3.y +
viewProjectionMatrix(2, 0) * vWorldLocationVec3.z +
viewProjectionMatrix(3, 0);
float y =
viewProjectionMatrix(0, 1) * vWorldLocationVec3.x +
viewProjectionMatrix(1, 1) * vWorldLocationVec3.y +
viewProjectionMatrix(2, 1) * vWorldLocationVec3.z +
viewProjectionMatrix(3, 1);
vOut->x = mX + mX * x / w;
vOut->y = mY - mY * y / w;
vOut->z = w;
return true;
}
But if i move my camera left or right this is what happens:
I think problem is in W2S. I made hack for bf3 in C#, translated this W2S funtcion (above) and it worked, idk what is problem here (guess its something with X).
Thank you for your answers! Janck.
Aucun commentaire:
Enregistrer un commentaire