[ Video ]
[ About ]
トーラスを走る線たち
Lines runs over the Torus.
[ 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 |
#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 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) {}; ofPoint make_point(float radius, float deg, float small_radius, float small_deg); ofEasyCam cam; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); ofNoFill(); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); int radius = 300; int small_radius = 50; vector<ofPoint> locations; locations.push_back(ofPoint(-380, -380)); locations.push_back(ofPoint(-380, 380)); locations.push_back(ofPoint(380, -380)); locations.push_back(ofPoint(380, 380)); for (ofPoint location : locations) { ofPushMatrix(); ofTranslate(location); for (int i = 0; i < 80; i++) { int deg_param = ofRandom(360); int small_deg_param = ofRandom(360); int deg_span = ofRandom(10) + 1; int small_deg_span = ofRandom(50) + 1; ofBeginShape(); for (int l = 0; l < 5; l++) { int deg = ((deg_param + ofGetFrameNum() + l) * deg_span) % 360; int small_deg = ((deg_param + ofGetFrameNum() + l) * small_deg_span) % 360; ofPoint point = make_point(radius, deg, small_radius, small_deg); ofVertex(point); } ofEndShape(); } ofPopMatrix(); } this->cam.end(); } //-------------------------------------------------------------- ofPoint ofApp::make_point(float radius, float deg, float small_radius, float small_deg) { float x_1 = radius * cos(deg * DEG_TO_RAD); float y_1 = radius * sin(deg * DEG_TO_RAD); float x_2 = small_radius * cos(small_deg * DEG_TO_RAD) * cos(deg * DEG_TO_RAD); float y_2 = small_radius * cos(small_deg * DEG_TO_RAD) * sin(deg * DEG_TO_RAD); float x = x_1 + x_2; float y = y_1 + y_2; float z = small_radius * sin(small_deg * DEG_TO_RAD); return ofPoint(x, y, z); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |