[ Video ]
[ About ]
3Dで並べて見比べるNoiseによる曲線
Compare noisy curves ( 3D Edition ).
[ 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 mouseEntered(int x, int y) {}; void mouseExited(int x, int y) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofEasyCam cam; int number_of_target = 48; vector<ofPoint> noise_seeds; vector<deque<ofPoint>> logs; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); ofSetLineWidth(3); ofSetDepthTest(true); for (int i = 0; i < this->number_of_target; i++) { ofPoint noise_seed = ofPoint(ofRandom(10), ofRandom(10), ofRandom(10)); this->noise_seeds.push_back(noise_seed); deque<ofPoint> log; this->logs.push_back(log); } } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); for (int i = 0; i < this->number_of_target; i++) { ofPoint point(ofMap(ofNoise(this->noise_seeds[i].x), 0, 1, -100, 100), ofMap(ofNoise(this->noise_seeds[i].y), 0, 1, -100, 100), ofMap(ofNoise(this->noise_seeds[i].z), 0, 1, -100, 100)); this->logs[i].push_front(point); while (this->logs[i].size() > 30) { this->logs[i].pop_back(); } this->noise_seeds[i].x += ofNoise(ofRandom(10), ofGetFrameNum() * 0.005) * 0.05; this->noise_seeds[i].y += ofNoise(ofRandom(10), ofGetFrameNum() * 0.005) * 0.05; this->noise_seeds[i].z += ofNoise(ofRandom(10), ofGetFrameNum() * 0.005) * 0.05; } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); for (int i = 0; i < this->number_of_target; i++) { ofPushMatrix(); int layer = i / 16; int x = (i - layer * 16) % 4 * 200 - ofGetWidth() * 0.5 + 50; int y = (i - layer * 16) / 4 * 200 - ofGetHeight() * 0.5 + 50; int z = layer * 300 - 300; ofTranslate(x, y, z); ofNoFill(); ofBeginShape(); for (int l = 0; l < this->logs[i].size(); l++) { ofVertex(this->logs[i][l]); } ofEndShape(); ofFill(); ofDrawSphere(this->logs[i][0], 5); ofPopMatrix(); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); } |