Skip to content

Instantly share code, notes, and snippets.

@moxuse

moxuse/triangle stripe

Last active Dec 13, 2017
Embed
What would you like to do?
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