Rotate 3D around it's center
in
Programming Questions
•
6 months ago
hello all,
I am still suffering from the rotation business.
I got a form consisting of many PShapes.
Now I want to rotateX it around its center.
Do I have to take the average x-pos and then reduce all x-pos by the average x-pos,
rotate and then translate it to the center?
The example shows a simple rotating cube.
Thanks!
Greetings, Chrisir
- //
- float i;
- void setup() {
- size(640, 360, P3D);
- background(0);
- lights();
- }
- void draw() {
- background(0);
- //
- pushMatrix();
- noStroke();
- translate(width/2, height/2, 0);
- rotateY(i);
- box(100);
- popMatrix();
- //
- i+=.0121;
- }
- //
1