Sweep selection using OpenGL
Hi!
I am making a RTS game using OpenGL. So far using the NeHe lessons i succeded to implement in my little project a moving camera, mouse scroling and mouse selection. The problem I have is that i can`t figure how to implement sweep selection, i can select only one unit at a time. I went through NeHe`s lesson on selection (lesson 32)and OpenGL Red Book (online version) but could not find a solution.
Can anyone help me?
P.S. Sorry for my english.
My project`s facebook page is “DreamLand Page”
Hi,
you can do it two ways.
First one:
Project a Box into your world and do collsion detection on it.
Second one:
Render your scene with names turned on for the current Box the mouse has drawn.
The first one is much faster than the second one.
you can do it two ways.
First one:
Project a Box into your world and do collsion detection on it.
Second one:
Render your scene with names turned on for the current Box the mouse has drawn.
The first one is much faster than the second one.
“Always programm as if the person who will be maintaining your program is a violent psychopath that knows where you live”
If you read and understasnd how the selection buffer works, it will all become clear.
Put it this way: you don't *have* to have a tiny frustum for the selection draw, it can be any size you want. Also, the names returned by the gl are in depth order.
Put it this way: you don't *have* to have a tiny frustum for the selection draw, it can be any size you want. Also, the names returned by the gl are in depth order.
[size="1"]
That was my second one.
But that is slow, because you have to do an extra render path.
Box - Sphere collison or Box - Box is much faster.
And you will need some kind of collison detection any way ...
But that is slow, because you have to do an extra render path.
Box - Sphere collison or Box - Box is much faster.
And you will need some kind of collison detection any way ...
“Always programm as if the person who will be maintaining your program is a violent psychopath that knows where you live”
I know that the "selecting box" can be as big as u want. What I can`t understand is how do you resize the "selecting box" (frustum) while you are draging the mouse.
My project`s facebook page is “DreamLand Page”
You save your starting point and where you are now.
That each frame (or every second or thrid) you call your frustrum,
with one corner the starting and the other corner the current mouse position.
That each frame (or every second or thrid) you call your frustrum,
with one corner the starting and the other corner the current mouse position.
“Always programm as if the person who will be maintaining your program is a violent psychopath that knows where you live”
This is not going to be easy. I will have to figure out how to implement your sugestion dragongame (I am a beginner in programming). Anyways thank`s for youre input guys.
My project`s facebook page is “DreamLand Page”
On mouse down, store the mouse position, on mouse up, calculate the center of the selection box, and pass the width and height params to opengl. Remember, selection usually occurs on mouse up, not in real-time as you drag the mouse.
--Michael Fawcett
Thank`s for your tip mfawcett.
My project`s facebook page is “DreamLand Page”
Quote: Original post by mfawcett
On mouse down, store the mouse position, on mouse up, calculate the center of the selection box, and pass the width and height params to opengl. Remember, selection usually occurs on mouse up, not in real-time as you drag the mouse.
Actually, you can make a flag that gets toggled to on when the mouse button is pressed and off when it is depressed and have the value of x,y stored upon the initial click. Then, inside your mouse-move event, you have a check for if the flag is toggled on. If it is, then you make your selection box's dimensions be from the initial x,y value to your current x,y value and you can do selection as you are dragging the selection box.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement