Rotating a sphere
The first task of our current mission is to create the mesh of a sphere and make it rotate on the screen. We will create a mesh resembling the latitude and longitude rings found on a globe. To simplify the mathematics required to create these rings, we will use polar coordinates and convert them to Cartesian XYZ coordinates when creating our sphere. Processing can make use of your graphics card's memory for storing the model data, which improves the speed of drawing the object on the screen a lot if the object itself is static. Since our sphere doesn't change while our sketch is running, we will use a PShape
object to store the model data.
Engage Thrusters
Let's start with the creation of our sphere's mesh:
Open a new sketch and add the
setup()
anddraw()
methods.void setup() { } void draw() { }
In the
setup()
method, we define our sketch window size and set the rendering mode toP3D
. We also create aPShape
object namedsphere
to store the mesh data.PShape sphere;void setup...