[ Video ]
[ About ]
2020年3月26日の落書きを別の方法で実装。
Implemented the March 26, 2020 doodle in a different way.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#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; ofMesh mesh; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(255); ofEnableDepthTest(); auto ico_sphere = ofIcoSpherePrimitive(280, 6); this->mesh = ico_sphere.getMesh(); for (int index = 0; index < this->mesh.getNumVertices(); index++) { this->mesh.addColor(ofColor(0)); } } //-------------------------------------------------------------- void ofApp::update() { auto noise_min = 0.45; auto noise_max = 0.8; for (int index = 0; index < this->mesh.getNumVertices(); index++) { auto noise_value = ofNoise(this->mesh.getVertex(index).x * 0.0035, this->mesh.getVertex(index).y * 0.0035, this->mesh.getVertex(index).z * 0.02 + ofGetFrameNum() * 0.018); auto color_value = 255; if (noise_value > noise_min) { if (noise_value < noise_max) { color_value = ofMap(noise_value, noise_min, noise_max, 255, 0); } else { color_value = 0; } } this->mesh.setColor(index, ofColor(color_value)); } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); this->mesh.draw(); this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |