Exemplo n.º 1
0
  public void InitNumberBox() {
    // Initialize number box
    conf_KP =
        controlP5
            .addNumberbox("KP")
            .setPosition(550, 50)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            //      .setScrollSensitivity(5.1)//?
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right

    conf_KI =
        controlP5
            .addNumberbox("KI")
            .setPosition(550, 90)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right

    conf_KD =
        controlP5
            .addNumberbox("KD")
            .setPosition(550, 130)
            .setColorBackground(c_red)
            .setSize(60, 18)
            .setRange(0, 250)
            .setMultiplier(1) // set the sensitifity of the numberbox
            .setDirection(Controller.HORIZONTAL); // change the control direction to left/right
  }
  public void setup() {
    size(800, 600);
    background(255);

    // Local variables to set where the components will be
    int margin = 16;
    int spacing = 36;
    int w = 128;
    int h = 32;

    // Initialize ControlP5
    controlP5 = new ControlP5(this);
    // Set the color of the labels
    controlP5.setColorLabel(color(255, 0, 0));

    // Add components
    controlP5.addButton("Clear Screen", 1, margin, spacing, w, h);
    controlP5.addSlider("Leaf Red", 0, 255, 255, margin, spacing * 2, w, h);
    controlP5.addSlider("Leaf Green", 0, 255, 64, margin, spacing * 3, w, h);
    controlP5.addSlider("Leaf Blue", 0, 255, 0, margin, spacing * 4, w, h);
    controlP5.addSlider("Branch Random", 0, PI, PI / 4, margin, spacing * 5, w, h);
    controlP5.addSlider("Leaf Random", 0, 32, 16, margin, spacing * 6, w, h);
    controlP5.addSlider("Leaf Size", 0, 32, 16, margin, spacing * 7, w, h);
    controlP5.addSlider("Start Size", 0, 128, 64, margin, spacing * 8, w, h);
  }
Exemplo n.º 3
0
  public void InitButton() {
    // Set zero acc e gyro
    controlP5
        .addButton("SET_ZERO")
        // .setValue(0)
        .setPosition(450, 50)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Read PID parameter
    controlP5
        .addButton("READ_PID")
        // .setValue(0)
        .setPosition(450, 90)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("WRITE_PID")
        // .setValue(0)
        .setPosition(450, 130)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("SAVE_PID")
        //  .setValue(0)
        .setPosition(450, 170)
        .setSize(60, 20)
        .setColorBackground(c_blue);
    /*
          // START
      controlP5.addButton("START")
         .setPosition(650,50)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;

      // STOP
      controlP5.addButton("STOP")
         .setPosition(650,90)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;
    */
  }
Exemplo n.º 4
0
 public void InitSlider() {
   // Initialize slider plot
   int posX = 330;
   int posY = 50;
   AccSlider =
       controlP5
           .addSlider("Acc_RAW")
           .setPosition(posX, posY)
           .setSize(20, 100)
           .setRange(0, 1023)
           .setValue(0)
           .lock()
           .setColorBackground(c_blue);
   GyroSlider =
       controlP5
           .addSlider("Gyro_RAW")
           .setPosition(posX + 50, posY)
           .setSize(20, 100)
           .setRange(0, 1023)
           .setValue(0)
           .lock()
           .setColorBackground(c_blue);
 }
Exemplo n.º 5
0
  public void setup() {
    size(1024, 768);
    background(0);
    frameRate(30);
    smooth();

    drawVectors = false;

    paused = true;

    timeline = new Timeline();

    sim = new GravitySimulation();

    sun = new Star(5000, 25, new PVector(300, 500), new PVector(0, 0), 0, "sun");
    planet = new Planet(10, 10, new PVector(500, 500), new PVector(0, 40), "planet");
    planet2 = new Planet(50, 10, new PVector(150, 500), new PVector(0, -40), "planet2");

    timeline.registerStatefulObject(sun);
    timeline.registerStatefulObject(planet);
    timeline.registerStatefulObject(planet2);

    controlP5 = new ControlP5(this);

    btnRewind = controlP5.addButton("btnRewind_OnClick", 0, 800, 20, 50, 20);
    btnRewind.setLabel("Rewind");

    btnPlayPause = controlP5.addButton("btnPlayPause_OnClick", 0, 860, 20, 50, 20);
    btnPlayPause.setLabel("Play");

    btnFastForward = controlP5.addButton("btnFastForward_OnClick", 0, 920, 20, 80, 20);
    btnFastForward.setLabel("Fast Forward");

    sliderTimeline = controlP5.addSlider("sliderTimeline_OnClick", 0, 10000, 0, 20, 720, 900, 10);
    sliderTimeline.setLabel("Timeline");
  }
Exemplo n.º 6
0
  public void GUISetup() {
    // set up GUI
    String[] outputs = MidiBus.availableOutputs();
    String[] inputs = MidiBus.availableInputs();

    controlP5 = new ControlP5(this);
    programlabel = controlP5.addTextlabel("programlabel", "Programs", 350, 65);
    Radio programs = controlP5.addRadio("programs", 350, 80);
    programs.deactivateAll();
    programs.add("on", 1);
    programs.add("off", 2);
    programs.add("oscillate", 0);
    programs.add("fade", 4);
    programs.add("random", 3);

    midioutlabel = controlP5.addTextlabel("midioutlabel", "MIDI Outputs", 200, 65);
    Radio midioutdevices = controlP5.addRadio("midioutdevices", 200, 80);
    midioutdevices.deactivateAll();
    for (int i = 0; i < (outputs.length - 1); i++) {
      midioutdevices.add(outputs[i], i);
    }

    midiinlabel = controlP5.addTextlabel("midiinlabel", "MIDI Inputs", 100, 65);
    Radio midiindevices = controlP5.addRadio("midiindevices", 100, 80);
    midiindevices.deactivateAll();
    for (int i = 0; i < (inputs.length - 1); i++) {
      midiindevices.add(inputs[i], i);
    }

    options = controlP5.addTextlabel("options", "Options", 10, 65);
    optionsbox = controlP5.addCheckBox("optionsbox", 10, 80);
    optionsbox.setItemsPerRow(3);
    optionsbox.setSpacingColumn(30);
    optionsbox.setSpacingRow(10);
    optionsbox.addItem("notes -> cc", 0);

    heading = controlP5.addTextlabel("heading", "grmnygrmny.lightarray", 200, 20);
  }
Exemplo n.º 7
0
 public void InitComDropdown() {
   // Initialize portCommList
   int posX = 20;
   int posY = 70;
   PortsList = controlP5.addDropdownList("portComList", posX, posY, 100, 84);
   // Set the background color of the list (you wont see this though).
   PortsList.setBackgroundColor(color(200));
   // Set the height of each item when the list is opened.
   PortsList.setItemHeight(20);
   // Set the height of the bar itself.
   PortsList.setBarHeight(15);
   // Set the lable of the bar when nothing is selected.
   PortsList.captionLabel().set("Select COM port");
   // Set the top margin of the lable.
   PortsList.captionLabel().style().marginTop = 3;
   // Set the left margin of the lable.
   PortsList.captionLabel().style().marginLeft = 3;
   // Set the top margin of the value selected.
   PortsList.valueLabel().style().marginTop = 3;
   // Store the Serial ports in the string comList (char array).
   comList = serial.list();
   // We need to know how many ports there are, to know how many items to add to the list, so we
   // will convert it to a String object (part of a class).
   String comlist = join(comList, ",");
   // We also need how many characters there is in a single port name, we\u00b4ll store the chars
   // here for counting later.
   String COMlist = comList[0];
   // Here we count the length of each port name.
   int size2 = COMlist.length();
   // Now we can count how many ports there are, well that is count how many chars there are, so we
   // will divide by the amount of chars per port name.
   int size1 = comlist.length() / size2;
   // Now well add the ports to the list, we use a for loop for that. How many items is determined
   // by the value of size1.
   for (int i = 0; i < size1; i++) {
     // This is the line doing the actual adding of items, we use the current loop we are in to
     // determin what place in the char array to access and what item number to add it as.
     PortsList.addItem(comList[i], i);
   }
   // Set the color of the background of the items and the bar.
   PortsList.setColorBackground(color(60));
   // Set the color of the item your mouse is hovering over.
   PortsList.setColorActive(color(255, 128));
 }
Exemplo n.º 8
0
  public void setup() {
    size(800, 500);
    ball = new Ball(width / 2, height / 2, new PVector(5, 5));
    rectMode(CENTER);
    paddles = new Paddle[2];
    paddles[0] = new Paddle(width - 40, 20);
    paddles[1] = new Paddle(40, 20);

    setupContext();
    skeleton = new TSSkeleton();
    cp5 = new ControlP5(this);
    //  cp5.addBang("restart").setPosition(350, 10).setSize(10, 10);

    d1 = cp5.addDropdownList("paddle1").setPosition(width - 150, 20);
    d2 = cp5.addDropdownList("paddle2").setPosition(50, 20);
    d3 = cp5.addDropdownList("1_or_2_player").setPosition(150, 20);
    d4 = cp5.addDropdownList("speed").setPosition(250, 20);

    jointNames = loadStrings("joints.txt");

    d4.addItem("slow", 0);
    d4.addItem("fast", 1);
    d4.addItem("Jeez-us", 2);

    for (int i = 0; i < jointNames.length; i++) {
      d1.addItem(jointNames[i], i);
      d2.addItem(jointNames[i], i);
    }

    d3.addItem("one player", 0);
    d3.addItem("two players", 1);

    smooth();
    println("SimpleOpenNI.SKEL_HEAD " + SimpleOpenNI.SKEL_HEAD);
    println("SimpleOpenNI.SKEL_LEFT_ANKLE " + SimpleOpenNI.SKEL_LEFT_ANKLE);
    println("SimpleOpenNI.SKEL_LEFT_COLLAR " + SimpleOpenNI.SKEL_LEFT_COLLAR);
    println("SimpleOpenNI.SKEL_LEFT_ELBOW " + SimpleOpenNI.SKEL_LEFT_ELBOW);
    println("SimpleOpenNI.SKEL_LEFT_FINGERTIP " + SimpleOpenNI.SKEL_LEFT_FINGERTIP);
    println("SimpleOpenNI.SKEL_LEFT_FOOT " + SimpleOpenNI.SKEL_LEFT_FOOT);
    println("SimpleOpenNI.SKEL_LEFT_HAND " + SimpleOpenNI.SKEL_LEFT_HAND);
    println("SimpleOpenNI.SKEL_LEFT_HIP " + SimpleOpenNI.SKEL_LEFT_HIP);
    println("SimpleOpenNI.SKEL_LEFT_KNEE " + SimpleOpenNI.SKEL_LEFT_KNEE);
    println("SimpleOpenNI.SKEL_LEFT_SHOULDER " + SimpleOpenNI.SKEL_LEFT_SHOULDER);
    println("SimpleOpenNI.SKEL_LEFT_WRIST " + SimpleOpenNI.SKEL_LEFT_WRIST);
    println("SimpleOpenNI.SKEL_NECK " + SimpleOpenNI.SKEL_NECK);
    println("SimpleOpenNI.SKEL_RIGHT_ANKLE " + SimpleOpenNI.SKEL_RIGHT_ANKLE);
    println("SimpleOpenNI.SKEL_RIGHT_COLLAR " + SimpleOpenNI.SKEL_RIGHT_COLLAR);
    println("SimpleOpenNI.SKEL_RIGHT_ELBOW " + SimpleOpenNI.SKEL_RIGHT_ELBOW);
    println("SimpleOpenNI.SKEL_RIGHT_FINGERTIP " + SimpleOpenNI.SKEL_RIGHT_FINGERTIP);
    println("SimpleOpenNI.SKEL_RIGHT_FOOT " + SimpleOpenNI.SKEL_RIGHT_FOOT);
    println("SimpleOpenNI.SKEL_RIGHT_HAND  " + SimpleOpenNI.SKEL_RIGHT_HAND);
    println("SimpleOpenNI.SKEL_RIGHT_HIP " + SimpleOpenNI.SKEL_RIGHT_HIP);
    println("SimpleOpenNI.SKEL_RIGHT_KNEE " + SimpleOpenNI.SKEL_RIGHT_KNEE);
    println("SimpleOpenNI.SKEL_RIGHT_SHOULDER " + SimpleOpenNI.SKEL_RIGHT_SHOULDER);
    println("SimpleOpenNI.SKEL_RIGHT_WRIST " + SimpleOpenNI.SKEL_RIGHT_WRIST);
    println("SimpleOpenNI.SKEL_TORSO " + SimpleOpenNI.SKEL_TORSO);
    println("SimpleOpenNI.SKEL_WAIST " + SimpleOpenNI.SKEL_WAIST);

    translations = new int[jointNames.length];
    translations[0] = 1;
    translations[1] = 19;
    translations[2] = 5;
    translations[3] = 7;
    translations[4] = 10;
    translations[5] = 20;
    translations[6] = 9;
    translations[7] = 17;
    translations[8] = 18;
    translations[9] = 6;
    translations[10] = 8;
    translations[11] = 2;
    translations[12] = 23;
    translations[13] = 11;
    translations[14] = 13;
    translations[15] = 16;
    translations[16] = 24;
    translations[17] = 15;
    translations[18] = 21;
    translations[19] = 22;
    translations[20] = 12;
    translations[21] = 14;
    translations[22] = 3;
    translations[23] = 4;

    font = loadFont("AlBayan-48.vlw");
    textFont(font, 48);
  }
Exemplo n.º 9
0
  public void draw() { // display things

    // execute sceneManager stuff
    resetMatrix();
    // beginCamera();
    camera();
    rotateX(HALF_PI);
    translate(globalCameraX, globalCameraY, globalCameraZ);

    /* rotation using a and d
    PMatrix3D foRealCameraMatrix=new PMatrix3D();
    getMatrix(foRealCameraMatrix);
    */
    // translate(0,-100, -400 );
    // translate(0,0, 0 );
    // rotate(sin(millis() * 0.001), 1,0,0);

    background(bGround);

    for (int i = 0; i < cameras.size(); i++) {
      //    camPicker.start(i);  //add picker to each cam
      picker.start(i);
      cameras.get(i).display();
    }
    //  camPicker.stop();

    for (int i = cameras.size(); i < cameras.size() + characters.size(); i++) {
      //    charPicker.start(i);
      picker.start(i);
      characters.get(i - cameras.size()).display();
    }
    //  charPicker.stop();
    picker.stop();

    // endCamera();

    //  int id = camPicker.get(mouseX, mouseY);
    //  if (id > -1) {
    //    for (int i=0; i<cameras.size(); i++) {
    //      if (i == id) {
    //        cameras.get(id).changeToSelectedColor();
    //        cameras.get(id).isSelected = true;
    //      } else {
    //        cameras.get(i).setDefaultColor();
    //        cameras.get(i).isSelected = false;
    //      }
    //    }
    //  }

    // checks for rule violations
    int id = -1;
    for (int i = 0; i < cameras.size(); i++) {
      if (cameras.get(i).isSelected) {
        if (selectedRule == 0) rulesChecker.checkLineOfAction(cameras, characters, i);
        else if (selectedRule == 1) rulesChecker.checkThirtyDegreeRule(cameras, characters, i);
        else resetAllCams();
      }
    }

    rulesChecker.checkCuttingOnAction(sm, timeline);
    rulesChecker.checkPacing(sm, timeline);

    /* This is for camera rotation using a and d
    resetMatrix();
    pushMatrix();
    setMatrix(myCamera);
    rotate(angle);
    getMatrix();
    popMatrix;
    */

    // have to rotate back to original orientation in order to properly display the drop-down menu

    rotateX(PI);
    rotateX(HALF_PI);

    controlP5.draw();
    timeline.draw();
  }