Drawing a wireframe sphere
Let's start working with 3D by creating a sphere surface and drawing it as a wireframe model.
Tip
A wireframe model is a type of graphical representation of a 3D object on the screen where only its edges are drawn. It appeared in the early era of 3D graphics as a simple way to draw objects in 3D. Now, it is used in 3D modeling software to control the structure of the created objects and as a special effect in films, games, and experimental graphics.
We will achieve this using the ofSpherePrimitive
class in the following way:
- Add the sphere object definition to the
ofApp
class, as follows:ofSpherePrimitive sphere;
- Initialize the sphere in
setup()
:sphere.set(250, 20);
Here, the first argument,
250
, is the radius of the sphere. The second argument,20
, is the resolution of the sphere. The resulting spherical surface will have20
meridians and 20 - 1 = 19 parallels.Tip
To obtain a smoother sphere, increase
20
to a larger value, for example, to40
. - Draw the sphere using...