[ Video ]
[ About ]
アーチ状に配置したBoxを伸縮させる。
Change the height of the box on arch shape.
[ 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) {}; ofEasyCam cam; ofLight light; ofBoxPrimitive box; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofBackground(0); ofSetWindowTitle("Insta"); ofEnableDepthTest(); this->light.setPosition(0, 0, 600); this->light.setAreaLight(1024, 1024); this->light.setSpecularColor(ofFloatColor(1.0, 1.0, 1.0)); this->light.setDiffuseColor(ofFloatColor(0.8, 0.8, 0.8)); this->light.setAmbientColor(ofFloatColor(0.2, 0.2, 0.2)); this->light.enable(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); float radius = 150; int deg_span = 3; ofVec3f location; float size = ofVec3f(radius * cos(0), radius * sin(0), 0).distance(ofVec3f(radius * cos(deg_span * DEG_TO_RAD), radius * sin(deg_span * DEG_TO_RAD), 0)); float h_size; for (float z = -100; z < 100; z += size) { for (int deg = 270; deg < 270 + 180; deg += deg_span) { location = ofVec3f(radius * sin(deg * DEG_TO_RAD), z, radius * cos(deg * DEG_TO_RAD)); h_size = 50 * ofNoise(location.y * 0.005, deg * 0.025 + ofGetFrameNum() * 0.05); ofPushMatrix(); ofTranslate(location); ofRotateY(deg); ofTranslate(0, 0, h_size / 2); this->box.set(size, size, h_size); this->box.draw(); ofPopMatrix(); } } //this->light.draw(); this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |