[ Video ]
[ About ]
ofTrueTypeFontからPath情報を取得、分解しました。ofPathからmeshは取得出来たのですが、メッシュの大きさが大小バラバラだったので、ResampleしてそれをofTessellatorというクラスを使って作り直すという変?な事をしています。
それっぽいMesh情報が取れた後は、さらにMeshの中にあるFaceを一つづつ取り出して、Noiseと掛け合わせています。
文字は、MonsterHunterが発売され、Hunter×Hunberが連載再開という事で、熱いキーワード「HUNTER」にしてみました。
[ 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 | #pragma once #include "ofMain.h" #include "ofFbo.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; 	ofTrueTypeFont font; 	string words; 	ofPoint words_size; 	vector<ofTTFCharacter> paths; }; | 
| 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 | #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofBackground(255); 	ofSetWindowTitle("Insta"); 	ofSetColor(0, 32, 255); 	this->font.loadFont("fonts/Kazesawa-Bold.ttf", 250, true, false, true); 	this->words = "OTHER"; 	this->words_size = ofPoint(this->font.stringWidth(this->words), this->font.stringHeight(this->words)); 	this->paths = this->font.getStringAsPoints(this->words); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { 	this->cam.begin(); 	ofRotateX(180); 	for (int p_index = 0; p_index < this->paths.size(); p_index++) { 		vector<ofPolyline> outline = this->paths[p_index].getOutline(); 		for (int o_index = 0; o_index < outline.size(); o_index++) { 			outline[o_index] = outline[o_index].getResampledBySpacing(30); 			ofMesh mesh; 			ofTessellator t; 			t.tessellateToMesh(outline, ofPolyWindingMode::OF_POLY_WINDING_ODD, mesh); 			vector<ofMeshFace> triangles = mesh.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.x * 0.005 - ofGetFrameNum() * 0.05); 				ofMesh draw_mesh; 				ofPoint adjust(-this->words_size.x / 2, this->words_size.y / 2); 				if (noise_value < 0.4){ 					adjust += ofPoint(0, 0, 500 * (noise_value - 0.4)); 				} 				draw_mesh.addVertex(triangles[i].getVertex(0) + adjust); 				draw_mesh.addVertex(triangles[i].getVertex(1) + adjust); 				draw_mesh.addVertex(triangles[i].getVertex(2) + adjust); 				draw_mesh.draw(); 			} 		} 	} 	this->cam.end(); } //======================================================================== int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); } |