Drawing 3D Solids

POLYSTART
POLYEND
POLYVIEW
SETLIGHT
LIGHT

3D Solids in FMSLogo uses all the standard 3D commands and a few additional commands to help FMSLogo understand what you're drawing. In order to do hidden line removal or hidden surface removal, you must define surfaces, not just vectors. Surfaces are simply filled polygons. You just need to tell FMSLogo when you're starting a surface and when you're done. If you used only vectors to draw a box, FMSLogo would not know if it's a 6-sided closed box (solid cube) or a 4-sided box with an open top and bottom. Vectors alone are ambiguous with respect to surfaces.

Logo programmers are used to dealing with filled polygons, you do it all the time so it should not be a strange new concept. But FMSLogo in 3D mode fills that polygon with respect to the color you should see based on your eye view, light source, obstructions, and the color of the surface.

Here are the new commands:

CommandDescription
POLYSTARTStart a new polygon (a surface of PENCOLOR).
POLYENDEnd the definition of the polygon.
POLYVIEWShade and view all polygons that have been defined.
SETTURTLE -3Use this turtle to position light source.
SETLIGHTUse to set how objects should be illuminated.

If you drew a box in 3D (6 Polygons) that all were drawn the same color and you FILLed each of them, all you'd see is a flat octagon-looking thing. This is not so with the new commands. The PENCOLOR in effect when drawing 3D a surface becomes the color of that surface. The color is also affected by the angle of the surface between your eye (turtle -1) and the light source (turtle -3).

The 3D lighting model in FMSLogo uses some modern techniques, but is primarily designed for performance. It does not draw shadows, reflections, etc. You may see pixel errors sometimes. This is an expected artifact of the algorithm I chose.


SourceForge.net Logo