Question about selection

Started by
2 comments, last by Hydrael 18 years, 4 months ago
I am currently able to select objects using the opengl selection mode. Currently, objects are selected via a right-mouse-down click. My question here is, assuming that a particular object has already been selected by a right-mouse-down click, what would be the easiest way to determine if the next left-mouse-down click happens to fall inside the existing selected object? (assuming i have a global pointer to the selected object already)
Advertisement
A "quick-shot" answer would be:
Either compare the ID returned from the selection buffer with the last selected ID, or insert another local pointer to the last selected object and compare them - which would look like this:

static YourObjectDatatype *pLastObject;if(pLastObject==YourGlobalObjectPointer)   //Object is the sameelse  pLastObject=YourGlobalObjectPointer; //Object not the same
Does that mean it will be necessary to process the same selection routines/functions for a left-mouse-down as well?
Not necessarily.
You could, for instance, pass a parameter to your selection routine which tells what mousebutton was pressed (maybe int iMButton - 1=left button, 2=right button, 3=middle, etc).
Then you could insert a switch(iMButton) within your selection routine and then do, whatever you want to do for each mousebutton.

Another solution (which would be less "clean") is, to simply add another global variable which holds the last pressed mousebutton

This topic is closed to new replies.

Advertisement