O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The oscillating plane example

This example demonstrates how to create a flat plane from triangles and then oscillate its vertices to obtain a dynamic surface. Also, the color of vertices will depend on the oscillation amplitude.

Note

This is example 07-3D/06-OscillatingPlane.

The example is based on the emptyExample project in openFrameworks. Begin with adding the declaration and definition of the setNormals() function, as described in the Computing normals using the setNormals() function section. Then in the testApp.h file, in the testApp class declaration, add definitions of mesh and light:

ofMesh mesh;          //Mesh
ofLight light;        //Light

In the beginning of the testApp.cpp file, add constants with vertex grid size:

int W = 100; //Grid size int H = 100; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required