Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing a solid sphere


Drawing a surface in the wireframe is a good way to check the structure of the triangle mesh forming the surface. In the context of video synthesis, it can be seen as a kind of special effect. But normally we are interested in drawing a 3D object as solid surfaces, which means that all its triangles are drawn as solid polygons.

To draw a solid sphere, just replace the sphere.drawWireframe() command in draw3d() with the following command:

sphere.draw();

On running the project, you will see the sphere as a white circle, as shown in the following screenshot:

This is a solid sphere without shading.

The reason for the sphere to look like a flat figure is that each triangle in the sphere is drawn as a solid white polygon without using information of its orientation for shading.

To obtain a sphere that looks more natural, let's implement the shading of its surface.

The things needed for shading the surface

To draw a shaded surface, the following things are required:

  • Light source...