2y ago · Apr 8, 2024 4:15 PM
Sharing my helper functions for drawing bottom-center snaplines and connected skeletal bones in Dear ImGui:
Tips for smooth rendering:
- Set for smooth anti-aliasing.
- Draw bounding boxes and text names using so they appear cleanly behind your ImGui menu windows.
CPP
// Draw Snapline from bottom screen center to enemy origin/feet
void DrawSnapline(const ImVec2& targetScreenPos, ImU32 color, float thickness = 1.0f) {
ImVec2 screenCenterBottom = ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y);
ImGui::GetBackgroundDrawList()->AddLine(screenCenterBottom, targetScreenPos, color, thickness);
}
// Draw Bone Segment
void DrawBoneSegment(const Vector3& from, const Vector3& to, ImU32 color) {
Vector2 screenFrom, screenTo;
if (WorldToScreen(from, screenFrom) && WorldToScreen(to, screenTo)) {
ImGui::GetBackgroundDrawList()->AddLine(
ImVec2(screenFrom.x, screenFrom.y),
ImVec2(screenTo.x, screenTo.y),
color, 1.5f
);
}
}Tips for smooth rendering:
- Set
CPP
ImDrawListFlags_AntiAliasedLines- Draw bounding boxes and text names using
CPP
ImGui::GetBackgroundDrawList()
GlowShader | Shaders, Stencils & DirectX DrawLists
The following users thanked GlowShader for this post: