[ Video ]
[ About ]
ライティングの練習…
Practice lighting…
[ 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(255); ofSetWindowTitle("Insta"); ofEnableDepthTest(); this->light.setSpotlight(); this->light.setPosition(0, 0, 600); this->light.setSpecularColor(ofFloatColor(1.0, 1.0, 1.0)); this->light.setDiffuseColor(ofFloatColor(0.0, 0.0, 0.9)); this->light.setAmbientColor(ofFloatColor(0.0, 0.0, 0.1)); this->light.enable(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); float radius = 300; int deg_span = 10; 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 = -300; z < 300; z += size) { for (int deg = 0; deg < 360; deg += deg_span) { location = ofVec3f(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), z); h_size = 200 * ofNoise(location.x * 0.0035, location.y * 0.0035, location.z * 0.0035, ofGetFrameNum() * 0.01); ofPushMatrix(); ofTranslate(location); ofRotate(deg); ofTranslate(-h_size / 2, 0); this->box.set(h_size, size, size); this->box.draw(); ofPopMatrix(); } } //this->light.draw(); this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |