logo

prolebra_StickyStuff_MeshWalking_GUI

class Culebra_UI {

  PApplet parent;
  ControlP5 cp5;
  int abc = 100;

  Slider pr, sd, pt, wr, wd, wrt, wt, mc, is, ms, mf, msep, ac, st, sct, hw, stw, t;
  Slider c_sd, c_pt, c_wr, c_wd, c_wrt, c_wt, c_is, c_ms, c_mf, c_msep, c_ct, c_mvr, c_mxvr, c_mvA, c_MvA, c_hw, c_t, c_stw;
  Slider f_sR, f_av, f_sv, f_cv;
  Button cbutt, cbut;
  Toggle se, d, t10;
  List<Slider> sliderList = new ArrayList<Slider>();
  boolean created = false;

  public Culebra_UI () {
  }

  public void run(PApplet _parent) {
    this.parent = _parent;
    this.cp5 = new ControlP5(parent);
    
    if (!D2) {
      this.cp5.setAutoDraw(false);
    } else {
      this.cp5.setAutoDraw(true);
    }

    this.cp5.setColorForeground(color(0, 255, 0));
    this.cp5.setColorValueLabel(color(255, 255, 255));
    this.cp5.setBackground(color(0, 0, 0));
    this.cp5.setColorActive(color(0, 255, 0));
    this.cp5.setColorBackground(color(50, 50, 50));

    this.pr = cp5.addSlider("PathRad").plugTo(parent).setRange(0, 100).setPosition(10, 10).setValue(28.0).setDecimalPrecision(2).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.sd = cp5.addSlider("ScalarProjectDist").plugTo(parent).plugTo(parent).setRange(0.00, 100.00).setPosition(10, 22).setValue(50).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.pt = cp5.addSlider("PathTresh").plugTo(parent).setRange(0.00, 1500.00).setPosition(10, 34).setValue(1000.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;

    this.wr = cp5.addSlider("WanderRadius").plugTo(parent).setRange(0.00, 500.00).setPosition(10, 46).setValue(10).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.wd = cp5.addSlider("WanderDist").plugTo(parent).setRange(0.00, 100.00).setPosition(10, 58).setValue(20).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.wrt = cp5.addSlider("WanderRotTrigger").plugTo(parent).setRange(0.00, 100.00).setPosition(10, 70).setValue(6).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.wt = cp5.addSlider("WanderTheta").plugTo(parent).setRange(0.0, 100.00).setPosition(10, 82).setValue(100).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;

    this.mc = cp5.addSlider("MaxChildren").plugTo(parent).plugTo(parent).setRange(0.00, 20.00).setPosition(10, 94).setValue(4).setDecimalPrecision(0).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;

    this.is = cp5.addSlider("InitSpeed").plugTo(parent).setRange(0.00, 10.00).setPosition(10, 106).setValue(2.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.ms = cp5.addSlider("MaxSpeed").plugTo(parent).setRange(0.00, 10.00).setPosition(10, 118).setValue(7.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.mf = cp5.addSlider("MaxForce").plugTo(parent).setRange(0.00, 2.00).setPosition(10, 130).setValue(0.85).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.msep = cp5.addSlider("MaxSep").plugTo(parent).plugTo(parent).setRange(0.00, 20.00).setPosition(10, 142).setValue(0.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;

    this.ac = cp5.addSlider("AgentCount").plugTo(parent).setRange(0.00, 2500.00).setPosition(10, 154).setValue(300).setDecimalPrecision(0).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.se = cp5.addToggle("SpawnEdge").plugTo(parent).setPosition(10, 166).setSize(50, 10).setValue(false).setMode(ControlP5.SWITCH).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    this.d = cp5.addToggle("Dimension").plugTo(parent).setPosition(10, 190).setSize(50, 10).setValue(false).setMode(ControlP5.SWITCH).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));

    Button sbutt = cp5.addButton("---TRACKERS---").plugTo(parent).setPosition(10, 220).setSize(100, 5);
    sbutt.setColorActive(color(0, 255, 0));
    sbutt.setColorBackground(color(255, 0, 0));
    this.st =  cp5.addSlider("seekerTrail").plugTo(parent).setRange(0.00, 5000.00).setPosition(10, 230).setValue(5000).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));

    Button wbutt = cp5.addButton("---SEEKERS---").plugTo(parent).setPosition(10, 244).setSize(100, 5);
    wbutt.setColorActive(color(0, 255, 0));
    wbutt.setColorBackground(color(255, 0, 0));
    this.sct =  cp5.addSlider("childSeekerTrail").plugTo(parent).setRange(0.00, 5000.00).setPosition(10, 254).setValue(5000.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));

    Button vbutt = cp5.addButton("---VIZ---").plugTo(parent).setPosition(10, 268).setSize(100, 5);
    vbutt.setColorActive(color(0, 255, 0));
    vbutt.setColorBackground(color(255, 0, 0));
    this.hw = cp5.addSlider("HeadWidth").plugTo(parent).setRange(0.00f, 8.0f).setPosition(10, 278).setValue(0.0f)
      .setDecimalPrecision(2).setSize(50, 10);
    this.stw = cp5.addSlider("StrokeWidth").plugTo(parent).setRange(0.00f, 10).setPosition(10, 290).setValue(1.5f)
      .setDecimalPrecision(2).setSize(50, 10);
    this.t = cp5.addSlider("Transparency").plugTo(parent).setRange(0.00f, 255).setPosition(10, 302)
      .setValue(255.0f).setDecimalPrecision(2).setSize(50, 10);

    this.cbut = cp5.addButton("---BABIES---").plugTo(parent).setPosition(10, 316).setSize(100, 5);
    this.cbut.setColorActive(color(0, 255, 0));
    this.cbut.setColorBackground(color(255, 0, 0));
    //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    this.c_sd = cp5.addSlider("c_ScalarProjectDist").plugTo(parent).plugTo(parent).setRange(0.00, 100.00).setPosition(10, 326).setValue(100).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_sd);
    this.c_pt = cp5.addSlider("c_PathTresh").plugTo(parent).setRange(0.00, 1500.00).setPosition(10, 338).setValue(1000).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_pt);
    this.c_wr = cp5.addSlider("c_WanderRad").plugTo(parent).setRange(0.00, 100.00).setPosition(10, 350).setValue(10).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_wr);
    this.c_wd = cp5.addSlider("c_WanderDist").plugTo(parent).setRange(0.00, 100.00).setPosition(10, 362).setValue(20).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_wd);
    this.c_wrt = cp5.addSlider("c_WanderRotTrigger").plugTo(parent).setRange(0.00, 100.00).setPosition(10, 374).setValue(6).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_wrt);
    this.c_wt = cp5.addSlider("c_WanderTheta").plugTo(parent).setRange(0.0, 100.00).setPosition(10, 386).setValue(0.6).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    sliderList.add(this.c_wt);
    this.c_is = cp5.addSlider("c_InitSpeed").plugTo(parent).setRange(0.00, 10.00).setPosition(10, 398).setValue(2.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    sliderList.add(this.c_is);
    this.c_ms = cp5.addSlider("c_MaxSpeed").plugTo(parent).setRange(0.00, 10.00).setPosition(10, 410).setValue(3.0).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    sliderList.add(this.c_ms);
    this.c_mf = cp5.addSlider("c_MaxForce").plugTo(parent).setRange(0.00, 2.00).setPosition(10, 422).setValue(0.16).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    sliderList.add(this.c_mf);
    this.c_ct =  cp5.addSlider("c_Child_TrailFO").plugTo(parent).setRange(0.00, 5000.00).setPosition(10, 434).setValue(5000).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40));
    sliderList.add(this.c_ct);

    this.cbutt = cp5.addButton("---Child-VIZ---").plugTo(parent).setPosition(10, 448).setSize(100, 5);
    this.cbutt.setColorActive(color(0, 255, 0));
    this.cbutt.setColorBackground(color(255, 0, 0));
    this.c_hw = cp5.addSlider("c_HeadWidth").plugTo(parent).setRange(0.00f, 8.0f).setPosition(10, 460).setValue(0.0f)
      .setDecimalPrecision(2).setSize(50, 10);
    sliderList.add(this.c_hw);
    this.c_stw = cp5.addSlider("c_StrokeWidth").plugTo(parent).setRange(0.00f, 10).setPosition(10, 472).setValue(1.1f)
      .setDecimalPrecision(2).setSize(50, 10);
    sliderList.add(this.c_stw);
    this.c_t = cp5.addSlider("c_Transparency").plugTo(parent).setRange(0.00f, 255).setPosition(10, 484)
      .setValue(255.0f).setDecimalPrecision(2).setSize(50, 10);
    sliderList.add(this.c_t);

    this.f_sR = cp5.addSlider("searchRadius").plugTo(parent).plugTo(parent).setRange(0.00, 300.00).setPosition(10, 500).setValue(30).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.f_av = cp5.addSlider("alignValue").plugTo(parent).plugTo(parent).setRange(0.00, 2.00).setPosition(10, 512).setValue(0.025).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.f_sv = cp5.addSlider("sepValue").plugTo(parent).plugTo(parent).setRange(0.00, 2.00).setPosition(10, 524).setValue(0.09).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;
    this.f_cv = cp5.addSlider("cohVal").plugTo(parent).plugTo(parent).setRange(0.00, 2.00).setPosition(10, 536).setValue(0.24).setDecimalPrecision(3).setSize(50, 10).setHandleSize(10).setColorForeground(color(255, 40)).setColorBackground(color(255, 40)) ;

    btypeA = cp5.addButton("Beh_A").plugTo(parent).setPosition(150, 10).setSize(100, 10);
    btypeA.setColorActive(color(0, 255, 0));              
    btypeA.setColorBackground(color(255, 0, 0));

    btypeAA = cp5.addButton("Beh_AA").plugTo(parent).setPosition(255, 10).setSize(50, 10);
    btypeAA.setColorActive(color(0, 255, 0));
    btypeAA.setColorBackground(color(255, 0, 0));

    btypeAB = cp5.addButton("Beh_AB").plugTo(parent).setPosition(310, 10).setSize(50, 10);
    btypeAB.setColorActive(color(0, 255, 0));
    btypeAB.setColorBackground(color(255, 0, 0));

    btypeB = cp5.addButton("Beh_B").plugTo(parent).setPosition(150, 22).setSize(100, 10);
    btypeB.setColorActive(color(0, 255, 0));
    btypeB.setColorBackground(color(255, 0, 0));

    btypeC = cp5.addButton("Beh_C").plugTo(parent).setPosition(150, 34).setSize(100, 10);
    btypeC.setColorActive(color(0, 255, 0));
    btypeC.setColorBackground(color(255, 0, 0));

    btypeD = cp5.addButton("Beh_D").plugTo(parent).setPosition(150, 46).setSize(100, 10);
    btypeD.setColorActive(color(0, 255, 0));
    btypeD.setColorBackground(color(255, 0, 0));

    btypeE = cp5.addButton("Beh_E").plugTo(parent).setPosition(150, 58).setSize(100, 10);
    btypeE.setColorActive(color(0, 255, 0));
    btypeE.setColorBackground(color(255, 0, 0));

    btypeF = cp5.addButton("Beh_F").plugTo(parent).setPosition(150, 70).setSize(100, 10);
    btypeF.setColorActive(color(0, 255, 0));
    btypeF.setColorBackground(color(255, 0, 0));
  }
  public void draw() {
    background(0);
  }
  public void createGui() {
    updateUI();
    guiInit();
  }
  public void updateUI() {
    if (cp5.isMouseOver()) {
      cam.setActive(false);
    } else {
      cam.setActive(true);
    }
    if (masterBehavior_A) {
      btypeA.setColorBackground(color(120, 255, 0));
    } else {
      btypeA.setColorBackground(color(255, 0, 0));
    }
    if (masterBehavior_B) {
      btypeB.setColorBackground(color(120, 255, 0));
    } else {
      btypeB.setColorBackground(color(255, 0, 0));
    }
    if (masterBehavior_C) {
      btypeC.setColorBackground(color(120, 255, 0));
    } else {
      btypeC.setColorBackground(color(255, 0, 0));
    }
    if (masterBehavior_D) {
      btypeD.setColorBackground(color(120, 255, 0));
    } else {
      btypeD.setColorBackground(color(255, 0, 0));
    }
    if (masterBehavior_E) {
      btypeE.setColorBackground(color(120, 255, 0));
    } else {
      btypeE.setColorBackground(color(255, 0, 0));
    }
    if (masterBehavior_F) {
      btypeF.setColorBackground(color(120, 255, 0));
    } else {
      btypeF.setColorBackground(color(255, 0, 0));
    }
    if (subBehavior_AA) {
      btypeAA.setColorBackground(color(120, 255, 0));
    } else {
      btypeAA.setColorBackground(color(255, 0, 0));
    }
    if (subBehavior_AB) {
      btypeAB.setColorBackground(color(120, 255, 0));
    } else {
      btypeAB.setColorBackground(color(255, 0, 0));
    }
    if (!masterBehavior_E) {
      this.f_sR.setVisible(false);
      this.f_av.setVisible(false);
      this.f_sv.setVisible(false);
      this.f_cv.setVisible(false);
    } else {
      this.f_sR.setVisible(true);
      this.f_av.setVisible(true);
      this.f_sv.setVisible(true);
      this.f_cv.setVisible(true);
    }
    if (toggleUI) {
      this.cbutt.setVisible(true);
      this.cbutt.setLabelVisible(true);
      this.cbut.setVisible(true);
      this.cbut.setLabelVisible(true);
      for (Slider s : sliderList) {
        s.setVisible(true);
        s.setLabelVisible(true);
      }
    } else {
      this.cbutt.setVisible(false);
      this.cbutt.setLabelVisible(false);
      this.cbut.setVisible(false);
      this.cbut.setLabelVisible(false);
      for (Slider s : sliderList) {
        s.setVisible(false);
        s.setLabelVisible(false);
      }
    }
  }
  void guiInit() {
    cp5.setAutoDraw(false);
    hint(DISABLE_DEPTH_TEST);
    cam.beginHUD();
    cp5.draw();
    cam.endHUD();
    hint(ENABLE_DEPTH_TEST);
  }
}
Update
  • Share