/********************************************************************
 * Arcball, written by Bradley Smith, March 24, 2006                *
 *                        modified by                               *
 *                    Antonio Marin-Hernandez,                      *
 *                        November 2011                             *
 *                                                                  *
 *                Deparment of Artificial Intelligence              *
 *                      University of Veracruz                      *
 *                                                                  *
 * arcball.h is free to use and modify for any purpose, with no     *
 * restrictions of copyright or license.                            *
 ********************************************************************/


/********************************************************************
 * Using the arcball:
 *   Call arcball_setzoom after setting up the projection matrix.
 *
 *     The arcball, by default, will act as if a sphere with the 
 *     given radius, centred on the origin, can be directly 
 *     manipulated with the mouse. Clicking on a point should drag 
 *     that point to rest under the current mouse position. eye is 
 *     the position of the eye relative to the origin. up is unused.
 *
 *     Alternatively, pass the value: (-radius/|eye|)
 *     This puts the arcball in a mode where the distance the mouse 
 *     moves is equivalent to rotation along the axes. This acts much 
 *     like a trackball. (It is for this mode that the up vector is 
 *     required, which must be a unit vector.)
 *
 *     You should call arcball_setzoom after use of gluLookAt.
 *     gluLookAt(eye.x,eye.y,eye.z, ?,?,?, up.x,up.y,up.z);
 *     The arcball derives its transformation information from the
 *     openGL projection and viewport matrices. (modelview is 
 *     ignored)
 *
 *     If looking at a point different from the origin, the arcball 
 *     will still act as if it centred at (0,0,0). (You can use this 
 *     to translate the arcball to some other part of the screen.)
 *
 *   Call arcball_start with a mouse position, and the arcball will
 *     be ready to manipulate. (Call on mouse button down.)
 *   Call arcball_move with a mouse position, and the arcball will
 *     find the rotation necessary to move the start mouse position to
 *     the current mouse position on the sphere. (Call on mouse move.)
 *   Call arcball_rotate after resetting the modelview matrix in your
 *     drawing code. It will call glRotate with its current rotation.
 *   Call arcball_reset if you wish to reset the arcball rotation.
 ********************************************************************/
#ifndef _GL_ARCBALL_H_
#define _GL_ARCBALL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <math.h> 

#define _GLAB_FALSE 0
#define _GLAB_TRUE  1
#define GLAB_OK    0
#define GLAB_ERROR -1
  
  extern int glArcballInit();
  
  extern void glArcballSetZoom(float radius, float eyeV[3], float upV[3]);
  extern void glArcballRotate();

  extern int glArcballReset();
  extern int glArcballStart(int mx, int my);
  extern int glArcballMove(int mx, int my);


#ifdef __cplusplus
}
#endif

#endif /*_GL_ARCBALL_H_*/


