PDA

View Full Version : Selection/Picking ---Imported Drawing?



Ali
06-21-2007, 01:53 AM
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

mfort
06-21-2007, 06:58 AM
It doesn't matter what you pick.
The picking routine:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPickMatrix(...);
GLuint pickedBuffer[100];
glSelectBuffer(100, pickedBuffer);
glRenderMode(GL_SELECT);
for(all objects in scene) {
glLoadName(your object ID);
render(object)
}
int pickedObjects = glRenderMode(GL_RENDER);
for(int i=0; i<pickedObjects ; i++) {
// process picked object with id pickedObjects [i];
}A list of IDs is returned to your buffer registered via glSelectBuffer.
It doesn't matter what is inside the render function that renders the object.

Ali
06-21-2007, 08:41 PM
kindly explain these lines in detail?
for(all objects in scene)
{ glLoadName(your object ID);
render(object) }

does this mean we have to reload the drawing in select mode ??
I am not clear how we will assign IDs because we are importing the drawing

Bob
06-22-2007, 02:45 AM
But what is really the problem you're having with drawing and picking imported objects?

The procedure for picking a non-imported objects is to load the ID that identifies the object to select, and then draw it. The hit record will contain any ID within the selction.

That's exactly the same procedure for imported objects. Load the ID that identifies the object, and draw it. How you assign the ID is completely up to you. Just generate a unique ID the same way you generate it for non-imported objects.

Ali
06-22-2007, 03:00 AM
thanks for explaining