views:

27

answers:

1

The Processing project website has an example of implementing a 3D textured sphere with rotational capabilities. I'm trying to understand the code, but I'm having trouble comprehending many of the code blocks since I don't have a background in graphics.

Any higher-level explanation of what each block is trying to accomplish, perhaps referencing the relevant algorithm, would allow me to read up on the concepts and better understand the implementation.

+1  A: 

After just a few minutes looking at the code, I'd say the draw() function is called by the Processing runtime system each time the image should be redrawn. This just paints a black background, then renders the globe with the renderGlobe() function.

The renderGlobe() function sets up the environment for drawing the globe, calculating position, turing on lights, setting the texture to IMAGE, etc. Then it calls texturedSphere to draw the globe. After that, it cleans up and adjusts the position variables for the next time through.

The initializeSphere() function calculates the vertex locations for the sphere. This is simple trigonometry.

The texturedSphere() function draws the sphere. First it draws the southern cap, which is really a cone, a very flat cone. Next it draws rings for each section of the sphere, and then tops it off with another cone for the northern cap.

Although I haven't gone through the Processing learning materials, the headings indicate that if you start from the beginning, and try everything in order, you'll easily understand this code.

Mr. Berna