欢迎光临散文网 会员登陆 & 注册

Processing.04_3D图形

2022-07-06 12:34 作者:可燃_kieran  | 我要投稿

创建3D空间:size(x,y,P3D),深度默认是无穷大的。

相比较2D平面,增加一个参数深度,可以理解为以屏幕为0,靠近用户为正,穿透屏幕为负

translate():把以(x,y)为原点,进行绘图

语法:translate(x, y) ,translate(x, y, z)

参数:

x (float) left/right translation

y (float) up/down translation

z (float) forward/backward translation


pushMatrix(),popMatrix():

pushMatrix(),类似于创建一个新的坐标系,用于绘制。popMatrix()类似于还原之前的坐标系。这两个函数需要打包使用。

rotate(angle) 旋转画面,包括这个坐标系里的所有图形。经常和pushMatrix以及popMatrix合起来使用。正值为顺时针方向。旋转原点为

参数:angle (float) angle of rotation specified in radians

box():绘制长方形

语法:box(size) ,box(w, h, d)

参数:

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)

参数:

r (float) the radius of the sphere

light():灯光渲染,这是一个可以非常深入的内容

directionalLight():定向光源,nx,ny,nz可以理解为向量

语法:directionalLight(v1, v2, v3, nx, ny, nz)

参数:

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():环境光,可以理解为从各个方向照射到物体,需要在draw函数中使用,不断渲染,如果在setup中只有第一次会出现,之后不会出现环境光了。一般和其他光源一起使用。

语法:ambientLight(v1, v2, v3) ,ambientLight(v1, v2, v3, x, y, z)

参数:

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

音乐可视化案例-心形阵列

旋转心形阵列,大小和声音强度正相关,表现音乐的律动感,可以用不同的光组合,让画面更丰富

https://www.bilibili.com/video/BV1Ef4y1d7Vu/


Processing.04_3D图形的评论 (共 条)

分享到微博请遵守国家法律