Hello,
I had some fun exploring 3D meshes from:
Coding Challenge #11: 3D Terrain Generation with Perlin Noise in Processing
Code < Click here
// 3D Mesh Sine Waves
// v 1.0.1
// GLV 2020-07-22
// Inspiration:
// Coding Challenge #11: 3D Terrain Generation with Perlin Noise in Processing
// https://youtu.be/IKB1hWWedMk
int rows, cols;
int sp = 10;
int w = 600;
int h = 600;
int col;
float theta;
boolean toggle = true;
void setup()
{
size(600, 600, P3D);
cols = w/sp;
rows = h/sp;
colorMode(HSB, 256*2*3, 100, 100); //all hues at full sat and brightness
background(0);
}
void draw()
{
background(0);
lights();
pushMatrix();
translate(width/2, height/2);
rotateX(TAU/8);
translate(-w/2, -h/2 -250, -150);
theta += TAU/1000;
col += 1;
if (col> 256*2*3-1) col = 0;
if(toggle)
{
noStroke();
fill(col, 100, 100);
}
else
{
stroke(60*256*2*3/360, 100, 100);
println(hex(color(60*256*2*3/360, 100, 100)));
noFill();
}
for(int y = 0; y< rows; y++)
{
beginShape(TRIANGLE_STRIP);
float angley = TAU/20;
for(int x = 0; x < cols; x++)
{
float anglex = TAU/20;
float z1 = 50*sin(x*anglex + theta) + 50*sin(y*angley + theta);
float z2 = 50*sin(x*anglex + theta) + 50*sin((y+1)*angley + theta);
vertex(x*sp, y*sp, z1);
vertex(x*sp, (y+1)*sp, z2);
}
endShape();
}
popMatrix();
push();
fill(256*3*2);
textSize(30);
color c = color(col, 100, 100);
text("RED: " + nfs( (c >> 16 & 0xFF), 3) +
" GREEN: " + nfs(( c >> 8 & 0xFF), 3) +
" BLUE: "+ nfs((c & 0xFF), 3), 40, height-60);
pop();
}
void keyPressed()
{
toggle = !toggle;
println(toggle);
}
I got it to cycle through all the hues for full sat and brightness in HSB mode; that I had to think about!
That was fun!
:)