我正在运行一个包含3D空间中一组点的草图(P3D)。我想添加一个界面,只使用"X,Y“参数绘制文本,就好像它是”屏幕上“的/2D一样。
当我尝试只添加"text("!@#$%",width/2,height/2);“时,它呈现在3D空间中。
有可能吗?我尝试了“textMode(屏幕),但在processing 2中不再存在。
发布于 2018-01-03 19:22:36
这是我在Processing论坛上找到的
您可以使用:
方法对2D内容进行编码
我希望它能帮上忙
PMatrix3D baseMat;
float alpha =0;
void setup() {
size(400, 400, P3D);
// Remember the start model view matrix values
baseMat = getMatrix(baseMat);
}
void draw() {
background(40);
pushMatrix();
camera(0, 0, 400, 0, 0, 0, 0, 1, 0);
directionalLight(255, 255, 255, -100, 150, -100);
ambientLight(40, 40, 40);
// 3D drawing stuff here
rotateY(alpha);
box(100);
alpha += 0.05;
popMatrix();
// Restore the base matrix and lighting ready for 2D
this.setMatrix(baseMat);
ambientLight(255, 255, 255);
// draw 2D stuff here
rect(10, 10, 50, 10);
textSize(25);
text("voila", mouseX, mouseY);
}发布于 2015-06-01 12:35:01
我想到的一种解决办法是创建一个与草图具有相同宽度/高度的2D PGraphic,为其提供透明的背景,在其上绘制文本,然后将PGraphic绘制到真实草图上,就像复制图像源数据一样。
https://stackoverflow.com/questions/30565354
复制相似问题