PDA

View Full Version : SDL/OpenGL selection example



cragwolf
08-04-2005, 04:03 AM
I have written some example code that illustrates one simple method of selecting and highlighting 3D objects in OpenGL. It uses gluUnProject + ray-sphere intersection for the selecting and stencil testing + wireframing for the highlighting. Not very original, but in case you wanted to see in action:

selection.tar.gz (http://www.ludicity.org/files/selection.tar.gz) (336 KB, there's some textures in it)

Oh, and I've only tested it with FreePascal on Linux (use fpc -Mobjfpc -dSOUND selection.pp to compile it). I suspect that some minor changes might be needed to get it to work on other platforms or with the Delphi compiler. And you need JEDI-SDL, too.

WILL
08-04-2005, 05:09 AM
If you write up a 'cover sheet' or brief description for your example -Doesn't have to be formal! I can host it on PGD for you. :) Under your name... It's really help others to have something that they can read the basic idea, look at your code, try it, play with it.

I'll even do up the HTML formatting for you. ;)

cragwolf
08-04-2005, 08:43 AM
I'll think about it, but I can't promise anything.

Lightning
22-09-2005, 01:20 PM
Can you explain how does it work a bit, it seems to give some other coordinates than it's suppose to.
How exactly do i identify wich poly i'm clicking on, in selection mode i "name" them do i get original coords here ?
Too bad selection is so slooow and limited/complicated.
Thanks.

cragwolf
03-02-2006, 04:52 AM
Can you explain how does it work a bit, it seems to give some other coordinates than it's suppose to.

Not for me. Perhaps you have a problem with your OpenGL header? Or maybe your driver?


How exactly do i identify wich poly i'm clicking on, in selection mode i "name" them do i get original coords here ?

I don't know what you're talking about. I don't use OpenGL selection mode in this example. I am not doing selection of polygons, I am doing selection of spheres. Look up "sphere-ray intersection" in any basic book on graphics, or Google it.


Too bad selection is so slooow and limited/complicated.

Again, this is probably your problem. Selection for me is fast, does what it is designed to do, and is very simple. Remember, you have the source, and good luck!