[ Video ]
[ About ]
Z軸に等間隔で、ある半径の円周上に5度間隔で取得した座標を取得。それぞれの点でSphereを描写・下層の点と線を結んでいます。
5度間隔の開始位置となる角度はNoise関数とフレーム数でズラしていっているので、前後の円周でズレが大きくなったり、小さくなったりしています。
[ 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) {}; // Make Member 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(39); ofSetWindowTitle("Insta"); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int radius = 300; int z_span = 150; int deg_span = 5; vector<vector<ofPoint>> points_list; this->cam.begin(); ofRotateX(-90); for (int z = -300; z <= 300; z += z_span) { vector<ofPoint> points; int deg_start = ofNoise(z * 0.1, ofGetFrameNum() * 0.005) * 720; for (int deg = deg_start; deg < deg_start + 360; deg += deg_span) { points.push_back(ofPoint(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), z)); } points_list.push_back(points); } for (int list_index = 1; list_index < points_list.size(); list_index++) { for (int i = 0; i < points_list[list_index].size(); i++) { ofSetColor(239); ofDrawSphere(points_list[list_index][i], 2); if (list_index == 1) { ofDrawSphere(points_list[0][i], 2); } ofSetColor(239, ofMap(points_list[list_index][i].distance(points_list[list_index - 1][i]), 0, radius, 0, 255)); ofDrawLine(points_list[list_index][i], points_list[list_index - 1][i]); } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |