Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool WorldToScreen(const Vector& origin, Vector& screen)
- {
- auto LWorldToScreen = [&]() -> bool
- {
- if (!origin.IsValid())
- return false;
- const auto screenTransform = [&origin, &screen]() -> bool
- {
- static uintptr_t pViewMatrix = NULL;
- static float* ViewMatrixOld = nullptr;
- if (!pViewMatrix)
- {
- pViewMatrix = static_cast<uintptr_t>(Signatures::dwWorldToScreen);//static_cast<uintptr_t>(DH::MemoryAPI::FindPatternV2(CLIENT_PANORAMA_DLL, XorStr("0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9")));
- pViewMatrix += 3;
- pViewMatrix = *reinterpret_cast<uintptr_t*>(pViewMatrix);
- pViewMatrix += 176;
- return true;
- }
- else if (pViewMatrix)
- {
- const VMatrix& w2sMatrix = *reinterpret_cast<VMatrix*>(pViewMatrix);
- screen.x = w2sMatrix.m[0][0] * origin.x + w2sMatrix.m[0][1] * origin.y + w2sMatrix.m[0][2] * origin.z + w2sMatrix.m[0][3];
- screen.y = w2sMatrix.m[1][0] * origin.x + w2sMatrix.m[1][1] * origin.y + w2sMatrix.m[1][2] * origin.z + w2sMatrix.m[1][3];
- screen.z = 0.0f;
- float w = w2sMatrix.m[3][0] * origin.x + w2sMatrix.m[3][1] * origin.y + w2sMatrix.m[3][2] * origin.z + w2sMatrix.m[3][3];
- if (w < 0.001f)
- {
- screen.x *= 100000;
- screen.y *= 100000;
- return true;
- }
- float invw = 1.f / w;
- screen.x *= invw;
- screen.y *= invw;
- return false;
- }
- };
- if (!screenTransform())
- {
- screen.x = (Client::iScreenWidth * 0.5f) + (screen.x * Client::iScreenWidth) * 0.5f;
- screen.y = (Client::iScreenHeight * 0.5f) - (screen.y * Client::iScreenHeight) * 0.5f;
- return true;
- }
- return false;
- };
- return LWorldToScreen();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement