3D Coding on the Z-axis

Hi all!
Phil here again, as you know this has been a very stressful year, so I thought coding would be a fantastic way to get back my mojo in self-isolation! For those of you who are unaware, I began to learn coding last year and I have loved every minute of it! I was inspired to code when my namesake, Punxsutawney Phil, the groundhog on groundhogs day said that we would have a long winter…brr… Anyway, it seems that I am in a bit of pickle as I have expanded my coding repertoire into the 3D world, an exciting new endeavor! I am having some trouble with coding 3D shapes that rotate on the Z axis and I would love any trips, tricks, or code that might be helpful.
Thank you all
Warmest regards,
Phil Random

2 Likes

Hello,

Check out resources here:

`:)`

2 Likes
2 Likes

here is an example

Chrisir

``````

float angle1;

void setup() {
// init
size(800, 600, P3D);
} // func

void draw() {
// runs on and on
background(0);
lights();

stroke(100);
//  noFill();
fill(255, 0, 0);

pushMatrix();
translate(100, 100, 0);
rotateZ(angle1);
angle1+=.04;
box(60);
popMatrix();

pushMatrix();
translate(400, 100, 0);
rotateX(angle1);
fill(0, 0, 255);
box(60);
popMatrix();

pushMatrix();
translate(700, 100, 0);
rotateY(angle1);
box(60);
popMatrix();

pushMatrix();
translate(700, 300, -330);
noStroke();
sphere(50);
popMatrix();
} // func
//
``````
2 Likes

Thank you all for the help! Immensely appreciated!
-Phil

1 Like

Also don’t forget the PeasyCam library, if you want to rotate something that is centered and look at it.

Thank you Jeremy! Much appreciated!
Best wishes to you and I hope you are staying healthy!
-Phil

1 Like

To you also, Phil–be well.