• Advertisement
Sign in to follow this  

Best way to compute BR from BB?

This topic is 460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

 

I want to find an optimized way to compute a bounding rectangle in screen space from a bounding box in 3D.

 

The best way I've been considering so far is to operate in homogeneous coords and project the BB vertices to screen space. For vertices behind the camera I will find the line-intersection point with the XY-plane. Then I use Liang–Barsky to compute the bounds in screen space. I would also capitalize on optimization opportunities wherever I can find them, e.g. don't look for intersection points when 2 connecting BB vertices are behind the camera.

 

So I just wanted to check if anyone knows of some better idea, maybe something you used? Maybe there are some methods specifically aimed for finding the BR from a BB?

 

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

I've used something sort of similar.  its pretty close.

 

Question.  Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

 

What are you doing in screen space, I assume its a HUD overlay?

Share this post


Link to post
Share on other sites

I've used something sort of similar.  its pretty close.

 

Question.  Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

 

What are you doing in screen space, I assume its a HUD overlay?

I think it can be used in many different contexts. Right now I'm going to use it for refraction. To only copy part of the backbuffer that's covered by the objects BB.

Share this post


Link to post
Share on other sites

I've used something sort of similar. its pretty close.

Question. Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

What are you doing in screen space, I assume its a HUD overlay?

I think it can be used in many different contexts. Right now I'm going to use it for refraction. To only copy part of the backbuffer that's covered by the objects BB.
In that case you want an axis aligned to the screen. I would take your 3d bounding box extents and use the wvp matrix and multiply it out. Recalc the extents in screen space as yet won't be aligned and you have your new bounding box in 2d space and clip as you have mentioned. It's quick.

Good luck

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement