Draw a 2D bounding box around a randomly placed 3D model

I do have a few other ideas that could be easier… But it depends on what you want.

If you just care about drawing a box and not having the coordinates, you can create a cube of LineSegs using the size of your model with TightBounds, where it is positioned appropriately, and then you apply a billboard effect to that cube object that surrounds your model. Because of how the billboard effect works, the orientation of the cube relative to the camera should not change making it appear as a box of 2 dimensions. However this cube will have depth, so after playing around with this, you can find which surface is projected at front by default and simply not draw any of the other 5 faces.

Now, as for the idea proposed in my earlier post, unlike the one I am describing now it should resize appropriately as you can imagine that in 3 dimensions orientation changes appropriately, and when converting to two dimensions the shape of this square you will end up drawing will change shape depending on not just where your model is positioned but how it is rotated relative to the camera (and of course its absolute size).

One more idea that I wouldn’t exactly recommend but may suit your needs is actually creating 4 vertical planes from the view of the camera (two horizontal and two vertical), shifting them towards the center of the screen until they collide with your object. Then using the 4 collision points it should be doable to draw a box that surrounds your object.

This is actually already used to create selection boxes as you can see from this post:

There may of course be an easier way of doing what you want, perhaps using existing API, however I am not exactly aware of anything like this, but since I started using Panda3D a bit more than a month ago, I am not very familiar with its API.

Nonetheless I hope you find these ideas useful.