PDA

View Full Version : "sweep selection" volume



joda
11-04-2004, 04:36 AM
hey,

Im working on an algorithm to produce a selection volume based on a "sweep selection" (rectangle) input. What I want is a bounding box volume based on coordinates from screenspace (selection) and the far clipping plane (correct me if Im wrong).

The "selection volume" will then be matched against model boundingboxes to check if they are inside or outside. (I know there are other ways to do this in ogl but this algorithm will be used for other purposes).

This is not a pure OpenGL thing but the forum could probably give some input.

So, any tips or hints or examples would be great! Or input on how to solve this!

thanks,

-j

991060
11-04-2004, 05:49 AM
Basically, you only need to apply the OpenGL transformation backwards(viewport->device coordinate->projection->modelview). You'll need the inverse of the projection and modelview matrix, since OpenGL provides such function, it'll be relatively easy.

rgpc
11-04-2004, 06:24 PM
If I understand correctly you want to drag a rectangle on the viewport and select objects inside that region.

This is basically just a variation of checking if your objects are inside the frustum or not. The rectangle you drag extrudes from the near plane to the far plane with the same shape as the frustum ("conical" for perspective and "cubic" for orthagonal). You will know the four corners that make your rectangle so you just need to calculate their position on the near plane, then extrude those four points out to your far plane.

From there you calculate the equations of the six sides of your selection volume, and treat it like a frustum (there's probably a million and one functions out there that you can use to check if your object is inside the volume you have created).

This is really a mathematics question and probably should be moved to that forum... I have no idea what 991060 is getting at...

joda
11-08-2004, 01:15 AM
thanks for the replies ... its definitly a question of math, will take this further in another forum, just wanted to check it up with you people!

thanks again!

-mk-