[ Video ]
[ About ]
色を持つ座標を線で結ぶ。線がグラデーションに。
Connect the coordinate. Coordinate has color.
[ 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; 	vector<ofMesh> mesh_list; 	float noise_seed; };  | 
					
| 
					 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 87 88 89  | 
						#include "ofApp.h"	 //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofSetWindowTitle("openFrameworks"); 	ofBackground(0); 	ofSetLineWidth(3); 	ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { 	ofSeedRandom(39); 	this->mesh_list.clear(); 	auto range = 120; 	auto span = 240; 	for (int x = -ofGetWidth() * 0.5; x <= ofGetWidth() * 0.5; x += span) { 		for (int y = -ofGetHeight() * 0.5; y <= ofGetHeight() * 0.5; y += span) { 			for (int z = -ofGetHeight() * 0.5; z <= ofGetHeight() * 0.5; z += span) { 				ofMesh mesh; 				mesh.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); 				for (int i = 0; i < 4; i++) { 					auto location = glm::vec3( 						x + ofMap(ofNoise(ofRandom(10000), this->noise_seed), 0, 1, -range * 0.5, range * 0.5), 						y + ofMap(ofNoise(ofRandom(10000), this->noise_seed), 0, 1, -range * 0.5, range * 0.5), 						z + ofMap(ofNoise(ofRandom(10000), this->noise_seed), 0, 1, -range * 0.5, range * 0.5)); 					mesh.addVertex(location); 				} 				for (int i = 0; i < mesh.getVertices().size(); i++) { 					mesh.addIndex(i); 					mesh.addIndex((i + 1) % mesh.getVertices().size()); 				} 				int hue = ofRandom(255); 				ofColor color; 				for (int i = 0; i < 4; i++) { 					color.setHsb((hue + i * 100) % 255, 200, 255); 					mesh.addColor(color); 				} 				this->mesh_list.push_back(mesh); 			} 		} 	} 	if (ofGetFrameNum() % 60 < 45) { 		this->noise_seed += ofMap(ofGetFrameNum() % 60, 0, 45, 0.03, 0); 	} } //-------------------------------------------------------------- void ofApp::draw() { 	this->cam.begin(); 	ofRotateY(ofGetFrameNum() * 0.5); 	for (auto& mesh : this->mesh_list) { 		mesh.draw(); 		for (int i = 0; i < mesh.getVertices().size(); i++) { 			ofSetColor(mesh.getColor(i)); 			ofDrawSphere(mesh.getVertex(i), 6); 		} 	} 	this->cam.end(); } //-------------------------------------------------------------- int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); }  |