We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I was running this code in java and javascript mode but I was getting two different output. I am using windows 7 64bit and processing 2.1 64 bit version. Can anyone test this code for me ?
Problem is the rotation of the rectangles, you would notice that in these two different modes. Actually 3D rotation is not working in javascript mode.
Rectangle[] R = new Rectangle[50];
void setup() {
size(600, 300, P3D);
for (int i=0;i<R.length;i++) {
R[i] = new Rectangle((int)random(0, width), (int)random(0, height));
}
}
void draw()
{
background(0);
for (int i=0;i<R.length;i++) {
R[i].display();
R[i].update(random(0, 0.2));
if (R[i].y>height )
{
R[i].y=0;
}
}
}
class Rectangle {
float x, y, z, angle, v, xspeed, depth;
color c;
Rectangle(float x, float y)
{
this.x = x;
this.y = y;
c= (color)random(#000000);
angle = random(0, PI);
v = random(0.5, 1.5);
//xspeed = 2*cos(x);
//depth = random(0, 1000);
z = map(depth, 0, 100, 0, 1000);
}
void display() {
noStroke();
fill(c);
pushMatrix();
translate(x, y);
pushMatrix();
rotate(angle, x, y, 0);
rect(0, 0, 10, 10);
popMatrix();
popMatrix();
}
void update(float _angle) {
angle= angle +_angle;
y = y + v;
x = x + sin(random(-PI/8, PI/8));
}
}
Answers
I couldn't find out a fix for rotate()! :o3
JavaScript is still very similar to Processing 1.5.1.
And indeed, running your code under the old version, renders crazy results! @-)
Anyways, I'll leave ya w/ the modifications I was trying to:
Thanks GoToLoop :)