Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pointNum = 1200;
- int rowNum = 20;
- PVector [] pointsArray = new PVector [pointNum];
- boolean shift;
- void setup() {
- size(400, 400, P3D);
- for (int i = 0; i <pointNum; i++) {
- if (i%rowNum == 0) { // shifts shifts other row over
- pointsArray[i] = new PVector((i % rowNum) * rowNum - width/2, (i / rowNum) * rowNum - height/2, random(20));
- } else {
- pointsArray[i] = new PVector((i % rowNum) * rowNum + rowNum/2 - width/2, (i / rowNum) * rowNum - height/2, random(20) );
- }
- }
- smooth();
- }
- void draw() {
- background(200);
- pushMatrix();
- translate(width/2, height/2);
- rotateX(4.3);
- beginShape(TRIANGLES);
- shift = true;
- // for (int i = 0; i < pointNum; i++) {
- for (int i = 0; i < pointNum - (rowNum +1); i++) {
- if (i%rowNum == 0) { // every other row shifts over half way
- shift = !shift;
- }
- if ( (i +1) % rowNum != 0) { // keeps it from drawing from one side to the other
- vertex(pointsArray[i].x, pointsArray[i].y, pointsArray[i].z);
- vertex(pointsArray[i +1].x, pointsArray[i +1].y, pointsArray[i +1].z);
- if (shift == false) {
- vertex(pointsArray[i + rowNum].x, pointsArray[i +rowNum].y, pointsArray[i + rowNum].z );
- } else {
- vertex(pointsArray[i + rowNum +1].x, pointsArray[i +rowNum+1].y, pointsArray[i + rowNum+1].z);
- }
- vertex(pointsArray[i +rowNum +1].x, pointsArray[i +rowNum + 1].y, pointsArray[i +rowNum + 1].z);
- vertex(pointsArray[i + rowNum].x, pointsArray[i +rowNum].y, pointsArray[i +rowNum].z);
- if (shift == false) {
- vertex(pointsArray[i + 1].x, pointsArray[i + 1].y, pointsArray[i + 1].z);
- } else {
- vertex(pointsArray[i].x, pointsArray[i].y, pointsArray[i].z);
- }
- }
- }
- endShape();
- popMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment