xxxxxxxxxx
192
var cam;
let centralX = 0;
let centralY = -400;
let centralZ = 0;
//Tree tree;
let treeSpacing = 500;
let treeSpacingRand = 200;
//float treeSpacing = 100;
//float treeSpacingRand = 20;
//Island
let jointSize = 2;
let boxSize = 200;
let trussSize = 5;
let facadeOn = true;
let floorOn = true;
let jointOn = true;
let trussOn = true;
let boxOn = false;
let boxFaceOn = true;
let platformOn = false;
let treetree;
let saving = false;
let xoff01 = 0.0;
/*
int thickness = 300;
int edgeNumber = 10;
int layerNumber = 30;
float randomRange = 100;
float layerHeight = 300;
ArrayList<PVector> jointList;
*/
function setup(){
c = createCanvas(window.innerWidth, window.innerHeight, WEBGL);
//c = createCanvas(windowWidth, windowHeight, WEBGL);
cam = new Dw.EasyCam(this._renderer, {distance:2000, center:[centralX,centralY,centralZ]});
treeList= [];
rockList = [];
FTreeLocList = [];
FTreeColorList = [];
FTreeSizeList = [];
for(let i = 0; i< 1; i+=1){
for(let j =0; j< 1; j+=1){
//loc = createVector(i*treeSpacing+random(-treeSpacingRand,treeSpacingRand),0,j*treeSpacing+random(-treeSpacingRand,treeSpacingRand));
var loc = createVector(i*treeSpacing,0,j*treeSpacing);
var jointList = [];
//PVector loc = new PVector(random(-3000,3000),0,random(-1500,1500));
//Tree(PVector loc, int thick, int eNumber, int lNumber, float rRange, float lHeight )
tree = new Tree(loc, 100,5,int(random(5,10)),50,150, jointList);
//tree = new Tree(loc, 100,5,8,50,150, jointList);
treeList.push(tree);
}
}
}
function draw(){
background(130);
//background(255*abs(sin(frameCount*0.01)));
push();
//directionalLight(255,0,0,1,1,-1);
//directionalLight(255,255,255,1,1,-1);
//directionalLight(255,255,255,1,1,1);
pop();
//platform & box
for(let i = 0; i< 1; i+=1){
for(let j =0; j< 1; j+=1){
push();
translate(i*treeSpacing,150+10,j*treeSpacing);
fill(170,100);
strokeWeight(2);
stroke(255);
box(500,10,500);
pop();
}
}
for(let i = 0; i< 1; i+=1){
for(let j =0; j< 1; j+=1){
push();
translate(i*treeSpacing,150-1200/2,j*treeSpacing);
//fill(170,220);
noFill();
strokeWeight(2);
stroke(255);
box(500,1200,500);
pop();
}
}
//bouncing
push();
translate(0, 100*sin(frameCount*0.01), 0);
//floor
push();
translate(0,50,0);
fill(170);
strokeWeight(2);
stroke(255);
//box(2000,10,2000);
pop();
for(let i=0; i<treeList.length; i++){
treeList[i].display();
//push();
//scale(1,-1,1);
//treeList[i].display();
//pop();
}
cam.rotateY(0.005);
if (frameCount % 200 == 0){
//jointList = [];
//loc = createVector(0,0,0);
//treetree = new Tree(loc,100,5,int(random(2,8)),50,150);
treeList = [];
for(let i = 0; i< 1; i+=1){
for(let j =0; j< 1; j+=1){
//loc = createVector(i*treeSpacing+random(-treeSpacingRand,treeSpacingRand),0,j*treeSpacing+random(-treeSpacingRand,treeSpacingRand));
var loc = createVector(i*treeSpacing,0,j*treeSpacing);
var jointList = [];
//PVector loc = new PVector(random(-3000,3000),0,random(-1500,1500));
//Tree(PVector loc, int thick, int eNumber, int lNumber, float rRange, float lHeight )
tree = new Tree(loc, 100,5,int(random(5,10)),50,150, jointList);
//tree = new Tree(loc, 100,5,8,50,150, jointList);
treeList.push(tree);
}
}
}
pop();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
cam.setViewport([0,0,windowWidth, windowHeight]);
}
function keyPressed(){
if(key == 'a'){
let fs = fullscreen();
fullscreen(!fs);
}
if(key == 'f'){
facadeOn = !facadeOn;
}
if(key == 'd'){
floorOn = !floorOn;
}
if(key == 'j'){
jointOn = !jointOn;
}
if(key == 't'){
trussOn = !trussOn;
}
if(key == 'b'){
boxOn = !boxOn;
}
if(key == 'p'){
boxFaceOn = !boxFaceOn;
}
//if(key == 'p'){
//platformOn = !platformOn;
//}
}