Results 1 to 3 of 3

Thread: Selecting solids and faces of solids in the screen

  1. #1
    Member Contributor
    Join Date
    Jan 2010
    Location
    Japan - Greece
    Posts
    99

    Selecting solids and faces of solids in the screen

    Hello,

    In the application I am currently writting I have come across the question of how I can select faces of objects rendered on the screen or the objects themselves.

    I am using wxWidgets and as with any other GUI lib I can easily get click Coordinates on the GLCanvas. The problem is how I can understand where on the openGL world the click was. I guess this must be a pretty common question but I can already understand that the answer can't be simple and must depend on how I keep the solids data structure in my program. I would really value any hints or pointers towards the right direction though!

    One additional question would be about rendering solids on the screen. I read somewhere that GL_TRIANGLES is the easiest surface for openGL to draw. Is that true? And if it is so then wouldn't it be wise for an application to try and draw everything with triangles only?
    My Blog

  2. #2
    Member Contributor
    Join Date
    Aug 2009
    Posts
    78

    Re: Selecting solids and faces of solids in the screen

    To "convert" canvas coords to your world you can use gluUnproject (see my post here ). This gives you approximate 3d coordinates or a 3d-ray from the camera location into the scene which you can use manually to compute intersections with objects you want to select.

    A more direct approach to select objects / primitives in your scene is provided by the selection mechanism or e.g. color based picking. See here for details.

    Regarding your last question - GL_TRIANGLES is probably the easiest method in the sense that it is easy to understand: Three vertices, one triangle at a time. However, there are further methods starting with GL_TRIANGLE_FAN/STRIP that are more efficient because only one additional vertex needs to be specified for each triangle after the first one. Much faster and more advanced methods like vertex arrays also exist.

  3. #3
    Member Contributor
    Join Date
    Jan 2010
    Location
    Japan - Greece
    Posts
    99

    Re: Selecting solids and faces of solids in the screen

    _x57_ thank you very much. I tried it and the method with gluUnproject works like a charm. Now it will be my app's responsibility of course to see whether the user's click is on an object or not.

    Also thanks for your advice on drawing. I have read about vertex arrays too. Since I strive (in the end) for my app to be as fast as possible I will have to take a much more extensive look at them.
    My Blog

Similar Threads

  1. How to remove material from Solids?
    By MichaelA in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-21-2011, 02:05 PM
  2. Trying to draw solids, faces not appearing correct
    By Lefteris in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 01-04-2010, 07:25 AM
  3. visualizaing solids and lines
    By ricardoangelico in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-28-2004, 01:41 PM
  4. solids of revolution?
    By el-ozz in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-29-2002, 07:57 PM
  5. glut Platonic solids
    By JohnD in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 06-05-2000, 06:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean