Processing.04_3D圖形
創(chuàng)建3D空間:size(x,y,P3D),深度默認(rèn)是無窮大的。
相比較2D平面,增加一個參數(shù)深度,可以理解為以屏幕為0,靠近用戶為正,穿透屏幕為負(fù)

translate():把以(x,y)為原點(diǎn),進(jìn)行繪圖
語法:translate(x, y) ,translate(x, y, z)
參數(shù):
x (float) left/right translation
y (float) up/down translation
z (float) forward/backward translation
pushMatrix(),popMatrix():
pushMatrix(),類似于創(chuàng)建一個新的坐標(biāo)系,用于繪制。popMatrix()類似于還原之前的坐標(biāo)系。這兩個函數(shù)需要打包使用。

rotate(angle) 旋轉(zhuǎn)畫面,包括這個坐標(biāo)系里的所有圖形。經(jīng)常和pushMatrix以及popMatrix合起來使用。正值為順時針方向。旋轉(zhuǎn)原點(diǎn)為
參數(shù):angle (float) angle of rotation specified in radians

box():繪制長方形
語法:box(size) ,box(w, h, d)
參數(shù):
size (float) dimension of the box in all dimensions (creates a cube)
w (float) dimension of the box in the x?dimension
h (float) dimension of the box in the y?dimension
d (float) dimension of the box in the z?dimension
sphere():繪制球形
語法:sphere(r)
參數(shù):
r (float) the radius of the sphere
light():燈光渲染,這是一個可以非常深入的內(nèi)容
directionalLight():定向光源,nx,ny,nz可以理解為向量
語法:directionalLight(v1, v2, v3, nx, ny, nz)
參數(shù):
v1 (float) red or hue value (depending on current color mode)
v2 (float) green or saturation value (depending on current color mode)
v3 (float) blue or brightness value (depending on current color mode)
nx (float) direction along the x?axis
ny (float) direction along the y?axis
nz (float) direction along the z?axis

ambientLight():環(huán)境光,可以理解為從各個方向照射到物體,需要在draw函數(shù)中使用,不斷渲染,如果在setup中只有第一次會出現(xiàn),之后不會出現(xiàn)環(huán)境光了。一般和其他光源一起使用。
語法:ambientLight(v1, v2, v3) ,ambientLight(v1, v2, v3, x, y, z)
參數(shù):
v1 (float) red or hue value (depending on current color mode)
v2 (float) green or saturation value (depending on current color mode)
v3 (float) blue or brightness value (depending on current color mode)
x (float) x-coordinate of the light
y (float) y-coordinate of the light
z (float) z-coordinate of the light
音樂可視化案例-心形陣列
旋轉(zhuǎn)心形陣列,大小和聲音強(qiáng)度正相關(guān),表現(xiàn)音樂的律動感,可以用不同的光組合,讓畫面更豐富
https://www.bilibili.com/video/BV1Ef4y1d7Vu/
