Polygon Picking ??

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

Just use the selection buffer.

It is all explained in the red book.

well it’s object picking …
and i won’t put a name on each polygon
of my object
and further more it’s pretty slow !

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

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.xfovaspect,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).]

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).]

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