
#include "MidiVizFractalTree.h"

MidiVizFractalTree::MidiVizFractalTree(int config){
  treeFractal = new TreeFractal(config);
}

MidiVizFractalTree::~MidiVizFractalTree(){
  cout << "begin ~MidiVizFractalTree" << endl;
  delete (&treeFractal);
  cout << "end ~MidiVizFractalTree" << endl;
}

void MidiVizFractalTree::draw(){

  glPushMatrix();

  //  glLoadIdentity();

  glTranslatef(position[0], position[1], position[2]);
  glRotatef(rotation[2], 0.0, 0.0, 1.0); 
  glRotatef(rotation[1], 0.0, 1.0, 0.0); 
  glRotatef(rotation[0], 1.0, 0.0, 0.0); 
  glScalef(scale[0], scale[1], scale[2]);

  treeFractal->draw();

  glPopMatrix();
}

void MidiVizFractalTree::frame(){
  	treeFractal->frame();

}

void MidiVizFractalTree::processMidiEvent(MidiEvent event){
  int note = event.getNote();
  float velocity = (float) event.getVelocity();
  float velocityScaled = velocity/127.0;
  int note_index = note %12;
  
  treeFractal->playNote(note_index, velocityScaled);  

}


