[ Video ]
[ About ]
ofIcoSphereをノイズで弄る。
それを並べて見比べる。
Play with the noise ofIcoSphere.
Compare them side by side.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#pragma once #include "ofMain.h" class ofApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed(int key) {}; void keyReleased(int key) {}; void mouseMoved(int x, int y) {}; void mouseDragged(int x, int y, int button) {}; void mousePressed(int x, int y, int button) {}; void mouseReleased(int x, int y, int button) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofEasyCam cam; vector<ofMeshFace> triangle_list; vector<glm::vec3> location_list; vector<ofMesh> mesh_list; }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(255); ofEnableDepthTest(); auto ico_sphere = ofIcoSpherePrimitive(250, 4); this->triangle_list.insert(this->triangle_list.end(), ico_sphere.getMesh().getUniqueFaces().begin(), ico_sphere.getMesh().getUniqueFaces().end()); for (auto& triangle : this->triangle_list) { glm::vec3 avg = (triangle.getVertex(0) + triangle.getVertex(1) + triangle.getVertex(2)) / 3; this->location_list.push_back(avg); } } //-------------------------------------------------------------- void ofApp::update() { this->mesh_list.clear(); for (int x = -450; x <= 450; x += 900) { for (int y = -600; y <= 600; y += 600) { ofMesh mesh; ofColor mesh_color = ofColor(255); ofColor frame_color = ofColor(0); int radius = 230; for (int i = 0; i < this->location_list.size(); i++) { glm::vec3 avg = (this->triangle_list[i].getVertex(0) + this->triangle_list[i].getVertex(1) + this->triangle_list[i].getVertex(2)) / 3; vector<glm::vec3> vertices; vertices.push_back(this->triangle_list[i].getVertex(0)); vertices.push_back(this->triangle_list[i].getVertex(1)); vertices.push_back(this->triangle_list[i].getVertex(2)); for (auto& vertex : vertices) { auto tmp_radius = ofMap(ofNoise(glm::vec4(vertex * 0.005 + glm::vec3(x, y, 0), ofGetFrameNum() * 0.005)), 0, 1, radius - 66, radius + 65); vertex = glm::normalize(vertex) * tmp_radius + glm::vec3(x, y, 0); } mesh.addVertices(vertices); mesh.addTriangle(mesh.getNumVertices() - 1, mesh.getNumVertices() - 2, mesh.getNumVertices() - 3); } this->mesh_list.push_back(mesh); } } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); for (auto& mesh : this->mesh_list) { ofSetColor(255); mesh.drawFaces(); ofSetColor(39); mesh.drawWireframe(); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |