thanx!
btw, anyone knows how to get OPENGL working with javascript?
my 3D sketch works fine in java, and isnt working in .js (whicht i need for the web), as soon as I alter the translate(x,y,z)
function to translate(x,y) it's working again.
here's the code:
//+++++++++++++++++++++++++++++++//
import processing.opengl.*;
VectorField Arrows;
void setup(){
size(560, 420, OPENGL);
Arrows = new VectorField();
}
void draw(){
background(0);
Arrows.Update();
}
class VectorField{
int col, row;
int resolution;
float alpha2;
float noisei, noisej;
PVector [][] Arrows;
PVector vec;
PVector mouse;
VectorField(){
resolution =20;
col=width/resolution;
row=height/resolution;
Arrows = new PVector [col][row];
}
void Update(){
for(int i=0; i<col; i++){
pushMatrix();
translate(0,0,20*cos((0.03*i+noisej)));
for(int j =0; j<row; j++){
pushMatrix();
translate(0,0,20*noise(noisei)*cos((0.03*j+noisei)));
Arrows[i][j] = new PVector((i*resolution), (j*resolution));
mouse = new PVector(mouseX, mouseY);
Arrows[i][j].sub(mouse);
Arrows[i][j].normalize();
Arrows[i][j].mult(25);
// Arrows[i][j].sub(new PVector(6*sin((0.03*i)), 6*cos((0.004*j))));
point(i*resolution, j*resolution);
//line(Arrows[i][j].x, Arrows[i][j].y, mouseX, mouseY);
stroke(255);
strokeWeight(1);
vec = new PVector(i*resolution-mouseX, j*resolution-mouseY);
if (vec.mag() < 30){
stroke(random(255), random(255), random(255));
}
line(i*resolution, j*resolution, i*resolution+Arrows[i][j].x, j*resolution+ Arrows[i][j].y);
alpha2=Arrows[i][j].heading2D();
pushMatrix();
translate(i*resolution, j*resolution);
rotate(alpha2);
stroke(#0372FF);
strokeWeight(4);
point(0,0);
// line( 0,0, 10*sin(radians(70)), 10*cos(radians(70)) );
// line( 0,0, 10*sin(radians(110)), 10*cos(radians(110)) );
popMatrix();
noisej+=0.000003*resolution;
popMatrix();
}
noisei+=0.000001*resolution;
popMatrix();
}
}
}
//+++++++++++++++++++++++++++++++//
any help is appreciated