[ Video ]
[ About ]
Riging particle. 
[ 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 windowResized(int w, int h) {}; 	void dragEvent(ofDragInfo dragInfo) {}; 	void gotMessage(ofMessage msg) {}; 	ofEasyCam cam; 	ofMesh mesh; 	vector<glm::vec3> location_list; 	vector<glm::vec3> direction_list; };  | 
					
| 
					 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  | 
						#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofSetWindowTitle("openFrameworks"); 	ofBackground(239); 	ofEnableDepthTest(); 	this->mesh.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); } //-------------------------------------------------------------- void ofApp::update() { 	this->mesh.clear(); 	for(int i = 0; i < 2; i++){ 		this->location_list.push_back(glm::vec3()); 		auto direction = glm::vec3(ofRandom(-1, 1), ofRandom(-1, 1), ofRandom(-1, 1)); 		direction = glm::normalize(direction) * 2; 		this->direction_list.push_back(direction); 	} 	for (int i = 0; i < this->location_list.size(); i++) { 		this->location_list[i] += this->direction_list[i]; 	} 	for (int i = this->location_list.size() - 1; i >= 0; i--) { 		auto len = glm::length(this->location_list[i]); 		if (len > 300) { 			this->location_list.erase(this->location_list.begin() + i); 			this->direction_list.erase(this->direction_list.begin() + i); 		} 		this->mesh.addVertex(this->location_list[i]); 		this->mesh.addColor(ofColor(39, ofMap(len, 0, 300, 255, 0))); 	} 	for (int i = 0; i < this->mesh.getNumVertices(); i++) { 		for (int k = i + 1; k < this->mesh.getNumVertices(); k++) { 			auto distance = glm::distance(this->mesh.getVertex(i), this->mesh.getVertex(k)); 			if (distance < 50) { 				this->mesh.addIndex(i); this->mesh.addIndex(k); 			} 		} 	} } //-------------------------------------------------------------- void ofApp::draw() { 	this->cam.begin(); 	ofRotateX(ofGetFrameNum() * 0.43); 	ofRotateY(ofGetFrameNum() * 0.65); 	this->mesh.drawVertices(); 	for (int i = 0; i < this->mesh.getNumVertices(); i++) { 		ofSetColor(this->mesh.getColor(i)); 		ofDrawSphere(this->mesh.getVertex(i), 2); 	} 	this->cam.end(); } //-------------------------------------------------------------- int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); }  |