I spawn a sphere not at the center of the space, and I would like the “camera” to rotate around that sphere, always looking towards the sphere’s center. According to https://gist.github.com/atduskgreg/1516424, it should be very easy, namely translate to the sphere’s center and then apply a rotation. However in my case it doesn’t work.
Here is a reasonable MWE (if you provide a solution I hope I can adapt it to my code afterwards):
int box_x = 550;
int box_y = 550;
void settings() {
System.setProperty("jogl.disable.openglcore", "true");
size(box_x, box_y, P3D);
}
void setup() {
frameRate(500);
background(0);
noFill();
translate(box_x/2.0, box_y/2.0, 0);
}
void draw() {
background(0);
translate(width/2-328, height/2-43, 500);
rotateY(frameCount / 100.0);
fill(128, 0, 128);
stroke(128, 0, 128);
lights();
translate(328, 43, 0);
sphereDetail(55);
sphere(100);
}
The problem, I think, is that despite the fact that the sphere is spawn where I want it to be, the axis of rotation does not match the sphere’s one. How can I fix this?