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

  }