From b11dec47f0788b0c1c3b516c9cd5f9fe14c230d6 Mon Sep 17 00:00:00 2001 From: Tobias Lindner Date: Tue, 9 Apr 2019 14:07:59 +0200 Subject: [PATCH] Upload --- Quelle.cpp | 0 addons.make | 3 + forum_particle.sln | 35 +++++ forum_particle.vcxproj | 273 +++++++++++++++++++++++++++++++++ forum_particle.vcxproj.filters | 252 ++++++++++++++++++++++++++++++ icon.rc | 8 + src/attractor.cpp | 42 +++++ src/attractor.h | 34 ++++ src/main.cpp | 9 ++ src/ofApp.cpp | 151 ++++++++++++++++++ src/ofApp.h | 44 ++++++ src/particle.cpp | Bin 0 -> 3470 bytes src/particle.h | 43 ++++++ 13 files changed, 894 insertions(+) create mode 100644 Quelle.cpp create mode 100644 addons.make create mode 100644 forum_particle.sln create mode 100644 forum_particle.vcxproj create mode 100644 forum_particle.vcxproj.filters create mode 100644 icon.rc create mode 100644 src/attractor.cpp create mode 100644 src/attractor.h create mode 100644 src/main.cpp create mode 100644 src/ofApp.cpp create mode 100644 src/ofApp.h create mode 100644 src/particle.cpp create mode 100644 src/particle.h diff --git a/Quelle.cpp b/Quelle.cpp new file mode 100644 index 0000000..e69de29 diff --git a/addons.make b/addons.make new file mode 100644 index 0000000..b610815 --- /dev/null +++ b/addons.make @@ -0,0 +1,3 @@ +ofxGui +ofxOsc +ofxVectorGraphics diff --git a/forum_particle.sln b/forum_particle.sln new file mode 100644 index 0000000..379ce36 --- /dev/null +++ b/forum_particle.sln @@ -0,0 +1,35 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "forum_particle", "forum_particle.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.Build.0 = Debug|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.ActiveCfg = Debug|x64 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.Build.0 = Debug|x64 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.ActiveCfg = Release|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.Build.0 = Release|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.ActiveCfg = Release|x64 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.Build.0 = Release|x64 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/forum_particle.vcxproj b/forum_particle.vcxproj new file mode 100644 index 0000000..c6eb12d --- /dev/null +++ b/forum_particle.vcxproj @@ -0,0 +1,273 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + $(LatestTargetPlatformVersion) + $(WindowsTargetPlatformVersion) + + + {7FD42DF7-442E-479A-BA76-D0022F99702A} + Win32Proj + forum_particle + + + + Application + Unicode + v141 + + + Application + Unicode + v141 + + + Application + Unicode + true + v141 + + + Application + Unicode + true + v141 + + + + + + + + + + + + + + + + + + + + + bin\ + obj\$(Platform)\$(Configuration)\ + $(ProjectName)_debug + true + true + + + bin\ + obj\$(Platform)\$(Configuration)\ + $(ProjectName)_debug + true + true + + + bin\ + obj\$(Platform)\$(Configuration)\ + false + + + bin\ + obj\$(Platform)\$(Configuration)\ + false + + + + Disabled + EnableFastChecks + %(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGui\src;..\..\..\addons\ofxOsc\libs;..\..\..\addons\ofxOsc\libs\oscpack;..\..\..\addons\ofxOsc\libs\oscpack\src;..\..\..\addons\ofxOsc\libs\oscpack\src\ip;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\posix;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\win32;..\..\..\addons\ofxOsc\libs\oscpack\src\osc;..\..\..\addons\ofxOsc\src;..\..\..\addons\ofxVectorGraphics\libs;..\..\..\addons\ofxVectorGraphics\src + CompileAsCpp + $(IntDir) + OSC_HOST_LITTLE_ENDIAN + + + true + Console + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + + Disabled + EnableFastChecks + %(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGui\src;..\..\..\addons\ofxOsc\libs;..\..\..\addons\ofxOsc\libs\oscpack;..\..\..\addons\ofxOsc\libs\oscpack\src;..\..\..\addons\ofxOsc\libs\oscpack\src\ip;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\posix;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\win32;..\..\..\addons\ofxOsc\libs\oscpack\src\osc;..\..\..\addons\ofxOsc\src;..\..\..\addons\ofxVectorGraphics\libs;..\..\..\addons\ofxVectorGraphics\src + CompileAsCpp + true + $(IntDir) + OSC_HOST_LITTLE_ENDIAN + + + true + Console + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + + false + %(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGui\src;..\..\..\addons\ofxOsc\libs;..\..\..\addons\ofxOsc\libs\oscpack;..\..\..\addons\ofxOsc\libs\oscpack\src;..\..\..\addons\ofxOsc\libs\oscpack\src\ip;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\posix;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\win32;..\..\..\addons\ofxOsc\libs\oscpack\src\osc;..\..\..\addons\ofxOsc\src;..\..\..\addons\ofxVectorGraphics\libs;..\..\..\addons\ofxVectorGraphics\src + CompileAsCpp + true + $(IntDir) + OSC_HOST_LITTLE_ENDIAN + + + false + false + Console + true + true + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + + false + %(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGui\src;..\..\..\addons\ofxOsc\libs;..\..\..\addons\ofxOsc\libs\oscpack;..\..\..\addons\ofxOsc\libs\oscpack\src;..\..\..\addons\ofxOsc\libs\oscpack\src\ip;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\posix;..\..\..\addons\ofxOsc\libs\oscpack\src\ip\win32;..\..\..\addons\ofxOsc\libs\oscpack\src\osc;..\..\..\addons\ofxOsc\src;..\..\..\addons\ofxVectorGraphics\libs;..\..\..\addons\ofxVectorGraphics\src + CompileAsCpp + $(IntDir) + OSC_HOST_LITTLE_ENDIAN + + + false + false + Console + true + true + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {5837595d-aca9-485c-8e76-729040ce4b0b} + + + + + /D_DEBUG %(AdditionalOptions) + /D_DEBUG %(AdditionalOptions) + $(OF_ROOT)\libs\openFrameworksCompiled\project\vs + + + + + + + + + \ No newline at end of file diff --git a/forum_particle.vcxproj.filters b/forum_particle.vcxproj.filters new file mode 100644 index 0000000..3db85e4 --- /dev/null +++ b/forum_particle.vcxproj.filters @@ -0,0 +1,252 @@ + + + + + src + + + src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\ip\win32 + + + addons\ofxOsc\libs\oscpack\src\ip\win32 + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxVectorGraphics\src + + + addons\ofxVectorGraphics\libs + + + src + + + src + + + + + {d8376475-7454-4a24-b08a-aac121d3ad6f} + + + {71834F65-F3A9-211E-73B8-DC85} + + + {4F2A59AF-5F4E-704B-D067-EC13} + + + {645E9533-4DCD-6179-1CDF-CB65} + + + {D91DCA33-6E5D-4481-2AEC-9FBB} + + + {B9DD339A-D93D-92A1-0A2F-4B41} + + + {99ECA1D9-873F-4622-8FC0-FC7B} + + + {D3A98534-1602-4FEF-57A6-6593} + + + {BFB5BB47-98C8-BBCB-3066-1046} + + + {5A029128-EB41-95C5-CBC0-CDED} + + + {79DFDFE2-400B-8654-3675-01A3} + + + {EDACB89C-9768-9551-4D41-B590} + + + {5A7F3658-B06B-DB97-F4E1-DD19} + + + {F615F000-D48C-B1D6-F1C2-6EDD} + + + {B341F552-35C4-7EB6-B3C9-9D96} + + + + + src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxGui\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\src + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\ip + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxOsc\libs\oscpack\src\osc + + + addons\ofxVectorGraphics\src + + + addons\ofxVectorGraphics\libs + + + addons\ofxVectorGraphics\libs + + + src + + + src + + + + + + \ No newline at end of file diff --git a/icon.rc b/icon.rc new file mode 100644 index 0000000..7e26eb3 --- /dev/null +++ b/icon.rc @@ -0,0 +1,8 @@ +// Icon Resource Definition +#define MAIN_ICON 102 + +#if defined(_DEBUG) +MAIN_ICON ICON "icon_debug.ico" +#else +MAIN_ICON ICON "icon.ico" +#endif diff --git a/src/attractor.cpp b/src/attractor.cpp new file mode 100644 index 0000000..4b8b6a2 --- /dev/null +++ b/src/attractor.cpp @@ -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; +} + diff --git a/src/attractor.h b/src/attractor.h new file mode 100644 index 0000000..42c0b79 --- /dev/null +++ b/src/attractor.h @@ -0,0 +1,34 @@ +// +// attractor.h +// particleSystem +// + +#include + + +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; +}; diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..a64314d --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,9 @@ +#include "ofMain.h" +#include "ofApp.h" + +//======================================================================== +int main() { + ofSetupOpenGL(1000, 1000, OF_WINDOW); // <-------- setup the GL context + ofRunApp(new ofApp()); +} + diff --git a/src/ofApp.cpp b/src/ofApp.cpp new file mode 100644 index 0000000..218b3c2 --- /dev/null +++ b/src/ofApp.cpp @@ -0,0 +1,151 @@ +#include "ofApp.h" + +//-------------------------------------------------------------- +void ofApp::setup() { + + //Initialize 8 empty attractrs + for (int i = 0; i < 8; i++) + { + attractors.push_back(new Attractor); + } + + //OSC reciever port setup + receiver.setup(PORT); + + //Black background + ofSetBackgroundColor(0, 0, 0); + + ofSetFrameRate(60); + + birthCount = 0; + + //attractors.at(0)->setup(200, 200); +} + +//-------------------------------------------------------------- +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; + + //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; + } + + + 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() { + + //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; + } + } + + // *** DEBUG INFO *** + + //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); +} + +//-------------------------------------------------------------- +void ofApp::keyPressed(int key) { + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key) { + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y) { + +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button) { + +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button) { + +} + diff --git a/src/ofApp.h b/src/ofApp.h new file mode 100644 index 0000000..8997ec3 --- /dev/null +++ b/src/ofApp.h @@ -0,0 +1,44 @@ +#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 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); + +private: + + // OSC Receiver + + string oscMsg; + ofxOscReceiver receiver; + float timeSent, timeReceived; + + int nBlobs; + int blobCount; + + float xOfCentroid; + float yOfCentroid; + + vector system; + vector attractors; + float birthCount; + double time; + +}; diff --git a/src/particle.cpp b/src/particle.cpp new file mode 100644 index 0000000000000000000000000000000000000000..549dd0fdb4275b267d8946a955e129acf86576e3 GIT binary patch literal 3470 mcmeIuF#!Mo0K%a4Pi+e?h(KY$fB^#r3>YwAz<>b*|A7GwjsO7w literal 0 HcmV?d00001 diff --git a/src/particle.h b/src/particle.h new file mode 100644 index 0000000..c6e3e12 --- /dev/null +++ b/src/particle.h @@ -0,0 +1,43 @@ +#pragma once + +#include "ofMain.h" +#include "attractor.h" + +class thParticle +{ + +public: + + thParticle(); + ~thParticle(); + + void setup(ofVec2f position); + + void update(float deltaT, vector* attractors); + // void update(float deltaT, ofVec2f attractor); + //Partikel wird komplett upgedated (Bewegung, Farbe, etc...) + //deltaT Zeitintervall seit letztem Update + void draw(); //Partikel anzeigen + + float getAgeNorm(); + float getMaxLife(); + ofImage tex; + +private: + + int counterOfActiveAttractors; + + ofVec2f vel; + ofVec2f position; + + float maxLife; + float age; + + float size; + float mass; + + int blobCounterInParticle; + + ofColor color; + +};