2

我的应用程序有一个分屏模式,其中只有一半的屏幕用于显示 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);
}

关于这个话题,我刚刚发现十年前提出的这个悬而未决的问题......有谁知道这是否有可能实现?

4

1 回答 1

0

您可以使用该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);
}

消失点在左半边

更多信息可以在参考资料中找到。

于 2016-09-01T18:35:23.883 回答