#include "ofApp.h"
void ofApp::setup() {
ofSetVerticalSync(true);
int rings = 32, resolution = 32;
float length = 256, maxRadius = 128;
for(int i = 0; i < rings; i++) {
float radius = ofNoise(i / 4.) * maxRadius;
ofVec3f offset(0, 0, ofMap(i, 0, rings, -length, length) / 2);
for(int j = 0; j < resolution; j++) {
float theta = ofMap(j, 0, resolution, 0, 360);
ofVec2f cur(radius, 0);
cur.rotate(theta);
mesh.addVertex(offset + cur);
mesh.addColor(ofColor((i * j) % 2 == 0 ? 255 : 0));
}
}
for(int i = 0; i < rings - 1; i++) {
for(int j = 0; j < resolution; j++) {
int sw = i * resolution + j, se = sw + 1;
if(j + 1 == resolution) {
se -= resolution;
}
int nw = sw + resolution, ne = se + resolution;
mesh.addTriangle(sw, se, nw);
mesh.addTriangle(nw, se, ne);
}
}
mesh.setMode(OF_PRIMITIVE_TRIANGLES);
}
void ofApp::update() {
}
void ofApp::draw() {
ofBackground(0);
cam.begin();
glEnable(GL_DEPTH_TEST);
ofSetColor(255);
ofRotateY(90);
mesh.draw();
cam.end();
}