[ Video ]
[ About ]
円を分割して、高さはパーリンノイズで変化させました。
I draw segmented circle. And height is determined by Perlin noise.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#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; }; |
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 85 86 87 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("Insta"); ofBackground(39); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { int radius_span = 50; int deg_span = 10; this->cam.begin(); for (int radius = radius_span; radius < 360; radius += radius_span) { for (int deg = 0; deg < 360; deg += deg_span) { ofPoint noise_point((radius + radius_span * 0.5) * cos((deg + deg_span * 0.5) * DEG_TO_RAD), (radius + radius_span * 0.5) * sin((deg + deg_span * 0.5) * DEG_TO_RAD)); float noise_value = ofNoise(noise_point.x * 0.005, noise_point.y * 0.005, ofGetFrameNum() * 0.005); int z = noise_value * radius; ofColor body_color(ofMap(noise_value, 0, 1, 39, 255)); ofSetColor(body_color); ofPoint p1(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), z); ofPoint p2(radius * cos((deg + deg_span) * DEG_TO_RAD), radius * sin((deg + deg_span) * DEG_TO_RAD), z); ofPoint p3((radius + radius_span) * cos((deg + deg_span) * DEG_TO_RAD), (radius + radius_span) * sin((deg + deg_span) * DEG_TO_RAD), z); ofPoint p4((radius + radius_span) * cos(deg * DEG_TO_RAD), (radius + radius_span) * sin(deg * DEG_TO_RAD), z); ofBeginShape(); ofVertex(p1); ofVertex(p2); ofVertex(p3); ofVertex(p4); ofEndShape(true); ofBeginShape(); ofVertex(p1); ofVertex(p2); ofVertex(p2 - ofPoint(0, 0, z)); ofVertex(p1 - ofPoint(0, 0, z)); ofEndShape(true); ofBeginShape(); ofVertex(p2); ofVertex(p3); ofVertex(p3 - ofPoint(0, 0, z)); ofVertex(p2 - ofPoint(0, 0, z)); ofEndShape(true); ofBeginShape(); ofVertex(p3); ofVertex(p4); ofVertex(p4 - ofPoint(0, 0, z)); ofVertex(p3 - ofPoint(0, 0, z)); ofEndShape(true); ofBeginShape(); ofVertex(p1); ofVertex(p4); ofVertex(p4 - ofPoint(0, 0, z)); ofVertex(p1 - ofPoint(0, 0, z)); ofEndShape(true); } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |