Tutorial by Examples

Here's how to translate objects in P3D: size(200, 200, P3D); //Starting P3D renderer fill(255, 0, 0, 150); //transparent red rect(10, 10, 100, 100); //first rectangle fill(0, 0, 255, 150); //transparent blue translate(50, 50, 50); //translate x, y and z by 50 pixels rect(0, 0, 100, 100); //sec...
There are three functions for 3D rotation: rotateX(angle), rotateY(angle) and rotateZ(angle) for rotation in their respective axes where angle is in radians. size(200, 200, P3D); //Starting P3D renderer fill(255, 0, 0, 150); //transparent red translate(width/2, height/2);//translate to centre, ie...
To draw a cuboid, you have to use the box() function by giving its dimensions as its parameters. size(200, 200, P3D); //Starting the P3D renderer translate(width/2, height/2); //Translating to the centre of the sketch rotateY(PI/4); //rotate so that... rotateX(PI/6); //... it will be easy to see...

Page 1 of 1