如何在处理P3D模式下绘制2D字体?

2023-12-05

我正在运行一个包含 3D 空间 (P3D) 中的点数组的草图。我想通过绘制文本来添加一个界面,就好像它是“屏幕上”/2D,仅使用“X,Y”参数。

当我尝试添加“text(”!@#$%”, width/2, height/2);”它在 3D 空间中呈现。

是否可以?我尝试了“textMode(SCREEN)”,但在处理 2 中不再存在。


这是我在处理论坛上发现的

您可以使用:

  • 适用于您的 3D 内容的 PMatrix3D
  • 并以简单的旧方式编码你的 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);
    }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在处理P3D模式下绘制2D字体? 的相关文章

随机推荐