我的应用程序有一个分屏模式,其中只有一半的屏幕用于显示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十年前曾问过...... 有谁知道这是否有可能实现?
答案 0 :(得分:0)
您可以使用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);
}
函数为左视口创建缓冲区,然后绘制到缓冲区,然后将缓冲区绘制到屏幕上。
find
可以在the reference找到更多信息。