Thread: Clicking an Object in OpenGL.

  1. #1
    Registered User gpr1me's Avatar
    Join Date
    Mar 2006
    Posts
    14

    Clicking an Object in OpenGL.

    In my program i want to be able to make an object (like a plane made with a GL_QUAD) clickable.

    So if i have a plane displayed on the screen i want to be able to click on a point on the screen and get the X, Y position on the plane (not the screen). Is this some sort of collision detection or something?

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    This is called "Picking". Im sure google has lots to say about it, also, NeHe has a tutorial on it.

  3. #3
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    You can define 2 variables: mouseX and mouseY and set them equal to the mouse's position.
    Code:
    case WM_MOUSEMOVE:							
    {
         mouseX = LOWORD(lParam);	
         mouseY = HIWORD(lParam);	
         return 0;					
    }
    just do some calculation to figure out the X,Y on the plane.
    Hello, testing testing. Everthing is running perfectly...for now

  4. #4
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    Edit:

    I just read your post again and what I said to do was completely wrong. Nevermind.
    Illusion and reality become impartiality and confidence.

  5. #5
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    Yes it is called Picking and can be done by shooting a ray down the position of the mouse and testing to see if it is intercecting with a plane of test, if this is some sort of first person view just use the cameras look vector for your ray.

  6. #6
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Yes it is called Picking and can be done by shooting a ray down the position of the mouse and testing to see if it is intercecting with a plane
    don't forget to transform that ray with your projection matrix.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. synchronization object choosing
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 03-22-2008, 04:33 AM
  2. Replies: 4
    Last Post: 11-14-2006, 11:52 AM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM