/* -----------------------------------------------------------------;
 * $source   : c:/ $
 * $revision : 1.0 $
 * $author   : root@null.co.za $
 * $date     : 2004/12/18 15:03:00 $
 * $desc     : $
 * $log      : $
 *
 * -----------------------------------------------------------------;
 */

#if !defined(__E_NV__)
#define	     __E_NV__

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

struct nv_mesh {

    std::string     name;           // Convenience for debugging

    int             numv;           // number of vertices
    float *         v;              // vertices
                                    // tangent basis per vertex
    float *         tangent;
    float *         binormal;
    float *         normal;

    float *         t;              // texture coords

    int             matidx;         // material index into the ase::model

    int             numf;           // number of faces
    int *           f;              // faces (indices into the array of vertices)
};

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

typedef std::vector<nv_mesh*>         nv_mesh_array;
typedef nv_mesh_array::const_iterator nv_mesh_cit;
typedef nv_mesh_array::iterator       nv_mesh_it;

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

// position of the mouse when the user clicked the button
typedef enum
{
    GL_TUMBLE,
    GL_DOLLY,
} track_modes;

typedef enum
{
    GL_WIREFRAME,
    GL_VISUALIZE_TANGENT_BASIS,
} render_modes;

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

struct c_nv {

   public :

                    c_nv ();
      virtual      ~c_nv ();

      // near and far clip planes
      nv_scalar     near_z;
      nv_scalar     far_z;
      nv_scalar     fovy;

      // client     area size
      int           width;
      int           height;

      vec2          mouse_start;
      bool          mouse_track;
      quat          track_quat;
      quat          delta_quat;
      mat4         *track_mat;
      nv_scalar    *track_z;
      nv_scalar     track_start_z;
      int           spin;
      vec2          mouse_pt_t0;
      vec2          mouse_pt_t1;
      track_modes   track_mode;

      // modelview matrix
      mat4          mv;
      nv_scalar     cam_z;

      // wireframe
      bool          fill_mode;
      bool          vis_mode;

      // model geometry
      nv_mesh_array mesh_array;
      ase::model   *model;

      // vertex program id
      GLuint        vpid;
 
   private :


};

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

void m_display  ();
void m_idle     ();
void m_mouse    ( int button, int state, int x, int y );
void m_motion   ( int x, int y );
void m_menu     ( int item );
void m_keyboard ( unsigned char key, int x, int y );
void m_reshape  ( int w, int h );

#endif	/* !defined(__E_NV__) */
