realtime mouse picking

Is it something about clipping? Sorry, I didn’t get to it yet. For now, for me it looks like I would have to check all the triangles are drawn, from objects that handles a mouse events (about 99%).

You know what? Now it sounds that (using VBO), the “natural” OGL’s pickin mechanism would be faster.

he’s all yours, kevin.

Akuda… I’m going to give you some of the best advice that I can give you. This the advice one of my mentors gave me when I first got into the game industry…

look it up on google. =)

  • Kevin B

And this looks like long-code, low-performance and easy-to-bug method. But if you say it’s the only one working, I’ll do it.
Noone said it’s the only one working. But performance is actually exactly the other way round as you see it. OGL’s picking has most likely the lowest performance, followed by color picking.

Doing it yourself has the best performance, because you have more chance to optimize.

Think about it that way: If you really test the ray with each triangle, you’ll do about the same amount of work as GL picking, so GL picking is at least not significantly faster than the manual way.

In addition to that you can do your intersection test against a LOD hierarchy, so you do only O(log N) test instead of O(N) tests, so you’re WAY faster.

About color-picking - no need to render scene into whole vieport, you can create 1*1 pixel FBO just for picking and draw your scene into it with modified projection matrix.

grisha - Yes, but it would handle only one event for frame.

About O(log N) - what type of tree you mean?

Originally posted by akuda:
About O(log N) - what type of tree you mean?
Octree, quadtree … whatever suits your geometry.

Hmm, about those trees, should the be built each frame, or built once, and actualize after a camera movement?

I hadly can imagine, how this should work.

any tutorials?

The trees make only sense if they are build only once, not each frame. If you have moving objects, the best approach is to make a static tree for immobile objects and associate the moving objects with a tree node dynamically (that is, find the new node where the object should go after it moved every frame, but leave the rest of the tree as it is).