package p5;
import anar.*;



import processing.core.PApplet;

public class Test04iTchenobyl extends PApplet {

  /*
   * Example for Anar library by Guillaume LaBelle + Julien Nembrini
   * http://anar.ch
   */


  Obj myObj;

  public void setup(){
    size(800,400,OPENGL);

    // this.hint(DISABLE_OPENGL_2X_SMOOTH);

    Anar.init(this);
    Anar.drawAxis();

    Scene.myOpenGLBackground = true;

    initForm();
  }

  public void initForm(){
    Pt a = Anar.Pt( -30,30,0);
    Pt b = Anar.Pt(30,0,100);

    myObj = new Revolve(new Pts(a,b),60);

    Anar.slidersReset();
    Anar.sliders(a);
    Anar.sliders(b);
    Anar.camTarget(myObj);

    // println(myObj.parentList());

    // String[] st = new String[1];
    // st[0] = myObj.parentListGraphViz();
    // saveStrings(this.getClass().getName()+".dot", st);


    // Pts ncopy = new Pts(Anar.scene.actualView);
    // ncopy.rotateZ(PI/2f);
    // ncopy.stroke(255,0,0);
    // myObj.add(ncopy);

    Anar.add(myObj);

  }

  public void draw(){
    background(255);
    myObj.draw();
  }

  // public void keyPressed(){
  // if(key==' ')
  // initForm();
  // if(key=='o')
  // Anar.scene.actualView.ortho();
  // if(key=='p')
  // Anar.scene.actualView.unortho();
  //    
  //    
  // }

  public void keyPressed(){
    switch(key){
      case ' ':
        initForm();
      break;

      case 'o':
        Anar.scene.actualView.ortho();
      break;

      case 'p':
        Anar.scene.actualView.unortho();
      break;

      case 'i':
        ObjExporter.export(Anar.main);
        RhinoScript.export(Anar.main);
        Autolisp.export(Anar.main);
        SketchUpRuby.export(Anar.main);
        PovRAY.export(myObj);
      break;
      
      case 'a':
        println(Anar.main.toANSYS());
        break;
    }
  }

  public static void main(String[] args){
    PApplet.main(new String[]{Test04iTchenobyl.class.getName()});
  }
}
