10 Commits
Author SHA1 Message Date
lindnerto66309 cdfeec2dbc ofxXmlSettings 2019-05-23 16:09:32 +00:00
lindnerto66309 1613d896e0 img upload 2019-05-23 16:07:23 +00:00
lindnerto66309 57dc25d39b xml upload 2019-05-23 16:06:38 +00:00
lindnerto66309 5faa3e0025 img upload 2019-05-23 16:01:38 +00:00
lindnerto66309 c3c7178b18 xml upload 2019-05-23 16:01:08 +00:00
lindnerto66309 14de0ec2f7 upload 2019-05-23 15:52:48 +00:00
lindnerto66309 6b1179c77e upload 2019-05-23 15:52:30 +00:00
Danial Eshete 247746be58 changed from thParticle to Particle because there's no thParticle class 2019-05-23 15:52:23 +02:00
lindnerto66309 fd32d1984b upload 2019-05-09 12:38:51 +00:00
lindnerto66309 75dd4f9bb3 upload 2019-05-09 12:38:07 +00:00
66 changed files with 1273 additions and 4221 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
ofxGui
ofxOsc
ofxVectorGraphics
ofxXmlSettings
ofxWarp
ofxSecondWindow
+42
View File
@@ -0,0 +1,42 @@
#include "attractor.h"
Attractor::Attractor()
{
x = 0;
y = 0;
}
//--------------------------------------------------------------------------------------
Attractor::~Attractor()
{
}
//--------------------------------------------------------------------------------------
float Attractor::getY() {
return y;
}
float Attractor::getX() {
return x;
}
void Attractor::setX(float xNew) {
x = xNew;
}
void Attractor::setY(float yNew) {
y = yNew;
}
void Attractor::setup(float xSetup, float ySetup) {
x = xSetup;
y = ySetup;
}
+34
View File
@@ -0,0 +1,34 @@
//
// 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;
};
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

@@ -1,16 +0,0 @@
#version 150
in vec2 vTexCoord;
in vec4 vColor;
out vec4 fragColor;
void main(void)
{
vec2 uv = vTexCoord * 2.0 - 1.0;
float d = dot(uv, uv);
float rim = smoothstep(0.7, 0.8, d);
rim += smoothstep(0.3, 0.4, d) - smoothstep(0.5, 0.6, d);
rim += smoothstep(0.1, 0.0, d);
fragColor = mix(vec4( 0.0, 0.0, 0.0, 0.25), vColor, rim);
}
@@ -1,23 +0,0 @@
#version 150
// OF default uniforms and attributes
uniform mat4 modelViewProjectionMatrix;
uniform vec4 globalColor;
in vec4 position;
in vec2 texcoord;
in vec4 color;
// App uniforms and attributes
in vec4 iPositionScale;
in vec4 iColor;
out vec2 vTexCoord;
out vec4 vColor;
void main(void)
{
vTexCoord = texcoord;
vColor = globalColor * iColor;
gl_Position = modelViewProjectionMatrix * vec4(position.xy * iPositionScale.z + iPositionScale.xy, position.zw);
}
@@ -1,57 +0,0 @@
#version 150
uniform sampler2D uTexture;
uniform vec4 uExtends;
uniform vec3 uLuminance;
uniform vec3 uGamma;
uniform vec4 uEdges;
uniform vec4 uCorners;
uniform float uExponent;
uniform bool uEditing;
in vec2 vTexCoord;
in vec4 vColor;
out vec4 fragColor;
float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
{
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
}
float grid(in vec2 uv, in vec2 size)
{
vec2 coord = uv / size;
vec2 grid = abs(fract(coord - 0.5) - 0.5) / (2.0 * fwidth(coord));
float line = min(grid.x, grid.y);
return 1.0 - min(line, 1.0);
}
void main(void)
{
vec4 texColor = texture(uTexture, vTexCoord);
vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
float a = 1.0;
if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
const vec3 one = vec3(1.0);
vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
texColor.rgb *= pow(blend, one / uGamma);
if (uEditing)
{
float f = grid(mapCoord.xy * uExtends.xy, uExtends.zw);
vec4 gridColor = vec4(1.0f);
fragColor = mix(texColor * vColor, gridColor, f);
}
else
{
fragColor = texColor * vColor;
}
}
@@ -1,21 +0,0 @@
#version 150
// OF default uniforms and attributes
uniform mat4 modelViewProjectionMatrix;
uniform vec4 globalColor;
in vec4 position;
in vec2 texcoord;
in vec4 color;
// App uniforms and attributes
out vec2 vTexCoord;
out vec4 vColor;
void main(void)
{
vTexCoord = texcoord;
vColor = globalColor;
gl_Position = modelViewProjectionMatrix * position;
}
@@ -1,38 +0,0 @@
#version 150
uniform sampler2D uTexture;
uniform vec3 uLuminance;
uniform vec3 uGamma;
uniform vec4 uEdges;
uniform vec4 uCorners;
uniform float uExponent;
in vec2 vTexCoord;
in vec4 vColor;
out vec4 fragColor;
float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
{
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
}
void main(void)
{
vec4 texColor = texture(uTexture, vTexCoord);
vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
float a = 1.0;
if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
const vec3 one = vec3(1.0);
vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
texColor.rgb *= pow(blend, one / uGamma);
fragColor = texColor * vColor;
}
@@ -1,21 +0,0 @@
#version 150
// OF default uniforms and attributes
uniform mat4 modelViewProjectionMatrix;
uniform vec4 globalColor;
in vec4 position;
in vec2 texcoord;
in vec4 color;
// App uniforms and attributes
out vec2 vTexCoord;
out vec4 vColor;
void main(void)
{
vTexCoord = texcoord;
vColor = globalColor;
gl_Position = modelViewProjectionMatrix * position;
}
+9 -3
View File
@@ -1,4 +1,10 @@
<default>
<attracted>true</attracted>
<playertype>0</playertype>
<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>
-76
View File
@@ -1,76 +0,0 @@
<! XML for particles depending on the active mode >
<default>
<size></size>
<color></color>
<age></age>
<maxLife></maxLife>
<mass></mass>
<velocity></velocity>
<position></position>
<transparency></transparency>
<floor></floor>
<stelen></stelen>
<aging>true</aging>
</default>
<! ----------------------------------------- >
<polymesh>
<size></size>
<color></color>
<age></age>
<maxLife></maxLife>
<mass></mass>
<velocity></velocity>
<position></position>
<transparency></transparency>
<floor></floor>
<stelen></stelen>
<aging>false</aging>
</polymesh>
<! ----------------------------------------- >
<rfid>
</rfid>
<! ----------------------------------------- >
-51
View File
@@ -1,51 +0,0 @@
<! XML for particleSystems, depending on the active mode >
<default>
<birthrate>4</birthrate>
<display>true</display>
<connectParticles>false</connectParticles>
<playerType>0</playerType>
</default>
<! ------------------------------------- >
<polymesh>
<birthrate>0</birthrate>
<display>true</display>
<connectParticles>false</connectParticles>
<playerType>0</playerType>
</polymesh>
<! ------------------------------------- >
<rfid>
</rfid>
<! ------------------------------------- >
-60
View File
@@ -1,60 +0,0 @@
<setupSquare>
<center>
<x>0.5</x>
<y>0.5</y>
</center>
<stele1>
<x>0.5</x>
<y>0.28</y>
</stele1>
<stele2>
<x>0.6905</x>
<y>0.39</y>
</stele2>
<stele3>
<x>0.6905</x>
<y>0.61</y>
</stele3>
<stele4>
<x>0.5</x>
<y>0.72</y>
</stele4>
<stele5>
<x>0.3095</x>
<y>0.61</y>
</stele5>
<stele6>
<x>0.3095</x>
<y>0.39</y>
</stele6>
</setupSquare>
<setup>
<center>
<x>0.5</x>
<y>0.5</y>
</center>
<stele1>
<x>0.25</x>
<y>0.0</y>
</stele1>
<stele2>
<x>0.46650635</x>
<y>0.125</y>
</stele2>
<stele3>
<x>0.46650635</x>
<y>0.375</y>
</stele3>
<stele4>
<x>0.25</x>
<y>0.5</y>
</stele4>
<stele5>
<x>0.03349375</x>
<y>0.375</y>
</stele5>
<stele6>
<x>0.03349375</x>
<y>0.125</y>
</stele6>
</setup>
+9
View File
@@ -0,0 +1,9 @@
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main() {
ofSetupOpenGL(2000, 2000, OF_WINDOW);
ofRunApp(new ofApp());
}
+261
View File
@@ -0,0 +1,261 @@
#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);
}
}
//--------------------------------------------------------------
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));
}
}
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) {
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y) {
attractors.at(0)->setup(ofGetMouseX(), ofGetMouseY());
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button) {
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button) {
}
+60
View File
@@ -0,0 +1,60 @@
#pragma once
#include "ofMain.h"
#include "particle.h"
#include "ofxOsc.h"
#include "ofxGui.h"
//OSC Reciever PORT & HOST IP
#define PORT 12345
#define HOST "172.20.10.2"
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);
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;
};
+211
View File
@@ -0,0 +1,211 @@
// particle.cpp
// particleSystem
//
#include "particle.h"
#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");
}
//--------------------------------------------------------------------------------------
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::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;
}
float Particle::getX() {
return pos.x;
}
+63
View File
@@ -0,0 +1,63 @@
#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;
};
-9
View File
@@ -1,9 +0,0 @@
//
// XML_information.cpp
// Projekt_FORUM
//
// Created by Sebastian Holzki on 14.06.19.
//
#include "XML_information.hpp"
-22
View File
@@ -1,22 +0,0 @@
//
// XML_information.hpp
// Projekt_FORUM
//
// Created by Sebastian Holzki on 14.06.19.
//
#pragma once
#include <stdio.h>
#include "ofxXmlSettings.h"
class XML_information {
public:
//ofxXmlSettings xmlParticleSystems;
//ofxXmlSettings xmlParticles; // ??? wo soll das hin ???
};
+10
View File
@@ -0,0 +1,10 @@
<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>
+10
View File
@@ -0,0 +1,10 @@
<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>
+10
View File
@@ -0,0 +1,10 @@
<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>
+10
View File
@@ -0,0 +1,10 @@
<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>
+10
View File
@@ -0,0 +1,10 @@
<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>
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

-409
View File
@@ -1,409 +0,0 @@
//
// checkedInVisitor.cpp
// Projekt_FORUM
//
// Created by Sebastian Holzki on 19.06.19.
//
#include "checkedInVisitor.hpp"
CheckedInVisitor::CheckedInVisitor(){
started = false;
xVelocityMax = 1.5000;
age = 0;
setupInOfAppIsFinished = false;
startingAnimationIsFinished = false;
}
// -----------------------------------------
CheckedInVisitor::~CheckedInVisitor(){
}
// -----------------------------------------
void CheckedInVisitor::setup(int _playerType, int _checkedInStele, float sceneWidth, float sceneHeight){
//Everytime a visitor checks in, we will generate a "CheckedInVisitor".
//Depending, what playerType checked in, a different image will be loaded into ofImage imageOfType, representing the playerType.
//We also scale and set the default color here. Later we might be able to also pass the "greatWhole" information about the currentMode of the system,
//so we can play around with the CheckedInVisitors as well.
k1 = ofRandom(0.3,0.5); // random value for k1*sin(...)+...
k2 = ofRandom(0.3,1.2); // random value for ...*sin(k2*age)+....
k3 = ofRandom(0.8, 1.2);
checkedInStele = _checkedInStele;
playerType = _playerType;
switch ( playerType ){
case 1: {
imageOfType.load("images/image1_color.png");
hexagon.load("images/hexagon_1.png");
break;
}
case 2: {
imageOfType.load("images/image2_color.png");
hexagon.load("images/hexagon_2.png");
break;
}
case 3: {
imageOfType.load("images/image3_color.png");
hexagon.load("images/hexagon_3.png");
break;
}
case 4: {
imageOfType.load("images/image4_color.png");
hexagon.load("images/hexagon_4.png");
break;
}
default:
imageOfType.load("images/noplayertype.png");
} //end of switch
setupPosition(sceneWidth, sceneHeight, checkedInStele);
imageOfType.resize(imageOfType.getWidth()*0.5, imageOfType.getHeight()*0.5);
hexagon.resize(hexagon.getWidth()*0.5, hexagon.getHeight()*0.5);
// pixelsWithValues(sceneWidth, sceneHeight, hexagon);
}
// -----------------------------------------
void CheckedInVisitor::update(float deltaT, float sceneWidth, float sceneHeight){
aging(deltaT);
move(deltaT, sceneWidth, sceneHeight);
if(age > 3 && started == false){
setupVelocity();
started = true;
}
// updateAttractingPixels();
positionLastFrame = position;
}
// -----------------------------------------
void CheckedInVisitor::draw(){
ofSetColor(255,255,255);
imageOfType.draw(position);
hexagon.draw(position);
if(attractingPixelsOfHexagon.size()){
ofDrawBitmapString(ofToString(attractingPixelsOfHexagon.at(0).x), position.x, position.y - 20);
ofDrawBitmapString(ofToString(position.x), position.x, position.y - 40);
}
}
// -----------------------------------------
ofVec2f CheckedInVisitor::getPosition(){
return position;
}
// -----------------------------------------
ofVec2f CheckedInVisitor::getBottom(){
ofVec2f bottom = this->position;
bottom.x += hexagon.getWidth()/2;
bottom.y += hexagon.getHeight()*0.99;
return bottom;
}
// -----------------------------------------
void CheckedInVisitor::aging(float deltaT){
age += deltaT;
}
// -----------------------------------------
vector<ofVec2f> CheckedInVisitor::getPositionsOfAttractingPixels(){
return attractingPixelsOfHexagon;
}
// -----------------------------------------
bool CheckedInVisitor::getIfEmitterIsDeleted(){
return emitterHasBeenDeleted;
}
// -----------------------------------------
void CheckedInVisitor::updateAttractingPixels(){
float differenceX = positionLastFrame.x - position.x;
float differenceY = positionLastFrame.y - position.y;
for(int i = 0; i < attractingPixelsOfHexagon.size(); i++){
attractingPixelsOfHexagon.at(i).x -= differenceX;
attractingPixelsOfHexagon.at(i).y -= differenceY;
}
}
// -----------------------------------------
void CheckedInVisitor::pixelsWithValues(float sceneWidth, float sceneHeight, ofImage _hexagon){
int hexagonWidth = _hexagon.getWidth();
int hexagonHeight = _hexagon.getHeight();
ofPixels pixels;
pixels = hexagon.getPixels();
int counter = 11;
// Iterate trough the pixels, skip 3 do 1 because only 1 channel is needed
for(int i = 3; i <= pixels.size(); i+=4){
if(pixels[i] > 0){ //if the pixel has a value jump into saving it
int width = pixels.getWidth();
int y = i / 4 / width ;
int x = i / 4 % width ;
ofVec2f pixelPosition;
pixelPosition.set(position.x + x, position.y + y);
if(counter > 10){
attractingPixelsOfHexagon.push_back(pixelPosition);
counter = 0;
}
counter++;
}
}
}
// -----------------------------------------
void CheckedInVisitor::setupPosition(int sceneWidth, int sceneHeight, int checkedInStele){
position.y = sceneHeight - imageOfType.getHeight()/2;
position.x = sceneHeight + ((sceneWidth - sceneHeight)/6)*(checkedInStele - 1); //Hinter Kreis + 1/2 Stele
position.x += (sceneWidth - sceneHeight)/12 - imageOfType.getWidth()/4;
positionLastFrame = position;
}
// -----------------------------------------
void CheckedInVisitor::setupCornerPositions(float sceneWidth, float sceneHeight){
//save the corners of the generated hexagon as positions into an array
//try with ofCircles
ofSetColor(255,0,0);
ofDrawCircle(position.x + hexagon.getWidth()/4, position.y, 10);
// attractingPixelsOfHexagon.push_back(
}
// -----------------------------------------
void CheckedInVisitor::setPosition(ofVec2f _position){
position = _position;
}
// -----------------------------------------
void CheckedInVisitor::setStateOfSetup(bool stateToSet){
setupInOfAppIsFinished = stateToSet;
}
// -----------------------------------------
bool CheckedInVisitor::getStateOfSetup(){
return setupInOfAppIsFinished;
}
// -----------------------------------------
void CheckedInVisitor::move(float deltaT, float sceneWidth, float sceneHeight){
int startingSpeed = 65;
if(startingAnimationIsFinished != true){
startingAnimation(startingSpeed, sceneWidth, sceneHeight);
position += velocity * startingSpeed * deltaT;
}
if(startingAnimationIsFinished == true){
position.y += k1*sin(age*k2);
position += velocity * startingSpeed * deltaT * k3;
}
//jump from right to left
if(position.x > (sceneWidth - (sceneWidth - 0.5*sceneHeight)/36 )){
position.x = sceneHeight;
}
}
// -----------------------------------------
void CheckedInVisitor::startingAnimation(float startingSpeed, float sceneWidth, float sceneHeight){
if(position.y < sceneHeight*0.4){
velocity.y *= 0.99 ;
}
if(position.y < sceneHeight*0.4 && startedMovingToTheRight == false){
velocity.x = 0.1;
startedMovingToTheRight = true;
}
if(velocity.x < xVelocityMax){
velocity.x *= 1.02;
}
if( (((xVelocityMax - velocity.x) < 0.0001)) && ((velocity.y < 0.0001)) ){
velocity.x = xVelocityMax;
velocity.y = 0;
startingAnimationIsFinished = true;
}
}
// -----------------------------------------
void CheckedInVisitor::setupVelocity(){
velocity.set(0.0, -2.0);
}
// -----------------------------------------
float CheckedInVisitor::getAge(){
return age;
}
// -----------------------------------------
void CheckedInVisitor::clipToLastCheckedInVisitor(CheckedInVisitor _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 ;
}
}
-102
View File
@@ -1,102 +0,0 @@
//
// checkedInVisitor.hpp
// Projekt_FORUM
//
// Created by Sebastian Holzki on 19.06.19.
//
#pragma once
#include "ofMain.h"
#include <stdio.h>
class CheckedInVisitor {
public:
CheckedInVisitor();
~CheckedInVisitor();
void setup(int playerType, int checkedInStele, float sceneWidth, float sceneHeight);
void update(float deltaT, float sceneWidth, float sceneHeight);
void draw();
void setupVelocity();
void setupPosition(int x, int y, int checkedInStele);
void setPosition(ofVec2f position);
ofVec2f getPosition();
ofVec2f getBottom();
void fillAttractingPixelsVector(float sceneWidth, float sceneHeight);
void pixelsWithValues(float sceneWidth, float sceneHeight, ofImage hexagon);
void updateAttractingPixels();
vector<ofVec2f>getPositionsOfAttractingPixels();
void setupCornerPositions(float sceneWidth, float sceneHeight);
void setStateOfSetup(bool setupFinished);
bool getStateOfSetup();
//Every CheckedInVisitor creates an Emitter for his starting Animation
//Following methods will help to not get any bad access errors when emitting
// from new attractors and not doing it from older ones
bool getIfEmitterIsDeleted();
void setIfEmitterIsDeleted(bool isDeleted);
void setPlayerType();
int getPlayerType();
void startingAnimation(float startingSpeed, float sceneWidth, float sceneHeight);
void move(float deltaT, float sceneWidth, float sceneHeight);
void aging(float deltaT);
float getAge();
void clipToLastCheckedInVisitor(CheckedInVisitor visitor); //A particular "image" can clip its position, depending on the position of the last
ofImage imageOfType;
ofImage hexagon;
vector<ofVec2f> attractingPixelsOfHexagon;
private:
int checkedInStele;
int playerType;
ofVec2f position;
ofVec2f positionLastFrame;
ofVec2f velocity;
float xVelocityMax;
bool started;
bool startedMovingToTheRight;
bool setupInOfAppIsFinished;
bool startingAnimationIsFinished;
bool emitterHasBeenDeleted;
//Random values between 0.0 and 1.0
float k1;
float k2;
float k3;
float age;
};
-79
View File
@@ -1,79 +0,0 @@
//
// greatWhole.cpp
// emptyExample
//
// Created by Sebastian Holzki on 17.04.19.
//
#include "greatWhole.hpp"
GreatWhole::GreatWhole()
{
}
// -----------------------------------
GreatWhole::~GreatWhole()
{
}
// -----------------------------------
void GreatWhole::setup(){
}
// -----------------------------------------------
void GreatWhole::update(vector<CheckedInVisitor*> checkedInVisitors){
}
// -----------------------------------------------
void GreatWhole::draw(){
/*
draw the whole avatar vector
*/
}
// -----------------------------------------------
void GreatWhole::addCheckedInVisitor(CheckedInVisitor checkedInVisitors){
// avatars.push_back(avatar);
/*
Set coordinates in abhängigkeit vom letzten also bei avatars at (max-1)
clip avatar dann an den letzten, y und x angepasst an x und y von avatars.at(max-1)
*/
}
-46
View File
@@ -1,46 +0,0 @@
//
// greatWhole.hpp
// emptyExample
//
// Created by Sebastian Holzki on 17.04.19.
//
#include <stdio.h>
#include "ofMain.h"
#include "checkedInVisitor.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<CheckedInVisitor*> checkedInVisitors);
void draw();
void addCheckedInVisitor(CheckedInVisitor checkedInVisitors);
CheckedInVisitor getCheckedInVisitorAt(int i);
private:
vector<CheckedInVisitor*> checkedInVisitors;
int rows;
};
+2 -14
View File
@@ -1,21 +1,9 @@
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main() {
//ofSetupOpenGL(3840,1200, OF_WINDOW); // <-------- setup the GL context
ofGLFWWindowSettings settings;
settings.setGLVersion(3, 2);
settings.setSize(3840, 1200);
settings.decorated = false;
ofCreateWindow(settings);
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofSetupOpenGL(2000, 2000, OF_WINDOW);
ofRunApp(new ofApp());
}
-337
View File
@@ -1,337 +0,0 @@
//
// objectPhysics.cpp
// particle_combined
//
// Created by Sebastian Holzki on 11.06.19.
//
#include "objectPhysics.hpp"
ObjectPhysics::ObjectPhysics(){
emitting = 0;
attracting = 0;
isAVisitorObject = false;
age = 0;
};
// -----------------------------------
ObjectPhysics::~ObjectPhysics()
{
};
// -----------------------------------
void ObjectPhysics::update(float deltaT){
aging(deltaT);
}
// -----------------------------------
void ObjectPhysics::setPosition(float x, float y){
position.set(x,y);
}
// -----------------------------------
void ObjectPhysics::setPosition(ofVec2f _position){
position = _position;
}
// -----------------------------------
ofVec2f ObjectPhysics::getPosition(){
return position;
}
// -----------------------------------
float ObjectPhysics::getAge(){
return age;
}
// -----------------------------------
void ObjectPhysics::setIsVisitor(bool isVisitor){
isAVisitorObject = isVisitor;
}
// -----------------------------------
bool ObjectPhysics::getIsVisitorObject(){
return isAVisitorObject;
}
// -----------------------------------
void ObjectPhysics::setEmitting(bool _emitting){
emitting = _emitting;
}
// -----------------------------------
void ObjectPhysics::setAttracting(bool _attracting){
attracting = _attracting;
}
// -----------------------------------
void ObjectPhysics::aging(float deltaT){
if(agingEnabled){
age += deltaT;
}
}
// ----------------------------------------------------------------------
// *** ATTRAKTORS *** ATTRAKTORS *** ATTRAKTORS *** ATTRAKTORS ***
// ----------------------------------------------------------------------
Attraktor::Attraktor(){
emitting = false;
attracting = true;
agingEnabled = false;
type = "attraktor";
cout << "Attraktor Konstruktor" << endl;
};
// -----------------------------------
Attraktor::Attraktor(float x, float y){
emitting = false;
attracting = true;
type = "attraktor";
position.set(x,y);
cout << "Attraktor Konstruktor überladen" << endl;
};
// -----------------------------------
Attraktor::Attraktor(ofVec2f _position){
emitting = false;
attracting = true;
type = "attraktor";
position.set(_position);
// cout << "Attraktor Konstruktor überladen (ofVec2f position)" << endl;
};
// -----------------------------------
Attraktor::~Attraktor(){
cout << "Attraktor Destruktor" << endl;
};
// ----------------------------------------------------------------------
// *** EMITTERS *** EMITTERS *** EMITTERS *** EMITTERS ***
// ----------------------------------------------------------------------
Emitter::Emitter(){
emitting = true;
attracting = false;
type = "emitter";
};
// -----------------------------------
Emitter::Emitter(float _x, float _y){
emitting = true;
attracting = false;
type = "emitter";
position.set(_x,_y);
};
// -----------------------------------
Emitter::Emitter(ofVec2f _position){
emitting = true;
attracting = false;
type = "emitter";
position.set(_position);
};
// -----------------------------------
Emitter::~Emitter(){
};
// ------------------------------------------------------------------
// *** EMITTER ON STELE *** EMITTER ON STELE *** EMITTER ON STELE ***
// ------------------------------------------------------------------
EmitterOnStele::EmitterOnStele(){
emitting = true;
attracting = false;
agingEnabled = true;
type = "emitterOnStele";
};
// -----------------------------------
EmitterOnStele::EmitterOnStele(float _x, float _y, bool _aging){
emitting = true;
attracting = false;
agingEnabled = _aging;
type = "emitterOnStele";
position.set(_x,_y);
};
// -----------------------------------
EmitterOnStele::EmitterOnStele(ofVec2f _position, bool _aging){
emitting = true;
attracting = false;
agingEnabled = _aging;
type = "emitterOnStele";
position.set(_position);
};
// -----------------------------------
EmitterOnStele::~EmitterOnStele(){
};
// -----------------------------------
// *** ATTRAKTOR ON STELE ***
// -----------------------------------
AttraktorOnStele::AttraktorOnStele(){
emitting = false;
attracting = true;
type = "attraktorStele";
};
// -----------------------------------
AttraktorOnStele::AttraktorOnStele(float x, float y){
emitting = false;
attracting = true;
type = "attraktorStele";
position.set(x,y);
// cout << "AttraktorStele Konstruktor überladen" << endl;
};
// -----------------------------------
AttraktorOnStele::AttraktorOnStele(ofVec2f _position){
emitting = false;
attracting = true;
type = "attraktorStele";
position.set(_position);
// cout << "Attraktor Konstruktor überladen (ofVec2f position)" << endl;
};
// -----------------------------------
AttraktorOnStele::~AttraktorOnStele(){
cout << "AttraktorStelen Destruktor" << endl;
};
// -----------------------------------
-139
View File
@@ -1,139 +0,0 @@
//
// objectPhysics.hpp
// emptyExample
//
// Created by Sebastian Holzki on 01.05.19.
//
#pragma once
#include <stdio.h>
#include "ofMain.h"
class ObjectPhysics {
public:
ObjectPhysics();
~ObjectPhysics();
void update(float deltaT);
void setPosition(float x, float y);
void setPosition(ofVec2f position);
ofVec2f getPosition();
void setEmitting(bool emitting);
void setAttracting(bool attracting);
void setIsVisitor(bool isVisitor);
bool getIsVisitorObject();
bool isAVisitorObject;
void aging(float deltaT);
string type;
ofVec2f position;
bool emitting; //if true: Particles will emit from the position
bool attracting; //if true: Particles will be attracted to the position
bool repell; //if true: Particles will be repelled from the position
bool agingEnabled;
float getAge();
float age;
protected:
float force;
float vel;
};
// ******* ATTRAKTOR ******* ATTRAKTOR ******* ATTRAKTOR ******* ATTRAKTOR ******* ATTRAKTOR *******
class Attraktor: public ObjectPhysics {
public:
Attraktor();
Attraktor(float x, float y);
Attraktor(ofVec2f position);
~Attraktor();
private:
};
// ******* EMITTER ******* EMITTER ******* EMITTER ******* EMITTER ******* EMITTER ******* EMITTER *******
class Emitter: public ObjectPhysics {
public:
Emitter();
Emitter(float x, float y);
Emitter(ofVec2f position);
~Emitter();
private:
};
// *** EMITTER ON STELE *** EMITTER ON STELE *** EMITTER ON STELE ***
class EmitterOnStele: public ObjectPhysics {
public:
EmitterOnStele();
EmitterOnStele(float x, float y, bool aging);
EmitterOnStele(ofVec2f position, bool aging);
~EmitterOnStele();
private:
};
// ******* ATTRAKTOR STELEN ******* ATTRAKTOR STELEN ******* ATTRAKTOR STELEN ******* ATTRAKTOR STELEN ******* ATTRAKTOR STELEN *******
class AttraktorOnStele: public ObjectPhysics {
public:
AttraktorOnStele();
AttraktorOnStele(float x, float y);
AttraktorOnStele(ofVec2f position);
~AttraktorOnStele();
private:
};
+193 -1201
View File
File diff suppressed because it is too large Load Diff
+31 -167
View File
@@ -1,199 +1,63 @@
#pragma once
//addons
#include "ofMain.h"
#include "particle.h"
#include "ofxOsc.h"
#include "ofxWarp.h"
//headers
//#include "ofMain.h"
#include "particleSystem.hpp"
#include "greatWhole.hpp"
#include "visitor.hpp"
#include "objectPhysics.hpp"
// #include "particle.hpp"
// *** SETUP OSC INFORMATION *** SETUP OSC INFORMATION ***
#include "ofxGui.h"
//OSC Reciever PORT & HOST IP
#define PORT 12345
//#define HOST "192.168.178.52"
//typeOfView will be used, to toggle between the views of the logical scene and the scene after all the particles have been mapped
//enum typeOfView{
// LOGIC,
// MAPPED
//};
//
#define HOST "172.20.10.2"
class ofApp : public ofBaseApp {
public:
void setup();
void setupWarpStuff();
void update();
void draw();
void reset();
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);
void drawMappedScene(float x, float y);
void drawLogicalScene(float x, float y);
int getTypeForCheckin(float x);
int getSteleForCheckin(float x);
void drawGrid(float sceneWidth, float sceneHeight, int columns, int rows);
void drawStelen(float sceneWidth, float sceneHeight);
int getBeginOfVisitorsInObjectPhysics();
void refreshCoordinatesOfVisitorAttraktors(int beginOfVisitorsInObjectPhysicsVector, float sceneHeight);
ofImage logicalBackground;
typeOfView activeTypeOfView;
bool listeningForStelenInput;
CheckedInVisitor checkedInVisitor;
//global mode for the whole scene; particles & particlesystem & objectPhysics will know about this!
particleMode currentMode;
//shall be used for checking if there has be a Change in the mode,
//to be able to generate stuff in the update method without generating it in every iteration
particleMode lastMode;
//mode for setting a Mode only for one or more particular system(s)
particleMode particularMode;
string getCurrentModeAsString();
bool currentModeHasChanged;
ofxXmlSettings xmlForSetup;
ofxXmlSettings xmlSettings;
// *** MAGIC INSIDE *** MAGIC INSIDE *** MAGIC INSIDE ***
vector<ObjectPhysics*> objectPhysics;
vector<ParticleSystem*> particleSystems;
vector<Visitor*> visitors;
vector<CheckedInVisitor*> checkedInVisitors;
//important stuff that regulates, whether a tornado can be triggered or not.
//tornadoIsPossible will be set false after the tornado has been triggered
//tornadoIsPossible will be set true after some time has passed
bool tornadoIsPossible;
float tornadoTimer;
// *** GLOBALS *** GLOBALS *** GLOBALS *** GLOBALS ****
//Changes in the scene can done with these
//We should load these coordinates in the ofApp/setup() depending on the rendered scene, maybe via xml?
ofVec2f centerOfScene;
ofVec2f stele1_bottom;
ofVec2f stele1_top;
ofVec2f stele2_bottom;
ofVec2f stele2_top;
ofVec2f stele3_bottom;
ofVec2f stele3_top;
ofVec2f stele4_bottom;
ofVec2f stele4_top;
ofVec2f stele5_bottom;
ofVec2f stele5_top;
ofVec2f stele6_bottom;
ofVec2f stele6_top;
//Supervision can be done with these
int COUNT_PARTICLES;
//+1 for every new Particle, -1 for every Particle that gets older than the defined maxLife
int COUNT_VISITORS;
//the visitor count will be fed with the nBlobs-value from incoming OSC messages
int COUNT_VISITORS_LASTFRAME;
int COUNT_PARTICLESYSTEMS;
int COUNT_OBJECTPHYSICS;
int COUNT_CHECKEDINVISITORS;
//OSC Buffer (we will store the information here and wait for the "go" (checkin) message to use it)
int stele;
int playerType;
float timerAfterCheckin;
string oscMsg;
ofxOscReceiver receiver;
ofxXmlSettings default;
ofxXmlSettings attractor;
ofxXmlSettings rain;
ofxXmlSettings brunig;
private:
// *** MAPPING *** MAPPING *** MAPPING *** MAPPING *** MAPPING ***
ofxWarpController warpControllerCircle;
ofxWarpController warpControllerStele1;
ofxWarpController warpControllerStele2;
ofxWarpController warpControllerStele3;
ofFbo fbo_warp;
ofVec2f sceneSizeWarp;
int sceneWidth;
int sceneHeight;
int sceneHeightLastFrame;
// *** OSC *** OSC *** OSC *** OSC *** OSC ***
// OSC Receiver
particleMode currentMode;
string currentModeDisp;
string oscMsg;
ofxOscReceiver receiver;
float timeSent, timeReceived;
int nBlobs;
int blobCount;
int num;
float history;
ofFbo fbo;
float deltaT;
float xOfCentroid;
float yOfCentroid;
vector<Particle*> system;
vector<Particle>sys;
vector<Attractor*> attractors;
GreatWhole dasGrosseGanze;
int WINDOWSIZE_WIDTH = 1000;
int WINDOWSIZE_HEIGHT = 1000;
float birthCount;
double time;
bool varSystem;
bool trails;
int w;
int h;
};
+187 -504
View File
@@ -1,555 +1,238 @@
//
// particle.cpp
// emptyExample
//
// Created by Sebastian Holzki on 16.04.19.
// particleSystem
//
#include "particle.hpp"
#include "particle.h"
#include "ofApp.h"
Particle::Particle()
{
// std::cout << "partikel konstruktor" << std::endl;
uniqueVal = ofRandom(-10000, 10000);
}
// -----------------------------------
//--------------------------------------------------------------------------------------
Particle::Particle(ofVec2f _position)
{
position = _position;
// std::cout << "partikel konstruktor überladen" << std::endl;
}
// -----------------------------------
Particle::~Particle()
{
}
// -----------------------------------
void Particle::setup(ofVec2f _position, float sceneHeight){
this->position = _position;
velocity.set(0,0);
void Particle::setup(particleMode newMode) {
mode = newMode;
age = 0.0;
maxLife = 25.0;
color.set(ofRandom(100,150),ofRandom(100,150),ofRandom(20,255));
size = 1.5;
mass = 100;
activeSlowingDown = 0;
factorOfSlowingDown = 0.3;
activeSpeedingUp = factorOfSlowingDown;
factorOfSpeedingUp = 1;
scaleFactorPerDeltaT = 0.002;
distanceToCenter = 0;
angleToCenter = 0;
aging = true;
particleIsOnGround = isTheSetupPositionOnTheGround(position, sceneHeight);
maxLife = 10.0;
frc = ofVec2f(0, 0);
size = ofRandom(1, 1);
size = .5;
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();
}
// -----------------------------------
void Particle::update(float deltaT, particleMode currentMode, vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors, float _sceneWidth, float _sceneHeight){
sceneWidth = _sceneWidth;
sceneHeight = _sceneHeight;
//angle and distance calculation to be able to map later
updateAngleToCenter(sceneHeight/2, sceneHeight/2); //updates the angle of the particle in relation to the center of the logical scene
updateDistanceToCenter(sceneHeight/2, sceneHeight/2, sceneHeight); //needs the center of the LED-Floor as reference
switch ( currentMode ) {
case PARTICLE_MODE_DEFAULT: {
//what does the PARTICLE do if the mode is 'PARTICLE_MODE_DEFAULT'
if(currentMode != lastMode && lastMode == PARTICLE_MODE_POLYMESH){
activeSpeedingUp = factorOfSlowingDown;
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;
}
if(activeSpeedingUp < factorOfSpeedingUp){
//This is helping to make the transition from faster to slower a little smoother
//The particle will be slowed down in every iteration until the "destination"-speed is reached
activeSpeedingUp = activeSpeedingUp + deltaT;
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;
}
attractParticle(objectPhysics, checkedInVisitors);
position += activeSpeedingUp * (velocity * deltaT) ;
aging = true;
if(aging == true){
age += deltaT;
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();
}
break;
}
//------------------------
case PARTICLE_MODE_POLYMESH: {
//what does the PARTICLE do if its mode is 'PARTICLE_MODE_POLYMESH'
if(currentMode != lastMode){
activeSlowingDown = 1;
}
if(activeSlowingDown > factorOfSlowingDown){
//This is helping to make the transition from faster to slower a little smoother
//The particle will be slowed down in every iteration until the "destination"-speed is reached
activeSlowingDown = activeSlowingDown - deltaT;
}
position += activeSlowingDown * (velocity * deltaT) ;
aging = true;
if(aging == true){
age += deltaT;
}
break;
}
//------------------------
case PARTICLE_MODE_TORNADO: {
//what does the PARTICLE do if the mode is 'PARTICLE_MODE_TORNADO'
break;
}
//------------------------
case PARTICLE_MODE_RFID: {
//what does the PARTICLE do if its mode is 'PARTICLE_MODE_RFID'
if(currentMode != lastMode && lastMode == PARTICLE_MODE_POLYMESH){
activeSpeedingUp = factorOfSlowingDown;
}
if(activeSpeedingUp < factorOfSpeedingUp){
//This is helping to make the transition from faster to slower a little smoother
//The particle will be slowed down in every iteration until the "destination"-speed is reached
activeSpeedingUp = activeSpeedingUp + deltaT;
}
position += activeSpeedingUp * (velocity * deltaT) ;
size += scaleFactorPerDeltaT * deltaT ;
aging = true;
if(aging == true){
age += deltaT;
}
break;
}
//------------------------
default: {}
} //end of switch
// *** PARTICLE MOVEMENT CONTROL AREA *** PARTICLE MOVEMENT CONTROL AREA ***
//first we slow down the particle in their y-direction,
if(particleIsOnGround == false){
if(velocity.y < 0 && velocity.y > -0.4){
velocity.y *= 0.995;
}
}
if(distanceToCenter > sceneHeight/4*3){
}
if(particleIsOnGround == false){
if(position.x < (sceneHeight)){
position.x = sceneWidth;
}
else if(position.x >= sceneWidth){
position.x = sceneHeight;
}
}
size += scaleFactorPerDeltaT * age ;
lastMode = currentMode;
}
// -----------------------------------
void Particle::draw(typeOfView activeTypeOfView){
updateColor();
ofSetColor(color);
ofSetCircleResolution(10);
mapParticle(sceneWidth, sceneHeight);
ofDrawCircle(position, size);
if(activeTypeOfView == MAPPED){
ofDrawBitmapString(distanceToCenter, position);
}
ofSetCircleResolution(35);
}
//-----------------------------------
float Particle::getMaxLife(){
return maxLife;
}
//-----------------------------------
float Particle::getAngle(){
return angleToCenter;
}
//-----------------------------------
ofVec2f Particle::getPosition(){
return position;
}
//-----------------------------------
void Particle::setRandomVelocity(){
velocity.set(ofRandom(-50,50), ofRandom(-50,50));
}
//-----------------------------------
void Particle::setRandomVelocityOnlyGoingUp(){
velocity.set(ofRandom(-50,50), ofRandom(-50,-1));
}
//-----------------------------------
void Particle::updateColor(){
if(getAgeNorm() >= 1){
color.set(69 + getAgeNorm() * 104, 164 - getAgeNorm() * 95 , 220, (color , 0));
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 {
color.set(69 + getAgeNorm() * 104, 164 - getAgeNorm() * 95 , 220, (color, (1 - getAgeNorm()) * 255 ));
}
drag = ofRandom(0.95, 0.998);
}
//-----------------------------------
tex.load("img/br.png");
}
void Particle::attractParticle(vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors){
//--------------------------------------------------------------------------------------
if(particleIsOnGround == true){
void Particle::update(float deltaT, vector<Attractor*>* attractors,vector<Particle*> system) {
if (mode == PARTICLE_MODE_DEFAULT) {
for(int i = 0; i < objectPhysics->size(); i++){
}
else if (mode == PARTICLE_MODE_RAIN) {
float wind = ofSignedNoise(pos.x * 0.003, pos.y * 0.006, ofGetElapsedTimef() * 0.6);
if(( (*objectPhysics).at(i)->type == "attraktor" ) && (objectPhysics->at(i)->attracting == true)){
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;
force.set(objectPhysics->at(i)->getPosition() - position);
if(force.length() < 150){
velocity += force.getNormalized() * 40;
}
if(force.length() < 50){
velocity -= force.getNormalized() * 20;
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();
}
}
}
if(particleIsOnGround == false){
for(int i = 0; i < checkedInVisitors->size(); i++){
float ageOfCheckedInVisitor = checkedInVisitors->at(i)->getAge();
if(( ageOfCheckedInVisitor < 30.0 )){
else if (mode == PARTICLE_MODE_DETRACTOR) {
ofVec2f force;
force.set(checkedInVisitors->at(i)->getBottom() - position);
float forceLength = force.length();
if(forceLength < 250){
force = force.getNormalized()* 30 * 4/checkedInVisitors->at(i)->getAge();
velocity += 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::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::updateAngleToCenter(float centerX, float centerY){
//case 1 ( distance =< radius )
ofVec2f center(centerX, centerY);
ofVec2f particleToCenter = position - center;
//Subtraction: (position of particle) - (position of floor center) = vector between center and particle
ofVec2f referenceVector(0, 0.5);
angleToCenter = particleToCenter.getNormalized().angle(referenceVector.getNormalized());
angleToCenter = angleToCenter + 180;
//case 2 ( distance > radius
//--------------------------------------------------------------------------------------
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::updateDistanceToCenter(float centerX, float centerY, float sceneHeight){
distanceToCenterLastFrame = distanceToCenter;
if(particleIsOnGround == true){
ofVec2f centerOfFloor(centerX, centerY);
distanceToCenter = position.distance(centerOfFloor);
}
if(particleIsOnGround == false){
distanceToCenter = sceneHeight/2 + sceneHeight - position.y;
}
if(distanceToCenterLastFrame >= sceneHeight/2 && distanceToCenter < sceneHeight/2){
//was passiert wenn es vorher größer als radius war, dann kleiner
particleJumpedOnGround = true;
}
if(distanceToCenterLastFrame <= sceneHeight/2 && distanceToCenter > sceneHeight/2){
//was passiert wenn es vorher kleiner als radius war, dann größer
particleJumpedOffGround = true;
float Particle::getX() {
return pos.x;
}
}
//-----------------------------------
bool Particle::isTheSetupPositionOnTheGround(ofVec2f _position, float sceneHeight){
ofVec2f centerOfFloor(sceneHeight/2, sceneHeight/2);
distanceToCenter = _position.distance(centerOfFloor);
if(distanceToCenter > (sceneHeight/2)){
return false;
}else{
return true;
}
}
//-----------------------------------
void Particle::mapParticle(float sceneWidth, float sceneHeight){
//The mapping works with the information about the particle's distance to the center and its angle to the center (distanceToCenter, angleToCenter).
//if the particle gets too far away from the center, it will leave the LED-Floor. Then there is a small black gap.
//After that it will hit the "Stelen". The Stelen are represented by a 360degree circle, 40deg for every Stele, 20deg for every black gap in between.
if(particleJumpedOffGround == true){
position.y = sceneHeight - 20;
//sceneWidth noch ändern damit es sich am kreisumfang orientiert
position.x = (sceneHeight + angleToCenter/360 * (sceneWidth - sceneHeight));
position.x += (sceneWidth - sceneHeight)/12 ; //so we dont have 0 deg exactly at the first pixel of the stelen
if(position.x > sceneWidth){
float difference = position.x - sceneWidth;
position.x = sceneHeight + difference;
}
ofVec2f referenceVector(0.0, 1.0); //will be used to get an angle of the velocityvector
referenceVector.getNormalized();
float lotAmKreisZuAustrittspunkt;
if(angleToCenter < 90){
lotAmKreisZuAustrittspunkt = 270 - angleToCenter;
}
if(angleToCenter >= 90){
lotAmKreisZuAustrittspunkt = angleToCenter - 90;
}
float velocityAngleZuReference = velocity.angle(referenceVector);
// velocity = velocity.rotate(270 - lotAmKreisZuAustrittspunkt);
float k = velocity.length();
velocity.set(0, -k);
particleJumpedOffGround = false;
// cout << "particleJumpedOffGround" << endl;
}
if(particleJumpedOnGround == true){
//Vorerst nicht implementiert
// particleJumpedOnGround = false;
}
if(distanceToCenter > sceneHeight/2){
particleIsOnGround = false;
}else if(distanceToCenter <= sceneHeight/2){
particleIsOnGround = true;
}
//setze bei übertritt einmal y auf sceneHeight
//setze x genau auf angle/360 * sceneWidth
//setze velocity neu mit weg über gedrehtes lot (siehe blatt)
//führe berechnung normal weiter aus
//correcting the velocity to the new way it is going to be displayed
}
+29 -8
View File
@@ -1,33 +1,54 @@
#pragma once
#include "ofMain.h"
#include "ofxXmlSettings.h"
#include "attractor.h"
#include "line.h"
class Particle
{
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();
~Particle();
void setup(ofVec2f position);
void setup(particleMode newMode);
void update(float deltaT, vector<Attractor*>* attractors);
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();
private:
ofxXmlSettings effect;
int counterOfActiveAttractors;
ofVec2f vel;
ofVec2f position;
ofVec2f pos;
ofVec2f frc;
float scale;
float drag;
float uniqueVal;
float maxLife;
float age;
-117
View File
@@ -1,117 +0,0 @@
//
// particle.hpp
//
// Created by Sebastian Holzki on 16.04.19.
//
#pragma once
#include <stdio.h>
#include "ofMain.h"
#include "objectPhysics.hpp"
#include "visitor.hpp"
#include "checkedInVisitor.hpp"
enum typeOfView{
LOGIC,
MAPPED
};
enum particleMode{
PARTICLE_MODE_DEFAULT,
PARTICLE_MODE_POLYMESH,
PARTICLE_MODE_RFID,
PARTICLE_MODE_TORNADO
};
class Particle {
public:
Particle();
Particle(ofVec2f _position);
~Particle();
void setup(ofVec2f position, float sceneHeight);
bool isTheSetupPositionOnTheGround(ofVec2f position, float sceneHeight);
void update(float deltaT, particleMode currentModeParticle, vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors, float sceneWidth, float sceneHeight);
void draw(typeOfView activeTypeOfView);
float getMaxLife();
float getAgeNorm();
float getAngle();
ofVec2f getPosition();
void setRandomVelocity();
void setRandomVelocityOnlyGoingUp();
void updateColor();
// void setColor(int r, int g, int b);
void attractParticle(vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors);
void updateAngleToCenter(float centerX, float centerY);
void updateDistanceToCenter(float centerX, float centerY, float sceneHeight);
bool particleIsOnGround;
bool particleJumpedOffGround;
bool particleJumpedOnGround;
void mapParticle(float sceneWidth, float sceneHeight);
bool borderCollission();
typeOfView activeTypeOfView;
particleMode currentMode;
particleMode lastMode;
float sceneWidth;
float sceneHeight;
private:
ofVec2f velocity;
ofVec2f position;
ofVec2f mappedPosition;
float factorOfSlowingDown;
float activeSlowingDown;
float factorOfSpeedingUp;
float activeSpeedingUp;
//Mapping information
float angleToCenter;
float distanceToCenter;
float distanceToCenterLastFrame;
float age;
float maxLife;
bool aging;
float size;
float scaleFactorPerDeltaT;
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
};
-305
View File
@@ -1,305 +0,0 @@
//
// particleSystem.cpp
// emptyExample
//
// Created by Sebastian Holzki on 16.04.19.
//
#include "particleSystem.hpp"
ParticleSystem::ParticleSystem(){
}
// -----------------------------------
ParticleSystem::~ParticleSystem(){
}
// -----------------------------------
void ParticleSystem::setup(){
// xmlParticleSystems.loadFile("xml/particleSystem.xml");
// this->particles.push_back(new Particle);
// std::cout << "breakpoint particleSystem_1 erreicht, particleSystem_setup beendet" << std::endl;
}
// -----------------------------------------------
//*** PARTICLESYSTEM UPDATE *** PARTICLESYSTEM UPDATE *** PARTICLESYSTEM UPDATE *** PARTICLESYSTEM UPDATE ***
void ParticleSystem::update(float deltaT, particleMode currentMode, vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors, float sceneWidth, float sceneHeight){
//preparation
double DELTA_T_IN_SECONDS = deltaT/1000;
this->currentMode = currentMode;
// *** PARTICLESYSTEM SWITCH *** PARTICLESYSTEM SWITCH *** PARTICLESYSTEM SWITCH *** PARTICLESYSTEM SWITCH ***
//If the particlesystem itself needs some logic, it will happen in the following switch!
switch ( currentMode )
{
case PARTICLE_MODE_DEFAULT: {
//what does the particle system do if its mode is 'PARTICLE_MODE_DEFAULT'
// value a = xmlParticleSystems.getValue (" default:..." , 0 ) ;
// value b = xmlParticleSystems.getValue (" default:..." , 0 ) ;
// value c = xmlParticleSystems.getValue (" default:..." , 0 ) ;
// value d = xmlParticleSystems.getValue (" default:..." , 0 ) ;
// value e ....
// ...
// PARTICLESYSTEM_BIRTHRATE = xmlParticleSystems.getValue("default:birthrate", 0);
PARTICLESYSTEM_BIRTHRATE = 1; //testing default
// std::cout << "birthrate from xml: " + ofToString(PARTICLESYSTEM_BIRTHRATE) << std::endl;
break;
}
//------------------------
case PARTICLE_MODE_POLYMESH: {
//what does the particle system do if its mode is 'PARTICLE_MODE_POLYMESH'
PARTICLESYSTEM_BIRTHRATE = 0;
updateLines(currentMode, objectPhysics);
// PARTICLESYSTEM_BIRTHRATE = xmlParticleSystems.getValue("polymesh:birthrate", 0);
int PARTICLESYSTEM_BIRTHRATE_CHECKEDINVISITORS = 4;
while (PRODUCED_PER_EMITTER < PARTICLESYSTEM_BIRTHRATE_CHECKEDINVISITORS){
for(int i = 0; i < checkedInVisitors->size(); i++){
if( checkedInVisitors->at(i)->getAge() <= 7){
this->particles.push_back(new Particle);
particles.back()->setup(checkedInVisitors->at(i)->getBottom(), sceneHeight);
particles.back()->setRandomVelocityOnlyGoingUp();
}
}
PRODUCED_PER_EMITTER++;
}
PRODUCED_PER_EMITTER = 0;
break;
}
//------------------------
case PARTICLE_MODE_RFID: {
//what does the particle system do if its mode is 'PARTICLE_MODE_RFID'
while (PRODUCED_PER_EMITTER < PARTICLESYSTEM_BIRTHRATE){
for(int i = 0; i < checkedInVisitors->size(); i++){
if( checkedInVisitors->at(i)->getAge() <= 5){
this->particles.push_back(new Particle);
particles.back()->setup(checkedInVisitors->at(i)->getBottom(), sceneHeight);
particles.back()->setRandomVelocityOnlyGoingUp();
}
}
PRODUCED_PER_EMITTER++;
}
PRODUCED_PER_EMITTER = 0;
break;
}
//------------------------
default: {
//following two lines only help for compiling right now
int a = 0;
a++;
}
} //end of switch
// std::cout << "breakpoint particleSystem_2 erreicht, switch anweisung beendet" << std::endl;
// *** BIRTH CONTROL *** BIRTH CONTROL *** BIRTH CONTROL ***
//the system will emit a new particle for every emitter, as long as the PRODUCED_PER_EMITTER is smaller than the wanted BIRTHRATE
//PPE is growing until it reaches deltaT, so the while statement will be executed more often, if deltaT gets bigger
//as long as the birthcount grows and is lower then the birthrate (depending on the mode (XML) ) it will emit once for every emitter
//that is active (bool emitting = true)
while (PRODUCED_PER_EMITTER < PARTICLESYSTEM_BIRTHRATE){
for(int i = 0; i < objectPhysics->size(); i++){
// if(( (*objectPhysics).at(i)->type == "emitter" ) && (objectPhysics->at(i)->emitting == true)){
if( objectPhysics->at(i)->emitting == true){
this->particles.push_back(new Particle);
particles.back()->setup(objectPhysics->at(i)->getPosition(), sceneHeight);
if(objectPhysics->at(i)->type == "emitterOnStele"){
particles.back()->setRandomVelocityOnlyGoingUp();
}else{
particles.back()->setRandomVelocity();
}
}
}
PRODUCED_PER_EMITTER++;
}
PRODUCED_PER_EMITTER = 0;
// *** PARTICLE SYSTEM UPDATING ITS PARTICLES *** *** PARTICLE SYSTEM UPDATING ITS PARTICLES *** PARTICLE SYSTEM UPDATING ITS PARTICLES ***
//for "alle partikel im system" update in abhängigkeit vom übergebenen "mode"
//The following lines will start working, when Particle::update has been reworked is active and particleMode implemented
for (int p = 0; p < particles.size(); p++){
particles.at(p)->update(deltaT, currentMode, objectPhysics, checkedInVisitors, sceneWidth, sceneHeight);
//Delete particles that reached maxAge
if(currentMode != PARTICLE_MODE_POLYMESH){
if (particles.at(p)->getAgeNorm() > 1) {
delete particles.at(p);
particles.erase(particles.begin() + p);
}
}
}
}
// -----------------------------------------------
void ParticleSystem::draw(typeOfView activeTypeOfView){
for(int i = 0; i < particles.size(); i++){
particles.at(i)->draw(activeTypeOfView);
}
if( currentMode == PARTICLE_MODE_POLYMESH){
for(int i = 0; i < lines.size(); i++){
ofDrawLine(lines.at(i)->point1, lines.at(i)->point2);
}
}
}
// -----------------------------------------------
void ParticleSystem::updateLines(particleMode currentMode, vector<ObjectPhysics*>* objectPhysics){
lines.clear();
if(currentMode == PARTICLE_MODE_POLYMESH){
for(int i = 0; i < objectPhysics->size(); i++){
if(( (*objectPhysics).at(i)->type == "attraktor" ) && (objectPhysics->at(i)->attracting == true)){
for(int p = 0; p < particles.size(); p++){
if(particles.at(p)->particleIsOnGround==true){
ofVec2f distance = particles.at(p)->getPosition() - objectPhysics->at(i)->getPosition();
if(distance.length() < 150){
lines.push_back(new Line(particles.at(p)->getPosition(), objectPhysics->at(i)->getPosition()));
for(int p2 = 0; p2 < particles.size(); p2++){
ofVec2f distance = particles.at(p)->getPosition() - particles.at(p2)->getPosition();
if(distance.length() < 50){
lines.push_back(new Line(particles.at(p)->getPosition(), particles.at(p2)->getPosition()));
}
p2 += 4; //lower value -> worse performance & nicer effect (more connections between the particles)
}
}
// p += 2 ; //if your system shows performance issues you might need to activate this line! (downside: effect seems to jump)
}
} //end of for schleife
}
}
}
}
-85
View File
@@ -1,85 +0,0 @@
//
// particleSystem.hpp
// emptyExample
//
// Created by Sebastian Holzki on 16.04.19.
//
#pragma once
#include <stdio.h>
#include "ofxXmlSettings.h"
#include "particle.hpp"
#include "objectPhysics.hpp"
#include "checkedInVisitor.hpp"
//class Line will be used to draw the polymesh
class Line {
public:
Line();
Line(ofPoint p1, ofPoint p2){
point1 = p1;
point2= p2;
};
~Line();
ofPoint point1;
ofPoint point2;
};
class ParticleSystem {
public:
ParticleSystem();
~ParticleSystem();
void setup();
void update(float deltaT, particleMode mode, vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors, float sceneWidth, float sceneHeight);
void draw(typeOfView activeTypeOfView);
void updateLines(particleMode currentMode, vector<ObjectPhysics*>* objectPhysics);
particleMode currentMode;
ofxXmlSettings xmlParticleSystems;
ofxXmlSettings xmlParticles; // ??? wo soll das hin ???
vector<Particle*> particles;
vector<Line*> lines;
private:
int playerType;
//Global for particleSystems-birthrate -> can be used to emit faster/slower
int PARTICLESYSTEM_BIRTHRATE;
int PRODUCED_PER_EMITTER;
};
-171
View File
@@ -1,171 +0,0 @@
//
// visitor.cpp
// particle_combined
//
// Created by Sebastian Holzki on 11.06.19.
//
#include "visitor.hpp"
Visitor::Visitor()
{
// ofRunApp.VISITOR_COUNT++;
std::cout << "Konstruktor visitor" << std::endl;
}
// -----------------------------------
Visitor::~Visitor()
{
}
// -----------------------------------
void Visitor::setup(){
}
// -----------------------------------------------
void Visitor::setup(float _x, float _y){
position.x = _x;
position.y = _y;
}
// -----------------------------------------------
void Visitor::update(){
}
// -----------------------------------------------
void Visitor::draw(){
}
// -----------------------------------------------
ofVec2f Visitor::getPosition(){
return position;
}
// -----------------------------------------------
float Visitor::getX(){
return position.x;
}
// -----------------------------------------------
float Visitor::getY(){
return position.y;
}
// -----------------------------------------------
void Visitor::setPosition(float _x, float _y){
position.x = _x;
position.y = _y;
}
// -----------------------------------------------
void Visitor::setPosition(ofVec2f _position){
position = _position;
}
// -----------------------------------------------
void Visitor::setX(float _x){
position.x = _x;
}
// -----------------------------------------------
void Visitor::setY(float _y){
position.y = _y;
}
-48
View File
@@ -1,48 +0,0 @@
//
// visitor.hpp
// particle_combined
//
// Created by Sebastian Holzki on 11.06.19.
//
#pragma once
#include <stdio.h>
#include "ofMain.h"
class Visitor {
public:
Visitor();
~Visitor();
void setup();
void setup(float _x, float _y);
void update();
void draw();
//GETTERS
ofVec2f getPosition();
float getX();
float getY();
//SETTERS
void setPosition(float x, float y);
void setPosition(ofVec2f position);
void setX(float _x);
void setY(float _y);
private:
ofVec2f position;
};