Is there an example of picking objects using mouse?

This is a discussion on Is there an example of picking objects using mouse? within the Game Programming forums, part of the General Programming Boards category; Hey guys, I was just wondering if there's an example of picking and dropping objects using mouse in OpenGL? The ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    26

    Question Is there an example of picking objects using mouse?

    Hey guys,

    I was just wondering if there's an example of picking and dropping objects using mouse in OpenGL? The tutorial # 32 on Nehe isn't that helpful. I know how to rotate an object or zoom etc. using mouse which i learned from Nehe tutorial # 48 and others. However, i couldn't find a good example of how to pick an object and then drop or even better if one could move an object (means translate from one spot to another) using mouse. Any example or ideas would be apperciated. Thanks in advance!!

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> how to pick an object and then drop or even better if one could move an object

    The term "picking" in 3D graphics means determining which object (in 3-space) the mouse was pointing at when it was clicked. This is what NeHe's tutorial describes.

    Moving the object (or picking it up in plain english terms) is just a matter of translating the selected (picked) object by the amount that the mouse moves.

  3. #3
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    1. Get the screen coordinates of where the user clicked.

    2. Convert those coords to the coordinate system you're using when you draw (may not be needed)

    3. Multiply that by camera frame/matrix/orientation/however you like to call it as well as your projection matrix

    4. That point and the camera position create a ray for you to use in order to find out what object they clicked.

    Give here a spin, and let us know how it goes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving objects with mouse in 3D.
    By psychopath in forum Game Programming
    Replies: 15
    Last Post: 07-10-2011, 04:20 PM
  2. Problem in mouse position
    By Arangol in forum Game Programming
    Replies: 6
    Last Post: 08-08-2006, 07:07 AM
  3. Making a mouse hover button, API style
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 05-27-2004, 06:17 AM
  4. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 03:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21