79
Processing 3D & Library 05 3D 以及 Library

Processing=005=3d&library

Embed Size (px)

DESCRIPTION

A_Little_Bit_Processing_Tutorial

Citation preview

Page 1: Processing=005=3d&library

Processing

3D & Library

053D 以及 Library

Page 2: Processing=005=3d&library

3D

Page 3: Processing=005=3d&library

void setup(){

size(500,500,P3D);

smooth();

}

void draw(){

background(0);

ellipse(250,250,100,100);

}

Page 4: Processing=005=3d&library

Where is the Camera

鏡頭呢?不會動?

Page 5: Processing=005=3d&library

Go to File/ Example

Page 6: Processing=005=3d&library

You can open it and

see what’s in the code

可以看看他們有甚麼

Page 7: Processing=005=3d&library
Page 8: Processing=005=3d&library

There is a LIBRARY,Easy way 還好有個Library簡單好用

Page 9: Processing=005=3d&library

http://processing.org/reference/libraries/

Page 10: Processing=005=3d&library

Click on it

Page 11: Processing=005=3d&library

http://mrfeinberg.com/peasycam/

Find the

Download

Page 12: Processing=005=3d&library

FOR

WIND

OWS微軟使用者

Page 13: Processing=005=3d&library

Unzip the file

解壓縮

Page 14: Processing=005=3d&library

There is a

“peasycam” under the

“PeasyCam_200 ”

Copy it !!!

裡面會有個peasyCam

資料夾

複製它

Page 15: Processing=005=3d&library

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

Page 16: Processing=005=3d&library

Something like this

像這樣

Page 17: Processing=005=3d&library

FOR

MAC蘋果使用者

Page 18: Processing=005=3d&library

Unzip the file

解壓縮

Page 19: Processing=005=3d&library

There is a

“peasycam” under the

“PeasyCam_200 ”

Copy it !!!

裡面會有個peasyCam

資料夾

複製它

Page 20: Processing=005=3d&library

1. 2.

3. 4.

Page 21: Processing=005=3d&library

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.

Page 22: Processing=005=3d&library

Something like this

Page 23: Processing=005=3d&library

Close and Reopen

Your

Proce

ssing

ALL the

ALL the

Users

全體通通有

重新啟動

Page 24: Processing=005=3d&library

Now we can go back to the CODE

Page 25: Processing=005=3d&library

How to import the LABRARIES如何輸入library

Page 26: Processing=005=3d&library
Page 27: Processing=005=3d&library
Page 28: Processing=005=3d&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);

}

Page 29: Processing=005=3d&library
Page 30: Processing=005=3d&library

Primitives3D基本量體

Page 31: Processing=005=3d&library

box(size);box(x,y,z);

Page 32: Processing=005=3d&library

import peasy.*;

PeasyCam gcam;

void setup(){

size(500,500,P3D);

smooth();

gcam = new PeasyCam(this, 500);

}

void draw(){

background(0);

box(50);

}

Page 33: Processing=005=3d&library
Page 34: Processing=005=3d&library

import peasy.*;

PeasyCam gcam;

void setup(){

size(500,500,P3D);

smooth();

gcam = new PeasyCam(this, 500);

}

void draw(){

background(0);

box(50);

}

Page 35: Processing=005=3d&library
Page 36: Processing=005=3d&library

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);

}

Page 37: Processing=005=3d&library

IKEA

Page 38: Processing=005=3d&library

sphere(size);

Page 39: Processing=005=3d&library

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)

}

Page 40: Processing=005=3d&library

IKEA

Page 41: Processing=005=3d&library

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)

}

Page 42: Processing=005=3d&library

We would like to make a

sin_Wave想要做一個sin的

波浪

Page 43: Processing=005=3d&library

Translate();移動

Page 44: Processing=005=3d&library

(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()會移動整個原點的座標位置

Page 45: Processing=005=3d&library

(0,0,0)

(-20,-20,0)

new

origin

Translate(-10,-40,0)

point(0,0,0);

(-10,-40,0)

Page 46: Processing=005=3d&library

(10,40,0)

(-10,20,0)

new

origin

(0,0,0)

Page 47: Processing=005=3d&library

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);

}

Page 48: Processing=005=3d&library

Gap distanceBecome Longer and longer

間距越來越長

Page 49: Processing=005=3d&library

pushMatrix();popMatrix();To avoid the situation

避免掉此問題

Page 50: Processing=005=3d&library

(20,20,0)

(0,0,0)

pushMatrix();

Translate(20,20,0)

point(0,0,0);

popMatirx();

origin

Page 51: Processing=005=3d&library

(20,20,0)

(0,0,0)

pushMatrix();

Translate(20,20,0)

point(0,0,0);

popMatirx();

new

origin

Page 52: Processing=005=3d&library

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();

Page 53: Processing=005=3d&library
Page 54: Processing=005=3d&library

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();

}

Page 55: Processing=005=3d&library
Page 56: Processing=005=3d&library

box(size); + For_Loop

Page 57: Processing=005=3d&library

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();

}

}

Page 58: Processing=005=3d&library
Page 59: Processing=005=3d&library

( i, sin(i) )

Page 60: Processing=005=3d&library

PI (π) = 180°

1° = PI / 180

Page 61: Processing=005=3d&library

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();

}

}

Page 62: Processing=005=3d&library
Page 63: Processing=005=3d&library

(r*cos(θ), r*sin(θ))

r

θ

Page 64: Processing=005=3d&library

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();

}

}

Page 65: Processing=005=3d&library
Page 66: Processing=005=3d&library

Make a Spiral

做個神鬼奇航

Page 67: Processing=005=3d&library

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();

}

}

Page 68: Processing=005=3d&library
Page 69: Processing=005=3d&library

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();

}

}

Page 70: Processing=005=3d&library
Page 71: Processing=005=3d&library

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();

}

}

Page 72: Processing=005=3d&library
Page 73: Processing=005=3d&library

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();

}

}

Page 74: Processing=005=3d&library
Page 75: Processing=005=3d&library

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;

Page 76: Processing=005=3d&library

If (you are interested more into 3D Mesh){another library “Hemesh”;

}

Page 77: Processing=005=3d&library

If (you are interested more into 3D Mesh){another library “toxiclibs”;

}

Page 79: Processing=005=3d&library