[ Video ]
[ About ]
円をねじねじ。
Circle are rotationg.
[ 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; 	vector<ofMesh> mesh_list, frame_list; }; | 
| 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofSetWindowTitle("openframeworks"); 	ofBackground(239); 	ofSetLineWidth(2); 	ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { 	this->mesh_list.clear(); 	this->frame_list.clear(); 	for (int x = 120; x < ofGetWidth(); x += 240) { 		for (int y = 120; y < ofGetHeight(); y += 240) { 			ofMesh mesh, frame; 			frame.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); 			for (int radius = 30; radius <= 100; radius += 10) { 				for (int deg = 0; deg < 360; deg += 1) { 					auto location = glm::vec3(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), 0); 					auto param = int(ofGetFrameNum() + location.x + x + y) % 450; 					auto angle = 0.f; 					if (param > 225) { 						angle = ofMap(param, 225, 450, 0, PI * 6); 					} 					auto rotation = glm::rotate(glm::mat4(), angle, glm::vec3(1, 0, 0)); 					location = glm::vec3(x, y, 0) + glm::vec4(location, 0) * rotation; 					if (radius == 30 || radius == 100) { 						frame.addVertex(location); 					} 					mesh.addVertex(location); 				} 			} 			for (int base = 0; base < mesh.getNumVertices() - 360; base += 360) { 				for (int i = base; i < base + 360; i += 1) { 					mesh.addIndex(i); mesh.addIndex(i + 360); mesh.addIndex((i + 1) % 360 + base + 360); 					mesh.addIndex(i); mesh.addIndex((i + 1) % 360 + base); mesh.addIndex((i + 1) % 360 + base + 360); 				} 			} 			for (int i = 0; i < 360; i++) { 				frame.addIndex(i); frame.addIndex((i + 1) % 360); 				frame.addIndex(i + 360); frame.addIndex((i + 1) % 360 + 360); 			} 			this->mesh_list.push_back(mesh); 			this->frame_list.push_back(frame); 		} 	} } //-------------------------------------------------------------- void ofApp::draw() { 	ofSetColor(39); 	for(auto& mesh : this->mesh_list){ 		mesh.draw(); 	} 	ofSetColor(239); 	for (auto& frame : this->frame_list) { 		frame.drawWireframe(); 	} } //-------------------------------------------------------------- int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); } |