[ Video ]
[ About ]
円柱
Cylinder.
[ 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 | #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; }; | 
| 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 | #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofSetWindowTitle("openframeworks"); 	ofBackground(239); 	ofSetColor(39); 	ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { 	float radius = 300; 	int tail_length = 60; 	int height = 500; 	this->cam.begin(); 	ofRotateX(270); 	for (int z = 0; z <= height; z += 20) { 		int start_deg = ofGetFrameNum() % 360 + z; 		int sphere_deg = start_deg + tail_length; 		ofNoFill(); 		ofBeginShape(); 		for (int deg = start_deg; deg < sphere_deg; deg++) { 			float x = radius * cos(deg * DEG_TO_RAD); 			float y = radius * sin(deg * DEG_TO_RAD); 			ofVertex(x, y, z - height * 0.5); 		} 		ofEndShape(); 		ofFill(); 		ofDrawSphere(ofPoint(radius * cos(sphere_deg * DEG_TO_RAD), radius * sin(sphere_deg * DEG_TO_RAD), z - height * 0.5), 5); 	} 	this->cam.end(); } //-------------------------------------------------------------- int main() { 	ofGLWindowSettings settings; 	settings.setGLVersion(3, 2); 	settings.setSize(720, 720); 	ofCreateWindow(settings); 	ofRunApp(new ofApp()); } |