PDA

View Full Version : help with selection ad picking??



Ali
06-18-2007, 08:19 PM
hey,
I am working on a drawing application(CSharp and Opengl)that uses mouse based picking..
for predefined drawing it is easy because you can reuse the function in GL_SELECT mode but
How will selection/picking work when I draw with the help my mouse e.g. clicking at two places to draw a line and then switching to selection mode, since the drawing has to be done in selection mode as well ...does the program has to remember all the points??

mfort
06-18-2007, 10:50 PM
Yes.
You have to remember it not only for picking but also for window updates.
Use Model View Controller design pattern.
Model is your list of points.
View is your OpenGL code
Controller is your mouse listener that adds/modifies points.

Ali
06-19-2007, 01:40 AM
hey...

could you please explain how to store these points effeciently?
and another question, if I create a figure triangle or a quad using a single drawing command can it's indivisual edges be selected/picked?
thanks

mfort
06-19-2007, 01:51 AM
Q1: don't know, vectors? try it and then profile your app, next time you choose the right method for the first time ;-)

Q2: yes, you can select the edges individually, but you have to "draw" them in selection mode separately.
First draw the triangles/quads, then draw only the outline edges. use different names or name stack to differentiate the triangle and edges).
See example in OpenGL programming guide, (picking car components).
Then in the selection result you will get both names when user selects edge (thats because the edge is too close to the triangle itself). You can then search for the edge name in the result list and then for triangle to get the edges first.

Ali
06-20-2007, 08:33 PM
hey..
how will selection/picking work for an imported drawing...e.g. i want to select/pick drawing in my application that was created in another software such as AutoCad or Paint

thanks