
// Lew Hill II
// MidiVizTrapezoid

#ifndef _MIDI_VIZ_TRAPEZOID_
#define _MIDI_VIZ_TRAPEZOID_

#include <GL/gl.h>
#include <math.h>

#include <iostream>
#include "NoteColorLookupTable.h"

#include "MidiEvent.h"

class MidiVizTrapezoid {

 public:
  MidiVizTrapezoid();
 
  void draw();

  void frame(double time);

  void startAnimation(MidiEvent* event);

  bool intersect(float in_position[]);

  void setColor(float r, float g, float b);

  float calculateDistance(float x1, float x2, 
			float y1, float y2, 
			  float z1, float z2);

  void setPosition(float x, float y, float z);

  void setRotation(float x, float y, float z);

  void setScale(float x, float y, float z);

  void setNote(int note);

  void setChannel(int channel);

  int getNote();

  int getChannel();

  bool isAnimating();

 private:
  
  float position[3];
  float rotation[3];
  float scale[3];
  float color[3];
  float dark_color[3];
  float inv_color[3];
 
  float coords[8][3];
  float bottom_coords[8][3];

  float scalefac;
  
  NoteColorLookupTable color_table;

  int note;
  int channel;

  int animationCounter;  
  // set when start animation is called...
  // counts down every frame until stop.

  int last_note_played;
  float animation_rot_speed;

  // offset from normal rest angle position of the note
  // this offset is used for animation.
  float rotation_offset[3];


};

#endif

