|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
// particle.cpp |
|
|
// particle.cpp |
|
|
// particleSystem |
|
|
|
|
|
|
|
|
// emptyExample |
|
|
|
|
|
// |
|
|
|
|
|
// Created by Sebastian Holzki on 16.04.19. |
|
|
// |
|
|
// |
|
|
|
|
|
|
|
|
#include "particle.h" |
|
|
|
|
|
#include "ofApp.h" |
|
|
|
|
|
|
|
|
#include "particle.hpp" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Particle::Particle() |
|
|
Particle::Particle() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// std::cout << "partikel konstruktor" << std::endl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Particle::Particle(ofVec2f _position) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
position = _position; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// std::cout << "partikel konstruktor überladen" << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
// ----------------------------------- |
|
|
|
|
|
|
|
|
Particle::~Particle() |
|
|
Particle::~Particle() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Particle::setup(ofVec2f _position, float sceneHeight){ |
|
|
|
|
|
|
|
|
|
|
|
this->position = _position; |
|
|
|
|
|
|
|
|
|
|
|
velocity.set(0,0); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
// ----------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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::setup(ofVec2f _position) { |
|
|
|
|
|
|
|
|
// ----------------------------------- |
|
|
|
|
|
|
|
|
this->position = _position; |
|
|
|
|
|
|
|
|
void Particle::draw(typeOfView activeTypeOfView){ |
|
|
|
|
|
|
|
|
vel.set(ofRandom(-3.0, 3.0), ofRandom(-3.0, 3.0)); |
|
|
|
|
|
|
|
|
updateColor(); |
|
|
|
|
|
ofSetColor(color); |
|
|
|
|
|
|
|
|
age = 0.0; |
|
|
|
|
|
maxLife = 12.0; |
|
|
|
|
|
|
|
|
ofSetCircleResolution(10); |
|
|
|
|
|
mapParticle(sceneWidth, sceneHeight); |
|
|
|
|
|
ofDrawCircle(position, size); |
|
|
|
|
|
|
|
|
|
|
|
if(activeTypeOfView == MAPPED){ |
|
|
|
|
|
ofDrawBitmapString(distanceToCenter, position); |
|
|
|
|
|
} |
|
|
|
|
|
ofSetCircleResolution(35); |
|
|
|
|
|
|
|
|
color.set(250, 250, 250); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
size = ofRandom(4.0, 0.01); |
|
|
|
|
|
|
|
|
|
|
|
mass = ofRandom(100, 250); |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
tex.load("img/overlay.png"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float Particle::getMaxLife(){ |
|
|
|
|
|
|
|
|
|
|
|
return maxLife; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
void Particle::update(float deltaT, vector<Attractor*>* attractors) { |
|
|
|
|
|
|
|
|
float Particle::getAngle(){ |
|
|
|
|
|
|
|
|
|
|
|
return angleToCenter; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
ofVec2f Particle::getPosition(){ |
|
|
|
|
|
|
|
|
|
|
|
return position; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (force.length() < 150) { |
|
|
|
|
|
force = 60 * force.getNormalized(); |
|
|
|
|
|
size = size + ofRandom(.01, 0.01); |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
vel += force; |
|
|
|
|
|
vel = mass * vel.getNormalized(); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
force = 0 * force.getNormalized(); |
|
|
|
|
|
vel += force; |
|
|
|
|
|
vel = mass * vel.getNormalized(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void Particle::setRandomVelocity(){ |
|
|
|
|
|
|
|
|
|
|
|
velocity.set(ofRandom(-50,50), ofRandom(-50,50)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
age += deltaT * .5; |
|
|
|
|
|
position += (vel * deltaT); |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
// *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION *** COLLISION |
|
|
|
|
|
|
|
|
void Particle::setRandomVelocityOnlyGoingUp(){ |
|
|
|
|
|
|
|
|
|
|
|
velocity.set(ofRandom(-50,50), ofRandom(-50,-1)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//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::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; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void Particle::draw() { |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
color.set(getAgeNorm() * 241,241/ getAgeNorm() ,219); |
|
|
|
|
|
|
|
|
|
|
|
ofSetColor(color, (1 - getAgeNorm()) * 255); |
|
|
|
|
|
//tex.setColor(color); |
|
|
|
|
|
//tex.draw(position, size, size); |
|
|
|
|
|
|
|
|
float Particle::getAgeNorm(){ |
|
|
|
|
|
|
|
|
|
|
|
return age/maxLife; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ofDrawCircle(position, size); |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float Particle::getAgeNorm() { |
|
|
|
|
|
return age / maxLife; |
|
|
|
|
|
|
|
|
//----------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float Particle::getMaxLife() { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- |
|
|
|