【问题标题】:Moving the perspective vanishing point in Processing在处理中移动透视消失点
【发布时间】:2015-08-04 14:36:37
【问题描述】:

我的应用程序有一个分屏模式,其中只有一半的屏幕用于显示 3d 场景。所以我想把消失点放在左半边的中间。

我已经尝试了camera()translate() 的各种组合,但是消失点不会从草图窗口的中心移动一个像素..

void setup(){
  size(800,400, P3D);
  fill(255,120);
}

void draw(){

  background(111);

  float camEyeX = 0;
  float camEyeY = 400;
  float camEyeZ = (height/2) / tan(PI/6);
  float camCenterX = 0;
  float camCenterY = -200;
  float camCenterZ = 0;
  float camUpX = 0;
  float camUpY = 1;
  float camUpZ = 0;

  pushMatrix();
  camera( camEyeX, camEyeY, camEyeZ, camCenterX, camCenterY, camCenterZ, camUpX, camUpY, camUpZ );
  translate( -200, 0, 0);
  rectMode(CENTER);
  rect(0,0, 800,400);
  rect(0,0, 100,100);
  popMatrix();
  hint(DISABLE_DEPTH_TEST);
  rectMode(CORNER);
  rect(400,0, 400,400);
  hint(ENABLE_DEPTH_TEST);
}

关于这个话题,我刚刚发现 this unanswered question 十年前问过...... 有谁知道这是否有可能实现?

【问题讨论】:

    标签: 3d processing vanishing-point


    【解决方案1】:

    您可以只使用createGraphics() 函数为您的左视口创建一个缓冲区,然后绘制到缓冲区,然后将缓冲区绘制到屏幕上。

    PGraphics leftSide;
    
    void setup(){
      size(800,400, P3D);
      leftSide = createGraphics(width/2, height, P3D);
    }
    
    void draw(){
    
      leftSide.beginDraw();
      leftSide.background(111);
    
      float camEyeX = 0;
      float camEyeY = 400;
      float camEyeZ = (height/2) / tan(PI/6);
      float camCenterX = 0;
      float camCenterY = -200;
      float camCenterZ = 0;
      float camUpX = 0;
      float camUpY = 1;
      float camUpZ = 0;
    
      leftSide.pushMatrix();
      leftSide.camera( camEyeX, camEyeY, camEyeZ, camCenterX, camCenterY, camCenterZ, camUpX, camUpY, camUpZ );
      leftSide.translate( -200, 0, 0);
      leftSide.rectMode(CENTER);
      leftSide.rect(0,0, 800,400);
      leftSide.rect(0,0, 100,100);
      leftSide.popMatrix();
      leftSide.hint(DISABLE_DEPTH_TEST);
      leftSide.rectMode(CORNER);
      leftSide.rect(400,0, 400,400);
      leftSide.hint(ENABLE_DEPTH_TEST);
    
      leftSide.endDraw();
    
      image(leftSide, 0, 0);
    }
    

    更多信息可以在the reference找到。

    【讨论】:

    • 感谢凯文,这听起来是正确的做法。 (不幸的是,该项目早已结束,但一旦有机会,我将尝试实施您的建议:我能想到的唯一可能的问题可能是性能..)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-29
    • 2017-11-22
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多