Possible 3D bug
in
Android Processing
•
3 years ago
Hello! I've found a difference in the 3D implementations using opengl in traditional Processing (on a desktop/laptop) and A3D on Android. In particular, the camera() function seems to not center correctly in A3D. I'm not yet sure if it is a bug or a feature, but here's how to replicate it.
The following sketch runs on both versions (to run on the desktop you need to uncomment the "import processing.opengl.*" and "size(800,480,OPENGL)" lines, while commenting out the sketchRenderer() method and the orientation() call)
<begin sketch>
float cameraDistance = 200.0;
float newCamXCoord = cameraDistance*cos(PI/4);
float newCamYCoord = cameraDistance*cos(PI/4);
float newCamZCoord = cameraDistance*cos(PI/4);
float xTop = 0;
float yTop = 0;
float zTop = -1;
void draw3DAxes(float minValue, float maxValue) {
// Draws lines along the x,y and z axes.
stroke(255,255,255);
float minAxValue = minValue - .10*(maxValue - minValue);
float maxAxValue = maxValue + .10*(maxValue - minValue);
line(minAxValue,0,0,maxAxValue,0,0);
line(0,minAxValue,0,0,maxAxValue,0);
line(0,0,minAxValue,0,0,maxAxValue);
}
//import processing.opengl.*;
public String sketchRenderer() {
return A3D;
}
void setup() {
//size(800,480,OPENGL);
orientation(LANDSCAPE);
background(0);
}
void draw() {
background(0);
camera(newCamXCoord,newCamYCoord,newCamZCoord,0,0,0,xTop,yTop,zTop);
draw3DAxes(-100,100);
}
</end sketch>
On the desktop, this draws a set of 3d Axes (as seen from somewhere on the intersection of the planes x=y, y=z and x=z) that are centered in the screen while on my android phone (which has a resolution of 800x480) it draws these axes in the upper left hand corner. It would appear that the problem is that camera() doesn't operate the same on the device as it does on the desktop.
Am I correct? If so, is this intended?
1