Working Driving Cross Sections
authorBen Morrow <childoftv@gmail.com>
Mon, 19 Aug 2013 02:55:40 +0000 (19:55 -0700)
committerBen Morrow <childoftv@gmail.com>
Mon, 19 Aug 2013 02:55:40 +0000 (19:55 -0700)
BenMorrow.pde
GranimPattern.pde

index 8b2b4f55ef47f4bb30d2fe103235c8de2a39d823..9294250cda3e5740a688ccfe61724de74c28c0dd 100644 (file)
@@ -116,9 +116,10 @@ class GranimTestPattern2 extends GranimPattern
 
 class DriveableCrossSections extends CrossSections
 {
-       BasicParameter xd = new BasicParameter("XD", 1.0);
-       BasicParameter yd = new BasicParameter("YD", 1.0);
-       BasicParameter zd = new BasicParameter("ZD", 1.0);
+       BasicParameter xd; 
+       BasicParameter yd;
+       BasicParameter zd;
+       BasicParameter mode; 
 
        DriveableCrossSections(GLucose glucose) {
                super(glucose); 
@@ -126,6 +127,11 @@ class DriveableCrossSections extends CrossSections
 
        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);
@@ -140,13 +146,33 @@ class DriveableCrossSections extends CrossSections
            addParameter(zw);
        }
 
+       public void onParameterChanged(LXParameter p) {
+                       if(p == mode)
+                       {
+                               if(interactive())
+                               {
+                                       xd.setValue(x.getValue()/200);
+                                       yd.setValue(y.getValue()/200);
+                                       zd.setValue(z.getValue()/100);
+                               }
+                       }
+       }
 
+       boolean interactive()
+       {
+               return Math.round(mode.getValuef())>0.5;
+       }
 
        public void updateXYZVals()
        {
-               xv = xd.getValuef();
-           yv = yd.getValuef();
-           zv = zd.getValuef(); 
+               if(interactive())
+               {
+                       xv = xd.getValuef()*200;
+                   yv = yd.getValuef()*200;
+                   zv = zd.getValuef()*100;
+               }else{
+                       super.updateXYZVals();
+               }
        }
 
 }
\ No newline at end of file
index 606c9e2e3ca17219f203eb11cabda5b06b8ce2b3..0a34bafe986d1d4baac8eda506158b9cc3a1ef40 100644 (file)
@@ -110,7 +110,7 @@ class GranimPattern extends SCPattern
                                ((Granim) g).update();
                        }
                        List<Point> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
-                       println("drawlistsize "+drawList.size());
+                       //println("drawlistsize "+drawList.size());
                        
                        gbuffer = g.graphicBuffer.toArray(new Integer[0]);