[ Video ]
[ About ]
Noise(x, y, z, z + frameCount)という結果を濃淡として使用。
輪郭のふちはOpenCVで計算。
The result Noise(x, y, z, z + frameCount) is used as a gradient.
The edge of the outline is calculated by OpenCV.
[ 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 28 29 |
#pragma once #include "ofMain.h" #include "opencv2/opencv.hpp" 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) {}; ofFbo fbo; ofPixels pixels; cv::Mat pixels_mat; ofMesh fbo_mesh, draw_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 62 63 64 65 66 67 68 69 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofSetWindowTitle("openframeworks"); ofBackground(239); ofEnableDepthTest(); auto fbo_ico_sphere = ofIcoSpherePrimitive(250, 4); this->fbo_mesh = fbo_ico_sphere.getMesh(); auto draw_ico_sphere = ofIcoSpherePrimitive(245, 4); this->draw_mesh = draw_ico_sphere.getMesh(); this->fbo.allocate(ofGetWidth(), ofGetHeight()); this->fbo.readToPixels(this->pixels); this->pixels_mat = cv::Mat(this->pixels.getHeight(), this->pixels.getWidth(), CV_8UC4, this->pixels.getData()); } //-------------------------------------------------------------- void ofApp::update() { this->fbo_mesh.clearColors(); this->draw_mesh.clearColors(); for (int i = 0; i < this->fbo_mesh.getVertices().size(); i++) { auto vertex = this->fbo_mesh.getVertices()[i]; ofColor color = ofColor(ofMap(ofNoise(glm::vec4(vertex * 0.005, vertex.z * 0.03 + ofGetFrameNum() * 0.03)), 0, 1, 39, 239)); this->fbo_mesh.addColor(color); this->draw_mesh.addColor(color); } this->fbo.begin(); ofClear(0); ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); this->fbo_mesh.draw(); this->fbo.end(); this->fbo.readToPixels(this->pixels); cv::GaussianBlur(this->pixels_mat, this->pixels_mat, cv::Size(19, 19), 29, 29); } //-------------------------------------------------------------- void ofApp::draw() { ofFill(); ofSetColor(255); ofImage draw_image; draw_image.setFromPixels(this->pixels); draw_image.draw(0, 0); ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); this->draw_mesh.draw(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |