Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CEsp::ESPBox CEsp::GetBOXX(IClientEntity* pEntity)
- {
- ESPBox result;
- // Variables
- Vector vOrigin, min, max, sMin, sMax, sOrigin,
- flb, brt, blb, frt, frb, brb, blt, flt;
- float left, top, right, bottom;
- // Get the locations
- vOrigin = pEntity->GetOrigin();
- min = pEntity->collisionProperty()->GetMins() + vOrigin;
- max = pEntity->collisionProperty()->GetMaxs() + vOrigin;
- // Points of a 3d bounding box
- Vector points[] = { Vector(min.x, min.y, min.z),
- Vector(min.x, max.y, min.z),
- Vector(max.x, max.y, min.z),
- Vector(max.x, min.y, min.z),
- Vector(max.x, max.y, max.z),
- Vector(min.x, max.y, max.z),
- Vector(min.x, min.y, max.z),
- Vector(max.x, min.y, max.z) };
- // Get screen positions
- if (!Render::WorldToScreen(points[3], flb) || !Render::WorldToScreen(points[5], brt)
- || !Render::WorldToScreen(points[0], blb) || !Render::WorldToScreen(points[4], frt)
- || !Render::WorldToScreen(points[2], frb) || !Render::WorldToScreen(points[1], brb)
- || !Render::WorldToScreen(points[6], blt) || !Render::WorldToScreen(points[7], flt))
- return result;
- // Put them in an array (maybe start them off in one later for speed?)
- Vector arr[] = { flb, brt, blb, frt, frb, brb, blt, flt };
- // Init this shit
- left = flb.x;
- top = flb.y;
- right = flb.x;
- bottom = flb.y;
- // Find the bounding corners for our box
- for (int i = 1; i < 8; i++)
- {
- if (left > arr[i].x)
- left = arr[i].x;
- if (bottom < arr[i].y)
- bottom = arr[i].y;
- if (right < arr[i].x)
- right = arr[i].x;
- if (top > arr[i].y)
- top = arr[i].y;
- }
- // Width / height
- result.x = left;
- result.y = top;
- result.w = right - left;
- result.h = bottom - top;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement