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

Deforming a sphere


Deformation, that is, changing the geometry of a surface, gives an opportunity to create new and unusual 3D shapes. We will explore two methods of deformation: shifting the sphere's vertices using analytical formulas and extruding the sphere's surface using a texture's pixels values.

To implement this, let's start with adding several sliders to control deformation in the following way:

  1. Declare new sliders in the ofApp class:

    ofxFloatSlider rad, deform, deformFreq, extrude;

    This line declares four sliders: sphere radius, amount and frequency of analytical deformation, and amount of extrusion.

  2. Add commands to set up sliders to setup() after the mixerGroup.add( show3d.setup... command:

    mixerGroup.add( rad.setup("rad", 250, 0, 500) );
    mixerGroup.add( deform.setup("deform", 0.3, 0, 1.5) );
    mixerGroup.add( deformFreq.setup("deformFreq", 3, 0, 10) );
    mixerGroup.add( extrude.setup("extrude", 1, 0, 1 ) );

Deforming by formulas

We will implement the sphere deformation by changing positions...