Ejemplo n.º 1
0
    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);
            }
          }
        }
      }
    }
Ejemplo n.º 2
0
  public void draw() {
    background(0);
    fill(255);

    if (!paused) timeline.moveForward();

    if (dragging) drawOrbits(timeline.getFutureObjectStates());
    else drawOrbits(timeline.getPastObjectStates());

    ArrayList objects = timeline.getStatefulObjects();
    for (int i = 0; i < objects.size(); i++) {
      CelestialObject obj = (CelestialObject) objects.get(i);
      obj.display();
    }
  }
Ejemplo n.º 3
0
 public void mouseClicked() {
   ArrayList objects = timeline.getStatefulObjects();
   for (int i = 0; i < objects.size(); i++) {
     CelestialObject obj = (CelestialObject) objects.get(i);
     if (obj.isMouseOver()) {
       println(obj.getName() + " clicked!");
       break;
     }
   }
 }
Ejemplo n.º 4
0
  public void mouseDragged() {
    if (paused) {
      ArrayList objects = timeline.getStatefulObjects();
      for (int i = 0; i < objects.size(); i++) {
        CelestialObject obj = (CelestialObject) objects.get(i);
        if (obj.isMouseOver()) {
          dragging = true;
          PVector pos = obj.getPosition();
          pos.x = mouseX;
          pos.y = mouseY;

          timeline.reset();
          timeline.setCurrentState(objects);
          sliderTimeline.setValue(0);
          break;
        }
      }
    }
  }
Ejemplo n.º 5
0
  /*
   * 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();
    }
  }
Ejemplo n.º 6
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");
  }
Ejemplo n.º 7
0
    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);
          }
        }
      }
    }
Ejemplo n.º 8
0
 public void sliderTimeline_OnClick(int theValue) {
   if (!dragging) timeline.move(theValue - timeline.getTimeIdx());
 }
Ejemplo n.º 9
0
 public void btnRewind_OnClick(int theValue) {
   timeline.moveBackward();
 }
Ejemplo n.º 10
0
 public void btnFastForward_OnClick(int theValue) {
   timeline.moveForward();
 }
Ejemplo n.º 11
0
  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);

  }
Ejemplo n.º 12
0
  /*
   * 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);
    }
  }
Ejemplo n.º 13
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();
  }