-
Book Overview & Buying
-
Table Of Contents
Mastering openFrameworks: Creative Coding Demystified
By :
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.
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;
The setup() function adds vertices and triangles to the mesh and enables lighting:
void testApp::setup(){
//Set up vertices and colors
for (int y=0; y<H; y++) {
for (int x=0; x<W; x++) {
mesh.addVertex...
Change the font size
Change margin width
Change background colour