Advertisement
tonti666

Untitled

Sep 16th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. CEsp::ESPBox CEsp::GetBOXX(IClientEntity* pEntity)
  2. {
  3. ESPBox result;
  4. // Variables
  5. Vector vOrigin, min, max, sMin, sMax, sOrigin,
  6. flb, brt, blb, frt, frb, brb, blt, flt;
  7. float left, top, right, bottom;
  8.  
  9. // Get the locations
  10. vOrigin = pEntity->GetOrigin();
  11. min = pEntity->collisionProperty()->GetMins() + vOrigin;
  12. max = pEntity->collisionProperty()->GetMaxs() + vOrigin;
  13.  
  14. // Points of a 3d bounding box
  15. Vector points[] = { Vector(min.x, min.y, min.z),
  16. Vector(min.x, max.y, min.z),
  17. Vector(max.x, max.y, min.z),
  18. Vector(max.x, min.y, min.z),
  19. Vector(max.x, max.y, max.z),
  20. Vector(min.x, max.y, max.z),
  21. Vector(min.x, min.y, max.z),
  22. Vector(max.x, min.y, max.z) };
  23.  
  24. // Get screen positions
  25. if (!Render::WorldToScreen(points[3], flb) || !Render::WorldToScreen(points[5], brt)
  26. || !Render::WorldToScreen(points[0], blb) || !Render::WorldToScreen(points[4], frt)
  27. || !Render::WorldToScreen(points[2], frb) || !Render::WorldToScreen(points[1], brb)
  28. || !Render::WorldToScreen(points[6], blt) || !Render::WorldToScreen(points[7], flt))
  29. return result;
  30.  
  31. // Put them in an array (maybe start them off in one later for speed?)
  32. Vector arr[] = { flb, brt, blb, frt, frb, brb, blt, flt };
  33.  
  34. // Init this shit
  35. left = flb.x;
  36. top = flb.y;
  37. right = flb.x;
  38. bottom = flb.y;
  39.  
  40. // Find the bounding corners for our box
  41. for (int i = 1; i < 8; i++)
  42. {
  43. if (left > arr[i].x)
  44. left = arr[i].x;
  45. if (bottom < arr[i].y)
  46. bottom = arr[i].y;
  47. if (right < arr[i].x)
  48. right = arr[i].x;
  49. if (top > arr[i].y)
  50. top = arr[i].y;
  51. }
  52.  
  53. // Width / height
  54. result.x = left;
  55. result.y = top;
  56. result.w = right - left;
  57. result.h = bottom - top;
  58.  
  59. return result;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement