Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. static bool screen_transform(const Vector3& vIn, Vector3& vOut){
  2.  
  3. auto cliente_mod = _GetModuleHandleW(L"client_panorama.dll");
  4. static ptrdiff_t ptrViewMatrix;
  5. if (!ptrViewMatrix){
  6. ptrViewMatrix = (ptrdiff_t)(PatternScan(cliente_mod, OBFUSCATED("0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9")));
  7. ptrViewMatrix += 0x3;
  8. ptrViewMatrix = *reinterpret_cast<uintptr_t*>(ptrViewMatrix);
  9. ptrViewMatrix += 176;
  10. }
  11.  
  12. if (!ptrViewMatrix) { return false; }
  13.  
  14. Matrix4x4 vMatrix = *(Matrix4x4*)(ptrViewMatrix);
  15.  
  16. vOut[0] = vMatrix.m[0][0] * vIn[0] + vMatrix.m[0][1] * vIn[1] + vMatrix.m[0][2] * vIn[2] + vMatrix.m[0][3];
  17. vOut[1] = vMatrix.m[1][0] * vIn[0] + vMatrix.m[1][1] * vIn[1] + vMatrix.m[1][2] * vIn[2] + vMatrix.m[1][3];
  18.  
  19. float w = vMatrix.m[3][0] * vIn[0] + vMatrix.m[3][1] * vIn[1] + vMatrix.m[3][2] * vIn[2] + vMatrix.m[3][3];
  20.  
  21. if (w < 0.01){
  22. vOut.x *= 100000;
  23. vOut.y *= 100000;
  24. return false;
  25. }
  26.  
  27. vOut.x /= w;
  28. vOut.y /= w;
  29.  
  30. return true;
  31. }
  32.  
  33. bool WorldToScreen(const Vector3& in, Vector3& out){
  34. if (screen_transform(in, out)) {
  35. int w = 0, h = 0;
  36. i_EngineClient->GetScreenSize(w, h);
  37.  
  38. out.x = (w / 2.0f) + (out.x * w) / 2.0f;
  39. out.y = (h / 2.0f) - (out.y * h) / 2.0f;
  40.  
  41. return true;
  42. }
  43. return false;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement