Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DynamicBox(C_CSPlayer* pEntity) {
- if (!pEntity)
- return;
- if (pEntity == HL2::GetLocalPlayer())
- return;
- if (pEntity->GetNetworkable()->IsDormant())
- return;
- if (pEntity->IsDead())
- return;
- Color color = Color::White();
- if (pEntity->GetTeamNum() == 2)
- color = Color::Red();
- else if (pEntity->GetTeamNum() == 3)
- color = Color::Cyan();
- const matrix3x4_t& trans = *(matrix3x4_t*)(pEntity + HL2::Dynamic::Entity::m_rgflCoordinateFrame);
- Vector3 min = *(Vector3*)(pEntity + HL2::Dynamic::Entity::m_Collision + HL2::Dynamic::Entity::m_vecMins);
- Vector3 max = *(Vector3*)(pEntity + HL2::Dynamic::Entity::m_Collision + HL2::Dynamic::Entity::m_vecMaxs);
- max.z += 10;
- Vector3 pointList[] = {
- Vector3(min.x, min.y, min.z),
- Vector3(min.x, max.y, min.z),
- Vector3(max.x, max.y, min.z),
- Vector3(max.x, min.y, min.z),
- Vector3(max.x, max.y, max.z),
- Vector3(min.x, max.y, max.z),
- Vector3(min.x, min.y, max.z),
- Vector3(max.x, min.y, max.z)
- };
- Vector3 transformed[8];
- for (int i = 0; i < 8; i++)
- VectorTransform(pointList[i], trans, transformed[i]);
- Vector3 flb, brt, blb, frt, frb, brb, blt, flt;
- if (!HL2::WorldToScreen(transformed[3], flb) ||
- !HL2::WorldToScreen(transformed[0], blb) ||
- !HL2::WorldToScreen(transformed[2], frb) ||
- !HL2::WorldToScreen(transformed[6], blt) ||
- !HL2::WorldToScreen(transformed[5], brt) ||
- !HL2::WorldToScreen(transformed[4], frt) ||
- !HL2::WorldToScreen(transformed[1], brb) ||
- !HL2::WorldToScreen(transformed[7], flt))
- return;
- Vector3 arr[] = { flb, brt, blb, frt, frb, brb, blt, flt };
- float left = flb.x;
- float top = flb.y;
- float right = flb.x;
- float bottom = flb.y;
- for (int i = 0; i < 8; i++) {
- if (left > arr[i].x)
- left = arr[i].x;
- if (top < arr[i].y)
- top = arr[i].y;
- if (right < arr[i].x)
- right = arr[i].x;
- if (bottom > arr[i].y)
- bottom = arr[i].y;
- }
- float x = left;
- float y = bottom;
- float w = right - left;
- float h = top - bottom;
- gRenderer.DrawBorderBoxOut(x, y, w, h, 1, color, Color::Black());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement