Sign in to follow this  

Rectangle marquee selection

This topic is 3679 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 all, I am implementing a rectangular marquee selection in a 3D app I am working on. I am using the good old frustum AABB test for a start. The test basically rejects an AABB if all the 8 points are on the negative side of the 6 planes making up the frustum. Problem comes when we have the intersecting cases. This method will generate false positive (i.e. a non intersecting AABB been tested positive as intersecting). The problem becomes really apparent when I have large AABB. Just wondering what is the common next level test that people use to eliminate the false positive? I am planning to do a triangle-AABB test, but not sure if this is the only way to go. I have also tried the selection buffer technique which renders each AABB using a unique color and looping through the pixels in the marquee looking for color. That method works in most case but fails when the objects are too far away for the rendering to work properly. Hope someone can advice on this. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by tts1980
Hi all,

I am implementing a rectangular marquee selection in a 3D app I am working on. I am using the good old frustum AABB test for a start. The test basically rejects an AABB if all the 8 points are on the negative side of the 6 planes making up the frustum.

Problem comes when we have the intersecting cases. This method will generate false positive (i.e. a non intersecting AABB been tested positive as intersecting). The problem becomes really apparent when I have large AABB. Just wondering what is the common next level test that people use to eliminate the false positive? I am planning to do a triangle-AABB test, but not sure if this is the only way to go.

I have also tried the selection buffer technique which renders each AABB using a unique color and looping through the pixels in the marquee looking for color. That method works in most case but fails when the objects are too far away for the rendering to work properly.

Hope someone can advice on this. Thanks.
You might post your AABB-vs-frustum code (from your description I can't quite tell how you're going about it).

Also, what are the conditions for the false positives you're seeing? Are these cases where the AABB is angled and near an edge of the frustum? Or something else?

Basically, a little more detail would probably help us in providing more useful feedback.

Share this post


Link to post
Share on other sites
Should have thought of that. Below is the C# code.


public bool FrustumAABBTest(ref Frustum f, ref AABB box)
{
foreach(Plane p in f.Planes)
{
int inCount = 8;
foreach(Vertex v in box.Vertices)
{
if(DistanceFromPlane(p, v) < 0.0f)
inCount--;
}
if(inCount == 0)
{
return false;
}
}
return true;
}



The false positive occurs when the AABB is large enough to cut a vertical plane and a horizontal plane of the frustum and yet remains outside of the frustum.

[Edited by - tts1980 on November 23, 2007 7:51:57 PM]

Share this post


Link to post
Share on other sites

This topic is 3679 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this