Midterm porject progress
Tree[] trees = new Tree[10];
int z = 450;
int angle;
//PShape car;
void setup() {
size(800, 800, P3D);
background(0);
//car = loadShape("car.obj");
//camera(width/2,height/2,0,100,mouseX,0, 0,1,0);
for (int i = 0; i < trees.length; i++) {
int ystart = i * 200;
trees[i] = new Tree(width/2, ystart+50);
}
}
void draw() {
background(103,195,255);
lights();
println(mouseX);
////////the grey road//////
pushMatrix();
translate(-2000,200, -3500);
rotateX(radians(443));
rotateZ(radians(360));
fill(138,227,57);
rect(0, 0, 4000, 4000);
popMatrix();
////////////grass ground//////////
pushMatrix();
translate(width/2-350,200, -3000);
rotateX(radians(443));
rotateZ(radians(360));
fill(170,173,167);
rect(0, 0, 650, 4000);
popMatrix();
///////////////trees on the left side/////////////
pushMatrix();
noFill();
stroke(random(255), random(255), random(255));
translate((width/2)-100, height/2);
rotateX(radians(85));
rotateZ(radians(360));
translate(-width/2, -height/2);
for (int i = 0; i < trees.length; i++) {
trees[i].update();
trees[i].display();
}
popMatrix();
///////////////trees on the right side/////////////
pushMatrix();
noFill();
stroke(random(255), random(255), random(255));
translate((width/2)+100, height/2);
rotateX(radians(85));
rotateZ(radians(-360));
translate(-width/2, -height/2);
for (int i = 0; i < trees.length; i++) {
trees[i].update();
trees[i].display();
}
popMatrix();
pushMatrix();
translate(width/2, (height/2)+80, z);
if (keyPressed) {
if (key == 'w') {
z +=-5;
}
if (key == 's') {
z +=5;
}
}
fill(255);
noStroke();
///////////car 3D model/////
//shape(car,0,0,5,5);
sphere(10);
popMatrix();
}
/////Tree class
class Tree {
float y;
float x;
PShape tree;
Tree(float tx, float ty) {
x = tx;
y = ty;
tree = loadShape("tree.obj");
}
void update() {
y += 0;
if (y > height*5) {
y = 0;
}
}
void display() {
pushMatrix();
translate(x, y, 0);
shape(tree,0,0,50,50);
popMatrix();
}
}
Progress: I am trying to create the countryside scene first by import the 3D model of the tree, and create some background. I'm having some problems when I tried to import more tree and grass and replace the sphere with a 3D model of a car, but it does not work maybe because my computer does not have enough capacity. So I am trying to figure out. Also, as the feedback from my classmate last class, I am trying to set up a camera that following along with the sphere.
The only problem is my computer is getting very lag as I import the 3D models into my sketch. So I may have to draw the building shapes by processing for the urban scene.
There are also some other interesting feedback from my classmates such as I should think about how to transform the scene from countryside to urban, so I think of flipping the whole sketch of the countryside scene horizontally to transform it to the urban scene. I should add different background such as day for countryside scene and night for the urban scene, and maybe at more cars moving along with the main object to make the movement of the sketch.
int z = 450;
int angle;
//PShape car;
void setup() {
size(800, 800, P3D);
background(0);
//car = loadShape("car.obj");
//camera(width/2,height/2,0,100,mouseX,0, 0,1,0);
for (int i = 0; i < trees.length; i++) {
int ystart = i * 200;
trees[i] = new Tree(width/2, ystart+50);
}
}
void draw() {
background(103,195,255);
lights();
println(mouseX);
////////the grey road//////
pushMatrix();
translate(-2000,200, -3500);
rotateX(radians(443));
rotateZ(radians(360));
fill(138,227,57);
rect(0, 0, 4000, 4000);
popMatrix();
////////////grass ground//////////
pushMatrix();
translate(width/2-350,200, -3000);
rotateX(radians(443));
rotateZ(radians(360));
fill(170,173,167);
rect(0, 0, 650, 4000);
popMatrix();
///////////////trees on the left side/////////////
pushMatrix();
noFill();
stroke(random(255), random(255), random(255));
translate((width/2)-100, height/2);
rotateX(radians(85));
rotateZ(radians(360));
translate(-width/2, -height/2);
for (int i = 0; i < trees.length; i++) {
trees[i].update();
trees[i].display();
}
popMatrix();
///////////////trees on the right side/////////////
pushMatrix();
noFill();
stroke(random(255), random(255), random(255));
translate((width/2)+100, height/2);
rotateX(radians(85));
rotateZ(radians(-360));
translate(-width/2, -height/2);
for (int i = 0; i < trees.length; i++) {
trees[i].update();
trees[i].display();
}
popMatrix();
pushMatrix();
translate(width/2, (height/2)+80, z);
if (keyPressed) {
if (key == 'w') {
z +=-5;
}
if (key == 's') {
z +=5;
}
}
fill(255);
noStroke();
///////////car 3D model/////
//shape(car,0,0,5,5);
sphere(10);
popMatrix();
}
/////Tree class
class Tree {
float y;
float x;
PShape tree;
Tree(float tx, float ty) {
x = tx;
y = ty;
tree = loadShape("tree.obj");
}
void update() {
y += 0;
if (y > height*5) {
y = 0;
}
}
void display() {
pushMatrix();
translate(x, y, 0);
shape(tree,0,0,50,50);
popMatrix();
}
}
Progress: I am trying to create the countryside scene first by import the 3D model of the tree, and create some background. I'm having some problems when I tried to import more tree and grass and replace the sphere with a 3D model of a car, but it does not work maybe because my computer does not have enough capacity. So I am trying to figure out. Also, as the feedback from my classmate last class, I am trying to set up a camera that following along with the sphere.
The only problem is my computer is getting very lag as I import the 3D models into my sketch. So I may have to draw the building shapes by processing for the urban scene.
There are also some other interesting feedback from my classmates such as I should think about how to transform the scene from countryside to urban, so I think of flipping the whole sketch of the countryside scene horizontally to transform it to the urban scene. I should add different background such as day for countryside scene and night for the urban scene, and maybe at more cars moving along with the main object to make the movement of the sketch.

Comments
Post a Comment