[ Video ]
[ About ]
富士山STLデータをノイズをグネグネ。
Mt.Fuji x Noise.
STL data from 地理院地図3D
https://maps.gsi.go.jp/
[ 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" #include "ofxAssimpModelLoader.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; ofLight pointLight; ofMesh 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofEnableDepthTest(); ofxAssimpModelLoader model_loader; model_loader.loadModel("fuji3.stl"); this->mesh = model_loader.getMesh(0); for (auto& vertex : this->mesh.getVertices()) { vertex -= glm::vec3(75, 0, 75); auto value = ofMap(vertex.y, 80, 0, 255, 0); this->mesh.addColor(ofColor(value)); } ofSetSmoothLighting(true); pointLight.setDiffuseColor(ofFloatColor(.85, .85, .85)); pointLight.setSpecularColor(ofFloatColor(1.f, 1.f, 1.f)); pointLight.setPosition(-200, 200, 200); pointLight.enable(); } //-------------------------------------------------------------- void ofApp::update(){ this->draw_mesh = this->mesh; for (auto& vertex : this->draw_mesh.getVertices()) { if (vertex.y > 0) { int param = 0; auto noise_value = ofNoise(vertex.x * 0.01, vertex.z * 0.01, ofGetFrameNum() * 0.035); if (noise_value > 0.5) { param = ofMap(noise_value, 0.5, 1, 0, 30); param = (param / 5) * 5; } vertex += glm::vec3(0, param, 0); } } } //-------------------------------------------------------------- void ofApp::draw(){ this->cam.begin(); this->draw_mesh.draw(); this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |