Hi! Thanks for all the help so far, this platform has been extremely supportive. I’m creating a 3D sphere but everytime i translate it, it also seems to rotate/deform, why is this the case? Is there an easy fix or do I need to recalculate the rotation amount every time to bring it back to the original shape when i translate?
1 Like
It seems like perhaps you want an orthographic perspective using ortho()
rather than the default perspective()
–
https://processing.org/reference/ortho_.html
but it is hard to tell what you mean by “everytime i translate it, it also seems to rotate/deform” without more details and example code.
Hi jeremy, this is what i mean:
void draw() {
background(0);
pushMatrix();
translate(width/2, height/2);
rotateX(0);
rotateZ(0);
shape.draw(getGraphics());
popMatrix();
}
If I change the translation:
translate(width/2+80, height/2-80);
The sphere/ellipse moves but also rotates, I want it to be exactly as it was.
Original:
After translation:
1 Like
What are you doing here? Can you provide a working sketch that shows what this is, and why you are doing it? From your title and question text I assumed you were using sphere()
.
Try enabling and disabling ortho()
in this example.
void setup() {
size(400, 400, P3D);
// ortho();
}
void draw() {
background(0);
pushMatrix();
translate(width/2+80, height/2-80);
rotateX(0);
rotateZ(0);
sphere(100);
popMatrix();
}
2 Likes
Thanks jeremy. Ortho worked like a charm. Appreciate it.