Developer knowledge network · moderated exchange

UnreliableCode 커뮤니티

개발자 연구, 리버스 엔지니어링 및 코딩 커뮤니티

Knowledge index살다
4Categories
919Threads
2.8K게시물
Tutorial

Screen-Space Coordinate Bounding Box Calculation with Perspective Distance Scaling [v2.4 Technical Discussion]

matrix_math_guy
Math Specialist
MEMBER
대표: 105
가입 날짜: Aug 2018
게시물: 52
감사해요: 41
3주 전 · Aug 1, 2026 3:51 PM
#1

Calculating dynamic 2D bounding boxes from 3D player coordinates:

CPP
struct BoundingBox2D { float x, y, w, h; };

bool GetPlayerBoundingBox(Vector3 headWorld, Vector3 feetWorld, const Matrix4x4& vMatrix, BoundingBox2D& outBox) {
    Vector2 headScreen, feetScreen;
    if (!WorldToScreen(headWorld, headScreen, vMatrix) || !WorldToScreen(feetWorld, feetScreen, vMatrix)) return false;
    
    float height = feetScreen.y - headScreen.y;
    float width = height * 0.45f; // Standard character aspect ratio
    
    outBox.x = headScreen.x - (width * 0.5f);
    outBox.y = headScreen.y;
    outBox.w = width;
    outBox.h = height;
    return true;
}
imgui_artisan
UI Designer
MEMBER
대표: 202
가입 날짜: Apr 2019
게시물: 54
감사해요: 28
3주 전 · Aug 1, 2026 9:05 PM
#2

The 0.45 aspect ratio multiplier fits character proportions accurately across all distances.

raycast_ryan
Ballistics Dev
MEMBER
대표: 72
가입 날짜: Sep 2019
게시물: 32
감사해요: 16
3주 전 · Aug 2, 2026 10:06 AM
#3

Clean 2D box math.