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

问题描述 投票:1回答:2

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

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

可能吗?我试过“textMode(SCREEN)但在处理2中不存在了。

text fonts 3d processing
2个回答
0
投票

想到一个解决方法是创建一个2D草图,它与草图具有相同的宽度/高度,给它一个透明的背景,在你想要的地方绘制你的文字,然后像你一样将PGraphic绘制到真实的草图上如果您正在复制图像源数据。


0
投票

以下是我在加工论坛上发现的内容

您可以使用:

  • 用于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);
    }
© www.soinside.com 2019 - 2024. All rights reserved.