diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-01-26 18:36:50 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-01-26 18:36:50 +0000 |
| commit | 913466726402512c4530dc3851b206f4292c3abd (patch) | |
| tree | 7fac759b3b35856cb99adbaec50523dd591e6529 | |
| parent | 100019c3c34cf19722091485560b1666229a43b1 (diff) | |
drawing a sphere
| -rw-r--r-- | vodaviz.pde | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/vodaviz.pde b/vodaviz.pde index 8764aec..4540841 100644 --- a/vodaviz.pde +++ b/vodaviz.pde @@ -34,17 +34,17 @@ // --> this is kind of hidden. why? anyway, it should be possible to use it //another option is to use the OUTLINE of the country (as a purely geometric thing). - +import processing.pdf.*; import geomerative.*; RShape shp; - RRectangle cb; + //RRectangle cb; int whichChild,numChildren; void setup(){ println("vodaviz v0.11"); RG.init(this); - size(800,600); //832,220); + size(800,600,P3D); //,PDF, "testoutput.pdf"); //P3D); //832,220); smooth(); float m = millis(); @@ -59,11 +59,42 @@ void draw() { background(0,0,0); noFill(); stroke(255); - RG.shape(shp); + //strokeWeight(.1); + //RG.shape(shp); whichChild=(whichChild+1)%numChildren; - println("child "+whichChild+" of "+numChildren); + //println("child "+whichChild+" of "+numChildren); + + //cb=shp.children[whichChild].getBounds(); - cb=shp.children[whichChild].getBounds(); + //plot shapes at points + for (int i=0;i<numChildren;i++) { + String cmd=""; + for (int j=0;j<shp.children[i].paths.length;j++) { + //shp.children[i].paths[j].draw(); + beginShape(); + for (int k=0;k<shp.children[i].paths[j].commands.length;k++) { + RPoint sp=shp.children[i].paths[j].commands[k].startPoint; + + //map lat,lng coords + //normalise + float px=(sp.x-26)/736; + float py=(sp.y-110)/358; + + float r=getHeight()/2; + float x=r*cos(px*PI*2)*(sin(py)*PI); + float y=r*sin(px*PI*2)*(sin(py)*PI); + float z=r*cos(sin(py)*PI); + + //vertex(px*getWidth(),py*getHeight()); //,0); can't use 3D points with PDF + vertex(x+(getWidth()/2),y+(getHeight()/2),z); //z); + if (i==0&&j==0) cmd+=(x+(getWidth()/2))+","+(y+(getHeight()/2))+","+z+" "; + } + endShape(); + } + if (cmd!="") println(cmd); + } + noLoop(); + //exit(); } void mousePressed() { |
