Rectangle marquee selection

Started by
1 comment, last by tts1980 16 years, 5 months ago
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.
Advertisement
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.
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]

This topic is closed to new replies.

Advertisement