PDA

View Full Version : Polygon Picking ??



Majestik
02-18-2002, 12:44 PM
Has anyone done a polygon picking code ?

i'd like the user able to select a polygon
using the mouse pointer, i could do it
using a polygon/vector collision
but i don't know how to compute the
vector defined by the mouse position.

Any help would be appreciated !
thx !

francois

harryx
02-18-2002, 01:50 PM
Just use the selection buffer.

It is all explained in the red book.

Majestik
02-18-2002, 01:52 PM
well it's object picking ...
and i won't put a name on each polygon
of my object http://www.opengl.org/discussion_boards/ubb/smile.gif
and further more it's pretty slow !

V-man
02-18-2002, 05:11 PM
Another method is to render each poly in a certain color. When you click on it, you use gluPickMatrix as usual and read the color in the region. You dont have to use SwapBuffers so the user will never see the oddly colored scene.

V-man

harryx
02-18-2002, 05:19 PM
how i get vector into screen:

get mouse in 2d space where:

centre (0,0)
min (-aspect,-1)
max (aspect,1)

now:
fov = field of view (y)
aspect = aspect ratio (w/h)
ori = camera orientation (3*3 matrix)

vector ray=vector(mouse.x*fov*aspect,mouse.y*fov,-1) * ori;

you might then want to normalize the ray vector


[This message has been edited by harryx (edited 02-18-2002).]

Eric
02-19-2002, 12:50 AM
Originally posted by Majestik:
well it's object picking ...
and i won't put a name on each polygon
of my object

Then, how do you think you will recognise one polygon from another ??? Choose any method you want: you'll still end up having to define some variable to tell which polygon is which ! And you may as well call that variable a name...


Originally posted by Majestik:
and further more it's pretty slow !

Well, what did you compare that method to ?

Regards.

Eric



[This message has been edited by Eric (edited 02-19-2002).]

opla
02-19-2002, 01:17 AM
well it's object picking ... and further more it's pretty slow !
yes, it's slow on ATI cards, but it's fast on nVidia cards.

have a look to http://64.33.37.114/objectpicking.html and look the picking tutorial of the DirectX8 SDK