X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=BenMorrow.pde;h=e610155120eced021237936582d2e4758d8c477e;hb=ae80d37a7fc19c8bce45067cdcf4e041808f9339;hp=8a1dd0270bcbbf28bbc8ff0bb13313e88f08f52f;hpb=cd059b79f8f95ea86cb865375a7a468980a0cd81;p=SugarCubes.git diff --git a/BenMorrow.pde b/BenMorrow.pde index 8a1dd02..e610155 100644 --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -112,4 +112,75 @@ class GranimTestPattern2 extends GranimPattern } +}; + +class DriveableCrossSections extends CrossSections +{ + BasicParameter xd; + BasicParameter yd; + BasicParameter zd; + BasicParameter mode; + + DriveableCrossSections(GLucose glucose) { + super(glucose); + } + + public void addParams() + { + mode = new BasicParameter("Mode", 0.0); + xd = new BasicParameter("XD", 0.0); + yd = new BasicParameter("YD", 0.0); + zd = new BasicParameter("ZD", 0.0); + addParameter(mode); + addParameter(xd); + addParameter(yd); + addParameter(zd); + + super.addParams(); + } + + public void onParameterChanged(LXParameter p) { + if(p == mode) + { + if(interactive()) + { + copyValuesToKnobs(); + }else{ + copyKnobsToValues(); + } + } + } + + void copyValuesToKnobs() + { + xd.setValue(x.getValue()/200); + yd.setValue(y.getValue()/115); + zd.setValue(z.getValue()/100); + } + + void copyKnobsToValues() + { + x.setValue(xd.getValue()*200); + y.setValue(yd.getValue()*115); + z.setValue(zd.getValue()*100); + } + + boolean interactive() + { + return Math.round(mode.getValuef())>0.5; + } + + public void updateXYZVals() + { + if(interactive()) + { + xv = xd.getValuef()*200; + yv = yd.getValuef()*115; + zv = zd.getValuef()*100; + }else{ + super.updateXYZVals(); + copyValuesToKnobs(); + } + } + } \ No newline at end of file