Thanks guys. I promise to be harder, better, faster, stronger and more creative from now on
The clipping issues appeared in the sunflow version (not in opengl) so they became apparent after rendering... I guess the boxes z-location could be used to solve this if needed?
andrew, here's the code I used. It may not be the most efficient or anything, but I'm just learning so... Anyway, I added a lot of comments so it's clear for everyone. Hope it helps some people.
Code:// import libraries for using OPENGL, P5Sunflow and MovieMaking
// OPENGL for preparing, P5Sunflow for rendering
// in the code below sunflow and moviemaking are commented out
// 'camera' movement = everything moving towards the camera :-)
import processing.opengl.*;
import hipstersinc.sunflow.shape.*;
import hipstersinc.sunflow.*;
import hipstersinc.sunflow.shader.*;
import hipstersinc.sunflow.util.*;
import hipstersinc.*;
import hipstersinc.sunflow.light.*;
import processing.video.*;
// starting location for the 'camera'
float z = -1000;
// number of boxes
int n = 1000;
// count used for resetting boxpositions etc. every once in a while
int count = 0;
// the first time the 'reset' is after 250 frames
int countlimit = 250;
// count used to eventually finish the movie and exit the sketch
int countclose = 0;
// arrays for all boxes stuff, names are pretty obvious
float[] arrayBoxdim = new float[n];
float[] arrayLocationx = new float[n];
float[] arrayLocationy = new float[n];
float[] arrayLocationz = new float[n];
float[] arraySpeed = new float[n];
float[] arrayBoxcolorhue = new float[n];
float[] arrayBoxcolorsat = new float[n];
float[] arrayBoxcolorbri = new float[n];
MovieMaker mm;
void setup() {
size(1280, 720, OPENGL);
// size(1280, 720, "hipstersinc.P5Sunflow");
noStroke();
// setting random values for everything
for (int i = 0; i < n-1; i++) {
arrayBoxdim[i] = random(30,250);
arrayLocationx[i] = random(3*width);
arrayLocationy[i] = random(3*height);
arrayLocationz[i] = -10*random(height);
arraySpeed[i] = random(-10,10);
arrayBoxcolorhue[i] = random(360);
arrayBoxcolorsat[i] = random(90,100);
arrayBoxcolorbri[i] = random(60,100);
}
// mm = new MovieMaker(this, width, height, "processing.mov",
// 24,MovieMaker.ANIMATION, MovieMaker.LOSSLESS);
}
void draw() {
background(255);
// 50% of all the boxes move horizontally (at different speeds)
for (int i = 0; i < n-1; i+=2) {
arrayLocationx[i] = arrayLocationx[i] + arraySpeed[i];
}
// 50% of all the boxes move vertically (at different speeds)
for (int i = 1; i < n-1; i+=2) {
arrayLocationy[i] = arrayLocationy[i] + arraySpeed[i];
}
translate(-width,-height);
// drawing all the boxes, translating them to their xyz locations
// the z is used for the 'camera' fly-through effect
// filling them with their respective HSB-colors
for(int i=0; i<n; i++) {
pushMatrix();
translate(arrayLocationx[i],arrayLocationy[i],arrayLocationz[i]+z);
colorMode(HSB,360,100,100);
fill(arrayBoxcolorhue[i],arrayBoxcolorsat[i],arrayBoxcolorbri[i]);
box(arrayBoxdim[i]);
popMatrix();
}
// mm.addFrame();
// 'camera' movement speed
z+=5;
// counter to reset scene every 100 frames (250 the first time)
count+=1;
if (count == countlimit) {
for (int i = 0; i < n-1; i++) {
arrayBoxdim[i] = random(30,250);
arrayLocationx[i] = random(3*width);
arrayLocationy[i] = random(3*height);
arrayLocationz[i] = -10*random(height);
arraySpeed[i] = random(-10,10);
arrayBoxcolorhue[i] = random(360);
arrayBoxcolorsat[i] = random(90,100);
arrayBoxcolorbri[i] = random(60,100);
}
count = 0;
countlimit = 100;
}
// counter for finishing the movie and exiting after 1850 frames
countclose+=1;
if (countclose >= 1850) {
// mm.finish();
exit();
}
}