upload
This commit is contained in:
parent
d0c0781a0c
commit
593471a901
337
src/objectPhysics.cpp
Normal file
337
src/objectPhysics.cpp
Normal file
@ -0,0 +1,337 @@
|
||||
//
|
||||
// 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
src/objectPhysics.hpp
Normal file
139
src/objectPhysics.hpp
Normal file
@ -0,0 +1,139 @@
|
||||
//
|
||||
// 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:
|
||||
|
||||
|
||||
};
|
||||
|
1280
src/ofApp.cpp
1280
src/ofApp.cpp
File diff suppressed because it is too large
Load Diff
185
src/ofApp.h
185
src/ofApp.h
@ -1,44 +1,199 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "particle.h"
|
||||
//addons
|
||||
#include "ofxOsc.h"
|
||||
#include "ofxGui.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 ***
|
||||
|
||||
//OSC Reciever PORT & HOST IP
|
||||
#define PORT 12345
|
||||
#define HOST "172.20.10.2"
|
||||
//#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
|
||||
//};
|
||||
//
|
||||
|
||||
class ofApp : public ofBaseApp{
|
||||
|
||||
public:
|
||||
|
||||
void setup();
|
||||
void setupWarpStuff();
|
||||
|
||||
void update();
|
||||
void draw();
|
||||
|
||||
void keyPressed(int key);
|
||||
void keyReleased(int key);
|
||||
void mouseMoved(int x, int y);
|
||||
void mouseDragged(int x, int y, int button);
|
||||
void mousePressed(int x, int y, int button);
|
||||
void mouseReleased(int x, int y, int button);
|
||||
void mouseEntered(int x, int y);
|
||||
void mouseExited(int x, int y);
|
||||
void windowResized(int w, int h);
|
||||
void dragEvent(ofDragInfo dragInfo);
|
||||
void gotMessage(ofMessage msg);
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
|
||||
// OSC Receiver
|
||||
|
||||
string oscMsg;
|
||||
ofxOscReceiver receiver;
|
||||
|
||||
|
||||
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 ***
|
||||
|
||||
|
||||
float timeSent, timeReceived;
|
||||
|
||||
int nBlobs;
|
||||
int blobCount;
|
||||
|
||||
float xOfCentroid;
|
||||
float yOfCentroid;
|
||||
float deltaT;
|
||||
|
||||
|
||||
GreatWhole dasGrosseGanze;
|
||||
|
||||
int WINDOWSIZE_WIDTH = 1000;
|
||||
int WINDOWSIZE_HEIGHT = 1000;
|
||||
|
||||
vector<thParticle*> system;
|
||||
vector<Attractor*> attractors;
|
||||
float birthCount;
|
||||
double time;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
581
src/particle.cpp
581
src/particle.cpp
@ -1,148 +1,555 @@
|
||||
|
||||
//
|
||||
// particle.cpp
|
||||
// particleSystem
|
||||
// emptyExample
|
||||
//
|
||||
// Created by Sebastian Holzki on 16.04.19.
|
||||
//
|
||||
|
||||
#include "particle.h"
|
||||
#include "ofApp.h"
|
||||
#include "particle.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
Particle::Particle()
|
||||
{
|
||||
|
||||
// std::cout << "partikel konstruktor" << std::endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
Particle::Particle(ofVec2f _position)
|
||||
{
|
||||
|
||||
position = _position;
|
||||
|
||||
|
||||
|
||||
// std::cout << "partikel konstruktor überladen" << std::endl;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
Particle::~Particle()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// -----------------------------------
|
||||
|
||||
|
||||
void Particle::setup(ofVec2f _position) {
|
||||
|
||||
void Particle::setup(ofVec2f _position, float sceneHeight){
|
||||
|
||||
this->position = _position;
|
||||
|
||||
vel.set(ofRandom(-3.0, 3.0), ofRandom(-3.0, 3.0));
|
||||
|
||||
velocity.set(0,0);
|
||||
age = 0.0;
|
||||
maxLife = 12.0;
|
||||
maxLife = 25.0;
|
||||
|
||||
color.set(250, 250, 250);
|
||||
color.set(ofRandom(100,150),ofRandom(100,150),ofRandom(20,255));
|
||||
size = 1.5;
|
||||
mass = 100;
|
||||
|
||||
size = ofRandom(4.0, 0.01);
|
||||
activeSlowingDown = 0;
|
||||
factorOfSlowingDown = 0.3;
|
||||
|
||||
activeSpeedingUp = factorOfSlowingDown;
|
||||
factorOfSpeedingUp = 1;
|
||||
|
||||
scaleFactorPerDeltaT = 0.002;
|
||||
|
||||
distanceToCenter = 0;
|
||||
angleToCenter = 0;
|
||||
|
||||
aging = true;
|
||||
|
||||
particleIsOnGround = isTheSetupPositionOnTheGround(position, sceneHeight);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
attractParticle(objectPhysics, checkedInVisitors);
|
||||
|
||||
|
||||
position += activeSpeedingUp * (velocity * deltaT) ;
|
||||
|
||||
aging = true;
|
||||
|
||||
if(aging == true){
|
||||
age += deltaT;
|
||||
|
||||
mass = ofRandom(100, 250);
|
||||
|
||||
tex.load("img/overlay.png");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
void Particle::update(float deltaT, vector<Attractor*>* attractors) {
|
||||
|
||||
ofVec2f force;
|
||||
counterOfActiveAttractors = 0;
|
||||
for (int i = 0; i < attractors->size(); i++) {
|
||||
if (attractors->at(i)->getX() == 0 && attractors->at(i)->getY() == 0) {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
break;
|
||||
}
|
||||
|
||||
counterOfActiveAttractors++;
|
||||
force.set(attractors->at(i)->getX() - position.x, attractors->at(i)->getY() - position.y);
|
||||
//------------------------
|
||||
|
||||
if (force.length() < 150) {
|
||||
force = 60 * force.getNormalized();
|
||||
size = size + ofRandom(.01, 0.01);
|
||||
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
case PARTICLE_MODE_POLYMESH: {
|
||||
|
||||
//what does the PARTICLE do if its mode is 'PARTICLE_MODE_POLYMESH'
|
||||
if(currentMode != lastMode){
|
||||
activeSlowingDown = 1;
|
||||
}
|
||||
else {
|
||||
force = 0 * force.getNormalized();
|
||||
vel += force;
|
||||
vel = mass * vel.getNormalized();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
age += deltaT * .5;
|
||||
position += (vel * deltaT);
|
||||
size += scaleFactorPerDeltaT * age ;
|
||||
|
||||
// *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION
|
||||
lastMode = currentMode;
|
||||
|
||||
//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 thParticle::update(float deltaT, ofVec2f attractor){
|
||||
//
|
||||
//
|
||||
// age += deltaT;
|
||||
//
|
||||
// ofVec2f force = attractor - position;
|
||||
// color.set(250,250, 250, (1 - age / maxLife) * 255);
|
||||
//
|
||||
// if( force.length() < 40 && force.length() > 11 ){
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 0.01 * force ;
|
||||
//
|
||||
// }else if(force.length() < 12){
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 5 * force ;
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// velocity = velocity.getNormalized() * mass;
|
||||
// velocity += 0.12 * force ;
|
||||
// }
|
||||
// position += velocity * deltaT;
|
||||
//}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// -----------------------------------
|
||||
|
||||
void Particle::draw() {
|
||||
void Particle::draw(typeOfView activeTypeOfView){
|
||||
|
||||
color.set(getAgeNorm() * 241,241/ getAgeNorm() ,219);
|
||||
|
||||
ofSetColor(color, (1 - getAgeNorm()) * 255);
|
||||
//tex.setColor(color);
|
||||
//tex.draw(position, size, size);
|
||||
updateColor();
|
||||
ofSetColor(color);
|
||||
|
||||
ofSetCircleResolution(10);
|
||||
mapParticle(sceneWidth, sceneHeight);
|
||||
ofDrawCircle(position, size);
|
||||
|
||||
if(activeTypeOfView == MAPPED){
|
||||
ofDrawBitmapString(distanceToCenter, position);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
ofSetCircleResolution(35);
|
||||
|
||||
|
||||
float Particle::getAgeNorm() {
|
||||
return age / maxLife;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//-----------------------------------
|
||||
|
||||
|
||||
float Particle::getMaxLife(){
|
||||
return 1;
|
||||
|
||||
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{
|
||||
color.set(69 + getAgeNorm() * 104, 164 - getAgeNorm() * 95 , 220, (color, (1 - getAgeNorm()) * 255 ));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
void Particle::attractParticle(vector<ObjectPhysics*>* objectPhysics, vector<CheckedInVisitor*>* checkedInVisitors){
|
||||
|
||||
if(particleIsOnGround == true){
|
||||
|
||||
for(int i = 0; i < objectPhysics->size(); i++){
|
||||
|
||||
if(( (*objectPhysics).at(i)->type == "attraktor" ) && (objectPhysics->at(i)->attracting == true)){
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(particleIsOnGround == false){
|
||||
|
||||
for(int i = 0; i < checkedInVisitors->size(); i++){
|
||||
|
||||
float ageOfCheckedInVisitor = checkedInVisitors->at(i)->getAge();
|
||||
|
||||
if(( ageOfCheckedInVisitor < 30.0 )){
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
|
||||
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::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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user