Q1. Please use Processing to draw a 3D box using PShape and vertex(x, y, z) inst
ID: 3601169 • Letter: Q
Question
Q1. Please use Processing to draw a 3D box using PShape and vertex(x, y, z) instead of using the default box(x, y, z) command. (You need to define your own 8 vertices for the box).
Q2. Recall how we draw a 3D Cone shape in Processing using PShape and vertex(x, y, z), please draw a 3D cylinder using PShade in Processing.
Q3. Now utilize the 3D cylinder, 3D box shape, and Geometric transformations to draw the Lego pieces shown below (HINT: as long as we can construct the single unit piece, we can use Geometric Transformation to construct any other pieces):
LEGO PIECESExplanation / Answer
1. Creating 3d-bx using Pshape and vertex(x,y,z)
================================Program Below=============================================
PShape box;
void setup(){
box = createShape();
//begin making the box shape
box.beginShape();
//creating a 3d-box of size : 1*1*1
//you can change the verticex and give coordinates according to your wish/requirement
//creating 8 vertices of the box
box.vertex(0,0,0);
box.vertex(1,0,0);
box.vertex(1,1,0);
box.vertex(0,1,0);
box.vertex(0,0,1);
box.vertex(0,1,1);
box.vertex(1,0,1);
box.vertex(1,1,1);
box.endShape(CLOSE); //end drawing the shape
}
void draw(){
//setting up background color for better visiblity of the 3d box
background(51);
//translate here if you want to move the box from origin
//to create the box where the mouse is use below line
//translate(mouseX,mouseY,0);
//create the box using shape method
shape(box);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.