如何在处理 P3D 模式下绘制 2D 字体? [英] How do I draw 2D fonts in processing P3D mode?

查看:31
本文介绍了如何在处理 P3D 模式下绘制 2D 字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm running a sketch with an array of points in 3D space (P3D). I'd like to add an interface to it by drawing text as if it were "onscreen"/2D, only using "X, Y" parameters.

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

When I tried just adding "text("!@#$%", width/2, height/2);" it rendered in 3D space.

有可能吗?我试过textMode(SCREEN),但在处理 2 中不再存在.

Is it possible? I tried "textMode(SCREEN) but doesnt exist in processing 2 anymore.

推荐答案

这是我在处理论坛上找到的内容

Here is what I found, I guess on the Processing Forum

您可以使用:

  • 用于 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);
    }

这篇关于如何在处理 P3D 模式下绘制 2D 字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆