//! GLU Picker /*! * A class to perform picking in a (hopefully) easier manner * Instructions: * * 1) Use glLoadName with a different number when rendering each "pickable" object * * 2) Use picker's PerformPicking() in ProcessEvent method. The returned object will be the closest * * 3) If you want you can look at App.currentlyPicking in your Redraw method * (e.g. to simplify graphics, not draw ignored objects, etc. when in picking mode) * * * Based in a great tutorial by gpWiki: http://gpwiki.org/index.php/OpenGL:Tutorials:Picking * */ /* * Copyright (C) 2010 Alejandro Valenzuela Roca, , http://lj9.mexinetica.com/ * * This file is part of MotorJ, a free framework for videogame development. * * * * MotorJ is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MotorJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with MotorJ. If not, see . */ #ifndef PICKER_CLASS_H #define PICKER_CLASS_H #ifdef VISUAL_STUDIO #include #endif #include #include #include "universe-class.h" #include "app.h" #define MJ_SEL_BUFF_SIZE 256 class mjPicker { public: mjPicker(); mjPicker(GLuint bufferSize); ~mjPicker(); void SetBufferSize(GLuint bufferSize); int PerformPicking(GLfloat x, GLfloat y); GLfloat pickingMatrix[16]; float selRadius; GLuint* selBuffer; GLuint selHits; GLuint bufferSize; }; #endif