We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a camera matrix extracted from another application. Currently, if I multiply a 3D point to this matrix, I get the 2D coords correspondent to where that point exists in camera projection plane.
I was trying to use "applyMatrix()" directly. BUT this is flattening everything, meaning object back faces and occluded faces becomes visible. Lights have no effect. stroke and fill get mixed.
PMatrix3D p;
void setup() {
size(600, 400, P3D);
}
void draw() {
float x = map(mouseX, 0, width, -10, 10);
float z = map(mouseY, 0, height, -10, 10);
p = new PMatrix3D(
5.400566, 0.519709, -4.3888016, 193.58757,
5.284709, -9.016302, 3.312224, 266.927,
0.012042404, 7.253584E-5, 0.0084899925, 1.0,
0, 0, 0, 1);
applyMatrix(p);
background(20);
translate(x,0,z);
fill(100);
box(10);
}
second attempt was to apply transformation on PGraphicsOpenGL, but I still couldn't figure out how to do it properly.
PMatrix3D p;
void setup() {
size(600, 400, P3D);
p = new PMatrix3D(
5.400566, 0.519709, -4.3888016, 193.58757,
5.284709, -9.016302, 3.312224, 266.927,
0.012042404, 7.253584E-5, 0.0084899925, 1.0,
0, 0, 0, 1);
p.invert();
}
void draw() {
float x = map(mouseX, 0, width, -200, 200);
float z = map(mouseY, 0, height, -150, 150);
//((PGraphicsOpenGL) g).modelview.set(p);
((PGraphicsOpenGL) g).camera.set(p);
//((PGraphicsOpenGL) g).projection.set(p);
//((PGraphicsOpenGL) g).projmodelview.set(p);
background(20);
lights();
translate(width/2, height/2);
translate(x, 0, z);
box(100);
}
from here: //https://github.com/processing/processing/issues/2904 I got the idea of making a shader but I have never done this before, so I am clueless so far...