PDA

View Full Version : RTS sweep selection?



overkode
02-22-2004, 10:00 PM
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.

mikael_aronsson
02-22-2004, 10:28 PM
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

overkode
02-23-2004, 09:28 AM
Hmm, I'm not sure how to do that. http://www.opengl.org/discussion_boards/ubb/smile.gif
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?

blip
02-23-2004, 12:55 PM
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).