Main Page | File List

Picking.h

00001 /**
00002  *\file         Picking.H
00003  *
00004  *\brief        OpenGL Picking.
00005  *
00006  *\author       Xianming Chen
00007  *
00008  *\date         15 Aug 2004
00009  *              
00010  */
00011 
00012 
00013 #ifndef _PICKING_H
00014 #define _PICKING_H
00015 
00016 #include <GL/glut.h>
00017 
00018 class Picking 
00019 {
00020     enum { invalid_selected_id = -1 };   
00021     enum { hit_buff_sz = 1024 };
00022     int selected_id;
00023 
00024     GLuint selectBuf[hit_buff_sz];
00025     int processHits(int hits);
00026 
00027 public:
00028     Picking() : selected_id(invalid_selected_id)                          { }
00029 
00030     /* Pick a rectangle area of (x, y, width, height) in the given viewport. Return picked object name id. */
00031     int operator() (int x, int y, double width=2, double height=2);
00032 
00033     int GetSelected()                                                     { return selected_id; }
00034     void UnSelect()                                                       { selected_id = invalid_selected_id; }
00035 };
00036 
00037 #endif
00038 

Generated on Sun Aug 15 16:22:50 2004 by doxygen 1.3.6