Skip to content

Instantly share code, notes, and snippets.

@moxuse
Last active December 13, 2017 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxuse/4f908c11e2f38960874218a106390701 to your computer and use it in GitHub Desktop.
Save moxuse/4f908c11e2f38960874218a106390701 to your computer and use it in GitHub Desktop.
triangle stripe
void ofApp::triangleMesh(ofMesh && mesh, float radius) {
ofPoint capturedPoint, capturedPoint2;
for (int i = 0; i < 25; i+=2) {
mesh.addIndex(i);
mesh.addIndex(i + 1);
}
for (int i = 0; i < 25; i++) {
float rradius = radius * (ofNoise(200) * 0.008 + 1.0);
float rradius2 = radius * (ofNoise(0.2) + 1.0);
float rad = 15 * i * PI / 180;
float rad2 = 15 * (i + 0.5) * PI / 180;
ofPoint newPtr = ofPoint(sin(rad) * rradius2, -cos(rad) * rradius2);
ofPoint newPtr2 = ofPoint(sin(rad2) * (rradius + 7.5), -cos(rad2) * (rradius + 7.5));
ofPoint textPtr = ofPoint(newPtr.x * 0.5 + 400, newPtr.y * 0.5 + 400);
ofPoint textPtr2 = ofPoint(newPtr2.x * 0.5 + 400, newPtr2.y * 0.5 + 400);
if (i == 0) {
capturedPoint = newPtr;
capturedPoint2 = newPtr2;
};
if (i != 24) {
mesh.addVertex(newPtr);
mesh.addTexCoord(textPtr);
mesh.addVertex(newPtr2);
mesh.addTexCoord(textPtr2);
} else {
mesh.addVertex(capturedPoint);
mesh.addTexCoord(textPtr);
mesh.addVertex(capturedPoint2);
mesh.addTexCoord(textPtr2);
}
mesh.addColor(ofColor(255, 255, 255));
mesh.addColor(ofColor(255, 255, 255));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment