Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer
what about an intersection calculation between projected 2D line on meshe's surface ? – Tigran Apr 17 '12 at 8:49
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. – ktodisco Apr 17 '12 at 15:40
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. – Tigran Apr 17 '12 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.