Exemple #1
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);
    }
  }