#Brimming with Blood
1 messages · Page 1 of 1 (latest)
it works from most angles
when the point i use to determine the pulsing box's size is off screen, it falls back to covering the whole player
the pulsing gets faster depending on how low the player's health is, too!
Wait what
Please explain how you're doing this because I have a great fear that the answer is "badly"
my friend gave me a baseline that used a 3d box for the effect
until the end of this if CLIENT block https://gitlab.com/cynhole/swcs/-/blob/master/lua/entities/swcs_sensorgrenade_projectile.lua?ref_type=heads#L245
Here's my pitch
It might be technically more computation, but not much
Take the entity's (a player in this case) OBBMins and OBBMaxs and use them to calculate the 8 corners of their bounding box
ToScreen() those points and find the leftmost, rightmost, topmost, and bottommost ones
That'll give you a rectangle that perfectly covers the entity from any angle
You can then draw that rectangle with some percentage of its full height to get the health bar thing working
Given that 3D games are fundamentally about taking thousands of 3D points and mapping them to a 2D screen, I don't think a few extra ToScreen() calls will tank performance
memories of making esp 
i believe i already have a function for 3d box -> 2d gift wrapped box
the point is 100 variable units above ent origin, depending on ent health and standing vs crouching
i am going crazy i don't remember any of this code
I'm not familiar with the term "gift wrapped" in this context
trying to conform to contents
Oh, sure
Is that done with ToScreen() or some math I haven't considered?
I'm hoping it's the math one, because I don't love my solution
ToScreen :(
i haven't been able to figure out a better way to do the math
it's simply too good
Well, it's absolutely not "good"
If it doesn't have a better solution, that's a different thing
I refuse to let "This is the only available solution" mean that that solution is "good"
if you keep things local to the camera EyePos() it works very nicely
i use it for my weapons' recoil crosshair
A few things come to mind when I'm thinking about this...
A player's bounding box is symmetric so in theory all you really need is the center point and any single corner's offset from that center point and you can recreate the entire bounding box
Relatedly, the size of that bounding box is the same when viewed from any 90° angle around the ...yaw axis... for lack of a better term
I'd bet that this kind of symmetry and such could be used to make something like a lookup table or simple math to tell you the on-screen size of a player given their relative angle to the camera and distance
Though, having said that, it's possible that the perspective weirdness at the edges of the screen might be an issue
I feel like ToScreen is a poorly written function
I'm not a mathmatographer, but I feel like this is a solved problem
let me find the C side of it
4 calls to CurrentView() seems good
specifically the Clip transform function right above that
compiler optimizes it to one call and holding the obj