We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Processing combined effort
Pages: 1 2 3 4 
Processing combined effort (Read 15633 times)
Re: Processing combined effort
Reply #30 - Feb 20th, 2010, 3:55am
 
my first attempt with the logo, just 20 lines i knocked up so i could work on the sketch switching, suffered from the P3D texture problem quite badly (the fact it had a border complicated things too)

Code:

PImage logo;

void setup() {
 size(640, 480, P3D);
 logo = loadImage("loading.gif");
 imageMode(CENTER);
 noFill();
 stroke(255);
}

void draw() {
 background(255);
 translate(width / 2, height / 2);
 pushMatrix();
 float f = frameCount;
 rotateY(f / 25);
 scale(3 - 2 * cos(f / 20));  // f(0) must = 1
 image(logo, 0, 0, logo.width, logo.height);
 popMatrix();
}


there are ways around that, i know, but using an ellipse instead would help.

Code:

public static float RAD = 25;

void setup() {
 size(640, 480, P3D);
 ellipseMode(CENTER);
 fill(255);
 stroke(255);
}

void draw() {
 background(0);
 translate(width / 2, height / 2); // move origin to centre
 pushMatrix();
 float f = frameCount;
 rotateY(f / 25);
 scale(3 - 2 * cos(f / 20));  // f(0) must = 1
 ellipse(0, 0, RAD, RAD);
 popMatrix();
}


but that looks too pixely and adding smooth() shows up the segments.

there's also the issue of movement. it's all very well having a dot in the middle but if the one sketch ends with it travelling up/down and the next starts with it speeding left/right then the transition will jar badly. need to think about continuity.
Re: Processing combined effort
Reply #31 - Feb 20th, 2010, 4:03am
 
Quote:
there's also the issue of movement. it's all very well having a dot in the middle but if the one sketch ends with it travelling up/down and the next starts with it speeding left/right then the transition will jar badly. need to think about continuity.


sure but you would have the same problem when using an image. but i guess thats something we have to deal with
Re: Processing combined effort
Reply #32 - Feb 20th, 2010, 5:28am
 
my idea of picking up all the inner classes beginning with a known prefix and using those randomly has fallen at the first hurdle. i need to call this.class.getDeclaredClasses() but this is just giving me an error:

Class c = this.class;

expecting SEMI, found 'c'
processing.app.debug.RunnerException: Syntax error, maybe a missing semicolon?
     at processing.app.Sketch.preprocess(Sketch.java:1350)
     at processing.app.Sketch.preprocess(Sketch.java:1194)
     at processing.app.Sketch.build(Sketch.java:1480)
     at processing.app.Sketch.compile(Sketch.java:1174)
     at processing.app.Editor.handleRun(Editor.java:1644)
...

it seems to want a semicolon after Class, which is nonsense.
Re: Processing combined effort
Reply #33 - Feb 20th, 2010, 5:36am
 
whereas this is fine in netbeans:

Code:

public class Main {
public static void main(String[] args) {
Class[] classes = Main.class.getDeclaredClasses();
for (Class c : classes) {
System.out.println("Class: " + c.getCanonicalName());
}
}
// noddy inner classes
class internalClass1 {}
class internalClass2 {}
}


(have to use Main.class here as it's static which isn't the case with processing. and that uses java 1.5 syntax for the for loop but....)
Re: Processing combined effort
Reply #34 - Feb 20th, 2010, 7:04am
 
koogy wrote on Feb 20th, 2010, 5:28am:
(...)
Class c = this.class;

expecting SEMI, found 'c'
processing.app.debug.RunnerException: Syntax error, maybe a missing semicolon
     at processing.app.Sketch.preprocess(Sketch.java:1350)
     at processing.app.Sketch.preprocess(Sketch.java:1194)
     at processing.app.Sketch.build(Sketch.java:1480)
     at processing.app.Sketch.compile(Sketch.java:1174)
     at processing.app.Editor.handleRun(Editor.java:1644)
...

it seems to want a semicolon after Class, which is nonsense.


(maybe it's not the rigth place for that kind of post)
Class c = this.getClass();
Work better no
Re: Processing combined effort
Reply #35 - Feb 20th, 2010, 3:42pm
 
If any one knows how to add a poll function, they can post a reply.
Re: Processing combined effort
Reply #36 - Feb 20th, 2010, 4:35pm
 
i guess you have to start the threat with a poll
Re: Processing combined effort
Reply #37 - Feb 20th, 2010, 5:01pm
 
Cedric wrote on Feb 20th, 2010, 4:03am:
[quote]there's also the issue of movement. it's all very well having a dot in the middle but if the one sketch ends with it travelling up/down and the next starts with it speeding left/right then the transition will jar badly. need to think about continuity.


It is possible that a few static frames could be taken into account in the beginning and end of each sketch, so that any starting and ending should gradually conform to a still spot/shape/image. Could be 3-9 frames max... This way each contributor can handle his part of the transition without worrying about the other part. Of course if there are cases of intended transitions of another type, this could be ignored.
Re: Processing combined effort
Reply #38 - Feb 21st, 2010, 4:41am
 
Here is a little showreel snippet that finds all sketches using introspection and then switches between them every 6 seconds ...
Maybe we could use it to stitch everything together ...

Code:
import java.lang.reflect.Constructor;

final int W = 640, H = 480, BG = #000000, fps = 30, seconds = 6;
boolean export = true;
PApplet[] sketches;
String[] names;
int s;


void setup() {
 
 size(W, H);
 Class[] classes = getClass().getDeclaredClasses();
 int n = classes.length;
 sketches = new PApplet[n];
 names = new String[n];
 
 for(int i=0; i<n; i++) {
   try {
     Constructor c = classes[i].getDeclaredConstructor(getClass());
     sketches[i] = (PApplet) c.newInstance(this);
     sketches[i].init();  
     names[i] = split(c.getName(), "$")[1];    
   } catch (Exception e) {}
 }
 
 frameRate(fps);
}


void draw() {

 if(frameCount % (seconds * fps) == 1) {
   
   // stop running sketch
   if(frameCount>1) {
     println("stopping " + names[s]);
     sketches[s].stop();
     s = (s+1) % sketches.length;
   }
   
   // start next sketch
   println("starting " + names[s]);
   sketches[s].run();
 }

 sketches[s].handleDraw();
 PImage img = sketches[s].get();
 img.loadPixels();
 image(img, 0, 0);
 if(export && frameCount <= fps*seconds*sketches.length) saveFrame("showreel-#####.png");
   
}
Re: Processing combined effort
Reply #39 - Feb 21st, 2010, 4:50am
 
Just add those template sketches to try it out ...

Code:

class Sketch1 extends PApplet {
 void setup() {
   size(W, H);
 }
 void draw()  {
   background(BG);
   ellipse(W/2, H/2, 20, 20);
 }
}

class Sketch2 extends PApplet {
 void setup() {
   size(W, H, P2D);
 }
 void draw()  {
   background(BG);
   ellipse(W/2, H/2, 20, 20);
 }
}


class Sketch3 extends PApplet {
 void setup() {
   size(W, H, P3D);
 }
 void draw()  {
   background(BG);
   lights();
   noStroke();
   translate(W/2, H/2, 0);
   sphere(10);
 }
}
Re: Processing combined effort
Reply #40 - Feb 21st, 2010, 8:27am
 
I have created an initial poll topic

http://processing.org/discourse/yabb2/num_1266769552.html#0

If any are to be deleted or modified, please indicate accordingly.
Re: Processing combined effort
Reply #41 - Feb 21st, 2010, 8:47am
 
I have added a basic bouncing procedure which works indepedently of the mouse

The idea is to have a parameter which maintains the x,y,z location and when the other sketch loads is starts from that point, and the transition will be smooth.

Quote:
import java.lang.reflect.Constructor;
public boolean forward = true;
public boolean up = false;
public int px=0;
public int py =0;
public int ly=0;
public int lx=0;

final int W = 640, H = 480, BG = #000000, fps = 30, seconds = 6;
boolean export = true;
PApplet[] sketches;
String[] names;
int s;


void setup() {
  
  size(W, H);
  Class[] classes = getClass().getDeclaredClasses();
  int n = classes.length;
  sketches = new PApplet[n];
  names = new String[n];
  
  for(int i=0; i<n; i++) {
    try {
      Constructor c = classes[i].getDeclaredConstructor(getClass());
      sketches[i] = (PApplet) c.newInstance(this);
      sketches[i].init();  
      names[i] = split(c.getName(), "$")[1];    
    } catch (Exception e) {}
  }
  
  frameRate(fps);
}


void draw() {
 bounce(true, 3, 1, 5);
  if(frameCount % (seconds * fps) == 1) {
    
    // stop running sketch
    if(frameCount>1) {
      println("stopping " + names[s]);
      sketches[s].stop();
      s = (s+1) % sketches.length;
    }
    
    // start next sketch
    println("starting " + names[s]);
    sketches[s].run();
  }

  sketches[s].handleDraw();
  PImage img = sketches[s].get();
  img.loadPixels();
  image(img, 0, 0);
  if(export && frameCount <= fps*seconds*sketches.length) saveFrame("showreel-#####.png");
     
}


class Sketch1 extends PApplet {
  void setup() {
    size(W, H,JAVA2D);
    smooth();
  }
  void draw()  {
    background(BG);
    ellipse(px, py, 20, 20);
  } 
}

class Sketch2 extends PApplet {
  void setup() {
    size(W, H, JAVA2D);
        smooth();
  }
  void draw()  {
    background(BG);
 //   ellipse(W/2, H/2, 20, 20);
    ellipse(px, py, 20, 20);
  } 
}


class Sketch3 extends PApplet {
  void setup() {
    size(W, H, P3D);
        smooth();
  }
  void draw()  {
    background(BG);
    lights();
    noStroke();
   // translate(W/2, H/2, 0);
    translate(px,py, 0);
    sphere(10);
  } 
}


void bounce(boolean rnd, int by, int lo, int hi){
 if (forward){
  if (rnd)px+=random(lo,hi);
   if (!rnd){
    px+=by; 
   }
 } 
 
 
   if (!forward){
     if(rnd)px-=random(lo,hi);  
     if (!rnd){
      px-=by; 
     }
     }
   
   if (up){
    if (rnd)py-=random(lo,hi*2);
     if (!rnd){
       py+=by;
     }
     }
     
     if (!up){
      if(rnd)py+=random(lo,hi*2);
     if (!rnd){
       py-=by;
     }  
       
     }
   
   
   if (px>width)forward = false;
   if (px<0)    forward = true;
   if (py>height)up     = true;
   if (py<0     )up     = false;
  }  
  
 
  
  

Re: Processing combined effort
Reply #42 - Feb 21st, 2010, 9:27am
 
I have posted a slightly modified version at the below openprocessing.

http://www.openprocessing.org/visuals/?visualID=7763

If anyone wants to post to the site using the Combined Processing effort

The logon details are

Username : processingcombinedeffort
Password  : combined


If anyone wants to submit test sketches post here or just submit to www.openprocessing.org
Re: Processing combined effort
Reply #43 - Feb 21st, 2010, 11:13am
 
oh, i've added a comment to the openprocessing sketch (as adean) but will repeat it here:

that code's a lot like i have (unfinished), specifically the way it picks up other classes. however, i think

Class[] classes = getClass().getDeclaredClasses();

will pick up the classes in all tabs and the rest of the code will try and run them. but that'll cause problems if the sub-sketches themselves define classes, for instance if someone defines a particle system class.

i filtered out the sketches by name (they had to start with Sketch), which imposes a naming scheme but... you could probably limit it to those that extend PApplet.
Re: Processing combined effort
Reply #44 - Mar 14th, 2010, 5:28pm
 
This is just a basic example of high fps using the idea by bit.craft

...
http://www.openprocessing.org/visuals/?visualID=8236


Processing rocks!!!
Pages: 1 2 3 4