RTS sweep selection?

Hi,
I am currently attempting to code an RTS game. I have alot of stuff in place already, like camera’s, etc. but I’m having a hard time with object selection. I have it set up so I can click on an object with the mouse cursor and it will report a hit, using the name stack and gluPickMatrix(). That isn’t where I’m having the difficulty. My problem is this: I’ve got it so when the mouse button gets pressed and stays pressed it draws a bounding rectangle in screen coordinates(like any RTS). I’m just not sure how I can select objects with this dynamic sized screen rect. Any suggestions as to how I might do this?

Thanks for any help.

Hi !

Set the position of the pick matrix to the center of the rectangle and specify width and height of rectangle as the size of the pick matrix.

Mikael

Hmm, I’m not sure how to do that.
The screen rect is being drawn with four line functions, one for each side of the selection rect:
Line(x0, y0, x1, y1); etc…

so the ortho rect is drawn like:

x0, y0-----------------------x1, y0
| |
| |
| |
x0, y1-----------------------x1, y1

but I’m not sure how I pass that to gluPickMatrix()… Will I need more than one call to gluPickMatrix() to set up the drawn rect to be a selection rect?

void gluPickMatrix( GLdouble x,
GLdouble y,
GLdouble delX,
GLdouble delY,
GLint *viewport )

PARAMETERS
x, y Specify the center of a picking region in window coordinates.

   delX, delY
        Specify the width and height, respectively, of the picking region in window coordinates.

   viewport
        Specifies the current viewport (as from a glGetIntegerv call).