[ Video ]
[ About ]
思いつくままにコーディングしていたら、良く分からないものが出来上がりました。これは何でしょう?
ソースコードのハイライトは、色が異なる面が重なると描写が乱れるので、ofTranslate(point * -0.001)という超小手先の対応で何とかしている所。
[ 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; 	ofIcoSpherePrimitive icoSphere; };  | 
					
| 
					 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  | 
						#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(30); 	ofBackground(239); 	ofSetWindowTitle("Insta"); 	ofEnableDepthTest(); 	this->icoSphere.setRadius(250); 	this->icoSphere.setResolution(2); } //-------------------------------------------------------------- void ofApp::update() { 	ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { 	this->cam.begin(); 	ofRotateX(ofGetFrameNum() * 0.1); 	ofRotateY(ofGetFrameNum() * 0.25); 	vector<ofMeshFace> triangles = icoSphere.getMesh().getUniqueFaces(); 	for (int i = 0; i < triangles.size(); i++) { 		ofPoint avg = (triangles[i].getVertex(0) + triangles[i].getVertex(1) + triangles[i].getVertex(2)) / 3; 		float noise_value = ofNoise(avg.y * 0.005 + ofGetFrameNum() * 0.05); 		for (float roop_noise = 1.f; roop_noise > noise_value; roop_noise -= 0.2f) { 			ofMesh mesh; 			for (int v_index = 0; v_index < 3; v_index++) { 				ofPoint point = triangles[i].getVertex(v_index) - avg; 				mesh.addVertex(point * roop_noise); 			} 			ofPushMatrix(); 			ofTranslate(avg); 			ofSetColor(239); 			mesh.drawWireframe(); 			if (roop_noise == 1.f) { 				ofTranslate(avg * -0.001); 				ofSetColor(39); 				mesh.drawFaces(); 			} 			else if (roop_noise - 0.2f < noise_value) { 				ofSetColor(239); 				mesh.drawFaces(); 			} 			ofPopMatrix(); 		} 	} 	this->cam.end(); } //======================================================================== int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); }  |