Results 1 to 4 of 4

Thread: RTS sweep selection?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Kingston, Ontario, Canada
    Posts
    2

    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.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: RTS sweep selection?

    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

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Kingston, Ontario, Canada
    Posts
    2

    Re: RTS sweep selection?

    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?

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    13

    Re: RTS sweep selection?

    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).

Similar Threads

  1. Sweep Selection in OpenGL
    By Jorufo in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-24-2008, 11:16 AM
  2. "sweep selection" volume
    By joda in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-08-2004, 01:15 AM
  3. sweep selection for multiple objects????
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-18-2002, 01:23 AM
  4. sweep selection for multiple objects
    By rajesh_malik in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-17-2002, 10:33 PM
  5. looking for an example of Sweep Selection
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-10-2002, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean