Generating an object
The second task of our current mission is to generate a 3D object that can be used as a small pen holder or vase. We will use the 2D shape we created in task 1 as a cross section of our object by extruding it along the z axis. We will extend our getR()
method and add a bunch of additional control variables that will allow us to change the circular shape depending on the object's height.
To make it easier for our users to look at the object, we will add the mousePressed()
and mouseDragged()
functions, which rotate the object in any direction. We will use a mathematical construct named quaternion to implement these rotations.
Engage Thrusters
Let's bring our shape to the third dimension:
To turn our shape into a 3D object, we need to extend our
vertx
andverty
arrays.import controlP5.*; ControlGroup box; ControlP5 cp5; Button toggleButton; float[][] vertx; float[][] verty;
In our
setup()
method, we change the display mode toP3D
and define our array initialization. Our shape...