1
\$\begingroup\$

If I have a mesh of triangles and going to make a selection on it using a region (and not rectangle using Glu.gluPickMatrix(...);), how can I implement it?

\$\endgroup\$
1
\$\begingroup\$

Here's how I would do it: Using the dimensions of the box you've selected on the screen, define a new 'camera' (view and projection matrices) which defines that region of the screen and the frustum that extrudes out from that region into world space.

From there, you can go through your primitives and emulate the rasterization pipeline by converting vertex positions into Normalized Device Coordinates. Anything that falls in the range [-1,1] in each of the axes is a primitive which is being selected.

Note that my explanation is really suited for finding selected vertices, and some additional logic would have to be added to determine which triangles were selected.

\$\endgroup\$
3
  • \$\begingroup\$ what about an intersection calculation between projected 2D line on meshe's surface ? \$\endgroup\$
    – Tigran
    Apr 17 '12 at 8:49
  • \$\begingroup\$ What are the endpoints of the line your talking about? It sound's like that's more suited for a single-click selection, but perhaps I'm misunderstanding. \$\endgroup\$ Apr 17 '12 at 15:40
  • \$\begingroup\$ The user is able (should) to construct a region by clicking the point on the screen, so the lines between points are drawn, so region constructed. One time it's constructed the triangles that are inside that region become selected. \$\endgroup\$
    – Tigran
    Apr 17 '12 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .