Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. bool WorldToScreen(const Vector& origin, Vector& screen)
  2. {
  3. auto LWorldToScreen = [&]() -> bool
  4. {
  5. if (!origin.IsValid())
  6. return false;
  7.  
  8. const auto screenTransform = [&origin, &screen]() -> bool
  9. {
  10. static uintptr_t pViewMatrix = NULL;
  11. static float* ViewMatrixOld = nullptr;
  12.  
  13. if (!pViewMatrix)
  14. {
  15. pViewMatrix = static_cast<uintptr_t>(Signatures::dwWorldToScreen);//static_cast<uintptr_t>(DH::MemoryAPI::FindPatternV2(CLIENT_PANORAMA_DLL, XorStr("0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9")));
  16. pViewMatrix += 3;
  17. pViewMatrix = *reinterpret_cast<uintptr_t*>(pViewMatrix);
  18. pViewMatrix += 176;
  19.  
  20. return true;
  21. }
  22. else if (pViewMatrix)
  23. {
  24. const VMatrix& w2sMatrix = *reinterpret_cast<VMatrix*>(pViewMatrix);
  25. screen.x = w2sMatrix.m[0][0] * origin.x + w2sMatrix.m[0][1] * origin.y + w2sMatrix.m[0][2] * origin.z + w2sMatrix.m[0][3];
  26. screen.y = w2sMatrix.m[1][0] * origin.x + w2sMatrix.m[1][1] * origin.y + w2sMatrix.m[1][2] * origin.z + w2sMatrix.m[1][3];
  27. screen.z = 0.0f;
  28.  
  29. float w = w2sMatrix.m[3][0] * origin.x + w2sMatrix.m[3][1] * origin.y + w2sMatrix.m[3][2] * origin.z + w2sMatrix.m[3][3];
  30.  
  31. if (w < 0.001f)
  32. {
  33. screen.x *= 100000;
  34. screen.y *= 100000;
  35. return true;
  36. }
  37.  
  38. float invw = 1.f / w;
  39. screen.x *= invw;
  40. screen.y *= invw;
  41.  
  42. return false;
  43. }
  44. };
  45.  
  46. if (!screenTransform())
  47. {
  48. screen.x = (Client::iScreenWidth * 0.5f) + (screen.x * Client::iScreenWidth) * 0.5f;
  49. screen.y = (Client::iScreenHeight * 0.5f) - (screen.y * Client::iScreenHeight) * 0.5f;
  50.  
  51. return true;
  52. }
  53.  
  54. return false;
  55. };
  56.  
  57. return LWorldToScreen();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement