Upload
gary-chang
View
213
Download
0
Embed Size (px)
DESCRIPTION
A_Little_Bit_Processing_Tutorial
Citation preview
Processing
3D & Library
053D 以及 Library
3D
void setup(){
size(500,500,P3D);
smooth();
}
void draw(){
background(0);
ellipse(250,250,100,100);
}
Where is the Camera
鏡頭呢?不會動?
Go to File/ Example
You can open it and
see what’s in the code
可以看看他們有甚麼
There is a LIBRARY,Easy way 還好有個Library簡單好用
http://processing.org/reference/libraries/
Click on it
FOR
WIND
OWS微軟使用者
Unzip the file
解壓縮
There is a
“peasycam” under the
“PeasyCam_200 ”
Copy it !!!
裡面會有個peasyCam
資料夾
複製它
If you are Windows Users,如果你是微軟用戶
Find the “Modes” folder
And find the “java” folder
And find the “libraries” folder
And Paste the “peasy” folder under it
Something like this
像這樣
FOR
MAC蘋果使用者
Unzip the file
解壓縮
There is a
“peasycam” under the
“PeasyCam_200 ”
Copy it !!!
裡面會有個peasyCam
資料夾
複製它
1. 2.
3. 4.
If you are Mac Users,
Find the “Processing.app/ Content/
Resource/ Java/ Modes/ jave/ libraries
And Paste the “peasy” folder under it
5. 6.
7.
Something like this
Close and Reopen
Your
Proce
ssing
ALL the
ALL the
Users
全體通通有
重新啟動
Now we can go back to the CODE
How to import the LABRARIES如何輸入library
import peasy.*;
PeasyCam gcam;
// you can name any name instead of “gcam”
//你可以任意取名
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
// telling that the gcam is a new object of PeasyCam
//告訴程式 我創建了一個叫gcam的PeasyCam物件}
void draw(){
background(0);
ellipse(250,250,100,100);
}
Primitives3D基本量體
box(size);box(x,y,z);
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(0);
box(50);
}
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(0);
box(50);
}
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(255,255,0);
stroke(255);
fill(40,80,200);
box(50,80,100);//box(x,y,z);
}
IKEA
sphere(size);
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(0);
stroke(255);
fill(40,80,200);
sphere(80)
}
IKEA
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(0);
stroke(255);
fill(40,80,200);
sphere(80)
}
We would like to make a
sin_Wave想要做一個sin的
波浪
Translate();移動
(20,20,0)
(0,0,0)
Translate(20,20,0)
point(0,0,0);
old
origin
translate() will move the whole coordination of theorigin point
translate()會移動整個原點的座標位置
(0,0,0)
(-20,-20,0)
new
origin
Translate(-10,-40,0)
point(0,0,0);
(-10,-40,0)
(10,40,0)
(-10,20,0)
new
origin
(0,0,0)
import peasy.*;
PeasyCam gCam;
void setup(){
size(800,800,P3D);
gCam = new PeasyCam(this,500);
}
void draw(){
background(0);
box(50);
translate(100,100);
box(50);
translate(100,100);
box(50);
}
Gap distanceBecome Longer and longer
間距越來越長
pushMatrix();popMatrix();To avoid the situation
避免掉此問題
(20,20,0)
(0,0,0)
pushMatrix();
Translate(20,20,0)
point(0,0,0);
popMatirx();
origin
(20,20,0)
(0,0,0)
pushMatrix();
Translate(20,20,0)
point(0,0,0);
popMatirx();
new
origin
import peasy.*;
PeasyCam gCam;
void setup(){
size(800,800,P3D);
gCam = new PeasyCam(this,500);
}
void draw(){
background(0);
box(50);
pushMatrix();
translate(100,100, 0);
box(50);
popMatrix();
pushMatrix();
translate(100,100, 0);
box(50);
popMatrix();
import peasy.*;
PeasyCam gCam;
void setup(){
size(800,800,P3D);
gCam = new PeasyCam(this,500);
}
void draw(){
background(0);
box(50);
pushMatrix();
translate(100,100, 0);
box(50);
popMatrix();
pushMatrix();
translate(-100,100, 0);
box(50);
popMatrix();
}
box(size); + For_Loop
import peasy.*;
PeasyCam gCam;
void setup(){
size(800,800,P3D);
gCam = new PeasyCam(this,500);
}
void draw(){
background(0);
for(int i =0; i< 500; i=i+50){
pushMatrix();
translate( i, 100, 0);
box(50);
popMatrix();
}
}
( i, sin(i) )
PI (π) = 180°
1° = PI / 180
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(255,255,0);
noStroke();
fill(40,80,200);
for(float i=0; i<1800; i+=15){
pushMatrix();
translate( i, 50*sin(i*(PI/180)), 0);
box(15);
popMatrix();
}
}
(r*cos(θ), r*sin(θ))
r
θ
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(255,255,0);
stroke(255);
fill(40,80,200);
for(float i=0; i<360; i+=6){
pushMatrix();
translate(50*cos(i*(PI/180)), 50*sin(i*(PI/180)), 0);
box(10);
popMatrix();
}
}
Make a Spiral
做個神鬼奇航
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(255,255,0);
stroke(255);
fill(40,80,200);
for(float i=0; i<1440; i+=6){
pushMatrix();
translate( (i/2)*cos(i*(PI/180)), (i/2)* sin(i*(PI/180)), i/3);
box(25);
popMatrix();
}
}
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 500);
}
void draw(){
background(255,255,0);
stroke(255);
fill(40,80,200);
for(float i=0; i<1440; i+=6){
pushMatrix();
translate( (i/2)*cos(i*(PI/180)), (i/2)*sin(i*(PI/180)), i );
box(i/10);
popMatrix();
}
}
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 1000);
}
void draw(){
background(255,255,0);
stroke(255);
fill(40,80,200);
for(float i=0; i<360; i+=1){
pushMatrix();
translate(200*cos(i*PI/180), 200*sin(i*PI/180), 200*sin(i*PI/180));
box(i/10);
popMatrix();
}
}
import peasy.*;
PeasyCam gcam;
void setup(){
size(500,500,P3D);
smooth();
gcam = new PeasyCam(this, 1000);
}
void draw(){
background(255,255,0);
fill(40,80,200);
int c1 = 1;
int c2 = 1;
int c3 = 2;
for(float i=0; i<360; i+=1){
pushMatrix();
translate(200*cos(c1*i*PI/180), 200*sin(c2*i*PI/180), 200*sin(c3*i*PI/180));
box(i/10);
popMatrix();
}
}
int c1 = 1;
int c2 = 1;
int c3 = 3;
int c1 = 1;
int c2 = 1;
int c3 = 6;
int c1 = 2;
int c2 = 1;
int c3 = 3;
int c1 = 2;
int c2 = 4;
int c3 = 3;
int c1 = 2;
int c2 = 5;
int c3 = 2;
int c1 = 3;
int c2 = 4;
int c3 = 1;
If (you are interested more into 3D Mesh){another library “Hemesh”;
}
If (you are interested more into 3D Mesh){another library “toxiclibs”;
}
http://www.wblut.com/2010/05/04/hemesh-a-3d-mesh-library-for-processing/