Finding an entity's on-screen dimensions in pixels

In several games, namely Deus Ex, items are outlined when selected for activation or pickup by corners around the item visually.

For example:

I’m trying to achieve the same effect in Garry’s Mod, but I’m having some difficulty determining the height and width of an entity with relation to the screen, rather than to the world.

In essence I need the width and height of the entity in pixels.

If anyone knows how to achieve this effect, I would be extremely appreciative of any help you could provide.


You can use OBBCenter, OBBmins and OBBMaxs for this.

The best way to achieve this would be looping throught all the entity models corners/vertices (obtained as RobotBoy said) or howerver you wanna call them and get the vectors of those points and use

And then as you get that you should get the smallest y and x and the biggest y and x and add some spacing.

I gave those a go a bit ago. As I recall they return the mins and maxs of the collision box without relation to the entities rotation. If I were to use it on a bathtub, for instance, it would be a rectangle even if the bathtub was facing right at me, is that right?