Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12c6ac1cad | ||
|
|
fc3f1be555 | ||
|
|
8c167b27a0 |
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Emitter.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
#pragma once
|
||||
#include "Emitter.hpp"
|
||||
|
||||
|
||||
Emitter::Emitter()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
Emitter::~Emitter()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
|
||||
void Emitter::setEmitterPosition(ofVec2f _position){
|
||||
|
||||
position = _position;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Emitter.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include "ofMain.h"
|
||||
|
||||
|
||||
class Emitter {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Emitter();
|
||||
~Emitter();
|
||||
|
||||
|
||||
void setEmitterPosition(ofVec2f _position);
|
||||
ofVec2f getEmitterPosition();
|
||||
|
||||
int getEmitterX();
|
||||
int getEmitterY();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool emitting;
|
||||
void emitParticles(ofVec2f _positionOfEmission, bool _emitting);
|
||||
|
||||
ofVec2f direction;
|
||||
ofVec2f position;
|
||||
|
||||
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
ofxGui
|
||||
ofxOsc
|
||||
ofxVectorGraphics
|
||||
ofxXmlSettings
|
||||
|
||||
@@ -1,42 +1,55 @@
|
||||
#include "attractor.h"
|
||||
//
|
||||
// attractor.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
Attractor::Attractor()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
#include "attractor.hpp"
|
||||
|
||||
|
||||
|
||||
Attractor::Attractor(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
Attractor::~Attractor()
|
||||
{
|
||||
// ------------------------------------
|
||||
|
||||
Attractor::~Attractor(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// ------------------------------------
|
||||
|
||||
|
||||
|
||||
float Attractor::getY() {
|
||||
return y;
|
||||
float Attractor::getX(){
|
||||
|
||||
return x;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
float Attractor::getX() {
|
||||
return x;
|
||||
float Attractor::getY(){
|
||||
|
||||
return y;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
void Attractor::setX(float xNew) {
|
||||
x = xNew;
|
||||
void Attractor::setX(float _x){
|
||||
|
||||
x = _x;
|
||||
|
||||
}
|
||||
|
||||
void Attractor::setY(float yNew) {
|
||||
y = yNew;
|
||||
}
|
||||
// ------------------------------------
|
||||
|
||||
void Attractor::setup(float xSetup, float ySetup) {
|
||||
x = xSetup;
|
||||
y = ySetup;
|
||||
void Attractor::setY(float _y){
|
||||
|
||||
y = _y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// attractor.h
|
||||
// particleSystem
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
class Attractor {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Attractor();
|
||||
~Attractor();
|
||||
|
||||
|
||||
float getX();
|
||||
float getY();
|
||||
|
||||
void setX(float x);
|
||||
void setY(float y);
|
||||
|
||||
void setup(float x, float y);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//ofVec2f direction
|
||||
float x;
|
||||
float y;
|
||||
|
||||
float force;
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// attractor.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
|
||||
class Attractor {
|
||||
|
||||
public:
|
||||
Attractor();
|
||||
~Attractor();
|
||||
|
||||
float getX();
|
||||
float getY();
|
||||
|
||||
void setX(float x);
|
||||
void setY(float y);
|
||||
|
||||
void updateCoordinates(float x, float y);
|
||||
|
||||
private:
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// avatar.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
|
||||
#include "avatar.hpp"
|
||||
|
||||
|
||||
|
||||
Avatar::Avatar(int playerType){
|
||||
|
||||
setup(playerType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
|
||||
Avatar::~Avatar(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
|
||||
void Avatar::setup(int playerType){
|
||||
|
||||
//Load the right icon from data in ofImage, by using the transmitted info about the playerType
|
||||
|
||||
// --> icon = ....
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
|
||||
void Avatar::update(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
void Avatar::draw(){
|
||||
|
||||
icon.draw(position);
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
ofVec2f Avatar::getPosition(){
|
||||
|
||||
return position;
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
void Avatar::setPosition(int _x, int _y){
|
||||
|
||||
position.x = _x;
|
||||
position.y = _y;
|
||||
|
||||
}
|
||||
|
||||
void Avatar::setPosition(ofVec2f _position){
|
||||
|
||||
position = _position;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
void Avatar::clipToAvatar(Avatar _avatar){
|
||||
|
||||
//Read coordinates to clip to:
|
||||
ofVec2f tempCoords = _avatar.getPosition();
|
||||
|
||||
if( tempCoords.y == 0 ){
|
||||
|
||||
position.x = tempCoords.x + 20 ;
|
||||
position.y = tempCoords.y + 20 ;
|
||||
|
||||
}else{
|
||||
|
||||
position.x = tempCoords.x + 20 ;
|
||||
position.y = tempCoords.y - 20 ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// avatar.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include "ofMain.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class Avatar {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Avatar(int playerType);
|
||||
~Avatar();
|
||||
|
||||
void setup(int playerType);
|
||||
// void update();
|
||||
void draw();
|
||||
|
||||
void setPlayerType();
|
||||
int getPlayerType();
|
||||
|
||||
ofVec2f getPosition();
|
||||
void setPosition(int x, int y);
|
||||
void setPosition(ofVec2f position);
|
||||
|
||||
|
||||
void clipToAvatar(Avatar avatar); //A particular avatar can clip its position, depending on the position of another avatar, compared to a beehive-structure)
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
ofImage icon;
|
||||
int playerType;
|
||||
ofVec2f position;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 111 KiB |
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// greatWhole.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
|
||||
#include "greatWhole.hpp"
|
||||
//#include "main.h"
|
||||
|
||||
|
||||
|
||||
|
||||
GreatWhole::GreatWhole()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
GreatWhole::~GreatWhole()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
|
||||
void GreatWhole::setup(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
|
||||
void GreatWhole::update(vector<Avatar*> avatars){
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
|
||||
void GreatWhole::draw(){
|
||||
|
||||
/*
|
||||
|
||||
draw the whole avatar vector
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
|
||||
void GreatWhole::addAvatar(Avatar avatar){
|
||||
|
||||
|
||||
avatars.push_back(avatar);
|
||||
|
||||
/*
|
||||
|
||||
Set coordinates in abhängigkeit vom letzten also bei avatars at (max-1)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// greatWhole.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 17.04.19.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ofMain.h"
|
||||
#include "avatar.hpp"
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
/* Das Große Ganze beinhaltet eine unbestimmte Anzahl an bereits eingecheckten Personen, deren Infos in Avatare gespeichert werden.
|
||||
Es bedarf eine setup(), update() und draw()-Methode. Dabei soll Platz für den vector<Avatar> geschaffen werden. In update wird eine
|
||||
gewisse Bewegung der Avatar-"Bubbles" definiert. Draw zeichnet die Avatare auf die Stelen, also die entsprechenden Koordinaten. */
|
||||
|
||||
|
||||
class GreatWhole {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
GreatWhole();
|
||||
~GreatWhole();
|
||||
|
||||
void setup();
|
||||
void update(vector<Avatar*> avatars);
|
||||
void draw();
|
||||
|
||||
void addAvatar(Avatar avatar);
|
||||
Avatar getAvatarAt(int i);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
vector<Avatar*> avatars;
|
||||
|
||||
};
|
||||
@@ -1,9 +1,15 @@
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "ofApp.h"
|
||||
|
||||
//========================================================================
|
||||
int main() {
|
||||
ofSetupOpenGL(2000, 2000, OF_WINDOW);
|
||||
ofRunApp(new ofApp());
|
||||
}
|
||||
int main( ){
|
||||
|
||||
ofSetupOpenGL(1000,1000, OF_WINDOW); // <-------- setup the GL context
|
||||
|
||||
// this kicks off the running of my app
|
||||
// can be OF_WINDOW or OF_FULLSCREEN
|
||||
// pass in width and height too:
|
||||
ofRunApp( new ofApp());
|
||||
|
||||
}
|
||||
|
||||
@@ -1,261 +1,146 @@
|
||||
#pragma once
|
||||
#include "ofApp.h"
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::setup() {
|
||||
ofSetVerticalSync(true);
|
||||
|
||||
//Initialize 8 empty attractrs
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
attractors.push_back(new Attractor);
|
||||
}
|
||||
|
||||
//OSC reciever port setup
|
||||
receiver.setup(PORT);
|
||||
|
||||
varSystem = true;
|
||||
trails = true;
|
||||
history = 0.95;
|
||||
num = 1000;
|
||||
sys.assign(num, Particle());
|
||||
|
||||
currentMode = PARTICLE_MODE_DEFAULT;
|
||||
currentModeDisp = "PARTICLE_MODE_DEFAULT";
|
||||
|
||||
//Black background
|
||||
ofSetBackgroundColor(0, 0, 0);
|
||||
ofSetFrameRate(60);
|
||||
birthCount = 0;
|
||||
int w = ofGetWidth();
|
||||
int h = ofGetHeight();
|
||||
fbo.allocate(w, h, GL_RGB);
|
||||
//attractors.at(0)->setup(600, 600);
|
||||
|
||||
attractors.at(1)->setup(200, 200);
|
||||
attractors.at(2)->setup(400, 400);
|
||||
attractors.at(3)->setup(500, 500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::update() {
|
||||
// *** OSC RECEIVER ***
|
||||
while (receiver.hasWaitingMessages()) {
|
||||
|
||||
ofxOscMessage contourCentroids;
|
||||
receiver.getNextMessage(&contourCentroids);
|
||||
oscMsg = ofToString(contourCentroids);
|
||||
|
||||
//Get active ammount of attractors (nBlobs) and their x & y coordinates
|
||||
//Exp. OSC Message: " /centroidsOfBlob ammount xValue, yValue"
|
||||
if (contourCentroids.getAddress() == "/centroidsOfBlob") {
|
||||
nBlobs = contourCentroids.getArgAsInt(0);
|
||||
for (int i = 1; i <= nBlobs; i++) {
|
||||
xOfCentroid = contourCentroids.getArgAsFloat(i * 2 - 1) * ofGetWindowWidth();
|
||||
yOfCentroid = contourCentroids.getArgAsFloat(i * 2) * ofGetWindowHeight();
|
||||
|
||||
attractors.at(i - 1)->setup(xOfCentroid, yOfCentroid);
|
||||
}
|
||||
}
|
||||
//Delete all Attractors on command
|
||||
if (contourCentroids.getAddress() == "/checkin") {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
attractors.at(i)->setup(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *** PARTICLE EMITTER ***
|
||||
|
||||
//Capture time based on FrameTime
|
||||
double deltaT = ofGetLastFrameTime();
|
||||
birthCount += deltaT;
|
||||
|
||||
if (varSystem == true) {
|
||||
//Birth control for new particles
|
||||
if (birthCount > 0.001) {
|
||||
for (int i = 0;i < 4;i++) {
|
||||
system.push_back(new Particle);
|
||||
system.back()->setup(currentMode);
|
||||
}
|
||||
birthCount = 0;
|
||||
}
|
||||
|
||||
|
||||
for (int p = 0; p < system.size();)
|
||||
{
|
||||
//Upate particle system /w all active attractors
|
||||
system.at(p)->update(deltaT, &attractors, system);
|
||||
|
||||
//Delete particles, that reached max Age
|
||||
if (system.at(p)->getAgeNorm() > 4) {
|
||||
delete system.at(p);
|
||||
system.erase(system.begin() + p);
|
||||
}
|
||||
else {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ofSeedRandom(39);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::reset() {
|
||||
|
||||
for (int p = 0; p < system.size();)
|
||||
{
|
||||
system.erase(system.begin() + p);
|
||||
}
|
||||
}
|
||||
// *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION ****
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::draw() {
|
||||
if (varSystem == false) {
|
||||
vector<ofVec2f> system;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
ofVec2f particle(ofMap(ofNoise(ofRandom(100), ofGetFrameNum() * 0.0005), 0, 1, 0, ofGetWidth()), ofMap(ofNoise(ofRandom(100), ofGetFrameNum() * 0.0005), 0, 1, 0, ofGetHeight()));
|
||||
system.push_back(particle);
|
||||
}
|
||||
void ofApp::setup(){
|
||||
|
||||
|
||||
for (int i = 0; i < particleSystems.size(); i++){
|
||||
|
||||
for (int out = 0; out < system.size(); out++) {
|
||||
for (int in = out + 1; in < system.size(); in++) {
|
||||
if (system[out].distance(system[in]) < 60) {
|
||||
ofDrawLine(system[out], system[in]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < system.size(); i++) {
|
||||
|
||||
ofDrawCircle(system[i], ofRandom(0.5, 3));
|
||||
}
|
||||
}
|
||||
|
||||
if (trails == true) {
|
||||
fbo.begin();
|
||||
ofEnableAlphaBlending(); //Enable transparency
|
||||
|
||||
float alpha = (1 - history) * 255;
|
||||
ofSetColor(0, 0, 0, alpha);
|
||||
ofFill();
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
ofDisableAlphaBlending(); //Disable transparency
|
||||
//Draw particle system
|
||||
for (int p = 0; p < system.size(); p++) {
|
||||
system.at(p)->draw();
|
||||
}
|
||||
fbo.end();
|
||||
}
|
||||
else {
|
||||
//Draw particle system
|
||||
for (int p = 0; p < system.size(); p++) {
|
||||
system.at(p)->draw();
|
||||
}
|
||||
}
|
||||
//Capture time based on FrameTime
|
||||
double deltaT = ofGetLastFrameTime();
|
||||
time += deltaT;
|
||||
|
||||
// Delete inactive attractors after 4 seconds based on Frametime
|
||||
if (time > 2) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
//attractors.at(i)->setup(0, 0);
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
fbo.draw(0, 0);
|
||||
// *** DEBUG INFO ***
|
||||
ofSetColor(230);
|
||||
//All 8 Attractors with x | y coordinates
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
string x = ofToString(attractors.at(i)->getX());
|
||||
string y = ofToString(attractors.at(i)->getY());
|
||||
|
||||
ofDrawBitmapString("x: " + x + " y: " + y, 100, 100 + i * 20);
|
||||
}
|
||||
//Recieved OSC messages
|
||||
ofDrawBitmapString("OSC: " + ofToString(oscMsg),100, 275);
|
||||
//Elapsed time since last clear of attractors
|
||||
ofDrawBitmapString("Time: " + ofToString(time),100, 300);
|
||||
//Current FPS
|
||||
ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 100, 325);
|
||||
//Current Mode
|
||||
ofDrawBitmapString("Current Effect: " + currentModeDisp, 100, 350);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyPressed(int key) {
|
||||
//Key press 1 to trigger default particle Mode
|
||||
if (key == '1') {
|
||||
currentMode = PARTICLE_MODE_DEFAULT;
|
||||
currentModeDisp = "PARTICLE_MODE_DEFAULT";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '2') {
|
||||
currentMode = PARTICLE_MODE_RADIAL;
|
||||
currentModeDisp = "PARTICLE_MODE_RADIAL";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger rain particle Mode
|
||||
if (key == '3') {
|
||||
currentMode = PARTICLE_MODE_RAIN;
|
||||
currentModeDisp = "PARTICLE_MODE_RAIN";
|
||||
varSystem = false;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '4') {
|
||||
currentMode = PARTICLE_MODE_ATTRACTOR;
|
||||
currentModeDisp = "PARTICLE_MODE_ATTRACTOR";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '5') {
|
||||
currentMode = PARTICLE_MODE_DETRACTOR;
|
||||
currentModeDisp = "PARTICLE_MODE_DETRACTOR";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '6') {
|
||||
currentMode = PARTICLE_MODE_POLY;
|
||||
currentModeDisp = "PARTICLE_MODE_POLY";
|
||||
varSystem = false;
|
||||
reset();
|
||||
}
|
||||
if (key == '7') {
|
||||
trails = true;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyReleased(int key) {
|
||||
}
|
||||
|
||||
|
||||
// *** OSC Setup *** OSC Setup *** OSC Setup ***
|
||||
|
||||
receiver.setup(PORT);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseMoved(int x, int y) {
|
||||
attractors.at(0)->setup(ofGetMouseX(), ofGetMouseY());
|
||||
void ofApp::update(){
|
||||
|
||||
|
||||
// *** OSC RECEIVER *** OSC RECEIVER *** OSC RECEIVER ***
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Here the program will read and convert the information from the tracking, probably count & coordinates of people entering the ground.
|
||||
We have to define, how this information will affect the particleSystems!
|
||||
|
||||
Check for every particleSystem, if the information is relevant for its "update".
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// *** RFID Input *** RFID Input *** RFID Input ***
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
Here we have to define, how the particleSystems react to RFID input.
|
||||
Read ID of a visitor and let the particlesystems react to it.
|
||||
|
||||
!!! Here in ofApp.cpp there will only be the transfer of incoming information about IDs, playertypes, etc. into the update-methods of the particleSystems. !!!
|
||||
|
||||
For example:
|
||||
|
||||
- Tell all particleSystems about a new checkedIn-Visitor
|
||||
- Set the playerType of one particular particleSystem to the checked in.
|
||||
|
||||
*/
|
||||
|
||||
for (int p = 0; p < particleSystems.size();)
|
||||
{
|
||||
// Update particle systems
|
||||
|
||||
// particleSystems.at(p)->update("xxx , xxx , xxx , .... ");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mousePressed(int x, int y, int button) {
|
||||
void ofApp::draw(){
|
||||
|
||||
|
||||
//draw all ParticleSystems that are in the particleSystems vector
|
||||
|
||||
for(int p = 0; p < particleSystems.size(); p++)
|
||||
{
|
||||
particleSystems.at(p)->draw();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseReleased(int x, int y, int button) {
|
||||
void ofApp::keyPressed(int key){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyReleased(int key){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseMoved(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseDragged(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mousePressed(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseReleased(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseEntered(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseExited(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::windowResized(int w, int h){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::gotMessage(ofMessage msg){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::dragEvent(ofDragInfo dragInfo){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,60 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "particle.h"
|
||||
#include "ofxOsc.h"
|
||||
#include "ofxGui.h"
|
||||
#include "particleSystem.hpp"
|
||||
#include "greatWhole.hpp"
|
||||
#include "avatar.hpp"
|
||||
//#include "ofxOsc.h"
|
||||
|
||||
//OSC Reciever PORT & HOST IP
|
||||
|
||||
int WINDOWSIZE_WIDTH = 1000;
|
||||
int WINDOWSIZE_HEIGHT = 1000;
|
||||
|
||||
int PARTICLE_COUNT;
|
||||
//+1 for every new Particle, -1 for every Particle that gets older than the defined maxLife
|
||||
|
||||
// *** SETUP OSC INFORMATION *** SETUP OSC INFORMATION ***
|
||||
#define PORT 12345
|
||||
#define HOST "172.20.10.2"
|
||||
#define HOST "xxx.xxx.xxx.xxx"
|
||||
|
||||
class ofApp : public ofBaseApp {
|
||||
|
||||
|
||||
public:
|
||||
void setup();
|
||||
void update();
|
||||
void draw();
|
||||
void reset();
|
||||
|
||||
void keyPressed(int key);
|
||||
void keyReleased(int key);
|
||||
void mouseMoved(int x, int y);
|
||||
void mousePressed(int x, int y, int button);
|
||||
void mouseReleased(int x, int y, int button);
|
||||
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);
|
||||
|
||||
|
||||
|
||||
ofxXmlSettings default;
|
||||
ofxXmlSettings attractor;
|
||||
ofxXmlSettings rain;
|
||||
ofxXmlSettings brunig;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// OSC Receiver
|
||||
|
||||
particleMode currentMode;
|
||||
string currentModeDisp;
|
||||
|
||||
string oscMsg;
|
||||
ofxOscReceiver receiver;
|
||||
float timeSent, timeReceived;
|
||||
|
||||
int nBlobs;
|
||||
int blobCount;
|
||||
int num;
|
||||
float history;
|
||||
ofFbo fbo;
|
||||
|
||||
float xOfCentroid;
|
||||
float yOfCentroid;
|
||||
|
||||
vector<Particle*> system;
|
||||
vector<Particle>sys;
|
||||
vector<Attractor*> attractors;
|
||||
|
||||
float birthCount;
|
||||
double time;
|
||||
|
||||
bool varSystem;
|
||||
bool trails;
|
||||
|
||||
// *** OSC *** OSC *** OSC ***
|
||||
|
||||
string oscMsg;
|
||||
// ofxOscReceiver receiver;
|
||||
float timeSent, timeReceived;
|
||||
|
||||
|
||||
//Information about what is going on in the scene
|
||||
|
||||
int nBlobs; //count of the tracked visitors
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vector<ParticleSystem*> particleSystems;
|
||||
|
||||
GreatWhole dasGrosseGanze;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,211 +1,122 @@
|
||||
|
||||
// particle.cpp
|
||||
// particleSystem
|
||||
//
|
||||
|
||||
#include "particle.h"
|
||||
// particle.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
#pragma once
|
||||
#include "particle.hpp"
|
||||
#include "ofApp.h"
|
||||
|
||||
|
||||
Particle::Particle()
|
||||
{
|
||||
uniqueVal = ofRandom(-10000, 10000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
void Particle::setup(particleMode newMode) {
|
||||
mode = newMode;
|
||||
age = 0.0;
|
||||
//maxLife = 30.0;
|
||||
frc = ofVec2f(0, 0);
|
||||
//size = ofRandom(4.0, 0.01);
|
||||
size = .5;
|
||||
maxLife = 0.99;
|
||||
mass = ofRandom(100, 250);
|
||||
if (mode == PARTICLE_MODE_DEFAULT) {
|
||||
effect.loadFile("xml/default.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
setVel(velMin, velMax);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RADIAL) {
|
||||
effect.loadFile("xml/radial.xml");
|
||||
int velMin = effect.getValue("radial:velMin", 0);
|
||||
int velMax = effect.getValue("radial:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
pos.x = ofGetWidth()/2;
|
||||
pos.y = ofGetHeight()/2;
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RAIN) {
|
||||
effect.loadFile("xml/rain.xml");
|
||||
vel.x = ofRandom(-40, 40);
|
||||
vel.y = ofRandom(-40, 40);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
drag = ofRandom(0.97, 0.99);
|
||||
vel.y = fabs(vel.y) * 6.0;
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_ATTRACTOR) {
|
||||
effect.loadFile("xml/rain.xml");
|
||||
vel.x = ofRandom(-40, 40);
|
||||
vel.y = ofRandom(-40, 40);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_DETRACTOR) {
|
||||
effect.loadFile("xml/rain.xml");
|
||||
vel.x = ofRandom(-40, 40);
|
||||
vel.y = ofRandom(-40, 40);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else {
|
||||
|
||||
drag = ofRandom(0.95, 0.998);
|
||||
}
|
||||
|
||||
tex.load("img/br.png");
|
||||
Particle::~Particle()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// -----------------------------------
|
||||
|
||||
void Particle::update(float deltaT, vector<Attractor*>* attractors,vector<Particle*> system) {
|
||||
if (mode == PARTICLE_MODE_DEFAULT) {
|
||||
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RAIN) {
|
||||
float wind = ofSignedNoise(pos.x * 0.003, pos.y * 0.0006, ofGetElapsedTimef() * 0.6);
|
||||
|
||||
frc.x = wind * 0.25 + ofSignedNoise(uniqueVal, pos.y * 0.08) * 0.6;
|
||||
frc.y = ofSignedNoise(uniqueVal, pos.x * 0.06, ofGetElapsedTimef()*0.2) * 0.09 + 0.18;
|
||||
|
||||
vel *= drag;
|
||||
vel += frc * 0.2;
|
||||
|
||||
if (pos.y + vel.y > ofGetHeight()) {
|
||||
pos.y -= ofGetHeight();
|
||||
}
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_ATTRACTOR) {
|
||||
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - pos.x, attractors->at(i)->getY() - pos.y);
|
||||
|
||||
if (force.length() < 250) {
|
||||
force = 40 * force.getNormalized();
|
||||
size = size + ofRandom(.03, 0.01);
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_DETRACTOR) {
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
//force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - pos.x, attractors->at(i)->getY() - pos.y);
|
||||
|
||||
if (force.length() < 600) {
|
||||
force.normalize();
|
||||
size = size + ofRandom(.01, 0.01);
|
||||
|
||||
vel += -force*2000;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update particle pos
|
||||
age += deltaT* .5;
|
||||
pos += (vel * deltaT);
|
||||
|
||||
// *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION
|
||||
|
||||
//if (position.x <= 0 || position.x >= ofGetWidth()) {
|
||||
//vel.x = -vel.x;
|
||||
//position += (vel * deltaT);
|
||||
//}
|
||||
//else if (position.y <= 0 || position.y >= ofGetHeight()) {
|
||||
//vel.y = -vel.y;
|
||||
//position += (vel * deltaT);
|
||||
//}
|
||||
//else {
|
||||
//position += (vel * deltaT);
|
||||
//}
|
||||
void Particle::setup(ofVec2f _position){
|
||||
|
||||
this->position = _position;
|
||||
|
||||
velocity.set(0,0);
|
||||
age = 0.0;
|
||||
maxLife = 12.0;
|
||||
|
||||
color.set(250,250,250);
|
||||
size = 2.0;
|
||||
mass = 100;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
void Particle::draw() {
|
||||
// -----------------------------------
|
||||
|
||||
color.set(getAgeNorm() * 241,241/ getAgeNorm() ,219);
|
||||
|
||||
ofSetColor(color, (1 - getAgeNorm()) * 255);
|
||||
if (mode == PARTICLE_MODE_BRUNIG) {
|
||||
tex.setColor(color);
|
||||
tex.draw(pos.x, pos.y, size);
|
||||
}
|
||||
else {
|
||||
ofDrawCircle(pos.x, pos.y, size);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
void Particle::setMode(particleMode newMode) {
|
||||
mode = newMode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
float Particle::getAgeNorm() {
|
||||
return age / maxLife;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
void Particle::setVel(float min, float max) {
|
||||
vel.x = ofRandom(min,max);
|
||||
vel.y = ofRandom(min,max);
|
||||
}
|
||||
|
||||
float Particle::getMaxLife() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
float Particle::getY() {
|
||||
return pos.y;
|
||||
void Particle::update(float deltaT, Attractor attractor){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float Particle::getX() {
|
||||
return pos.x;
|
||||
// -----------------------------------
|
||||
|
||||
void Particle::draw(){
|
||||
|
||||
ofDrawCircle(position,size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
float Particle::getMaxLife(){
|
||||
|
||||
return maxLife;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
float Particle::getAge(){
|
||||
|
||||
return age;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
|
||||
void Particle::mapParticle(){
|
||||
|
||||
/*
|
||||
Put an if Statement before it:
|
||||
|
||||
if(borderCollission == true){mapParticle()}
|
||||
|
||||
|
||||
The particle will be mapped to a new position, using information about:
|
||||
|
||||
- old position
|
||||
- velocity (direction)
|
||||
- defined borders in the projection --> globals like window size, angle between "stelen", width of stelen, etc.
|
||||
|
||||
if the particle hits a border
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "ofxXmlSettings.h"
|
||||
#include "attractor.h"
|
||||
|
||||
enum particleMode{
|
||||
PARTICLE_MODE_DEFAULT,
|
||||
PARTICLE_MODE_ATTRACTOR,
|
||||
PARTICLE_MODE_RAIN,
|
||||
PARTICLE_MODE_RADIAL,
|
||||
PARTICLE_MODE_DETRACTOR,
|
||||
PARTICLE_MODE_POLY,
|
||||
PARTICLE_MODE_BRUNIG
|
||||
};
|
||||
|
||||
class Particle{
|
||||
|
||||
public:
|
||||
|
||||
Particle();
|
||||
|
||||
void setup(particleMode newMode);
|
||||
|
||||
void update(float deltaT, vector<Attractor*>* attractors, vector<Particle*> system);
|
||||
void setMode(particleMode newMode);
|
||||
particleMode mode;
|
||||
|
||||
void draw();
|
||||
void reset(ofVec2f _pos);
|
||||
|
||||
float getX();
|
||||
float getY();
|
||||
|
||||
void setVel(float min, float max);
|
||||
|
||||
float getAgeNorm();
|
||||
float getMaxLife();
|
||||
|
||||
|
||||
ofxXmlSettings effect;
|
||||
|
||||
int counterOfActiveAttractors;
|
||||
|
||||
ofVec2f vel;
|
||||
ofVec2f pos;
|
||||
ofVec2f frc;
|
||||
|
||||
float scale;
|
||||
float drag;
|
||||
float uniqueVal;
|
||||
|
||||
float maxLife;
|
||||
float age;
|
||||
|
||||
float size;
|
||||
float mass;
|
||||
|
||||
int blobCounterInParticle;
|
||||
|
||||
ofColor color;
|
||||
ofImage tex;
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// particle.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ofMain.h"
|
||||
#include "attractor.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
class Particle {
|
||||
|
||||
public:
|
||||
|
||||
Particle();
|
||||
~Particle();
|
||||
|
||||
void setup(ofVec2f position);
|
||||
void update(float deltaT, Attractor attractor);
|
||||
void draw();
|
||||
|
||||
float getMaxLife();
|
||||
float getAge();
|
||||
float getAgeNorm();
|
||||
|
||||
|
||||
void mapParticle();
|
||||
bool borderCollission();
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
ofVec2f velocity;
|
||||
ofVec2f position;
|
||||
|
||||
float maxLife;
|
||||
float age;
|
||||
float size;
|
||||
float mass;
|
||||
|
||||
ofColor color;
|
||||
|
||||
|
||||
int stele;
|
||||
//on which "stele" is the particle? --> will affect the movement (mapping), when it reaches borders of its "stele" !
|
||||
//if border 1/2/3/4 (<,>,v,^), then map particle
|
||||
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// particleSystem.cpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "particleSystem.hpp"
|
||||
|
||||
|
||||
|
||||
ParticleSystem::ParticleSystem(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
ParticleSystem::~ParticleSystem(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
|
||||
void ParticleSystem::setup(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
|
||||
void ParticleSystem::update(float deltaT, int visitorID, bool attracted){
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
- wenn attracted, dann springe in Berechnung der Attraktion durch die vorhandenen Attraktoren
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
VisitorID stellt bekannten Besucher dar, also fertiges, auswertbares Profil.
|
||||
visitorID steuert die Optik des Partikelsystems, aktiviert also eine Art Preset
|
||||
z.B. Switch-Anweisung (visitorID 1-8):
|
||||
|
||||
case 0: default mode, attraction
|
||||
case 1: load xml blabla1
|
||||
case 2: load xml blabla2
|
||||
...
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
|
||||
void ParticleSystem::draw(){
|
||||
|
||||
/*
|
||||
|
||||
draw all the particles from the vector in the ParticleSystem
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// particleSystem.hpp
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "attractor.hpp"
|
||||
#include "particle.hpp"
|
||||
#include "emitter.hpp"
|
||||
|
||||
|
||||
class ParticleSystem {
|
||||
|
||||
ParticleSystem();
|
||||
~ParticleSystem();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
void setup();
|
||||
void update(float deltaT, int playerType, bool attracted);
|
||||
void draw();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Where do we make the quick setting-changes?
|
||||
Like for exampe change direction of an emitter + its position?
|
||||
--> XML?
|
||||
|
||||
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
vector<Particle*> particles;
|
||||
vector<Attractor*> attractors;
|
||||
|
||||
vector<Emitter*> emitters;
|
||||
|
||||
//Maybe the emitter does not have to be an own class, but is more like a Vector of Positions, so in the system.back it will setup particles for every position that is saved in this Vector
|
||||
//like following:
|
||||
|
||||
//vector<Vec2f> positionsToEmitFrom;
|
||||
|
||||
|
||||
float birthcount;
|
||||
bool attracted;
|
||||
int playerType;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
class AttractedSystem : public ParticleSystem {
|
||||
|
||||
|
||||
bool attracted = true;
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
@@ -1,10 +0,0 @@
|
||||
<default>
|
||||
<sizeMin>0.05</sizeMin>
|
||||
<sizeMax>4</sizeMax>
|
||||
<mass>100</mass>
|
||||
<drag>0</drag>
|
||||
<maxLife>10</maxLife>
|
||||
<velMin>-80</velMin>
|
||||
<velMax>80</velMax>
|
||||
<color></color>
|
||||
</default>
|
||||
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 111 KiB |
@@ -3,7 +3,7 @@
|
||||
|
||||
//========================================================================
|
||||
int main() {
|
||||
ofSetupOpenGL(2000, 2000, OF_WINDOW);
|
||||
ofSetupOpenGL(1000, 1000, OF_WINDOW); // <-------- setup the GL context
|
||||
ofRunApp(new ofApp());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::setup() {
|
||||
ofSetVerticalSync(true);
|
||||
|
||||
//Initialize 8 empty attractrs
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -13,27 +12,19 @@ void ofApp::setup() {
|
||||
//OSC reciever port setup
|
||||
receiver.setup(PORT);
|
||||
|
||||
varSystem = true;
|
||||
trails = true;
|
||||
history = 0.95;
|
||||
//num = 1000;
|
||||
//sys.assign(num, Particle());
|
||||
|
||||
currentMode = PARTICLE_MODE_DEFAULT;
|
||||
currentModeDisp = "PARTICLE_MODE_DEFAULT";
|
||||
|
||||
//Black background
|
||||
ofSetBackgroundColor(0, 0, 0);
|
||||
|
||||
ofSetFrameRate(60);
|
||||
birthCount = 100;
|
||||
w = ofGetWidth();
|
||||
h = ofGetHeight();
|
||||
fbo.allocate(w, h, GL_RGB);
|
||||
//attractors.at(0)->setup(600, 600);
|
||||
|
||||
birthCount = 0;
|
||||
|
||||
//attractors.at(0)->setup(200, 200);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::update() {
|
||||
|
||||
// *** OSC RECEIVER ***
|
||||
while (receiver.hasWaitingMessages()) {
|
||||
|
||||
@@ -66,92 +57,43 @@ void ofApp::update() {
|
||||
double deltaT = ofGetLastFrameTime();
|
||||
birthCount += deltaT;
|
||||
|
||||
if (varSystem == true) {
|
||||
//Birth control for new particles
|
||||
if (birthCount > 0.001) {
|
||||
for (int i = 0;i < 4;i++) {
|
||||
system.push_back(new Particle);
|
||||
system.back()->setup(currentMode);
|
||||
}
|
||||
birthCount = 0;
|
||||
}
|
||||
|
||||
|
||||
for (int p = 0; p < system.size();)
|
||||
{
|
||||
//Upate particle system /w all active attractors
|
||||
system.at(p)->update(deltaT, &attractors, system);
|
||||
|
||||
//Delete particles, that reached max Age
|
||||
if (system.at(p)->getAgeNorm() > 4) {
|
||||
delete system.at(p);
|
||||
system.erase(system.begin() + p);
|
||||
}
|
||||
else {
|
||||
p++;
|
||||
}
|
||||
//Birth control for new particles
|
||||
if (birthCount > 0.001) {
|
||||
for (int i = 0;i < 4;i++) {
|
||||
system.push_back(new thParticle);
|
||||
system.back()->setup(ofVec2f(ofGetWidth()*.5, ofGetHeight()*.5));
|
||||
}
|
||||
birthCount = 0;
|
||||
}
|
||||
else {
|
||||
ofSeedRandom(39);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::reset() {
|
||||
|
||||
for (int p = 0; p < system.size();)
|
||||
{
|
||||
//Upate particle system /w all active attractors
|
||||
system.at(p)->update(deltaT, &attractors);
|
||||
|
||||
//Delete particles, that reached max Age
|
||||
if (system.at(p)->getAgeNorm() > 4) {
|
||||
delete system.at(p);
|
||||
system.erase(system.begin() + p);
|
||||
}
|
||||
else {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::draw() {
|
||||
if (varSystem == false) {
|
||||
vector<ofVec2f> system;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
ofVec2f particle(ofMap(ofNoise(ofRandom(100), ofGetFrameNum() * 0.0005), 0, 1, 0, ofGetWidth()), ofMap(ofNoise(ofRandom(100), ofGetFrameNum() * 0.0005), 0, 1, 0, ofGetHeight()));
|
||||
system.push_back(particle);
|
||||
}
|
||||
|
||||
for (int out = 0; out < system.size(); out++) {
|
||||
for (int in = out + 1; in < system.size(); in++) {
|
||||
if (system[out].distance(system[in]) < 60) {
|
||||
ofDrawLine(system[out], system[in]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < system.size(); i++) {
|
||||
|
||||
ofDrawCircle(system[i], ofRandom(0.5, 3));
|
||||
}
|
||||
//Draw particle system
|
||||
for (int p = 0; p < system.size(); p++) {
|
||||
system.at(p)->draw();
|
||||
}
|
||||
|
||||
if (trails == true) {
|
||||
fbo.begin();
|
||||
ofEnableAlphaBlending(); //Enable transparency
|
||||
|
||||
float alpha = (1 - history) * 255;
|
||||
ofSetColor(0, 0, 0, alpha);
|
||||
ofFill();
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
ofDisableAlphaBlending(); //Disable transparency
|
||||
//Draw particle system
|
||||
for (int p = 0; p < system.size(); p++) {
|
||||
system.at(p)->draw();
|
||||
}
|
||||
fbo.end();
|
||||
}
|
||||
else {
|
||||
//Draw particle system
|
||||
for (int p = 0; p < system.size(); p++) {
|
||||
system.at(p)->draw();
|
||||
}
|
||||
}
|
||||
//Capture time based on FrameTime
|
||||
double deltaT = ofGetLastFrameTime();
|
||||
time += deltaT;
|
||||
@@ -163,91 +105,28 @@ void ofApp::draw() {
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
fbo.draw(0, 0);
|
||||
|
||||
// *** DEBUG INFO ***
|
||||
ofSetColor(230);
|
||||
|
||||
//All 8 Attractors with x | y coordinates
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
string x = ofToString(attractors.at(i)->getX());
|
||||
string y = ofToString(attractors.at(i)->getY());
|
||||
//string x = ofToString(attractors.at(i)->getX());
|
||||
//string y = ofToString(attractors.at(i)->getY());
|
||||
|
||||
ofDrawBitmapString("x: " + x + " y: " + y, 100, 100 + i * 20);
|
||||
//ofDrawBitmapString("x: " + x + " y: " + y, 100, 100 + i * 20);
|
||||
}
|
||||
//Recieved OSC messages
|
||||
ofDrawBitmapString("OSC: " + ofToString(oscMsg),100, 275);
|
||||
//ofDrawBitmapString("OSC: " + ofToString(oscMsg),100, 275);
|
||||
//Elapsed time since last clear of attractors
|
||||
ofDrawBitmapString("Time: " + ofToString(time),100, 300);
|
||||
//ofDrawBitmapString("Time: " + ofToString(time),100, 300);
|
||||
//Current FPS
|
||||
ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 100, 325);
|
||||
//Current Mode
|
||||
ofDrawBitmapString("Current Effect: " + currentModeDisp, 100, 350);
|
||||
//ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 100, 325);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyPressed(int key) {
|
||||
//Key press 1 to trigger default particle Mode
|
||||
if (key == '1') {
|
||||
currentMode = PARTICLE_MODE_DEFAULT;
|
||||
currentModeDisp = "PARTICLE_MODE_DEFAULT";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '2') {
|
||||
currentMode = PARTICLE_MODE_RADIAL;
|
||||
currentModeDisp = "PARTICLE_MODE_RADIAL";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger rain particle Mode
|
||||
if (key == '3') {
|
||||
currentMode = PARTICLE_MODE_RAIN;
|
||||
currentModeDisp = "PARTICLE_MODE_RAIN";
|
||||
varSystem = true;
|
||||
trails = false;
|
||||
fbo.clear();
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '4') {
|
||||
currentMode = PARTICLE_MODE_ATTRACTOR;
|
||||
currentModeDisp = "PARTICLE_MODE_ATTRACTOR";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '5') {
|
||||
currentMode = PARTICLE_MODE_DETRACTOR;
|
||||
currentModeDisp = "PARTICLE_MODE_DETRACTOR";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
//Key press 2 to trigger attractor particle Mode
|
||||
if (key == '6') {
|
||||
currentMode = PARTICLE_MODE_POLY;
|
||||
currentModeDisp = "PARTICLE_MODE_POLY";
|
||||
varSystem = false;
|
||||
trails = false;
|
||||
fbo.clear();
|
||||
reset();
|
||||
}
|
||||
if (key == '7') {
|
||||
trails = true;
|
||||
fbo.allocate(w, h, GL_RGB);
|
||||
reset();
|
||||
}
|
||||
if (key == '8') {
|
||||
trails = false;
|
||||
fbo.clear();
|
||||
reset();
|
||||
}
|
||||
if (key == '9') {
|
||||
currentMode = PARTICLE_MODE_POLY;
|
||||
currentModeDisp = "PARTICLE_MODE_BRUNIG";
|
||||
varSystem = true;
|
||||
reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -257,7 +136,6 @@ void ofApp::keyReleased(int key) {
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseMoved(int x, int y) {
|
||||
attractors.at(0)->setup(ofGetMouseX(), ofGetMouseY());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ public:
|
||||
void setup();
|
||||
void update();
|
||||
void draw();
|
||||
void reset();
|
||||
|
||||
void keyPressed(int key);
|
||||
void keyReleased(int key);
|
||||
@@ -23,41 +22,23 @@ public:
|
||||
void mousePressed(int x, int y, int button);
|
||||
void mouseReleased(int x, int y, int button);
|
||||
|
||||
ofxXmlSettings default;
|
||||
ofxXmlSettings attractor;
|
||||
ofxXmlSettings rain;
|
||||
ofxXmlSettings brunig;
|
||||
|
||||
private:
|
||||
|
||||
// OSC Receiver
|
||||
|
||||
particleMode currentMode;
|
||||
string currentModeDisp;
|
||||
|
||||
string oscMsg;
|
||||
ofxOscReceiver receiver;
|
||||
float timeSent, timeReceived;
|
||||
|
||||
int nBlobs;
|
||||
int blobCount;
|
||||
int num;
|
||||
float history;
|
||||
ofFbo fbo;
|
||||
|
||||
float xOfCentroid;
|
||||
float yOfCentroid;
|
||||
|
||||
vector<Particle*> system;
|
||||
vector<Particle>sys;
|
||||
vector<thParticle*> system;
|
||||
vector<Attractor*> attractors;
|
||||
|
||||
float birthCount;
|
||||
double time;
|
||||
|
||||
bool varSystem;
|
||||
bool trails;
|
||||
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
@@ -8,173 +8,73 @@
|
||||
|
||||
Particle::Particle()
|
||||
{
|
||||
uniqueVal = ofRandom(-10000, 10000);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
Particle::~Particle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void Particle::setup(particleMode newMode) {
|
||||
mode = newMode;
|
||||
void Particle::setup(ofVec2f _position) {
|
||||
|
||||
this->position = _position;
|
||||
|
||||
vel.set(ofRandom(-3.0, 3.0), ofRandom(-3.0, 3.0));
|
||||
|
||||
age = 0.0;
|
||||
maxLife = 10.0;
|
||||
frc = ofVec2f(0, 0);
|
||||
size = ofRandom(1, 1);
|
||||
size = .5;
|
||||
maxLife = 12.0;
|
||||
|
||||
color.set(250, 250, 250);
|
||||
|
||||
size = ofRandom(4.0, 0.01);
|
||||
|
||||
mass = ofRandom(100, 250);
|
||||
//setVel(-40, 40);
|
||||
if (mode == PARTICLE_MODE_DEFAULT) {
|
||||
effect.loadFile("xml/default.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
maxLife = lifeMax;
|
||||
int sizeMin = effect.getValue("default:sizeMin", 0);
|
||||
int sizeMax = effect.getValue("default:sizeMax", 0);
|
||||
size = ofRandom(sizeMin, sizeMax);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RADIAL) {
|
||||
effect.loadFile("xml/radial.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
maxLife = lifeMax;
|
||||
int sizeMin = effect.getValue("default:sizeMin", 0);
|
||||
int sizeMax = effect.getValue("default:sizeMax", 0);
|
||||
size = ofRandom(sizeMin, sizeMax);
|
||||
pos.x = ofGetWidth()/2;
|
||||
pos.y = ofGetHeight()/2;
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RAIN) {
|
||||
effect.loadFile("xml/rain.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
maxLife = lifeMax;
|
||||
int sizeMin = effect.getValue("default:sizeMin", 0);
|
||||
int sizeMax = effect.getValue("default:sizeMax", 0);
|
||||
size = ofRandom(sizeMin, sizeMax);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
drag = ofRandom(0.97, 0.99);
|
||||
vel.y = fabs(vel.y) * 6.0;
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_ATTRACTOR) {
|
||||
effect.loadFile("xml/attractor.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
maxLife = lifeMax;
|
||||
int sizeMin = effect.getValue("default:sizeMin", 0);
|
||||
int sizeMax = effect.getValue("default:sizeMax", 0);
|
||||
size = ofRandom(sizeMin, sizeMax);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_DETRACTOR) {
|
||||
effect.loadFile("xml/detractor.xml");
|
||||
int velMin = effect.getValue("default:velMin", 0);
|
||||
int velMax = effect.getValue("default:velMax", 0);
|
||||
setVel(velMin, velMax);
|
||||
int lifeMax = effect.getValue("default:maxLife", 0);
|
||||
maxLife = lifeMax;
|
||||
int sizeMin = effect.getValue("default:sizeMin", 0);
|
||||
int sizeMax = effect.getValue("default:sizeMax", 0);
|
||||
size = ofRandom(sizeMin, sizeMax);
|
||||
pos.x = ofRandomWidth();
|
||||
pos.y = ofRandomHeight();
|
||||
}
|
||||
else {
|
||||
|
||||
drag = ofRandom(0.95, 0.998);
|
||||
}
|
||||
tex.load("img/overlay.png");
|
||||
|
||||
tex.load("img/br.png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
void Particle::update(float deltaT, vector<Attractor*>* attractors,vector<Particle*> system) {
|
||||
if (mode == PARTICLE_MODE_DEFAULT) {
|
||||
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_RAIN) {
|
||||
float wind = ofSignedNoise(pos.x * 0.003, pos.y * 0.006, ofGetElapsedTimef() * 0.6);
|
||||
void Particle::update(float deltaT, vector<Attractor*>* attractors) {
|
||||
|
||||
frc.x = wind * 0.25 + ofSignedNoise(uniqueVal, pos.y * 0.08) * 0.6;
|
||||
frc.y = ofSignedNoise(uniqueVal, pos.x * 0.06, ofGetElapsedTimef()*0.2) * 0.09 + 0.18;
|
||||
|
||||
vel *= drag;
|
||||
vel += frc * 0.2;
|
||||
|
||||
if (pos.y + vel.y > ofGetHeight()) {
|
||||
pos.y -= ofGetHeight();
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - position.x, attractors->at(i)->getY() - position.y);
|
||||
|
||||
if (force.length() < 150) {
|
||||
force = 60 * force.getNormalized();
|
||||
size = size + ofRandom(.01, 0.01);
|
||||
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_ATTRACTOR) {
|
||||
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - pos.x, attractors->at(i)->getY() - pos.y);
|
||||
|
||||
if (force.length() < 250) {
|
||||
force = 40 * force.getNormalized();
|
||||
size = size + ofRandom(.03, 0.01);
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
}
|
||||
else if (mode == PARTICLE_MODE_DETRACTOR) {
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
//force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - pos.x, attractors->at(i)->getY() - pos.y);
|
||||
|
||||
if (force.length() < 600) {
|
||||
force.normalize();
|
||||
size = size + ofRandom(.01, 0.01);
|
||||
|
||||
vel += -force*2000;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update particle pos
|
||||
age += deltaT * .5;
|
||||
pos += (vel * deltaT);
|
||||
position += (vel * deltaT);
|
||||
|
||||
// *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION
|
||||
|
||||
@@ -189,50 +89,60 @@ void Particle::update(float deltaT, vector<Attractor*>* attractors,vector<Partic
|
||||
//else {
|
||||
//position += (vel * deltaT);
|
||||
//}
|
||||
|
||||
|
||||
//void thParticle::update(float deltaT, ofVec2f attractor){
|
||||
//
|
||||
//
|
||||
// age += deltaT;
|
||||
//
|
||||
// ofVec2f force = attractor - position;
|
||||
// color.set(250,250, 250, (1 - age / maxLife) * 255);
|
||||
//
|
||||
// if( force.length() < 40 && force.length() > 11 ){
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 0.01 * force ;
|
||||
//
|
||||
// }else if(force.length() < 12){
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 5 * force ;
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 0.12 * force ;
|
||||
// }
|
||||
// position += velocity * deltaT;
|
||||
//}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
void Particle::draw() {
|
||||
|
||||
color.set(getAgeNorm() * 241,241/ getAgeNorm() ,219);
|
||||
|
||||
ofSetColor(color, (1 - getAgeNorm()) * 255);
|
||||
if (mode == PARTICLE_MODE_BRUNIG) {
|
||||
tex.setColor(color);
|
||||
tex.draw(pos.x, pos.y, size);
|
||||
}
|
||||
else {
|
||||
ofDrawCircle(pos.x, pos.y, size);
|
||||
}
|
||||
}
|
||||
//tex.setColor(color);
|
||||
//tex.draw(position, size, size);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
void Particle::setMode(particleMode newMode) {
|
||||
mode = newMode;
|
||||
ofDrawCircle(position, size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
float Particle::getAgeNorm() {
|
||||
return age / maxLife;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
void Particle::setVel(float min, float max) {
|
||||
vel.x = ofRandom(min,max);
|
||||
vel.y = ofRandom(min,max);
|
||||
}
|
||||
|
||||
|
||||
float Particle::getMaxLife() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
float Particle::getY() {
|
||||
return pos.y;
|
||||
}
|
||||
|
||||
|
||||
float Particle::getX() {
|
||||
return pos.x;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -1,54 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "ofxXmlSettings.h"
|
||||
#include "attractor.h"
|
||||
#include "line.h"
|
||||
|
||||
enum particleMode{
|
||||
PARTICLE_MODE_DEFAULT,
|
||||
PARTICLE_MODE_ATTRACTOR,
|
||||
PARTICLE_MODE_RAIN,
|
||||
PARTICLE_MODE_RADIAL,
|
||||
PARTICLE_MODE_DETRACTOR,
|
||||
PARTICLE_MODE_POLY,
|
||||
PARTICLE_MODE_BRUNIG
|
||||
};
|
||||
|
||||
class Particle{
|
||||
class Particle
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Particle();
|
||||
~Particle();
|
||||
|
||||
void setup(particleMode newMode);
|
||||
void setup(ofVec2f position);
|
||||
|
||||
void update(float deltaT, vector<Attractor*>* attractors, vector<Particle*> system);
|
||||
void setMode(particleMode newMode);
|
||||
particleMode mode;
|
||||
void update(float deltaT, vector<Attractor*>* attractors);
|
||||
|
||||
void draw();
|
||||
void reset(ofVec2f _pos);
|
||||
|
||||
float getX();
|
||||
float getY();
|
||||
|
||||
void setVel(float min, float max);
|
||||
|
||||
float getAgeNorm();
|
||||
float getMaxLife();
|
||||
|
||||
|
||||
ofxXmlSettings effect;
|
||||
|
||||
private:
|
||||
|
||||
int counterOfActiveAttractors;
|
||||
|
||||
ofVec2f vel;
|
||||
ofVec2f pos;
|
||||
ofVec2f frc;
|
||||
|
||||
float scale;
|
||||
float drag;
|
||||
float uniqueVal;
|
||||
ofVec2f position;
|
||||
|
||||
float maxLife;
|
||||
float age;
|
||||
|
||||