In my engine I need a selection system that works for simple picking and dragging.
However dragging won’t work with GL selection buffer which is what I’d use. I don’t know of any other kind of geometric selection, so I’m thinkin that I have:
about 300 points, 300 points possible on the screen
will use gluProject to find the screen 2d positions of these points so they can be compared to the 2d mouse pointer to see if the mouse has selected them
But I’ve read that gluProject may not be efficient enough to do this. Beware this is a game where speed is important.
Please give me lots of info I’ve spent many hours on the problem.
I used the opposite way. gluUnProject the screencoordinate where you picked with z = 0.0 and another time with z = 1.0. Then you get a line in 3D object space from the mouse position back in space. Then you cut this line with your objects in 3D. Should be faster, as you have less matrix multiplications (i think 3 muls for every gluProject). When you got a structure like octrees or bsp it could be very fast to determine what the line hits.
I use it in a modeller and I have objects with a lot of faces (>2000). The picking runs well.
Don’t you mean world space Kilam? Well, I can excuse you for confusing object space with world space since you are working on a modeling program where the object and world spaces are usually the same.
I don’t know if this falls into the same boat as the gl selection buffer, but I thought I’d mention it…
The gl feedback mechanism can give you the projections of your points into screen coordinates pretty quickly.
You could use the GL_2D argument when calling the glFeedbackBuffer() function, call glRenderMode(GL_FEEDBACK), render the points, …
Then, you can parse the feedback array and get the 2D positions back. Use the insertion of GL_PASS_THROUGH_TOKENs to identify which point is which. I’m not sure if this is faster than looping with gluProject, but I thought I’d mention it.
I have no idea how to do that, looking into the Red Book right now.
I would have looked at this already, but I was told that feedback would be slower than/less efficient than using un/projection
functions.
Here it is: You put in a 2D screen point and get back two point describing the line in world space (DFrey: Yep, world space… object space and world space are really the same in my prog. Although I got more than one object, they are all positioned in world space as the modelling kernel calculates the 3D positions).
Your ray selection sounds really good! I have a question regarding this, though. What is a BSP (or OctTree). I was thinking about intersecting the 3D world line with object to find out if it hits and it seems that testing each and every object in the scene is not the way to go. If you could briefly explain what a BSP is (or point me to a web-page) I’d really appreciate it.