Let there be light
The second task of our current mission is to turn the mesh we created in the first task into a solid sphere with a smooth surface. We will use different light sources to illuminate our sphere and define so-called normal vectors for each vertex to make our sphere's surface look smooth without the need for a very dense mesh.
Engage Thrusters
Let's turn on some lights:
Open the sketch we created for the last task.
Our mesh is currently hollow, and we can see the front-facing lines as well as the back of the sphere. To change this, we can define a fill color for the faces.
PShape makeSphere( int r, int step) { PShape s = createShape(); s.beginShape(QUAD_STRIP); s.fill(200); s.stroke(255); s.strokeWeight(2); for( int i = 0; i < 180; i+=step ) { float sini = sin( radians( i )); float cosi = cos( radians( i )); float sinip = sin( radians( i + step )); float cosip = cos( radians( i + step )); for( int j = 0; j <= 360; j+=step ) { float...