Last active
December 13, 2017 05:38
-
-
Save moxuse/4f908c11e2f38960874218a106390701 to your computer and use it in GitHub Desktop.
triangle stripe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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