Beispiel #1
0
 ////// VIDEO FUNCTIONS ////////////////
 public void switchVideo() {
   thePopUp.isVideoPlaying = false;
   thePopUp.stopVideo();
   /// change the path of the video
   /// have to pass an id since can't switch
   /// on a string
   thePopUp.switchCurVideo(videoCounter);
 }
Beispiel #2
0
  public void initXMLObject() {

    numProfiles = xmlFeed.getChildCount();
    println("NUM PROFILES: " + numProfiles);
    for (int i = 0; i < numProfiles; i++) {
      XMLElement profile = xmlFeed.getChild(i);
      /// *
      try {
        headerList.add(profile.getChild(0).getContent());
        nameList.add(profile.getChild(1).getContent());
        blurbList.add(profile.getChild(2).getContent());
        // videoPathList.add(profile.getChild(3).getContent());
        thePopUp.videoPath.add(profile.getChild(3).getContent());
        latList.add(profile.getChild(4).getContent());
        longList.add(profile.getChild(5).getContent());

        pApp.println("Title= " + profile.getChild(0).getContent());
        pApp.println("Name= " + profile.getChild(1).getContent());
        pApp.println("Blurb= " + profile.getChild(2).getContent());
        // pApp.println("video = " +  profile.getChild(3).getContent());
        pApp.println("Address = " + profile.getChild(4).getContent());
        // pApp.println("long = " + profile.getChild(5).getContent());
        // pApp.println(" ");
        pApp.println(" ");
      } catch (Exception e) {
        println("XML init error: " + e);
      }
    }
    /// now that the popup video array has data, init the video
    thePopUp.initVideo();
    /// convert the lat and long string to floats
    initLocations();
  }
Beispiel #3
0
  public void draw() {

    background(bgColorR, bgColorG, bgColorB);
    // image(bgImage, 512, 384);

    renderGlobe();

    // *
    if (thePopUp.isVideoPlaying == true) {
      // thePopUp.playVideo();
      // println("LAYING VIDEO" + thePopUp.isVideoPlaying);
      thePopUp.drawVideo();
    }

    // */

  }
Beispiel #4
0
  public void keyPressed() {
    if (key == '-') {
      targetZoom = max(targetZoom - 0.1f, 0.5f);
    }
    if (key == '=') {
      targetZoom = min(targetZoom + 0.1f, 1.9f);
    }
    if (key == 'l') {
      showLabels = !showLabels;
    }
    if (key == 'k') {
      if (useKeyboard == false) {
        useKeyboard = true;
      } else {
        useKeyboard = false;
      }
    }
    /// switches video
    if (key == 't') {

      thePopUp.videoCounter++;
      if (thePopUp.videoCounter >= thePopUp.videoPath.size()) {
        thePopUp.videoCounter = 0;
        // println("COUNTER: " + videoCounter + " " + videoPaths[videoCounter]);
      }
      thePopUp.switchCurVideo(thePopUp.videoCounter);
    }
    /// play video
    if (key == 'p') {

      thePopUp.isVideoPlaying = true;
      thePopUp.startVideo();
    }
    /// swap video
    if (key == 's') {

      thePopUp.isVideoPlaying = false;
      thePopUp.stopVideo();
    }
  }
Beispiel #5
0
  public void oscEvent(OscMessage theOscMessage) {
    // print the address pattern of the received OscMessage
    String addr = theOscMessage.addrPattern();

    print("### received an osc message.");
    println("tag type: " + theOscMessage.typetag());
    println("addr type: " + theOscMessage.addrPattern()); // it was lowercase in the documentation

    /// we have to check for init OSC values
    /// so the mouse doesn't override it on
    /// globe and cursor postion
    if (addr.indexOf("/EpsonPlanet/xy1") != -1) {
      hasOsc = true;
      println(hasOsc);
    }
    if (addr.indexOf("/EpsonPlanet/xy2") != -1) {
      hasOsc = true;
      println(hasOsc);
    }

    if (theOscMessage.checkTypetag("i")) {
      if (addr.equals("/EpsonPlanet/fader1")) {
        int valI = theOscMessage.get(0).intValue();
      }
    }

    /// check for 2 FLOATS
    if (theOscMessage.checkTypetag("ff")) {
      float val0 = theOscMessage.get(0).floatValue();
      float val1 = theOscMessage.get(1).floatValue();
      // hasOsc == true
      println("FF type: " + val0 + " " + val1);
      try {
        if (addr.equals("/EpsonPlanet/xy1")) {
          println("Do globe " + val0);
          oscX0 = new Float(val0);
          oscY0 = new Float(val1);
        } else if (addr.equals("/EpsonPlanet/xy2")) {
          float val2 = theOscMessage.get(0).floatValue();
          float val3 = theOscMessage.get(1).floatValue();
          doCursor = true;
          oscX1 = new Float(val2);
          oscY1 = new Float(val3);
        }
      } catch (Exception e) {
        println("can't run real floats");
      }
    }
    /// check for ONE FLOAT
    /// thanks stupid oscP5
    if (theOscMessage.checkTypetag("f")) {
      /// set up strings for the 2 values because stupid OSC
      String str0 = theOscMessage.toString();
      String str1 = theOscMessage.toString();

      try {

        // println(" VALUE 0: "+theOscMessage.get(0).floatValue());
        if (addr.equals("/EpsonPlanet/fader1")) {
          // targetZoom = max(targetZoom - 0.1f, 0.5f);
          // targetZoom = min(targetZoom + 0.1f, 1.9f);
          float val0 = theOscMessage.get(0).floatValue();
          println("DO ZOOM " + addr + " " + val0);
          targetZoom = map(val0, 0, 1, 0.5f, 1.9f);

        } else if (addr.equals("/1/fader2")) {
          println("v2 " + str0);
        } else if (addr.equals("/1/xy1")) {

        } else if (addr.equals("/EpsonPlanet/toggle1")) {
          println("toggle visibility");
          theDestroyer.toggleVisibility();

        } else if (addr.equals("/EpsonPlanet/resetGlobeButt")) {
          println("reset position");
          theCamX = defaultCamX;
          theCamY = defaultCamY;
          targetZoom = 1;

        } else if (addr.equals("/EpsonPlanet/playVidButt")) {
          println("play vid");
          thePopUp.startVideo();

        } else if (addr.equals("/EpsonPlanet/stopVidButt")) {
          println("pause vid");
          thePopUp.stopVideo();

        } else if (addr.equals("/EpsonPlanet/rotary1")) {
          int v = parseInt(theOscMessage.get(0).floatValue());
          println("R: " + v + " " + str0);
          bgColorR = v;
        } else if (addr.equals("/EpsonPlanet/rotary2")) {
          int v = parseInt(theOscMessage.get(0).floatValue());
          println("G: " + v + " " + str0);
          bgColorG = v;
        } else if (addr.equals("/EpsonPlanet/rotary3")) {
          int v = parseInt(theOscMessage.get(0).floatValue());
          println("B: " + v + " " + str0);
          bgColorB = v;
        }
      } catch (Exception e) {
        println(" osc error: " + e);
      }
    }

    /// control x and y globe

    /// control x and y destroyer
  }
Beispiel #6
0
  public void setDestroyer() {
    // convert cur mouse pos to lat and long
    // map(value, low1, high1, low2, high2)

    if (doCursor == true) {
      // theLat = map(oscY1, 1, 0, 0, 90);
      // theLong = map(oscX1, 0, 1, -180, 180);

      /// change osc values to mouse-parsed
      float newOscY = map(oscY1, 0, 1, 0, screenHeight);
      float newOscX = map(oscX1, 0, 1, 0, screenWidth);

      desRot.interpolateToSelf(new Vec3D(newOscX * 0.51f, newOscY * 0.51f, 0), 0.25f / currZoom);
      theLat = desRot.y; // map(mouseY, 0, screenHeight, 0, 90);
      theLong = desRot.x; // map(mouseX, 0, screenWidth, -180, 180);

    } else {
      // theLat = map(mouseY, 600, 0, 0, 90);
      // theLong = map(mouseX, 200, 800, -180, 180);

    }
    if (!mousePressed && useKeyboard == true) {

      /// *
      desRot.interpolateToSelf(new Vec3D(mouseX * 0.51f, mouseY * 0.51f, 0), 0.25f / currZoom);
      theLat = desRot.y; // map(mouseY, 0, screenHeight, 0, 90);
      theLong = desRot.x; // map(mouseX, 0, screenWidth, -180, 180);
      // */

    }
    doCursor = false;

    /*
    * theCamX = camRot.x;
    theCamY = camRot.y;
    */

    //

    theDestroyer.setSpherePosition(theLong, theLat);
    theDestroyer.computePosOnSphere(EARTH_RADIUS);

    //// CHECK FOR INTERSECTION with other markers
    boolean isPopupVisible = false;
    for (int i = 0; i < GPSArray.size(); i++) {
      // for(int i=0; i<2; i++){

      /// DESTROYER LAT AND LONG
      float dlat = theDestroyer.theLat;
      float dlong = theDestroyer.theLong; // theDestroyer.theLat;

      //// MARKER LAT AND LONG
      float mlat = GPSArray.get(i).theLat;
      float mlong = GPSArray.get(i).theLong;
      // println("dlat " + dlat + " mlat: " + mlat);
      // println("dlong " + dlong + " mlong: " + mlong);
      //// check to see if the destroyer is within the range of the current lat and long
      /// if (dlat >= (mlat -1) && dlat <= (mlat + 1) &&  dlong <= (mlong + 1) && dlong >= (mlong -
      // 1)){

      //// CHECK INTERSECTION of MARKER AND DESTROYER
      GPSMarker tMark = GPSArray.get(i);
      if (isPopupVisible == false
          && theDestroyer.pos.y <= (tMark.pos.y + 10)
          && theDestroyer.pos.y >= (tMark.pos.y - 10)
          && theDestroyer.pos.x <= (tMark.pos.x + 10)
          && theDestroyer.pos.x >= (tMark.pos.x - 10)) {

        tMark.doHit();

        //// init popup data
        thePopUp.theName = "";
        thePopUp.theText = "";

        thePopUp.theHeader = headerList.get(tMark.theID);
        thePopUp.theName = nameList.get(tMark.theID);
        thePopUp.theText = blurbList.get(tMark.theID);
        // thePopUp.theVideoPath = videoPathList.get(tMark.theID);

        /// swtich video if it's different than the current
        if (curID != tMark.theID) {
          // println("Cur ID: " + curID + " new ID: " + tMark.theID);
          /// stop current, switch
          thePopUp.stopVideo();
          thePopUp.switchCurVideo(tMark.theID);
          curID = tMark.theID;
        }

        //// showing popup data
        thePopUp.drawPopup(tMark.theID);
        isPopupVisible = true;
      }
    }
  }