コード例 #1
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
    public void checkPacing(SceneManager sm, Timeline tl) {
      ArrayList<Tick> tArr = tl.getTickArr();
      int[] delTimeArr = new int[tArr.size() - 1];

      int total = 0;
      //    int count = 0;
      if (tArr.size() > 1) {
        for (int i = 1; i < tArr.size(); i++) {
          delTimeArr[i - 1] = tArr.get(i).getTimeStamp() - tArr.get(i - 1).getTimeStamp();
          total = total + delTimeArr[i - 1];
        }

        println("current sscrubber is at time " + tl.getScrollbarTimeInSecs());
        println("totalTime is " + total);

        int average = total / (tArr.size() - 1);
        println("totalAverage is " + average);

        // compare the average to the actual distribution of tick events
        for (int i = 0; i < delTimeArr.length; i++) {
          if (!(delTimeArr[i] < (average + 20) && delTimeArr[i] > (average - 20))
              || delTimeArr[i] < 3) {
            tArr.get(i + 1).setPacingViolation(true);
          } else {
            if (tArr.get(i + 1).getPacingViolation()) {
              tArr.get(i + 1).setPacingViolation(false);
            }
          }
        }
      }
    }
コード例 #2
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
    public void checkCuttingOnAction(SceneManager sm, Timeline tl) {
      LinkedList<Event> eList = sm.getEventList();
      ArrayList<Tick> tArr = tl.getTickArr();
      ListIterator<Event> listIt;

      for (int i = 0; i < tArr.size(); i++) {
        //      println("here");
        listIt = eList.listIterator();
        while (listIt.hasNext()) {
          Event tempEvent = listIt.next();
          // check for time colisions.
          //        println("event " + tempEvent.getTimeStamp() + " tick time " +
          // tArr.get(i).getTimeStamp() + " " + tempEvent.type);

          if ((tempEvent.getType() == DIA_TIME)
              && (tempEvent.getTimeStamp() == tArr.get(i).getTimeStamp())) {
            println("CUTTING ON ACTION ERROR!");
            tArr.get(i).setCutViolation(true);
          } else {
            tArr.get(i).setCutViolation(false);
          }
        }
      }
    }
コード例 #3
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
  public void setup() {
    minim = new Minim(this);
    size(winWidth, winHeight, OPENGL);
    background(bGround);
    sm = new SceneManager(minim);
    rulesChecker = new RulesChecker();

    controlP5 = new ControlP5(this);
    // ruleChoiceList = controlP5.addDropdownList("ruleChoiceList",850,100,100,100);
    // customize(ruleChoiceList);
    selectedRule = 0;
    selectedCamera = 0;
    gl = ((PGraphicsOpenGL) g).gl;

    picker = new Picker(this);
    oscP5 = new OscP5(this, port);
    // TODO(sanjeet): Change the address
    interfaceAddr = new NetAddress("127.0.0.1", port);

    noStroke();
    lines = loadStrings("fileFriedrich.txt"); // Hardcoded input file name
    String[] tokens = split(lines[0], " ");
    if (tokens.length != 1) {
      println("Incorrect file format for number of cameras");
      return;
    }
    int numOfCams = PApplet.parseInt(tokens[0]);
    for (int i = 1; i < numOfCams + 1; i++) {

      tokens = split(lines[i], " ");
      float[] matrix = new float[16];
      for (int j = 0; j < tokens.length; j++) {
        matrix[j] = PApplet.parseFloat(tokens[j]);
      }

      cameras.add(new Cam(FloatBuffer.wrap(matrix))); // add all the cameras
    }

    tokens = split(lines[1 + numOfCams], " ");
    if (tokens.length != 1) {
      println("Incorrect file format for number of characters");
      return;
    }
    int numOfChars = PApplet.parseInt(tokens[0]);
    for (int i = 2 + numOfCams; i < lines.length; i++) {
      tokens = split(lines[i], " ");
      float[] matrix = new float[16];
      for (int j = 0; j < tokens.length; j++) {
        matrix[j] = PApplet.parseFloat(tokens[j]);
      }

      characters.add(new Character(FloatBuffer.wrap(matrix))); // add all the characters
    }

    characters.get(0).col = color(255, 255, 0);
    characters.get(1).col = color(255, 0, 255);

    timeline = new Timeline(sm);
    // add initial tick to the begining of the timeline
    timeline.addTick(cameras.get(0));

    debug = new Debug(controlP5);

    // title, start, end, initVal, xpos, ypos, width, height
    // controlP5.addSlider("Timeline", 0,120,0,100,winHeight-50,winWidth-200,30);

  }
コード例 #4
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
  /*
   * Method used to receive messages from Kinnect or MSB in the future
   */
  public void oscEvent(OscMessage theOscMessage) {

    // Friedrich added this select camera event
    if (theOscMessage != null && theOscMessage.checkAddrPattern("/selectActorByName")) {
      println("select Actor!");
      String myNewCamera = theOscMessage.get(0).stringValue();

      println(myNewCamera);

      // RAFACTOR THIS PART; MAYBE MAKE A DYNAMIC ENUM IN THE CAM DATA STRUCTURE?
      if (myNewCamera.compareTo("Camera1") == 0) selectedCamera = 0;
      if (myNewCamera.compareTo("Camera2") == 0) selectedCamera = 1;
      if (myNewCamera.compareTo("Camera3") == 0) selectedCamera = 2;
      if (myNewCamera.compareTo("Camera4") == 0) selectedCamera = 3;

      // Friedrich changed the coloring code here
      for (int i = 0; i < cameras.size(); i++) {
        cameras.get(i).changeToDefaultColor();
        cameras.get(i).isSelected = false;
      }

      cameras.get(selectedCamera).isSelected = true;
      cameras.get(selectedCamera).changeToSelectedColor();
      //    println(""  + timeline.getTickArr());
      timeline.getActiveTick().setCam(cameras.get(selectedCamera));
    }

    // Friedrich changed the AddressPattern for the submitted package - we can ignore the first
    // string part of the message
    if (theOscMessage != null
        && theOscMessage.checkAddrPattern("/setPropertyForSelected/string/matrix4f")) {
      float[] matrix = new float[16];

      // we do not need to use this in Processing, but let's pop it off the stack anyway
      String propertyName = theOscMessage.get(0).stringValue();

      for (int i = 1; i <= 16; i++) {
        if (i > 12 && i <= 15) {
          matrix[i - 1] = theOscMessage.get(i).floatValue() * 10;
        } else {
          matrix[i - 1] = theOscMessage.get(i).floatValue();
        }
      }

      matrix[2] = -matrix[2];
      matrix[8] = -matrix[8];

      // Friedrich - manual scaling adjustments
      matrix[12] = (700 - matrix[12]) * 2.0f;
      matrix[14] = matrix[14] * 1.5f;
      // println (matrix[12]);

      FloatBuffer fb = FloatBuffer.allocate(16);
      fb = FloatBuffer.wrap(matrix);
      // TODO(sanjeet): Currently using only camera 5
      // Change this variable based on the data received from OSC
      //    int selectedCamera = 5;
      cameras.get(selectedCamera).modelViewMatrix = fb;
    }

    // receive the currentFrame from kinect
    // this is where the playhead is on the timeline
    // currentFrame is global
    if (theOscMessage != null && theOscMessage.checkAddrPattern("/setPlayheadFrame/int")) {
      currentFrame = theOscMessage.get(0).intValue();
      println("Current Frame: " + currentFrame);
    }
  }
コード例 #5
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
  /*
   * Q - Up, E - Down, A - Left, D - Right, W - Forward, S - Backward
   */
  public void keyPressed() {
    if (key == 'q' || key == 'Q') {
      globalCameraY--;
    }
    if (key == 'e' || key == 'E') {
      globalCameraY++;
    }
    if (key == 'w' || key == 'W') {
      globalCameraZ--;
    }
    if (key == 'a' || key == 'A') {
      globalCameraX++;
    }
    if (key == 's' || key == 'S') {
      globalCameraZ++;
    }
    if (key == 'd' || key == 'D') {
      globalCameraX--;
    }
    if (key == ' ') {
      if (selectedRule == 0) selectedRule = 1;
      else selectedRule = 0;
    }
    if (key == 't' || key == 'T') {
      // if a camera is active, add tick
      for (int i = 0; i < cameras.size(); i++) {
        if (cameras.get(i).camIsSelected()) {

          // need to find which tick is before/after the one that would be placed here
          // TODO above
          timeline.addTick(cameras.get(i));
        }
      }
    }
    if (key == 'l' || key == 'L') {
      timeline.play();
    }
    if (key == 'p' || key == 'P') {
      timeline.pause();
    }
  }
コード例 #6
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
  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();
  }